This commit is contained in:
Frank 2020-08-25 01:03:18 +02:00
parent cfc45cf068
commit 3f39ec0ae0
6 changed files with 169 additions and 77 deletions

View File

@ -642,10 +642,11 @@ do -- FSM
return errmsg
end
-- Protected call.
local Result, Value = xpcall( function() return self[handler]( self, unpack( params ) ) end, ErrorHandler )
--return self[handler](self, unpack( params ))
return Value
-- Protected call.
local Result, Value = xpcall( function() return self[handler]( self, unpack( params ) ) end, ErrorHandler )
return Value
end
end
@ -773,7 +774,7 @@ do -- FSM
end
else
self:I( "*** FSM *** NO Transition *** " .. self.current .. " --> " .. EventName .. " --> ? " )
self:T( "*** FSM *** NO Transition *** " .. self.current .. " --> " .. EventName .. " --> ? " )
end
return nil

View File

@ -7530,6 +7530,10 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
-- Get parking spot data table. This contains all free and "non-free" spots.
local parkingdata=airbase.parking --airbase:GetParkingSpotsTable()
---
-- Find all obstacles
---
-- List of obstacles.
local obstacles={}
@ -7579,6 +7583,10 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
end
end
---
-- Get Parking Spots
---
-- Parking data for all assets.
local parking={}

View File

