Navygroup

This commit is contained in:
Frank
2020-10-09 00:15:19 +02:00
parent ce10390406
commit 591dd128ce
2 changed files with 49 additions and 60 deletions
+3 -25
View File
@@ -617,15 +617,8 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
-- Waypoints. -- Waypoints.
local waypoints={} local waypoints={}
-- Add remaining waypoints to route.
local depth=nil
for i=n, #self.waypoints do
-- Waypoint. -- Waypoint.
local wp=UTILS.DeepCopy(self.waypoints[i]) --Ops.OpsGroup#OPSGROUP.Waypoint local wp=UTILS.DeepCopy(self.waypoints[n]) --Ops.OpsGroup#OPSGROUP.Waypoint
-- Check if next wp.
if i==n then
-- Speed. -- Speed.
if Speed then if Speed then
@@ -649,33 +642,18 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth)
-- Current set speed in m/s. -- Current set speed in m/s.
self.speedWp=wp.speed self.speedWp=wp.speed
-- Current set depth.
depth=wp.alt
else
-- Dive depth is applied to all other waypoints.
if self.depth then
wp.alt=-self.depth
else
-- Take default waypoint depth.
end
end
-- Add waypoint. -- Add waypoint.
table.insert(waypoints, wp) table.insert(waypoints, wp)
end
-- Current waypoint. -- Current waypoint.
local current=self:GetCoordinate():WaypointNaval(UTILS.MpsToKmph(self.speedWp), depth) local current=self:GetCoordinate():WaypointNaval(UTILS.MpsToKmph(self.speedWp), wp.alt)
table.insert(waypoints, 1, current) table.insert(waypoints, 1, current)
if #waypoints>1 then if #waypoints>1 then
self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m", self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m",
self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speedWp), depth)) self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speedWp), wp.alt))
-- Route group to all defined waypoints remaining. -- Route group to all defined waypoints remaining.
+13 -2
View File
@@ -2682,10 +2682,10 @@ function OPSGROUP:onafterPassingWaypoint(From, Event, To, Waypoint)
end end
-- Check if all tasks/mission are done? If so, RTB or WAIT. -- Check if all tasks/mission are done?
-- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there. -- Note, we delay it for a second to let the OnAfterPassingwaypoint function to be executed in case someone wants to add another waypoint there.
if ntasks==0 then if ntasks==0 then
self:_CheckGroupDone() self:_CheckGroupDone(0.1)
end end
-- Debug info. -- Debug info.
@@ -3061,6 +3061,10 @@ function OPSGROUP:_CheckGroupDone(delay)
self:ScheduleOnce(delay, self._CheckGroupDone, self) self:ScheduleOnce(delay, self._CheckGroupDone, self)
else else
local waypoint=self:GetWaypoint(self.currentwp)
local n=self:GetTasksWaypoint(id)
if self.adinfinitum then if self.adinfinitum then
@@ -3068,6 +3072,8 @@ function OPSGROUP:_CheckGroupDone(delay)
-- Parol Ad Infinitum -- Parol Ad Infinitum
--- ---
if #self.waypoints>0 then
-- Next waypoint index. -- Next waypoint index.
local i=self:GetWaypointIndexNext(true) local i=self:GetWaypointIndexNext(true)
@@ -3079,6 +3085,11 @@ function OPSGROUP:_CheckGroupDone(delay)
self:T(self.lid..string.format("Adinfinitum=TRUE ==> Goto WP index=%d at speed=%d knots", i, speed)) self:T(self.lid..string.format("Adinfinitum=TRUE ==> Goto WP index=%d at speed=%d knots", i, speed))
else
self:E(self.lid..string.format("WARNING: No waypoints left! Commanding a Full Stop"))
self:__FullStop(-1)
end
else else
--- ---