From 9838e1af1968822ab15a588c2288e9596555c1f5 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 9 Jul 2020 00:06:02 +0200 Subject: [PATCH] Ops --- Moose Development/Moose/Ops/Auftrag.lua | 8 +++--- Moose Development/Moose/Ops/FlightGroup.lua | 24 +++++++++--------- Moose Development/Moose/Ops/NavyGroup.lua | 27 +++++++++++++++------ Moose Development/Moose/Ops/OpsGroup.lua | 20 ++++++++------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 012b62b33..a801c5499 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -508,7 +508,6 @@ function AUFTRAG:New(Type) self:AddTransition("*", "GroupDead", "*") self:AddTransition("*", "AssetDead", "*") - -- Init status update. self:__Status(-1) @@ -1767,7 +1766,7 @@ function AUFTRAG:onafterStatus(From, Event, To) -- Check if mission is not OVER yet. if self:IsNotOver() then - + if self:CheckGroupsDone() then -- All groups have reported MISSON DONE. @@ -1873,7 +1872,8 @@ function AUFTRAG:Evaluate() text=text..string.format("Targets = %d/%d\n", self.Ntargets, Ntargets) text=text..string.format("Damage = %.1f %%\n", targetdamage) text=text..string.format("Success Cond = %s\n", tostring(successCondition)) - text=text..string.format("Failure Cond = %s", tostring(failureCondition)) + text=text..string.format("Failure Cond = %s\n", tostring(failureCondition)) + text=text..string.format("Failed = %s", tostring(failed)) self:I(self.lid..text) if failed then @@ -2372,8 +2372,6 @@ function AUFTRAG:onafterRepeat(From, Event, To) end - - --- On after "Stop" event. Remove mission from AIRWING and FLIGHTGROUP mission queues. -- @param #AUFTRAG self -- @param #string From From state. diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 2179004e7..c4bb34953 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -721,7 +721,7 @@ function FLIGHTGROUP:onafterStatus(From, Event, To) end -- Element status. - if self.verbose>1 or true then + if self.verbose>1 then local text="Elements:" for i,_element in pairs(self.elements) do local element=_element --#FLIGHTGROUP.Element @@ -970,7 +970,7 @@ function FLIGHTGROUP:OnEventBirth(EventData) end -- Set element to spawned state. - self:I(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown")) + self:T(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown")) self:ElementSpawned(element) end @@ -1145,7 +1145,7 @@ function FLIGHTGROUP:OnEventUnitLost(EventData) -- Check that this is the right group. if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then - self:I(self.lid..string.format("EVENT: Unit %s lost!", EventData.IniUnitName)) + self:T(self.lid..string.format("EVENT: Unit %s lost!", EventData.IniUnitName)) local unit=EventData.IniUnit local group=EventData.IniGroup @@ -1155,7 +1155,7 @@ function FLIGHTGROUP:OnEventUnitLost(EventData) local element=self:GetElementByName(unitname) if element then - self:T3(self.lid..string.format("EVENT: Element %s crashed ==> dead", element.name)) + self:I(self.lid..string.format("EVENT: Element %s unit lost ==> dead", element.name)) self:ElementDead(element) end @@ -1276,7 +1276,7 @@ function FLIGHTGROUP:onafterElementTaxiing(From, Event, To, Element) local TerminalID=Element.parking and tostring(Element.parking.TerminalID) or "N/A" -- Debug info. - self:I(self.lid..string.format("Element taxiing %s. Parking spot %s is now free", Element.name, TerminalID)) + self:T(self.lid..string.format("Element taxiing %s. Parking spot %s is now free", Element.name, TerminalID)) -- Set parking spot to free. Also for FC. self:_SetElementParkingFree(Element) @@ -1293,7 +1293,7 @@ end -- @param #FLIGHTGROUP.Element Element The flight group element. -- @param Wrapper.Airbase#AIRBASE airbase The airbase if applicable or nil. function FLIGHTGROUP:onafterElementTakeoff(From, Event, To, Element, airbase) - self:I(self.lid..string.format("Element takeoff %s at %s airbase.", Element.name, airbase and airbase:GetName() or "unknown")) + self:T(self.lid..string.format("Element takeoff %s at %s airbase.", Element.name, airbase and airbase:GetName() or "unknown")) -- Helos with skids just take off without taxiing! if Element.parking then @@ -1434,7 +1434,7 @@ end -- @param #string Event Event. -- @param #string To To state. function FLIGHTGROUP:onafterParking(From, Event, To) - self:I(self.lid..string.format("Flight is parking")) + self:T(self.lid..string.format("Flight is parking")) local airbase=self:GetClosestAirbase() --self.group:GetCoordinate():GetClosestAirbase() @@ -1690,7 +1690,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n) n=n or self.currentwp+1 -- Update waypoint tasks, i.e. inject WP tasks into waypoint table. - self:_UpdateWaypointTasks() + self:_UpdateWaypointTasks(n) -- Waypoints. local wp={} @@ -1710,7 +1710,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n) -- Debug info. local hb=self.homebase and self.homebase:GetName() or "unknown" local db=self.destbase and self.destbase:GetName() or "unknown" - self:I(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db)) + self:T(self.lid..string.format("Updating route for WP #%d-%d homebase=%s destination=%s", n, #wp, hb, db)) if #wp>1 then @@ -1905,7 +1905,8 @@ end -- @param #number SpeedLand Landing speed in knots. Default 170 kts. function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, SpeedLand) - self:I(self.lid..string.format("RTB: event=%s: %s --> %s to %s", Event, From, To, airbase:GetName())) + -- Debug info. + self:T(self.lid..string.format("RTB: event=%s: %s --> %s to %s", Event, From, To, airbase:GetName())) -- Set the destination base. self.destbase=airbase @@ -3043,7 +3044,8 @@ function FLIGHTGROUP:_SetElementParkingAt(Element, Spot) if Spot then - self:I(self.lid..string.format("Element %s is parking on spot %d", Element.name, Spot.TerminalID)) + -- Debug info. + self:T(self.lid..string.format("Element %s is parking on spot %d", Element.name, Spot.TerminalID)) if self.flightcontrol then diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 82dfb64d0..d976cff45 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -314,6 +314,18 @@ end -- Status ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--- Update status. +-- @param #NAVYGROUP self +function NAVYGROUP:onbeforeStatus(From, Event, To) + + if self:IsDead() or self:IsStopped() or self:IsAlive()==nil then + self:I(self.lid..string.format("Onbefore Status ==> false")) + return false + end + + return true +end + --- Update status. -- @param #NAVYGROUP self function NAVYGROUP:onafterStatus(From, Event, To) @@ -482,16 +494,16 @@ end function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth) -- Update route from this waypoint number onwards. - n=n or self:GetWaypointIndexNext(true) + n=n or self:GetWaypointIndexNext(self.adinfinitum) + + -- Debug info. + self:T(self.lid..string.format("FF Update route n=%d", n)) -- Update waypoint tasks, i.e. inject WP tasks into waypoint table. - self:_UpdateWaypointTasks() + self:_UpdateWaypointTasks(n) -- Waypoints. local waypoints={} - - -- Speed. - --local speed=Speed and UTILS.KnotsToKmph(Speed) or self.speedCruise -- Depth for submarines. local depth=Depth or 0 @@ -736,7 +748,6 @@ end -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. --- @param #number Depth Dive depth in meters. function NAVYGROUP:onafterSurface(From, Event, To) self.depth=0 @@ -926,7 +937,7 @@ function NAVYGROUP:_InitGroup() element.status=OPSGROUP.ElementStatus.INUTERO table.insert(self.elements, element) - self:GetAmmoUnit(unit, true) + self:GetAmmoUnit(unit, false) if unit:IsAlive() then self:ElementSpawned(element) @@ -1145,7 +1156,7 @@ function NAVYGROUP:_CheckTurnsIntoWind() end -- Debug output. - self:I(self.lid..text) + self:T(self.lid..text) -- Loop over all slots. diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index e99ae114c..8e6f13814 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -1483,7 +1483,7 @@ function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission) self:I(self.lid..string.format("Starting mission %s, FSM=%s, LateActivated=%s, UnControlled=%s", tostring(Mission.name), self:GetState(), tostring(self:IsLateActivated()), tostring(self:IsUncontrolled()))) -- Delay for route to mission. Group needs to be activated and controlled. - local delay=1 + local delay=0 -- Check if group is spawned. if self:IsInUtero() then @@ -1491,7 +1491,7 @@ function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission) -- Activate group if it is late activated. if self:IsLateActivated() then self:Activate(delay) - delay=delay+1 + --delay=delay+1 end end @@ -1515,7 +1515,7 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission) -- Debug output. local text=string.format("Starting %s Mission %s, target %s", Mission.type, tostring(Mission.name), Mission:GetTargetName()) self:T(self.lid..text) - MESSAGE:New(text, 30, self.groupname):ToAllIf(true) + MESSAGE:New(text, 30, self.groupname):ToAllIf(self.Debug) -- Set current mission. self.currentmission=Mission.auftragsnummer @@ -1524,7 +1524,7 @@ function OPSGROUP:onafterMissionStart(From, Event, To, Mission) Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.STARTED) -- Set mission status to STARTED. - Mission:Started() + Mission:__Started(3) -- Route group to mission zone. self:RouteToMission(Mission, 3) @@ -1541,7 +1541,7 @@ function OPSGROUP:onafterMissionExecute(From, Event, To, Mission) local text=string.format("Executing %s Mission %s, target %s", Mission.type, tostring(Mission.name), Mission:GetTargetName()) self:T(self.lid..text) - MESSAGE:New(text, 30, self.groupname):ToAllIf(true) + MESSAGE:New(text, 30, self.groupname):ToAllIf(self.Debug) -- Set group mission status to EXECUTING. Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.EXECUTING) @@ -1658,7 +1658,7 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission) -- Debug info. local text=string.format("Mission %s DONE!", Mission.name) self:I(self.lid..text) - MESSAGE:New(text, 30, self.groupname):ToAllIf(true) + MESSAGE:New(text, 30, self.groupname):ToAllIf(self.Debug) -- Set group status. Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.DONE) @@ -2189,17 +2189,18 @@ end --- Initialize Mission Editor waypoints. -- @param #OPSGROUP self -function OPSGROUP:_UpdateWaypointTasks() +-- @param #number n Waypoint +function OPSGROUP:_UpdateWaypointTasks(n) local waypoints=self.waypoints local nwaypoints=#waypoints for i,wp in pairs(waypoints) do - if i>self.currentwp or nwaypoints==1 then + if i>=n or nwaypoints==1 then -- Debug info. - self:I(self.lid..string.format("Updating waypoint task for waypoint %d/%d. Last waypoint passed %d", i, nwaypoints, self.currentwp)) + self:T(self.lid..string.format("Updating waypoint task for waypoint %d/%d. Last waypoint passed %d", i, nwaypoints, self.currentwp)) -- Tasks of this waypoint local taskswp={} @@ -2212,6 +2213,7 @@ function OPSGROUP:_UpdateWaypointTasks() wp.task=self.group:TaskCombo(taskswp) end + end end