mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
OPS
request
This commit is contained in:
parent
9564d9d893
commit
a9b0017c04
@ -7988,6 +7988,8 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
for _,asset in pairs(assets) do
|
for _,asset in pairs(assets) do
|
||||||
local _asset=asset --#WAREHOUSE.Assetitem
|
local _asset=asset --#WAREHOUSE.Assetitem
|
||||||
|
|
||||||
|
if not _asset.spawned then
|
||||||
|
|
||||||
-- Get terminal type of this asset
|
-- Get terminal type of this asset
|
||||||
local terminaltype=asset.terminalType or self:_GetTerminal(asset.attribute, self:GetAirbaseCategory())
|
local terminaltype=asset.terminalType or self:_GetTerminal(asset.attribute, self:GetAirbaseCategory())
|
||||||
|
|
||||||
@ -8101,6 +8103,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end -- loop over asset units
|
end -- loop over asset units
|
||||||
|
end -- Asset spawned check
|
||||||
end -- loop over asset groups
|
end -- loop over asset groups
|
||||||
|
|
||||||
return parking
|
return parking
|
||||||
|
|||||||
@ -5467,16 +5467,73 @@ function AUFTRAG:_SetLogID()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Update DCS task.
|
--- Get request ID from legion this mission requested assets from
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Ops.Legion#LEGION Legion The legion from which to get the request ID.
|
||||||
|
-- @return #number Request ID (if any).
|
||||||
|
function AUFTRAG:_GetRequestID(Legion)
|
||||||
|
|
||||||
|
local requestid=nil
|
||||||
|
local name=nil
|
||||||
|
|
||||||
|
if type(Legion)=="string" then
|
||||||
|
name=Legion
|
||||||
|
else
|
||||||
|
name=Legion.alias
|
||||||
|
end
|
||||||
|
|
||||||
|
if name then
|
||||||
|
requestid=self.requestID[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get request from legion this mission requested assets from.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Ops.Legion#LEGION Legion The legion from which to get the request ID.
|
||||||
|
-- @return Functional.Warehouse#WAREHOUSE.PendingItem Request.
|
||||||
|
function AUFTRAG:_GetRequest(Legion)
|
||||||
|
|
||||||
|
local request=nil
|
||||||
|
|
||||||
|
local requestID=self:_GetRequestID(Legion)
|
||||||
|
|
||||||
|
if requestID then
|
||||||
|
request=Legion:GetRequestByID(requestID)
|
||||||
|
end
|
||||||
|
|
||||||
|
return request
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set request ID from legion this mission requested assets from
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Ops.Legion#LEGION Legion The legion from which to get the request ID.
|
||||||
|
-- @param #number RequestID Request ID.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:_UpdateTask()
|
function AUFTRAG:_SetRequestID(Legion, RequestID)
|
||||||
|
|
||||||
|
local requestid=nil
|
||||||
|
local name=nil
|
||||||
|
|
||||||
|
if type(Legion)=="string" then
|
||||||
|
name=Legion
|
||||||
|
else
|
||||||
|
name=Legion.alias
|
||||||
|
end
|
||||||
|
|
||||||
|
if name then
|
||||||
|
if self.requestID[name] then
|
||||||
|
self:I(self.lid..string.format("WARNING: Mission already has a request ID=%d!", self.requestID[name]))
|
||||||
|
end
|
||||||
|
self.requestID[name]=RequestID
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Update mission F10 map marker.
|
--- Update mission F10 map marker.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
|
|||||||
@ -572,9 +572,9 @@ function BRIGADE:onafterStatus(From, Event, To)
|
|||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------
|
---------------------
|
||||||
-- Refuelling Info --
|
-- Refuelling Info --
|
||||||
-------------------
|
---------------------
|
||||||
if self.verbose>=4 then
|
if self.verbose>=4 then
|
||||||
local text="Refuelling Zones:"
|
local text="Refuelling Zones:"
|
||||||
for i,_refuellingzone in pairs(self.refuellingZones) do
|
for i,_refuellingzone in pairs(self.refuellingZones) do
|
||||||
@ -585,6 +585,19 @@ function BRIGADE:onafterStatus(From, Event, To)
|
|||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----------------
|
||||||
|
-- Asset Info --
|
||||||
|
----------------
|
||||||
|
if self.verbose>=5 then
|
||||||
|
local text="Assets in stock:"
|
||||||
|
for i,_asset in pairs(self.stock) do
|
||||||
|
local asset=_asset --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
|
-- Info text.
|
||||||
|
text=text..string.format("\n* %s: spawned=%s", asset.spawngroupname, tostring(asset.spawned))
|
||||||
|
end
|
||||||
|
self:I(self.lid..text)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -839,6 +839,58 @@ function LEGION:onafterMissionAssign(From, Event, To, Mission, Legions)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Create a request and add it to the warehouse queue.
|
||||||
|
-- @param #LEGION self
|
||||||
|
-- @param Functional.Warehouse#WAREHOUSE.Descriptor AssetDescriptor Descriptor describing the asset that is requested.
|
||||||
|
-- @param AssetDescriptorValue Value of the asset descriptor. Type depends on descriptor, i.e. could be a string, etc.
|
||||||
|
-- @param #number nAsset Number of groups requested that match the asset specification.
|
||||||
|
-- @param #number Prio Priority of the request. Number ranging from 1=high to 100=low.
|
||||||
|
-- @param #string Assignment A keyword or text that can later be used to identify this request and postprocess the assets.
|
||||||
|
function LEGION:_AddRequest(AssetDescriptor, AssetDescriptorValue, nAsset, Prio, Assignment)
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
|
nAsset=nAsset or 1
|
||||||
|
Prio=Prio or 50
|
||||||
|
|
||||||
|
-- Increase id.
|
||||||
|
self.queueid=self.queueid+1
|
||||||
|
|
||||||
|
-- Request queue table item.
|
||||||
|
local request={
|
||||||
|
uid=self.queueid,
|
||||||
|
prio=Prio,
|
||||||
|
warehouse=self,
|
||||||
|
assetdesc=AssetDescriptor,
|
||||||
|
assetdescval=AssetDescriptorValue,
|
||||||
|
nasset=nAsset,
|
||||||
|
transporttype=WAREHOUSE.TransportType.SELFPROPELLED,
|
||||||
|
ntransport=0,
|
||||||
|
assignment=tostring(Assignment),
|
||||||
|
airbase=self:GetAirbase(),
|
||||||
|
category=self:GetAirbaseCategory(),
|
||||||
|
ndelivered=0,
|
||||||
|
ntransporthome=0,
|
||||||
|
assets={},
|
||||||
|
toself=true,
|
||||||
|
} --Functional.Warehouse#WAREHOUSE.Queueitem
|
||||||
|
|
||||||
|
|
||||||
|
-- Add request to queue.
|
||||||
|
table.insert(self.queue, request)
|
||||||
|
|
||||||
|
local descval="assetlist"
|
||||||
|
if request.assetdesc==WAREHOUSE.Descriptor.ASSETLIST then
|
||||||
|
|
||||||
|
else
|
||||||
|
descval=tostring(request.assetdescval)
|
||||||
|
end
|
||||||
|
|
||||||
|
local text=string.format("Warehouse %s: New request from warehouse %s.\nDescriptor %s=%s, #assets=%s; Transport=%s, #transports=%s.",
|
||||||
|
self.alias, self.alias, request.assetdesc, descval, tostring(request.nasset), request.transporttype, tostring(request.ntransport))
|
||||||
|
self:_DebugMessage(text, 5)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- On after "MissionRequest" event. Performs a self request to the warehouse for the mission assets. Sets mission status to REQUESTED.
|
--- On after "MissionRequest" event. Performs a self request to the warehouse for the mission assets. Sets mission status to REQUESTED.
|
||||||
-- @param #LEGION self
|
-- @param #LEGION self
|
||||||
@ -914,11 +966,8 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
if Mission.type==AUFTRAG.Type.RELOCATECOHORT then
|
if Mission.type==AUFTRAG.Type.RELOCATECOHORT then
|
||||||
cancel=true
|
cancel=true
|
||||||
|
|
||||||
-- Get request ID.
|
|
||||||
local requestID=currM.requestID[self.alias]
|
|
||||||
|
|
||||||
-- Get request.
|
-- Get request.
|
||||||
local request=self:GetRequestByID(requestID)
|
local request=currM:_GetRequest(self)
|
||||||
|
|
||||||
if request then
|
if request then
|
||||||
self:T2(self.lid.."Removing group from cargoset")
|
self:T2(self.lid.."Removing group from cargoset")
|
||||||
@ -999,7 +1048,8 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission)
|
|||||||
local assignment=string.format("Mission-%d", Mission.auftragsnummer)
|
local assignment=string.format("Mission-%d", Mission.auftragsnummer)
|
||||||
|
|
||||||
-- Add request to legion warehouse.
|
-- Add request to legion warehouse.
|
||||||
self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, Assetlist, #Assetlist, nil, nil, Mission.prio, assignment)
|
--self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, Assetlist, #Assetlist, nil, nil, Mission.prio, assignment)
|
||||||
|
self:_AddRequest(WAREHOUSE.Descriptor.ASSETLIST, Assetlist, #Assetlist, Mission.prio, assignment)
|
||||||
|
|
||||||
-- The queueid has been increased in the onafterAddRequest function. So we can simply use it here.
|
-- The queueid has been increased in the onafterAddRequest function. So we can simply use it here.
|
||||||
Mission.requestID[self.alias]=self.queueid
|
Mission.requestID[self.alias]=self.queueid
|
||||||
@ -1091,7 +1141,8 @@ function LEGION:onafterTransportRequest(From, Event, To, OpsTransport)
|
|||||||
local assignment=string.format("Transport-%d", OpsTransport.uid)
|
local assignment=string.format("Transport-%d", OpsTransport.uid)
|
||||||
|
|
||||||
-- Add request to legion warehouse.
|
-- Add request to legion warehouse.
|
||||||
self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, AssetList, #AssetList, nil, nil, OpsTransport.prio, assignment)
|
--self:AddRequest(self, WAREHOUSE.Descriptor.ASSETLIST, AssetList, #AssetList, nil, nil, OpsTransport.prio, assignment)
|
||||||
|
self:_AddRequest(WAREHOUSE.Descriptor.ASSETLIST, AssetList, #AssetList, OpsTransport.prio, assignment)
|
||||||
|
|
||||||
-- The queueid has been increased in the onafterAddRequest function. So we can simply use it here.
|
-- The queueid has been increased in the onafterAddRequest function. So we can simply use it here.
|
||||||
OpsTransport.requestID[self.alias]=self.queueid
|
OpsTransport.requestID[self.alias]=self.queueid
|
||||||
@ -1198,8 +1249,9 @@ function LEGION:onafterMissionCancel(From, Event, To, Mission)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Remove queued request (if any).
|
-- Remove queued request (if any).
|
||||||
if Mission.requestID[self.alias] then
|
local requestID=Mission:_GetRequestID(self)
|
||||||
self:_DeleteQueueItemByID(Mission.requestID[self.alias], self.queue)
|
if requestID then
|
||||||
|
self:_DeleteQueueItemByID(requestID, self.queue)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user