From 54bf6686eb95bb3007ac36a6b438ca323f8434bb Mon Sep 17 00:00:00 2001 From: VladMordock Date: Wed, 17 Feb 2021 19:17:27 +0100 Subject: [PATCH] lua will now send some timming information --- .../Mods/services/Perun/lua/perun_config.lua | 4 ++-- 01_DCS/Scripts/Hooks/Perun-hook.lua | 24 ++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/01_DCS/Mods/services/Perun/lua/perun_config.lua b/01_DCS/Mods/services/Perun/lua/perun_config.lua index bf9e9a2..b18012b 100644 --- a/01_DCS/Mods/services/Perun/lua/perun_config.lua +++ b/01_DCS/Mods/services/Perun/lua/perun_config.lua @@ -5,13 +5,13 @@ local PerunConfig = {} PerunConfig.TCPPerunHost = "localhost" -- (string) [default: "localhost"] IP adress of the Perun instance or "localhost" PerunConfig.TCPTargetPort = 48621 -- (int) [default: 48621] TCP port to send data to -PerunConfig.Instance = 3 -- (int) [default: 1] Id number of instance (if multiple DCS instances are to run at the same PC) +PerunConfig.Instance = 1 -- (int) [default: 1] Id number of instance (if multiple DCS instances are to run at the same PC) PerunConfig.RefreshStatus = 60 -- (int) [default: 60] Base refresh rate in seconds to send status update PerunConfig.RefreshMission = 120 -- (int) [default: 120] Refresh rate in seconds to send mission information PerunConfig.MissionStartNoDeathWindow = 300 -- (int) [default: 300] Number of secounds after mission start when death of the pilot will not go to statistics, shall avoid death penalty during spawning DCS bugs PerunConfig.DebugMode = 2 -- (int) [0 (default),1,2] Value greater than 0 will display Perun information in DCS log file, values: 1 - minimal verbose, 2 - all log information will be logged PerunConfig.MOTD_L1 = "Witamy na serwerze #1 Gildia.org !" -- (string) Message send to players connecting the server - Line 1 -PerunConfig.MOTD_L2 = "Wymagamy obecnosci DCS SRS oraz TeamSpeak - szczegoly na forum" -- (string) Message send to players connecting the server - Line 2 +PerunConfig.MOTD_L2 = "Wymagamy obecnosci DCS SRS (UNICOM 242.00MHz) - szczegoly na forum" -- (string) Message send to players connecting the server - Line 2 -- ###################### END OF SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION ###################### return PerunConfig diff --git a/01_DCS/Scripts/Hooks/Perun-hook.lua b/01_DCS/Scripts/Hooks/Perun-hook.lua index 1f93035..db22637 100644 --- a/01_DCS/Scripts/Hooks/Perun-hook.lua +++ b/01_DCS/Scripts/Hooks/Perun-hook.lua @@ -35,12 +35,15 @@ Perun.lastSentStatus = 0 Perun.lastSentMission = 0 Perun.lastSentKeepAlive = 0 Perun.lastConnectionError = 0 +Perun.lastFrameStart = 0; Perun.lastTimer = 0 Perun.lastReconnect = (-1) * Perun.ReconnectTimeout Perun.SendRetries = 2 Perun.RefreshKeepAlive = 3 +Perun.FrameTime = 0; Perun.socket = require("socket") -Perun.IsServer = DCS.isServer( ) +Perun.IsServer = DCS.isServer( ) + Perun.ConnectionError = "[Perun] ERROR: Connection broken - contact server admin!" -- ################################ Helper function definitions ################################ @@ -411,7 +414,9 @@ Perun.SendToPerun = function(data_id, data_package) _TempData["payload"]=data_package _TempData["timestamp"]=os.date('%Y-%m-%d %H:%M:%S') _TempData["instance"]=Perun.Instance - + _TempData['dcs_frame_time']=Perun.FrameTime * 1000000 + _TempData['dcs_current_frame_delay']=(DCS.getRealTime() - Perun.lastFrameStart) * 1000000 + -- Build TCP frame local _TCPFrame="" .. stripChars(net.lua2json(_TempData)) .. "" @@ -420,20 +425,22 @@ Perun.SendToPerun = function(data_id, data_package) local _intTries =0 local _err=nil local _dropped = true - + local _delay = 0 -- Try to send a few times (defind in settings section) local _now = DCS.getRealTime() while _intStatus == nil and _intTries < Perun.SendRetries do _intStatus, _err = Perun.TCP:send(_TCPFrame) if _err then -- Failure, packet was not send - Perun.AddLog("Packed not send : " .. data_id .. " , error: " .. _err .. ", tries: " .. _intTries,2) + _delay = (DCS.getRealTime() - Perun.lastFrameStart) * 1000000 + Perun.AddLog("Packed not send : " .. data_id .. " , error: " .. _err .. ", tries: " .. _intTries .. ", delay: " .. _delay,2) if _now > Perun.lastReconnect + Perun.ReconnectTimeout then Perun.ConnectToPerun() end else -- Succes, packet was send - Perun.AddLog("Packet send : " .. data_id .. " , tries:" .. _intTries,2) + _delay = (DCS.getRealTime() - Perun.lastFrameStart) * 1000000 + Perun.AddLog("Packet send : " .. data_id .. " , tries:" .. _intTries .. ", delay: " .. _delay,2) _dropped = false end _intTries=_intTries+1 @@ -804,6 +811,7 @@ end Perun.onSimulationFrame = function() -- Repeat for each simulator frame local _now = DCS.getRealTime() + Perun.lastFrameStart = _now -- First run if Perun.lastSentMission == 0 and Perun.lastSentStatus == 0 then @@ -829,6 +837,8 @@ Perun.onSimulationFrame = function() -- Send keepalive if _now > Perun.lastSentKeepAlive + Perun.RefreshKeepAlive then Perun.lastSentKeepAlive = _now + + -- Lets send aprox. frame time in us Perun.SendToPerun(0,nil) end @@ -842,7 +852,9 @@ Perun.onSimulationFrame = function() end end end - + + -- Calculate approx. frame time + Perun.FrameTime = DCS.getRealTime() - _now end Perun.onPlayerStart = function (id)