Fix for missing Perun.RefreshStatus

This commit is contained in:
VladMordock
2020-12-29 17:41:45 +01:00
parent 9569762eac
commit 4e50fcbca9

View File

@@ -10,6 +10,7 @@ package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
-- Load config file -- Load config file
local Config = require "perun_config" local Config = require "perun_config"
Perun.RefreshStatus = Config.RefreshStatus
Perun.RefreshMission = Config.RefreshMission Perun.RefreshMission = Config.RefreshMission
Perun.TCPTargetPort = Config.TCPTargetPort Perun.TCPTargetPort = Config.TCPTargetPort
Perun.TCPPerunHost = Config.TCPPerunHost Perun.TCPPerunHost = Config.TCPPerunHost
@@ -665,16 +666,12 @@ Perun.UpdateStatus = function()
Perun.SendToPerun(2,Perun.StatusData) Perun.SendToPerun(2,Perun.StatusData)
end end
Perun.UpdateMission = function() Perun.UpdateSlots = function()
-- Main function for mission information updates
Perun.AddLog("Updating mission data",2)
-- Get mission information
Perun.MissionData=DCS.getCurrentMission()
-- Update and send slots data -- Update and send slots data
Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions() Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions()
Perun.SlotsData['slots']={} Perun.SlotsData['slots']={}
-- Build up slot table -- Build up slot table
for _j, _i in pairs(Perun.SlotsData['coalitions']) do for _j, _i in pairs(Perun.SlotsData['coalitions']) do
Perun.SlotsData['slots'][_j]=DCS.getAvailableSlots(_j) Perun.SlotsData['slots'][_j]=DCS.getAvailableSlots(_j)
@@ -693,8 +690,14 @@ Perun.UpdateMission = function()
Perun.AddLog("Sending slots data",2) Perun.AddLog("Sending slots data",2)
Perun.SendToPerun(3,Perun.SlotsData) Perun.SendToPerun(3,Perun.SlotsData)
end
-- Perun.SendToPerun(4,Perun.MissionData) -- TBD can cause data transmission troubles Perun.UpdateMission = function()
-- Main function for mission information updates
Perun.AddLog("Updating mission data",2)
-- Get mission information
Perun.MissionData=DCS.getCurrentMission()
Perun.AddLog("Mission data updated",2) Perun.AddLog("Mission data updated",2)
end end
@@ -739,14 +742,16 @@ Perun.onSimulationFrame = function()
-- First run -- First run
if Perun.lastSentMission == 0 and Perun.lastSentStatus == 0 then if Perun.lastSentMission == 0 and Perun.lastSentStatus == 0 then
Perun.lastSentMission = _now
Perun.UpdateMission() Perun.UpdateMission()
Perun.UpdateSlots()
end end
-- Send mission update and update JSON -- Send mission update and update JSON
if _now > Perun.lastSentMission + Perun.RefreshMission then if _now > Perun.lastSentMission + Perun.RefreshMission then
Perun.lastSentMission = _now Perun.lastSentMission = _now
-- Perun.UpdateMission() XXX Perun.UpdateMission()
end end
-- Send status update -- Send status update