@ -513,7 +513,7 @@ ATIS.Sound = {
MegaHertz={filename="MegaHertz.ogg", duration=0.87},
Meters={filename="Meters.ogg", duration=0.59},
MetersPerSecond={filename="MetersPerSecond.ogg", duration=1.14},
Miles={filename="Miles.ogg", duration=1.04},
Miles={filename="Miles.ogg", duration=0.60},
MillimetersOfMercury={filename="MillimetersOfMercury.ogg", duration=1.53},
Minus={filename="Minus.ogg", duration=0.64},
N0={filename="N-0.ogg", duration=0.55},
@ -534,6 +534,7 @@ ATIS.Sound = {
Right={filename="Right.ogg", duration=0.44},
Snow={filename="Snow.ogg", duration=0.48},
SnowStorm={filename="SnowStorm.ogg", duration=0.82},
StatuteMiles={filename="StatuteMiles.ogg", duration=1.15},
SunriseAt={filename="SunriseAt.ogg", duration=0.92},
SunsetAt={filename="SunsetAt.ogg", duration=0.95},
Temperature={filename="Temperature.ogg", duration=0.64},
@ -553,6 +554,7 @@ ATIS.Sound = {
TACANChannel={filename="TACANChannel.ogg", duration=0.88},
PRMGChannel={filename="PRMGChannel.ogg", duration=1.18},
RSBNChannel={filename="RSBNChannel.ogg", duration=1.14},
Zulu={filename="Zulu.ogg", duration=0.62},
}
@ -925,7 +927,7 @@ function ATIS:SetAltimeterQNH(switch)
return self
end
-- Suppresses QFE readout. Default is to report both QNH and QFE.
--- Suppresses QFE readout. Default is to report both QNH and QFE.
-- @param #ATIS self
-- @return #ATIS self
function ATIS:ReportQNHOnly()
@ -995,7 +997,7 @@ function ATIS:SetZuluTimeDifference(delta)
return self
end
-- Suppresses local time, sunrise, and sunset. Default is to report all these times.
--- Suppresses local time, sunrise, and sunset. Default is to report all these times.
-- @param #ATIS self
-- @return #ATIS self
function ATIS:ReportZuluTimeOnly()
@ -1502,7 +1504,7 @@ function ATIS:onafterBroadcast(From, Event, To)
-- Zulu Time
subtitle=string.format("%s Zulu", ZULU)
self.radioqueue:Number2Transmission(ZULU, nil, 0.5)
self:Transmission(ATIS.Sound.TimeZulu, 0.2, subtitle)
self:Transmission(ATIS.Sound.Zulu, 0.2, subtitle)
alltext=alltext..";\n"..subtitle
if not self.zulutimeonly then
@ -1557,7 +1559,7 @@ function ATIS:onafterBroadcast(From, Event, To)
if self.metric then
self:Transmission(ATIS.Sound.Kilometers, 0.2)
else
self:Transmission(ATIS.Sound.Miles, 0.2)
self:Transmission(ATIS.Sound.StatuteMiles, 0.2)
end
alltext=alltext..";\n"..subtitle
@ -1974,13 +1976,6 @@ function ATIS:onafterBroadcast(From, Event, To)
alltext=alltext..";\n"..subtitle
end
--[[
-- End of Information Alpha, Bravo, ...
subtitle=string.format("End of information %s", NATO)
self:Transmission(ATIS.Sound.EndOfInformation, 0.5, subtitle)
self.radioqueue:NewTransmission(string.format("NATO Alphabet/%s.ogg", NATO), 0.75, self.soundpath)
--]]
-- Advice on initial...
subtitle=string.format("Advise on initial contact, you have information %s", NATO)

View File

@ -1586,7 +1586,7 @@ end
--- Set Reaction on Threat (ROT) for this mission.
-- @param #AUFTRAG self
-- @param #string roe Mission ROT.
-- @param #string rot Mission ROT.
-- @return #AUFTRAG self
function AUFTRAG:SetROT(rot)

View File

@ -156,8 +156,9 @@ function PROFILER.Start(Delay, Duration)
env.info(string.format("- Will be stopped when mission ends"))
end
env.info(string.format("- Calls per second threshold %.3f/sec", PROFILER.ThreshCPS))
env.info(string.format("- Total function time threshold %.3f/sec", PROFILER.ThreshTtot))
env.info(string.format("- Output file \"%s\" in your DCS log file folder", PROFILER.getfilename()))
env.info(string.format("- Total function time threshold %.3f sec", PROFILER.ThreshTtot))
env.info(string.format("- Output file \"%s\" in your DCS log file folder", PROFILER.getfilename(PROFILER.fileNameSuffix)))
env.info(string.format("- Output file \"%s\" in CSV format", PROFILER.getfilename("csv")))
env.info('###############################################################################')
@ -306,13 +307,47 @@ function PROFILER.showTable(data, f, runTimeGame)
end
--- Print csv file.
-- @param #table data Data table.
-- @param #number runTimeGame Game run time in seconds.
function PROFILER.printCSV(data, runTimeGame)
-- Output file.
local file=PROFILER.getfilename("csv")
local g=io.open(file, 'w')
-- Header.
local text="Function,Total Calls,Calls per Sec,Total Time,Total in %,Sec per Call,Source File;Line Number,"
g:write(text.."\r\n")
-- Loop over data.
for i=1, #data do
local t=data[i] --#PROFILER.Data
-- Calls per second.
local cps=t.count/runTimeGame
-- Output
local txt=string.format("%s,%d,%.1f,%.3f,%.3f,%.3f,%s,%s,", t.func, t.count, cps, t.tm, t.tm/runTimeGame*100, t.tm/t.count, tostring(t.src), tostring(t.line))
g:write(txt.."\r\n")
end
-- Close file.
g:close()
end
--- Write info to output file.
-- @param #string ext Extension.
-- @return #string File name.
function PROFILER.getfilename()
function PROFILER.getfilename(ext)
local dir=lfs.writedir()..[[Logs\]]
local file=dir..PROFILER.fileNamePrefix.."."..PROFILER.fileNameSuffix
ext=ext or PROFILER.fileNameSuffix
local file=dir..PROFILER.fileNamePrefix.."."..ext
if not UTILS.FileExists(file) then
return file
@ -320,7 +355,7 @@ function PROFILER.getfilename()
for i=1,999 do
local file=string.format("%s%s-%03d.%s", dir,PROFILER.fileNamePrefix, i, PROFILER.fileNameSuffix)
local file=string.format("%s%s-%03d.%s", dir,PROFILER.fileNamePrefix, i, ext)
if not UTILS.FileExists(file) then
return file
@ -336,7 +371,7 @@ end
function PROFILER.showInfo(runTimeGame, runTimeOS)
-- Output file.
local file=PROFILER.getfilename()
local file=PROFILER.getfilename(PROFILER.fileNameSuffix)
local f=io.open(file, 'w')
-- Gather data.
@ -427,16 +462,15 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
table.insert(t, tpairs)
end
env.info("**************************************************************************************************")
env.info(string.format("Profiler"))
env.info(string.format("--------"))
env.info('############################ Profiler Stopped ############################')
env.info(string.format("* Runtime Game : %s = %d sec", UTILS.SecondsToClock(runTimeGame, true), runTimeGame))
env.info(string.format("* Runtime Real : %s = %d sec", UTILS.SecondsToClock(runTimeOS, true), runTimeOS))
env.info(string.format("* Function time : %s = %.1f sec (%.1f percent of runtime game)", UTILS.SecondsToClock(Ttot, true), Ttot, Ttot/runTimeGame*100))
env.info(string.format("* Total functions : %d", #t))
env.info(string.format("* Total func calls : %d", Calls))
env.info(string.format("* Writing to file : \"%s\"", file))
env.info("**************************************************************************************************")
env.info(string.format("* Writing to file : \"%s\"", PROFILER.getfilename("csv")))
env.info("##############################################################################")
-- Sort by total time.
table.sort(t, function(a,b) return a.tm>b.tm end)
@ -459,7 +493,7 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
PROFILER._flog(f,string.format("* Total func calls = %d", Calls))
PROFILER._flog(f,"")
PROFILER._flog(f,string.format("* Calls per second threshold = %.3f/sec", PROFILER.ThreshCPS))
PROFILER._flog(f,string.format("* Total func time threshold = %.3f/sec", PROFILER.ThreshTtot))
PROFILER._flog(f,string.format("* Total func time threshold = %.3f sec", PROFILER.ThreshTtot))
PROFILER._flog(f,"")
PROFILER._flog(f,"************************************************************************************************************************")
PROFILER._flog(f,"")
@ -498,5 +532,8 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
PROFILER._flog(f,"************************************************************************************************************************")
-- Close file.
f:close()
-- Print csv file.
PROFILER.printCSV(t, runTimeGame)
end

View File

@ -1292,41 +1292,124 @@ function AIRBASE:GetRunwayData(magvar, mark)
return {}
end
-- Get spawn points on runway.
-- Get spawn points on runway. These can be used to determine the runway heading.
local runwaycoords=self:GetParkingSpotsCoordinates(AIRBASE.TerminalType.Runway)
-- Debug: For finding the numbers of the spawn points belonging to each runway.
if false then
for i,_coord in pairs(runwaycoords) do
local coord=_coord --Core.Point#COORDINATE
coord:Translate(100, 0):MarkToAll("Runway i="..i)
end
end
-- Magnetic declination.
magvar=magvar or UTILS.GetMagneticDeclination()
-- Number of runways.
local N=#runwaycoords
local dN=2
local ex=false
local N2=N/2
local exception=false
-- Airbase name.
local name=self:GetName()
-- Exceptions
if name==AIRBASE.Nevada.Jean_Airport or
name==AIRBASE.Nevada.Creech_AFB or
name==AIRBASE.PersianGulf.Abu_Dhabi_International_Airport or
name==AIRBASE.PersianGulf.Dubai_Intl or
name==AIRBASE.PersianGulf.Shiraz_International_Airport or
name==AIRBASE.PersianGulf.Kish_International_Airport then
name==AIRBASE.PersianGulf.Kish_International_Airport
then
N=#runwaycoords/2
dN=1
ex=true
-- 1-->4, 2-->3, 3-->2, 4-->1
exception=1
elseif UTILS.GetDCSMap()==DCSMAP.Syria and N>=2 and
name~=AIRBASE.Syria.Minakh and
name~=AIRBASE.Syria.Damascus and
name~=AIRBASE.Syria.Khalkhalah and
name~=AIRBASE.Syria.Marj_Ruhayyil and
name~=AIRBASE.Syria.Beirut_Rafic_Hariri then
-- 1-->3, 2-->4, 3-->1, 4-->2
exception=2
end
local function f(i)
local j
if exception==1 then
j=N-(i+1) -- 1-->4, 2-->3
elseif exception==2 then
if i<=N2 then
j=i+N2 -- 1-->3, 2-->4
else
j=i-N2 -- 3-->1, 4-->3
end
else
if i%2==0 then
j=i-1 -- even 2-->1, 4-->3
else
j=i+1 -- odd 1-->2, 3-->4
end
end
-- Special case where there is no obvious order.
if name==AIRBASE.Syria.Beirut_Rafic_Hariri then
if i==1 then
j=3
elseif i==2 then
j=6
elseif i==3 then
j=1
elseif i==4 then
j=5
elseif i==5 then
j=4
elseif i==6 then
j=2
end
end
if name==AIRBASE.Syria.Ramat_David then
if i==1 then
j=4
elseif i==2 then
j=6
elseif i==3 then
j=5
elseif i==4 then
j=1
elseif i==5 then
j=3
elseif i==6 then
j=2
end
end
return j
end
for i=1,N,dN do
for i=1,N do
local j=i+1
if ex then
--j=N+i
j=#runwaycoords-i+1
end
-- Get the other spawn point coordinate.
local j=f(i)
-- Coordinates of the two runway points.
local c1=runwaycoords[i] --Core.Point#COORDINATES
local c2=runwaycoords[j] --Core.Point#COORDINATES
local c1=runwaycoords[i] --Core.Point#COORDINATE
local c2=runwaycoords[j] --Core.Point#COORDINATE
-- Heading of runway.
local hdg=c1:HeadingTo(c2)
@ -1343,11 +1426,11 @@ function AIRBASE:GetRunwayData(magvar, mark)
runway.endpoint=c2
-- Debug info.
self:T(string.format("Airbase %s: Adding runway id=%s, heading=%03d, length=%d m", self:GetName(), runway.idx, runway.heading, runway.length))
self:I(string.format("Airbase %s: Adding runway id=%s, heading=%03d, length=%d m i=%d j=%d", self:GetName(), runway.idx, runway.heading, runway.length, i, j))
-- Debug mark
if mark then
runway.position:MarkToAll(string.format("Runway %s: true heading=%03d (magvar=%d), length=%d m", runway.idx, runway.heading, magvar, runway.length))
runway.position:MarkToAll(string.format("Runway %s: true heading=%03d (magvar=%d), length=%d m, i=%d, j=%d", runway.idx, runway.heading, magvar, runway.length, i, j))
end
-- Add runway.
@ -1355,38 +1438,6 @@ function AIRBASE:GetRunwayData(magvar, mark)
end
-- Get inverse runways
local inverse={}
for _,_runway in pairs(runways) do
local r=_runway --#AIRBASE.Runway
local runway={} --#AIRBASE.Runway
runway.heading=r.heading-180
if runway.heading<0 then
runway.heading=runway.heading+360
end
runway.idx=string.format("%02d", math.max(0, UTILS.Round((runway.heading-magvar)/10, 0)))
runway.length=r.length
runway.position=r.endpoint
runway.endpoint=r.position
-- Debug info.
self:T(string.format("Airbase %s: Adding runway id=%s, heading=%03d, length=%d m", self:GetName(), runway.idx, runway.heading, runway.length))
-- Debug mark
if mark then
runway.position:MarkToAll(string.format("Runway %s: true heading=%03d (magvar=%d), length=%d m", runway.idx, runway.heading, magvar, runway.length))
end
-- Add runway.
table.insert(inverse, runway)
end
-- Add inverse runway.
for _,runway in pairs(inverse) do
table.insert(runways, runway)
end
return runways
end