From d1a18913f352f8441bbbad9207f2f4ac0a917f46 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 2 Aug 2020 01:31:47 +0200 Subject: [PATCH] Ops --- Moose Development/Moose/Core/Radio.lua | 93 +++++++----- Moose Development/Moose/Ops/ArmyGroup.lua | 16 +-- Moose Development/Moose/Ops/Auftrag.lua | 50 +++++-- Moose Development/Moose/Ops/FlightGroup.lua | 55 ++++--- Moose Development/Moose/Ops/NavyGroup.lua | 17 +-- Moose Development/Moose/Ops/OpsGroup.lua | 151 +++++++++++++------- 6 files changed, 232 insertions(+), 150 deletions(-) diff --git a/Moose Development/Moose/Core/Radio.lua b/Moose Development/Moose/Core/Radio.lua index 575b45044..175bc2106 100644 --- a/Moose Development/Moose/Core/Radio.lua +++ b/Moose Development/Moose/Core/Radio.lua @@ -429,7 +429,7 @@ BEACON = { -- @field #number VOR -- @field #number DME -- @field #number VOR_DME --- @field #number TACAN +-- @field #number TACAN TACtical Air Navigation system. -- @field #number VORTAC -- @field #number RSBN -- @field #number BROADCAST_STATION @@ -440,45 +440,74 @@ BEACON = { -- @field #number ILS_NEAR_HOMER -- @field #number ILS_LOCALIZER -- @field #number ILS_GLIDESLOPE +-- @field #number PRMG_LOCALIZER +-- @field #number PRMG_GLIDESLOPE +-- @field #number ICLS Same as ICLS glideslope. +-- @field #number ICLS_LOCALIZER +-- @field #number ICLS_GLIDESLOPE -- @field #number NAUTICAL_HOMER --- @field #number ICLS BEACON.Type={ - NULL = 0, - VOR = 1, - DME = 2, - VOR_DME = 3, - TACAN = 4, - VORTAC = 5, - RSBN = 32, - BROADCAST_STATION = 1024, - HOMER = 8, - AIRPORT_HOMER = 4104, + NULL = 0, + VOR = 1, + DME = 2, + VOR_DME = 3, + TACAN = 4, + VORTAC = 5, + RSBN = 128, + BROADCAST_STATION = 1024, + HOMER = 8, + AIRPORT_HOMER = 4104, AIRPORT_HOMER_WITH_MARKER = 4136, - ILS_FAR_HOMER = 16408, - ILS_NEAR_HOMER = 16456, - ILS_LOCALIZER = 16640, - ILS_GLIDESLOPE = 16896, - NAUTICAL_HOMER = 32776, - ICLS = 131584, + ILS_FAR_HOMER = 16408, + ILS_NEAR_HOMER = 16424, + ILS_LOCALIZER = 16640, + ILS_GLIDESLOPE = 16896, + PRMG_LOCALIZER = 33024, + PRMG_GLIDESLOPE = 33280, + ICLS = 131584, --leaving this in here but it is the same as ICLS_GLIDESLOPE + ICLS_LOCALIZER = 131328, + ICLS_GLIDESLOPE = 131584, + NAUTICAL_HOMER = 65536, + } --- Beacon systems supported by DCS. https://wiki.hoggitworld.com/view/DCS_command_activateBeacon -- @type BEACON.System --- @field #number PAR_10 --- @field #number RSBN_5 --- @field #number TACAN --- @field #number TACAN_TANKER --- @field #number ILS_LOCALIZER (This is the one to be used for AA TACAN Tanker!) --- @field #number ILS_GLIDESLOPE --- @field #number BROADCAST_STATION +-- @field #number PAR_10 ? +-- @field #number RSBN_5 Russian VOR/DME system. +-- @field #number TACAN TACtical Air Navigation system on ground. +-- @field #number TACAN_TANKER_X TACtical Air Navigation system for tankers on X band. +-- @field #number TACAN_TANKER_Y TACtical Air Navigation system for tankers on Y band. +-- @field #number VOR Very High Frequency Omni-Directional Range +-- @field #number ILS_LOCALIZER ILS localizer +-- @field #number ILS_GLIDESLOPE ILS glideslope. +-- @field #number PRGM_LOCALIZER PRGM localizer. +-- @field #number PRGM_GLIDESLOPE PRGM glideslope. +-- @field #number BROADCAST_STATION Broadcast station. +-- @field #number VORTAC Radio-based navigational aid for aircraft pilots consisting of a co-located VHF omnidirectional range (VOR) beacon and a tactical air navigation system (TACAN) beacon. +-- @field #number TACAN_AA_MODE_X TACtical Air Navigation for aircraft on X band. +-- @field #number TACAN_AA_MODE_Y TACtical Air Navigation for aircraft on Y band. +-- @field #number VORDME Radio beacon that combines a VHF omnidirectional range (VOR) with a distance measuring equipment (DME). +-- @field #number ICLS_LOCALIZER Carrier landing system. +-- @field #number ICLS_GLIDESLOPE Carrier landing system. BEACON.System={ - PAR_10 = 1, - RSBN_5 = 2, - TACAN = 3, - TACAN_TANKER = 4, - ILS_LOCALIZER = 5, - ILS_GLIDESLOPE = 6, - BROADCAST_STATION = 7, + PAR_10 = 1, + RSBN_5 = 2, + TACAN = 3, + TACAN_TANKER_X = 4, + TACAN_TANKER_Y = 5, + VOR = 6, + ILS_LOCALIZER = 7, + ILS_GLIDESLOPE = 8, + PRMG_LOCALIZER = 9, + PRMG_GLIDESLOPE = 10, + BROADCAST_STATION = 11, + VORTAC = 12, + TACAN_AA_MODE_X = 13, + TACAN_AA_MODE_Y = 14, + VORDME = 15, + ICLS_LOCALIZER = 16, + ICLS_GLIDESLOPE = 17, } --- Create a new BEACON Object. This doesn't activate the beacon, though, use @{#BEACON.ActivateTACAN} etc. diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index b8db518b0..dab6351f7 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -681,13 +681,7 @@ end function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation, Updateroute) -- Set waypoint index. - local wpnumber=#self.waypoints+1 - if wpnumber then - local index=self:GetWaypointIndex(AfterWaypointWithID) - if index then - wpnumber=index+1 - end - end + local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID) -- Check if final waypoint is still passed. if wpnumber>self.currentwp then @@ -697,22 +691,18 @@ function ARMYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Formation -- Speed in knots. Speed=Speed or self:GetSpeedCruise() - -- Speed at waypoint. - local speedkmh=UTILS.KnotsToKmph(Speed) - -- Create a Naval waypoint. - local wp=Coordinate:WaypointGround(speedkmh, Formation) + local wp=Coordinate:WaypointGround(UTILS.KnotsToKmph(Speed), Formation) -- Create waypoint data table. local waypoint=self:_CreateWaypoint(wp) - + -- Add waypoint to table. self:_AddWaypoint(waypoint, wpnumber) -- Debug info. self:T(self.lid..string.format("Adding GROUND waypoint #%d, speed=%.1f knots. Last waypoint passed was #%s. Total waypoints #%d", wpnumber, Speed, self.currentwp, #self.waypoints)) - -- Update route. if Updateroute==nil or Updateroute==true then self:_CheckGroupDone(1) diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 7c25a4a1d..2c3b83010 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -34,7 +34,7 @@ -- @field #number duration Mission duration in seconds. -- @field Wrapper.Marker#MARKER marker F10 map marker. -- @field #boolean markerOn If true, display marker on F10 map with the AUFTRAG status. --- @field #numberr markerCoaliton Coalition to which the marker is dispayed. +-- @field #number markerCoaliton Coalition to which the marker is dispayed. -- @field #table DCStask DCS task structure. -- @field #number Ntargets Number of mission targets. -- @field #number dTevaluate Time interval in seconds before the mission result is evaluated after mission is over. @@ -93,13 +93,17 @@ -- -- @field #table enrouteTasks Mission enroute tasks. -- +-- @field #number missionRepeated Number of times mission was repeated. +-- @field #number missionRepeatMax Number of times mission is repeated if failed. +-- -- @field #number radioFreq Mission radio frequency in MHz. -- @field #number radioModu Mission radio modulation (0=AM and 1=FM). -- @field #number tacanChannel Mission TACAN channel. -- @field #number tacanMorse Mission TACAN morse code. -- --- @field #number missionRepeated Number of times mission was repeated. --- @field #number missionRepeatMax Number of times mission is repeated if failed. +-- @field Ops.OpsGroup#OPSGROUP.Radio radio Radio freq and modulation. +-- @field Ops.OpsGroup#OPSGROUP.Beacon tacan TACAN setting. +-- @field Ops.OpsGroup#OPSGROUP.Beacon icls ICLS setting. -- -- @field #number optionROE ROE. -- @field #number optionROT ROT. @@ -859,7 +863,7 @@ function AUFTRAG:NewBAI(Target, Altitude) -- DCS Task options: mission.engageWeaponType=ENUMS.WeaponFlag.AnyAG mission.engageWeaponExpend=AI.Task.WeaponExpend.ALL - mission.engageAltitude=Altitude or UTILS.FeetToMeters(2000) + mission.engageAltitude=UTILS.FeetToMeters(Altitude or 2000) -- Mission options: mission.missionTask=ENUMS.MissionTask.GROUNDATTACK @@ -887,7 +891,7 @@ function AUFTRAG:NewSEAD(Target, Altitude) -- DCS Task options: mission.engageWeaponType=ENUMS.WeaponFlag.AnyAG --ENUMS.WeaponFlag.Cannons mission.engageWeaponExpend=AI.Task.WeaponExpend.ALL - mission.engageAltitude=Altitude or UTILS.FeetToMeters(2000) + mission.engageAltitude=UTILS.FeetToMeters(Altitude or 2000) -- Mission options: mission.missionTask=ENUMS.MissionTask.SEAD @@ -1318,7 +1322,7 @@ end --- Set weapon type used for the engagement. -- @param #AUFTRAG self --- @param #number WeaponType Weapon type. Default is ENUMS.WeaponFlag.Auto +-- @param #number WeaponType Weapon type. Default is `ENUMS.WeaponFlag.Auto`. -- @return #AUFTRAG self function AUFTRAG:SetWeaponType(WeaponType) @@ -1434,9 +1438,10 @@ end -- @param #number Modulation Radio modulation. Default 0=AM. -- @return #AUFTRAG self function AUFTRAG:SetRadio(Frequency, Modulation) - - self.radioFreq=Frequency - self.radioModu=Modulation or 0 + + self.radio={} + self.radio.Freq=Frequency + self.radio.Modu=Modulation return self end @@ -1445,11 +1450,32 @@ end -- @param #AUFTRAG self -- @param #number Channel TACAN channel. -- @param #string Morse Morse code. Default "XXX". +-- @param #string UnitName Name of the unit in the group for which acts as TACAN beacon. Default is the first unit in the group. +-- @param #string Band Tacan channel mode ("X" or "Y"). Default is "X" for ground/naval and "Y" for aircraft. -- @return #AUFTRAG self -function AUFTRAG:SetTACAN(Channel, Morse) +function AUFTRAG:SetTACAN(Channel, Morse, UnitName, Band) - self.tacanChannel=Channel - self.tacanMorse=Morse or "XXX" + self.tacan={} + self.tacan.Channel=Channel + self.tacan.Morse=Morse or "XXX" + self.tacan.UnitName=UnitName + self.tacan.Band=Band + + return self +end + +--- Set ICLS beacon channel and Morse code for this mission. +-- @param #AUFTRAG self +-- @param #number Channel ICLS channel. +-- @param #string Morse Morse code. Default "XXX". +-- @param #string UnitName Name of the unit in the group for which acts as ICLS beacon. Default is the first unit in the group. +-- @return #AUFTRAG self +function AUFTRAG:SetICLS(Channel, Morse, UnitName) + + self.icls={} + self.icls.Channel=Channel + self.icls.Morse=Morse or "XXX" + self.icls.UnitName=UnitName return self end diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index f442bd46f..51773a5c5 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -269,7 +269,6 @@ function FLIGHTGROUP:New(group) self:AddTransition("*", "ElementLanded", "*") -- An element landed. self:AddTransition("*", "ElementArrived", "*") -- An element arrived. - self:AddTransition("*", "ElementOutOfAmmo", "*") -- An element is completely out of ammo. @@ -1395,27 +1394,27 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To) self:SwitchROE(self.option.ROE) self:SwitchROT(self.option.ROT) + -- Turn TACAN beacon on. + if self.tacanDefault then + self:SwitchTACAN(self.tacanDefault.Channel, self.tacanDefault.Morse) + end + + -- Turn on the radio. + if self.radioDefault then + self:SwitchRadio(self.radioDefault.Freq, self.radioDefault.Modu) + end + + -- Set callsign. + if self.callsignDefault then + self:SwitchCallsign(self.callsignDefault.Name, self.callsignNumberDefault) + end + -- TODO: make this input. self.group:SetOption(AI.Option.Air.id.PROHIBIT_JETT, true) self.group:SetOption(AI.Option.Air.id.PROHIBIT_AB, true) -- Does not seem to work. AI still used the after burner. self.group:SetOption(AI.Option.Air.id.RTB_ON_BINGO, false) --self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH) - - -- Turn TACAN beacon on. - if self.tacanDefault.Channel then - self:SwitchTACAN(self.tacanDefault.Channel, self.tacanDefault.Morse) - end - - -- Turn on the radio. - if self.radioDefault.Freq then - self:SwitchRadio(self.radioDefault.Freq, self.radioDefault.Modu) - end - -- Set callsign. - if self.callsignDefault.Name then - self:SwitchCallsign(self.callsignNameDefault, self.callsignNumberDefault) - else - end -- Update route. self:__UpdateRoute(-0.5) @@ -2957,21 +2956,16 @@ end --- Add an AIR waypoint to the flight plan. -- @param #FLIGHTGROUP self --- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude. +-- @param Core.Point#COORDINATE Coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude. -- @param #number Speed Speed in knots. Default 350 kts. -- @param #number AfterWaypointWithID Insert waypoint after waypoint given ID. Default is to insert as last waypoint. +-- @param #number Altitude Altitude in feet. Default is y-component of Coordinate. Note that these altitudes are wrt to sea level (barometric altitude). -- @param #boolean Updateroute If true or nil, call UpdateRoute. If false, no call. -- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table. -function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Updateroute) +function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Altitude, Updateroute) -- Set waypoint index. - local wpnumber=#self.waypoints+1 - if wpnumber then - local index=self:GetWaypointIndex(AfterWaypointWithID) - if index then - wpnumber=index+1 - end - end + local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID) if wpnumber>self.currentwp then self.passedfinalwp=false @@ -2980,15 +2974,16 @@ function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Updater -- Speed in knots. Speed=Speed or 350 - -- Speed at waypoint. - local speedkmh=UTILS.KnotsToKmph(Speed) - -- Create air waypoint. - local name=string.format("Added Waypoint #%d", wpnumber) - local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speedkmh, true, nil, {}, name) + local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, UTILS.KnotsToKmph(Speed), true, nil, {}) -- Create waypoint data table. local waypoint=self:_CreateWaypoint(wp) + + -- Set altitude. + if Altitude then + waypoint.alt=UTILS.FeetToMeters(Altitude) + end -- Add waypoint to table. self:_AddWaypoint(waypoint, wpnumber) diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 674efd470..3e4e8a6b2 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -990,19 +990,13 @@ end -- @param Core.Point#COORDINATE Coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude. -- @param #number Speed Speed in knots. Default is default cruise speed or 70% of max speed. -- @param #number AfterWaypointWithID Insert waypoint after waypoint given ID. Default is to insert as last waypoint. --- @param #number Depth Depth at waypoint in meters. +-- @param #number Depth Depth at waypoint in meters. Only for submarines. -- @param #boolean Updateroute If true or nil, call UpdateRoute. If false, no call. -- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table. -function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Updateroute) +function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Updateroute) -- Set waypoint index. - local wpnumber=#self.waypoints+1 - if wpnumber then - local index=self:GetWaypointIndex(AfterWaypointWithID) - if index then - wpnumber=index+1 - end - end + local wpnumber=self:GetWaypointIndexAfterID(AfterWaypointWithID) -- Check if final waypoint is still passed. if wpnumber>self.currentwp then @@ -1012,11 +1006,8 @@ function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Updaterou -- Speed in knots. Speed=Speed or self:GetSpeedCruise() - -- Speed at waypoint. - local speedkmh=UTILS.KnotsToKmph(Speed) - -- Create a Naval waypoint. - local wp=Coordinate:WaypointNaval(speedkmh) + local wp=Coordinate:WaypointNaval(UTILS.KnotsToKmph(Speed), Depth) -- Create waypoint data table. local waypoint=self:_CreateWaypoint(wp) diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index af03bc341..12618cf18 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -205,18 +205,21 @@ OPSGROUP.TaskType={ -- @field #number Channel Channel. -- @field #number Morse Morse Code. -- @field #string Band Band "X" or "Y" for TACAN beacon. --- @field #string UnitName Name of the unit acting as beacon. +-- @field #string BeaconName Name of the unit acting as beacon. +-- @field Wrapper.Unit#UNIT BeaconUnit Unit object acting as beacon. --- Radio data. -- @type OPSGROUP.Radio -- @field #number Freq Frequency -- @field #number Modu Modulation. ---- Callsign data +--- Callsign data. -- @type OPSGROUP.Callsign --- @field #number Name --- @field #number Number1 Number 1 --- @field #number Number2 Number 2 +-- @field #number NumberS Squadron name number. +-- @field #number NumberG Group number. +-- @field #number NumberE Element number. +-- @field #string NameGroup Name of the group, e.g. Uzi. +-- @field #string NameElement Name of group element, e.g. Uzi 11. --- Option data. -- @type OPSGROUP.Option @@ -249,6 +252,7 @@ OPSGROUP.TaskType={ -- @field #string action Waypoint action (turning point, etc.). Ground groups have the formation here. -- @field #table task Waypoint task combo. -- @field #string type Waypoint type. +-- @field #string name Waypoint description. Shown in the F10 map. -- @field #number x Waypoint x-coordinate. -- @field #number y Waypoint y-coordinate. -- @field #boolean detour If true, this waypoint is not part of the normal route. @@ -653,10 +657,12 @@ end -- @return #OPSGROUP.Waypoint Waypoint data. function OPSGROUP:GetWaypointIndex(uid) - for i,_waypoint in pairs(self.waypoints) do - local waypoint=_waypoint --#OPSGROUP.Waypoint - if waypoint.uid==uid then - return i + if uid then + for i,_waypoint in pairs(self.waypoints) do + local waypoint=_waypoint --#OPSGROUP.Waypoint + if waypoint.uid==uid then + return i + end end end @@ -696,6 +702,21 @@ function OPSGROUP:GetWaypointIndexCurrent() return self.currentwp or 1 end +--- Get waypoint index after waypoint with given ID. So if the waypoint has index 3 it will return 4. +-- @param #OPSGROUP self +-- @param #number uid Unique ID of the waypoint. Default is new waypoint index after the last current one. +-- @return #number Index after waypoint with given ID. +function OPSGROUP:GetWaypointIndexAfterID(uid) + + local index=self:GetWaypointIndex(uid) + if index then + return index+1 + else + return #self.waypoints+1 + end + +end + --- Get waypoint. -- @param #OPSGROUP self -- @param #number indx Waypoint index. @@ -1952,7 +1973,7 @@ function OPSGROUP:RouteToMission(mission, delay) local SpeedToMission=UTILS.KmphToKnots(self.speedCruise) -- Add waypoint. - local waypoint=self:AddWaypoint(waypointcoord, SpeedToMission, nil, false) + local waypoint=self:AddWaypoint(waypointcoord, SpeedToMission, nil, nil, false) -- Special for Troop transport. if mission.type==AUFTRAG.Type.TROOPTRANSPORT then @@ -1988,20 +2009,24 @@ function OPSGROUP:RouteToMission(mission, delay) -- ROE if mission.optionROE then - self:SetOptionROE(mission.optionROE) + self:SwitchROE(mission.optionROE) end -- ROT if mission.optionROT then - self:SetOptionROT(mission.optionROT) + self:SwitchROT(mission.optionROT) end -- Radio - if mission.radioFreq then - self:SwitchRadioOn(mission.radioFreq, mission.radioModu) + if mission.radio then + self:SwitchRadio(mission.radio.Freq, mission.radio.Modu) end -- TACAN - if mission.tacanChannel then - self:SwitchTACANOn(mission.tacanChannel, mission.tacanMorse) + if mission.tacan then + self:SwitchTACAN(mission.tacan.Channel, mission.tacan.Morse, mission.tacan.BeaconName, mission.tacan.Band) end + -- ICLS + if mission.icls then + self:SwitchICLS(mission.icls.Channel, mission.icls.Morse, mission.icls.UnitName) + end -- Formation if mission.optionFormation then self:SwitchFormation(mission.optionFormation) @@ -2489,21 +2514,29 @@ end -- Waypoints & Routing ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Initialize Mission Editor waypoints. +--- Enhance waypoint table. -- @param #OPSGROUP self --- @param #OPSGROUP.Waypoint waypoint DCS waypoint data table. -- @return #OPSGROUP.Waypoint Waypoint data. -function OPSGROUP:_CreateWaypoint(waypoint, formation, detour) +function OPSGROUP:_CreateWaypoint(waypoint) - waypoint.uid=self.wpcounter - waypoint.coordinate=COORDINATE:New(waypoint.x, waypoint.alt, waypoint.y) - waypoint.detour=detour and detour or false - if formation then - waypoint.action=formation - end + -- Set uid. + waypoint.uid=self.wpcounter + + -- Waypoint has not been passed yet. waypoint.npassed=0 - waypoint.patrol=false + + -- Coordinate. + waypoint.coordinate=COORDINATE:New(waypoint.x, waypoint.alt, waypoint.y) + -- Set waypoint name. + waypoint.name=string.format("Waypoint UID=%d", waypoint.uid) + + -- Set types. + waypoint.patrol=false + waypoint.detour=false + waypoint.astar=false + + -- Increase UID counter. self.wpcounter=self.wpcounter+1 return waypoint @@ -2613,7 +2646,7 @@ function OPSGROUP:_UpdateWaypointTasks(n) if i>=n or nwaypoints==1 then -- Debug info. - self:I(self.lid..string.format("Updating waypoint task for waypoint %d/%d ID=%d. Last waypoint passed %d", i, nwaypoints, wp.uid, self.currentwp)) + self:T(self.lid..string.format("Updating waypoint task for waypoint %d/%d ID=%d. Last waypoint passed %d", i, nwaypoints, wp.uid, self.currentwp)) -- Tasks of this waypoint local taskswp={} @@ -2866,64 +2899,83 @@ end -- @param #OPSGROUP self -- @param #number Channel TACAN channel. -- @param #string Morse Morse code. Default "XXX". +-- @param #string UnitName Name of the unit acting as beacon. +-- @param #string Band TACAN mode. Default is "X" for ground and "Y" for airborne units. -- @return #OPSGROUP self -function OPSGROUP:SetDefaultTACAN(Channel, Morse) - - self.tacanChannelDefault=Channel - self.tacanMorseDefault=Morse or "XXX" +function OPSGROUP:SetDefaultTACAN(Channel, Morse, UnitName, Band) - self.tacan.Channel=Channel - self.tacan.Band=Band - self.tacan.Morse=Morse or "XXX" - self.tacan.UnitName=UnitName + self.tacanDefault={} + self.tacanDefault.Channel=Channel + self.tacanDefault.Morse=Morse or "XXX" + self.tacanDefault.BeaconName=UnitName + self.tacanDefault.Band=Band return self end ---- Activate TACAN beacon. +--- Activate/switch TACAN beacon settings. -- @param #OPSGROUP self -- @param #number Channel TACAN Channel. -- @param #string Morse TACAN morse code. +-- @param #string UnitName Name of the unit in the group which should activate the TACAN beacon. Can also be given as #number to specify the unit number. Default is the first unit of the group. -- @param #string Band TACAN channel mode "X" or "Y". Default is "Y" for aircraft and "X" for ground and naval groups. -- @return #OPSGROUP self -function OPSGROUP:SwitchTACAN(Channel, Morse, Band) +function OPSGROUP:SwitchTACAN(Channel, Morse, UnitName, Band) if self:IsAlive() then local unit=self.group:GetUnit(1) --Wrapper.Unit#UNIT + + if UnitName then + if type(UnitName)=="number" then + unit=self.group:GetUnit(UnitName) + else + unit=UNIT:FindByName(UnitName) + end + end + + if not unit then + self:E(self.lid.."ERROR: Could not get TACAN unit. Trying first unit in the group.") + unit=self.group:GetUnit(1) + end if unit and unit:IsAlive() then local UnitID=unit:GetID() - local Type=BEACON.Type.TACAN + local Type=BEACON.Type.TACAN local System=BEACON.System.TACAN - - --local TACANMode="Y" + if self.isAircraft then - Type=4 - System=5 + System=BEACON.System.TACAN_TANKER_Y Band=Band or "Y" else + System=BEACON.System.TACAN Band=Band or "X" end -- Tacan frequency. local Frequency=UTILS.TACANToFrequency(Channel, Band) + -- Activate beacon. unit:CommandActivateBeacon(Type, System, Frequency, UnitID, Channel, Band, true, Morse, true) - self.tacanBeacon=unit - + -- Update info. + self.tacan={} self.tacan.Channel=Channel self.tacan.Morse=Morse self.tacan.Band=Band - self.tacan.UnitName=unit:GetName() + self.tacan.BeaconName=unit:GetName() + self.tacan.BeaconUnit=unit -- TACAN is now on. self.tacanOn=true self:I(self.lid..string.format("Switching TACAN to Channel %d%s Morse %s on unit %s", self.tacan.Channel, self.tacan.Band, tostring(self.tacan.Morse), self.tacan.UnitName)) + + else + + self:E(self.lid.."ERROR: Cound not set TACAN! Unit is not alive.") end @@ -2937,12 +2989,11 @@ end -- @return #OPSGROUP self function OPSGROUP:SwitchTACANOff() - if self.tacanBeacon and self.tacanBeacon:IsAlive() then - self.tacanBeacon:CommandDeactivateBeacon() + if self.tacan.BeaconUnit and self.tacan.BeaconUnit:IsAlive() then + self.tacan.BeaconUnit:CommandDeactivateBeacon() end self:I(self.lid..string.format("Switching TACAN OFF")) - self.tacanOn=false end @@ -3059,8 +3110,8 @@ end -- @return #OPSGROUP self function OPSGROUP:SetDefaultCallsign(CallsignName, CallsignNumber) - self.callsignNameDefault=CallsignName - self.callsignNumberDefault=CallsignNumber or 1 + self.callsignDefault.Name=CallsignName + self.callsignDefault.NumberG=CallsignNumber or 1 return self end