mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 23:05:39 +02:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afb935da72 | ||
|
|
61e201b261 | ||
|
|
fc009892f2 | ||
|
|
732f8b5fce | ||
|
|
ceec3a7616 | ||
|
|
763e6e3314 | ||
|
|
2ad1a531b8 | ||
|
|
c35c216c78 | ||
|
|
0a17fcf0b2 | ||
|
|
b36127c272 | ||
|
|
bd0769c997 | ||
|
|
27c2163784 | ||
|
|
624347b1a0 | ||
|
|
8bbac989cd | ||
|
|
fcb007bc98 | ||
|
|
2f7d2d07bb | ||
|
|
48f60abbfa | ||
|
|
20d19b2670 | ||
|
|
49e35bcd5e | ||
|
|
7a8a36e91b | ||
|
|
a0742c8c43 | ||
|
|
666c3a859f | ||
|
|
fb0620d178 | ||
|
|
1d6b32872b | ||
|
|
af4bc135da | ||
|
|
57483ad4c8 | ||
|
|
fcb2f62646 |
@@ -9,18 +9,18 @@ package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
|
|||||||
|
|
||||||
Perun.RefreshStatus = 15 -- (int) base refresh rate in seconds to send status update (values lower than 60 may affect performance!)
|
Perun.RefreshStatus = 15 -- (int) base refresh rate in seconds to send status update (values lower than 60 may affect performance!)
|
||||||
Perun.RefreshMission = 60 -- (int) refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
|
Perun.RefreshMission = 60 -- (int) refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
|
||||||
Perun.TCPTargetPort = 48621 -- (int) TCP port to send data to
|
Perun.TCPTargetPort = 48622 -- (int) TCP port to send data to
|
||||||
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
|
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
|
||||||
Perun.Instance = 1 -- (int) Id number of instance (if multiple DCS instances are to run at the same PC)
|
Perun.Instance = 2 -- (int) Id number of instance (if multiple DCS instances are to run at the same PC)
|
||||||
Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
|
Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
|
||||||
Perun.MOTD_L1 = "Welcome to our server!" -- (string) Message send to players connecting the server - Line 1
|
Perun.MOTD_L1 = "Witamy na serwerze Gildia.org !" -- (string) Message send to players connecting the server - Line 1
|
||||||
Perun.MOTD_L2 = "Please use SRS radio." -- (string) Message send to players connecting the server - Line 2
|
Perun.MOTD_L2 = "Wymagamy obecnosci DCS SRS oraz TeamSpeak - szczegoly na forum" -- (string) Message send to players connecting the server - Line 2
|
||||||
|
|
||||||
-- ###################### END OF SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION ######################
|
-- ###################### END OF SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION ######################
|
||||||
|
|
||||||
|
|
||||||
-- Variable init
|
-- Variable init
|
||||||
Perun.Version = "v0.8.0"
|
Perun.Version = "v0.8.2"
|
||||||
Perun.StatusData = {}
|
Perun.StatusData = {}
|
||||||
Perun.SlotsData = {}
|
Perun.SlotsData = {}
|
||||||
Perun.MissionData = {}
|
Perun.MissionData = {}
|
||||||
@@ -30,15 +30,16 @@ Perun.StatDataLastType = {}
|
|||||||
Perun.MissionHash=""
|
Perun.MissionHash=""
|
||||||
Perun.lastSentStatus =0
|
Perun.lastSentStatus =0
|
||||||
Perun.lastSentMission =0
|
Perun.lastSentMission =0
|
||||||
|
Perun.lastSentKeepAlive =0
|
||||||
|
Perun.lastReconnect = 0
|
||||||
Perun.JsonStatusLocation = lfs.writedir() .. Perun.JsonStatusLocation
|
Perun.JsonStatusLocation = lfs.writedir() .. Perun.JsonStatusLocation
|
||||||
Perun.socket = require("socket")
|
Perun.socket = require("socket")
|
||||||
Perun.IsServer = true --DCS.isServer( ) -- TBD looks like DCS API error, always returning True
|
Perun.IsServer = true --DCS.isServer( ) -- TBD looks like DCS API error, always returning True
|
||||||
Perun.TCPSourcePort = Perun.TCPTargetPort + 10 + Perun.Instance - 1
|
|
||||||
|
|
||||||
-- ########### Helper function definitions ###########
|
-- ########### Helper function definitions ###########
|
||||||
function stripChars(str)
|
function stripChars(str)
|
||||||
-- remove accents characters from string
|
-- remove accents characters from string
|
||||||
-- via https://stackoverflow.com/questions/50459102/replace-accented-characters-in-string-to-standard-with-lua TBD: rewrite
|
-- via https://stackoverflow.com/questions/50459102/replace-accented-characters-in-string-to-standard-with-lua
|
||||||
tableAccents = {}
|
tableAccents = {}
|
||||||
tableAccents["à"] = "a"
|
tableAccents["à"] = "a"
|
||||||
tableAccents["á"] = "a"
|
tableAccents["á"] = "a"
|
||||||
@@ -152,6 +153,11 @@ Perun.SideID2Name = function(id)
|
|||||||
return sides[id]
|
return sides[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Perun.UpdateStatusPart = function(part_id, data_package)
|
||||||
|
-- Helper for status update container
|
||||||
|
Perun.StatusData[part_id] = data_package
|
||||||
|
end
|
||||||
|
|
||||||
-- ########### Main code ###########
|
-- ########### Main code ###########
|
||||||
|
|
||||||
Perun.AddLog = function(text)
|
Perun.AddLog = function(text)
|
||||||
@@ -159,29 +165,6 @@ Perun.AddLog = function(text)
|
|||||||
net.log("Perun : ".. text)
|
net.log("Perun : ".. text)
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.ConnectToPerun = function ()
|
|
||||||
Perun.AddLog("Connecting to TCP server")
|
|
||||||
Perun.TCP = assert(Perun.socket.tcp())
|
|
||||||
Perun.TCP:settimeout(2000)
|
|
||||||
_, err = Perun.TCP:connect(Perun.TCPPerunHost, Perun.TCPTargetPort)
|
|
||||||
if err then
|
|
||||||
Perun.AddLog("TCP connection error : " .. err)
|
|
||||||
else
|
|
||||||
Perun.AddLog("Connected to TCP server")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Perun.SendPacket = function (data_id,temp)
|
|
||||||
_, err = Perun.TCP:send(temp)
|
|
||||||
|
|
||||||
if err then
|
|
||||||
Perun.AddLog("Packed drop " .. data_id .. ", error: " .. err)
|
|
||||||
Perun.ConnectToPerun()
|
|
||||||
else
|
|
||||||
Perun.AddLog("Packet send " .. data_id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Perun.UpdateJsonStatus = function()
|
Perun.UpdateJsonStatus = function()
|
||||||
-- Updates status json file
|
-- Updates status json file
|
||||||
TempData={}
|
TempData={}
|
||||||
@@ -195,10 +178,28 @@ Perun.UpdateJsonStatus = function()
|
|||||||
perun_export = io.open(Perun.JsonStatusLocation .. "perun_status_data.json", "w")
|
perun_export = io.open(Perun.JsonStatusLocation .. "perun_status_data.json", "w")
|
||||||
perun_export:write(_temp .. "\n")
|
perun_export:write(_temp .. "\n")
|
||||||
perun_export:close()
|
perun_export:close()
|
||||||
|
Perun.AddLog("Updated JSON")
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.Send = function(data_id, data_package)
|
Perun.ConnectToPerun = function ()
|
||||||
-- Sends data package
|
-- Connects to Perun server
|
||||||
|
Perun.AddLog("Connecting to TCP server")
|
||||||
|
Perun.TCP = assert(Perun.socket.tcp())
|
||||||
|
Perun.TCP:settimeout(5000)
|
||||||
|
|
||||||
|
_, err = Perun.TCP:connect(Perun.TCPPerunHost, Perun.TCPTargetPort)
|
||||||
|
if err then
|
||||||
|
Perun.AddLog("TCP connection error : " .. err)
|
||||||
|
else
|
||||||
|
Perun.AddLog("Connected to TCP server")
|
||||||
|
Perun.TCP:setoption("keepalive")
|
||||||
|
Perun.lastReconnect = _now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Perun.SendToPerun = function(data_id, data_package)
|
||||||
|
-- Prepares and sends data package
|
||||||
|
-- Prepare data
|
||||||
TempData={}
|
TempData={}
|
||||||
TempData["type"]=data_id
|
TempData["type"]=data_id
|
||||||
TempData["payload"]=data_package
|
TempData["payload"]=data_package
|
||||||
@@ -208,12 +209,25 @@ Perun.Send = function(data_id, data_package)
|
|||||||
temp=net.lua2json(TempData)
|
temp=net.lua2json(TempData)
|
||||||
temp=stripChars(temp)
|
temp=stripChars(temp)
|
||||||
|
|
||||||
Perun.SendPacket(data_id,temp)
|
-- TCP Part - sending
|
||||||
end
|
Perun.AddLog("Sending packet: " .. data_id)
|
||||||
|
intStatus = nil
|
||||||
Perun.UpdateStatusPart = function(part_id, data_package)
|
intTries =0
|
||||||
-- Helper for status update container
|
err=nil
|
||||||
Perun.StatusData[part_id] = data_package
|
while intStatus == nil and intTries < 3 do
|
||||||
|
intStatus, err = Perun.TCP:send(temp)
|
||||||
|
if err then
|
||||||
|
Perun.AddLog("Packed not send : " .. data_id .. " , error: " .. err .. ", tries: " .. intTries)
|
||||||
|
Perun.ConnectToPerun()
|
||||||
|
else
|
||||||
|
Perun.AddLog("Packet send : " .. data_id .. " , tries:" .. intTries)
|
||||||
|
end
|
||||||
|
intTries=intTries+1
|
||||||
|
err = nil
|
||||||
|
end
|
||||||
|
if err then
|
||||||
|
Perun.AddLog("Packed dropped : " .. data_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.UpdateStatus = function()
|
Perun.UpdateStatus = function()
|
||||||
@@ -223,14 +237,14 @@ Perun.UpdateStatus = function()
|
|||||||
-- Update version data
|
-- Update version data
|
||||||
Perun.ServerData['v_dcs_hook']=Perun.Version
|
Perun.ServerData['v_dcs_hook']=Perun.Version
|
||||||
|
|
||||||
-- Update server data
|
-- Update clients data data
|
||||||
_table=net.get_player_list()
|
_table=net.get_player_list()
|
||||||
_count = 0
|
_count = 0
|
||||||
for _ in pairs(_table) do _count = _count + 1 end
|
for _ in pairs(_table) do _count = _count + 1 end
|
||||||
Perun.ServerData['c_players']=_count
|
Perun.ServerData['c_players']=_count
|
||||||
|
|
||||||
-- Send
|
-- Send
|
||||||
Perun.Send(1,Perun.ServerData)
|
Perun.SendToPerun(1,Perun.ServerData)
|
||||||
|
|
||||||
-- Status data - update all subsections
|
-- Status data - update all subsections
|
||||||
-- 1 - Mission
|
-- 1 - Mission
|
||||||
@@ -253,7 +267,7 @@ Perun.UpdateStatus = function()
|
|||||||
Perun.UpdateStatusPart("players",_temp2)
|
Perun.UpdateStatusPart("players",_temp2)
|
||||||
|
|
||||||
-- Send
|
-- Send
|
||||||
Perun.Send(2,Perun.StatusData)
|
Perun.SendToPerun(2,Perun.StatusData)
|
||||||
|
|
||||||
-- Update slots data
|
-- Update slots data
|
||||||
Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions()
|
Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions()
|
||||||
@@ -275,18 +289,18 @@ Perun.UpdateStatus = function()
|
|||||||
|
|
||||||
end
|
end
|
||||||
-- Send
|
-- Send
|
||||||
Perun.Send(3,Perun.SlotsData)
|
Perun.SendToPerun(3,Perun.SlotsData)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Perun.UpdateMission = function()
|
Perun.UpdateMission = function()
|
||||||
-- Main function for mission information updates
|
-- Main function for mission information updates
|
||||||
Perun.MissionData=DCS.getCurrentMission()
|
Perun.MissionData=DCS.getCurrentMission()
|
||||||
-- Perun.Send(4,Perun.MissionData)
|
-- Perun.SendToPerun(4,Perun.MissionData) -- TBD can cause data transmission troubles
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.LogChat = function(playerID,msg,all)
|
Perun.LogChat = function(playerID,msg,all)
|
||||||
-- Log chat messages
|
-- Logs chat messages
|
||||||
|
|
||||||
data={}
|
data={}
|
||||||
data['player']= net.get_player_info(playerID, "name")
|
data['player']= net.get_player_info(playerID, "name")
|
||||||
@@ -296,11 +310,11 @@ Perun.LogChat = function(playerID,msg,all)
|
|||||||
data['datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
data['datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||||
data['missionhash']=Perun.MissionHash
|
data['missionhash']=Perun.MissionHash
|
||||||
|
|
||||||
Perun.Send(50,data)
|
Perun.SendToPerun(50,data)
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.LogEvent = function(log_type,log_content,log_arg_1,log_arg_2)
|
Perun.LogEvent = function(log_type,log_content,log_arg_1,log_arg_2)
|
||||||
-- Log chat messages
|
-- Logs chat messages
|
||||||
|
|
||||||
data={}
|
data={}
|
||||||
data['log_type']= log_type
|
data['log_type']= log_type
|
||||||
@@ -310,7 +324,7 @@ Perun.LogEvent = function(log_type,log_content,log_arg_1,log_arg_2)
|
|||||||
data['log_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
data['log_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||||
data['log_missionhash']=Perun.MissionHash
|
data['log_missionhash']=Perun.MissionHash
|
||||||
|
|
||||||
Perun.Send(51,data)
|
Perun.SendToPerun(51,data)
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.LogStatsCount = function(argPlayerID,argAction,argType)
|
Perun.LogStatsCount = function(argPlayerID,argAction,argType)
|
||||||
@@ -358,6 +372,7 @@ Perun.LogStatsCount = function(argPlayerID,argAction,argType)
|
|||||||
Perun.StatData[_ucid]['ps_ejections']=Perun.StatData[_ucid]['ps_ejections']+1
|
Perun.StatData[_ucid]['ps_ejections']=Perun.StatData[_ucid]['ps_ejections']+1
|
||||||
elseif argAction == "pilot_death" then
|
elseif argAction == "pilot_death" then
|
||||||
if DCS.getModelTime() > 300 then
|
if DCS.getModelTime() > 300 then
|
||||||
|
-- we do not track deaths during first 5 minutes due to spawning issues TBD
|
||||||
Perun.StatData[_ucid]['ps_deaths']=Perun.StatData[_ucid]['ps_deaths']+1
|
Perun.StatData[_ucid]['ps_deaths']=Perun.StatData[_ucid]['ps_deaths']+1
|
||||||
end
|
end
|
||||||
elseif argAction == "friendly_fire" then
|
elseif argAction == "friendly_fire" then
|
||||||
@@ -453,7 +468,7 @@ Perun.LogStats = function(playerID)
|
|||||||
data['stat_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
data['stat_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||||
data['stat_missionhash']=Perun.MissionHash
|
data['stat_missionhash']=Perun.MissionHash
|
||||||
|
|
||||||
Perun.Send(52,data)
|
Perun.SendToPerun(52,data)
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.LogLogin = function(playerID)
|
Perun.LogLogin = function(playerID)
|
||||||
@@ -465,7 +480,7 @@ Perun.LogLogin = function(playerID)
|
|||||||
data['login_name']=net.get_player_info(playerID, 'name')
|
data['login_name']=net.get_player_info(playerID, 'name')
|
||||||
data['login_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
data['login_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
Perun.Send(53,data)
|
Perun.SendToPerun(53,data)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- ########### Event callbacks ###########
|
--- ########### Event callbacks ###########
|
||||||
@@ -510,6 +525,12 @@ Perun.onSimulationFrame = function()
|
|||||||
|
|
||||||
Perun.UpdateStatus()
|
Perun.UpdateStatus()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Send keepalive
|
||||||
|
if _now > Perun.lastSentKeepAlive + 5 then
|
||||||
|
Perun.lastSentKeepAlive = _now
|
||||||
|
Perun.SendToPerun(0,nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.onPlayerStart = function (id)
|
Perun.onPlayerStart = function (id)
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ public class DatabaseController
|
|||||||
strUDPFrame.payload["v_win"] = "v" + Globals.strPerunVersion; // Inject app version information
|
strUDPFrame.payload["v_win"] = "v" + Globals.strPerunVersion; // Inject app version information
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specific SQL
|
// Specific SQL per each frame type
|
||||||
if (strUDPFrameType == "50")
|
if (strUDPFrameType == "50")
|
||||||
{
|
{
|
||||||
// Add entry to chat log
|
// Add entry to chat log
|
||||||
strSQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.ucid + "' );";
|
strSQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.ucid + "' );";
|
||||||
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated` = " + strUDPFrameTimestamp + ",`pe_DataPlayers_lastname`='" + strUDPFrame.payload.player + "' WHERE `pe_DataPlayers_ucid`='" + strUDPFrame.payload.ucid + "' ;";
|
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated` = " + strUDPFrameTimestamp + ",`pe_DataPlayers_lastname`='" + strUDPFrame.payload.player + "' WHERE `pe_DataPlayers_ucid`='" + strUDPFrame.payload.ucid + "' ;";
|
||||||
strSQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + strUDPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`="+ strUDPFrameInstance + ");";
|
strSQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + strUDPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
|
||||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + " ;";
|
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + " ;";
|
||||||
strSQLQueryTxt += "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`,`pe_LogChat_missionhash_id`) VALUES (NULL,'" + strUDPFrame.payload.datetime + "', (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.ucid + "'), '" + strUDPFrame.payload.msg + "', '" + strUDPFrame.payload.all + "',(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "'));";
|
strSQLQueryTxt += "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`,`pe_LogChat_missionhash_id`) VALUES (NULL,'" + strUDPFrame.payload.datetime + "', (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.ucid + "'), '" + strUDPFrame.payload.msg + "', '" + strUDPFrame.payload.all + "',(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "'));";
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ public class DatabaseController
|
|||||||
// Add entry to event log
|
// Add entry to event log
|
||||||
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.log_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
|
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.log_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
|
||||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ";";
|
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ";";
|
||||||
strSQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_arg1`,`pe_LogEvent_arg2`,`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ('"+ strUDPFrame.payload.log_arg_1 + "','"+ strUDPFrame.payload.log_arg_2 + "', NULL, '" + strUDPFrame.payload.log_datetime + "', '" + strUDPFrame.payload.log_type + "', '" + strUDPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "'));";
|
strSQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_arg1`,`pe_LogEvent_arg2`,`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ('" + strUDPFrame.payload.log_arg_1 + "','" + strUDPFrame.payload.log_arg_2 + "', NULL, '" + strUDPFrame.payload.log_datetime + "', '" + strUDPFrame.payload.log_type + "', '" + strUDPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "'));";
|
||||||
}
|
}
|
||||||
else if (strUDPFrameType == "52")
|
else if (strUDPFrameType == "52")
|
||||||
{
|
{
|
||||||
@@ -74,15 +74,15 @@ public class DatabaseController
|
|||||||
|
|
||||||
strSQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.login_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where pe_DataPlayers_ucid='" + strUDPFrame.payload.login_ucid + "');";
|
strSQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.login_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where pe_DataPlayers_ucid='" + strUDPFrame.payload.login_ucid + "');";
|
||||||
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET pe_DataPlayers_lastip='" + strUDPFrame.payload.login_ipaddr + "', pe_DataPlayers_lastname='" + strUDPFrame.payload.login_name + "',pe_DataPlayers_updated='" + strUDPFrame.payload.login_datetime + "' WHERE `pe_DataPlayers_ucid`= '" + strUDPFrame.payload.login_ucid + "';";
|
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET pe_DataPlayers_lastip='" + strUDPFrame.payload.login_ipaddr + "', pe_DataPlayers_lastname='" + strUDPFrame.payload.login_name + "',pe_DataPlayers_updated='" + strUDPFrame.payload.login_datetime + "' WHERE `pe_DataPlayers_ucid`= '" + strUDPFrame.payload.login_ucid + "';";
|
||||||
strSQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`,`pe_LogLogins_instance`) VALUES ('" + strUDPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + strUDPFrame.payload.login_ucid + "'), '" + strUDPFrame.payload.login_name + "', '" + strUDPFrame.payload.login_ipaddr + "','"+ strUDPFrameInstance + "');";
|
strSQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`,`pe_LogLogins_instance`) VALUES ('" + strUDPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + strUDPFrame.payload.login_ucid + "'), '" + strUDPFrame.payload.login_name + "', '" + strUDPFrame.payload.login_ipaddr + "','" + strUDPFrameInstance + "');";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// General definition used for 1-10 type packets
|
// General definition used for 1-10 type packets
|
||||||
strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload); // Deserialize payload
|
strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload); // Deserialize payload
|
||||||
|
|
||||||
strSQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`,`pe_dataraw_instance`) SELECT '" + strUDPFrameType + "','"+ strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE `pe_dataraw_type` = '" + strUDPFrameType + "' AND `pe_dataraw_instance` = " + strUDPFrameInstance + ");";
|
strSQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`,`pe_dataraw_instance`) SELECT '" + strUDPFrameType + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE `pe_dataraw_type` = '" + strUDPFrameType + "' AND `pe_dataraw_instance` = " + strUDPFrameInstance + ");";
|
||||||
strSQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = JSON_QUOTE('" + strUDPFramePayload + "'), `pe_dataraw_updated`=" + strUDPFrameTimestamp + " WHERE `pe_dataraw_type`=" + strUDPFrameType + " AND `pe_dataraw_instance` = "+ strUDPFrameInstance + ";";
|
strSQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = JSON_QUOTE('" + strUDPFramePayload + "'), `pe_dataraw_updated`=" + strUDPFrameTimestamp + " WHERE `pe_dataraw_type`=" + strUDPFrameType + " AND `pe_dataraw_instance` = " + strUDPFrameInstance + ";";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect to mysql and execute sql
|
// Connect to mysql and execute sql
|
||||||
@@ -103,29 +103,31 @@ public class DatabaseController
|
|||||||
Console.WriteLine(rdrMySQL[0] + " -- " + rdrMySQL[1]);
|
Console.WriteLine(rdrMySQL[0] + " -- " + rdrMySQL[1]);
|
||||||
}
|
}
|
||||||
rdrMySQL.Close();
|
rdrMySQL.Close();
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > MySQL updated, package type: " + strUDPFrameType);
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > MySQL updated, package type: " + strUDPFrameType);
|
||||||
}
|
}
|
||||||
catch (ArgumentException a_ex)
|
catch (ArgumentException a_ex)
|
||||||
{
|
{
|
||||||
// General exception found
|
// General exception found
|
||||||
Console.WriteLine(a_ex.ToString());
|
Console.WriteLine(a_ex.ToString());
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType);
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - package type: " + strUDPFrameType);
|
||||||
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL >" + a_ex.Message);
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
}
|
}
|
||||||
catch (MySqlException m_ex)
|
catch (MySqlException m_ex)
|
||||||
{
|
{
|
||||||
// MySQL exception found
|
// MySQL exception found
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType);
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - package type: " + strUDPFrameType);
|
||||||
switch (m_ex.Number)
|
switch (m_ex.Number)
|
||||||
{
|
{
|
||||||
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
|
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - unable to connect");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - unable to connect >" + m_ex.Message);
|
||||||
break;
|
break;
|
||||||
case 0: // Access denied (Check DB name,username,password)
|
case 0: // Access denied (Check DB name,username,password)
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - access denied");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - access denied > " + m_ex.Message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - " + m_ex.Number);
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL > " + m_ex.Number);
|
||||||
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL > " + m_ex.Message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bStatus = false;
|
bStatus = false;
|
||||||
@@ -133,9 +135,9 @@ public class DatabaseController
|
|||||||
connMySQL.Close();
|
connMySQL.Close();
|
||||||
Console.WriteLine("Sending data to MySQL - Done");
|
Console.WriteLine("Sending data to MySQL - Done");
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException x_ex)
|
||||||
{
|
{
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - wrong connection parameters");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + strUDPFrameInstance + " > ERROR MySQL - unable to connect > " + x_ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
// This class gathers all global variable
|
// This class gathers all global variable
|
||||||
using MySql.Data.MySqlClient;
|
|
||||||
|
|
||||||
internal class Globals
|
internal class Globals
|
||||||
{
|
{
|
||||||
public static string strPerunVersion = "DEBUG"; // Helper for pulling version definition
|
public static string strPerunVersion = "DEBUG"; // Helper for pulling version definition
|
||||||
public static string[] arrLogHistory = new string[10]; // Log history for GUI
|
public static string[] arrGUILogHistory = new string[10]; // Log history for GUI
|
||||||
public static string strPerunTitleText = "";
|
public static bool bGUILogHistoryUpdate = true; // Flag if log control requires update
|
||||||
|
public static string strPerunTitleText = ""; // Helper to update title
|
||||||
|
public static int intInstanceId = 0; // Kepp the instance ID
|
||||||
|
public static bool bStatusIconsForce = true; // Force main window icons reload
|
||||||
|
public static bool bdcConnection = false; // Historic db connection status
|
||||||
|
public static bool bTCPServer = false; // Historic tcp connection status
|
||||||
|
public static bool bSRSStatus = false; // Historic srs connection status
|
||||||
|
public static bool bLotATCStatus = false; // Historic lotatc connection status
|
||||||
|
public static bool bClientConnected = false; // Flag if is TCP connectionstill alive
|
||||||
|
public static int intMysqlErros = 0; // MySQL - Error counter
|
||||||
|
public static int intGameErros = 0; // TCP connection - Error counter
|
||||||
|
public static int intGameErrosHistory = 0; // TCP connection - historic value of Error counter
|
||||||
|
public static int intSRSErros = 0; // DCS SRS - error counter
|
||||||
|
public static int intLotATCErros = 0; // LotATC - error counter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
45
02_Windows_App/Perun_v1/01_Classes/LogController.cs
Normal file
45
02_Windows_App/Perun_v1/01_Classes/LogController.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
class LogController
|
||||||
|
{
|
||||||
|
// TBD - done via https://stackoverflow.com/questions/20185015/how-to-write-log-file-in-c
|
||||||
|
public static void WriteLog(string strLog)
|
||||||
|
{
|
||||||
|
StreamWriter log;
|
||||||
|
FileStream fileStream = null;
|
||||||
|
DirectoryInfo logDirInfo = null;
|
||||||
|
FileInfo logFileInfo;
|
||||||
|
|
||||||
|
string logFilePath = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents") + "\\Perun\\";
|
||||||
|
logFilePath = logFilePath + "Perun_Log_" + System.DateTime.Today.ToString("yyyyddMM") + "." + "txt";
|
||||||
|
logFileInfo = new FileInfo(logFilePath);
|
||||||
|
logDirInfo = new DirectoryInfo(logFileInfo.DirectoryName);
|
||||||
|
if (!logDirInfo.Exists) logDirInfo.Create();
|
||||||
|
if (!logFileInfo.Exists)
|
||||||
|
{
|
||||||
|
fileStream = logFileInfo.Create();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileStream = new FileStream(logFilePath, FileMode.Append);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
log = new StreamWriter(fileStream);
|
||||||
|
log.WriteLine(strLog);
|
||||||
|
log.Close();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
// This class just wraps some Win32 stuff that we're going to use for blocking of multiple instances
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
internal class NativeMethods
|
|
||||||
{
|
|
||||||
public const int HWND_BROADCAST = 0xffff;
|
|
||||||
public static readonly int WM_SHOWME = RegisterWindowMessage("WM_SHOWME");
|
|
||||||
[DllImport("user32")]
|
|
||||||
public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
|
|
||||||
[DllImport("user32")]
|
|
||||||
public static extern int RegisterWindowMessage(string message);
|
|
||||||
}
|
|
||||||
@@ -1,26 +1,40 @@
|
|||||||
// This class gathers all helper functions
|
// This class gathers all helper functions
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
internal class PerunHelper
|
internal class PerunHelper
|
||||||
{
|
{
|
||||||
public static void LogHistoryAdd(ref string[] arrLogHistory, string strEntryToAdd)
|
public static void GUILogHistoryAdd(ref string[] arrLogHistory, string strEntryToAdd)
|
||||||
{
|
{
|
||||||
// Add entry to log history and rotate
|
// Rotate log history
|
||||||
for (int i = 0; i < arrLogHistory.Length - 1; i++)
|
for (int i = 0; i < arrLogHistory.Length - 1; i++)
|
||||||
{
|
{
|
||||||
arrLogHistory[i] = arrLogHistory[i + 1]; // Shift one down
|
arrLogHistory[i] = arrLogHistory[i + 1]; // Shift one down
|
||||||
}
|
}
|
||||||
|
|
||||||
arrLogHistory[arrLogHistory.Length - 1] = DateTime.Now.ToString("HH:mm:ss") + " > " + strEntryToAdd; // Add entry at the last position
|
// Add new entry
|
||||||
|
arrLogHistory[arrLogHistory.Length - 1] = DateTime.Now.ToString("yyyy-dd-MM HH:mm:ss") + " > " + strEntryToAdd; // Add entry at the last position
|
||||||
|
|
||||||
|
// Add the entry to log file
|
||||||
|
LogController.WriteLog(arrLogHistory[arrLogHistory.Length - 1]);
|
||||||
|
|
||||||
|
// Update control at my window
|
||||||
|
Globals.bGUILogHistoryUpdate = true;
|
||||||
}
|
}
|
||||||
public static string GetAppVersion(string strBeginning)
|
public static string GetAppVersion(string strBeginning)
|
||||||
{
|
{
|
||||||
// Gets build version
|
// Gets build version
|
||||||
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
|
if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
|
||||||
{
|
{
|
||||||
|
// For network deployed
|
||||||
System.Deployment.Application.ApplicationDeployment cd = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
|
System.Deployment.Application.ApplicationDeployment cd = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
|
||||||
Globals.strPerunVersion = cd.CurrentVersion.ToString();
|
Globals.strPerunVersion = cd.CurrentVersion.ToString();
|
||||||
}
|
}
|
||||||
return strBeginning+"v" + Globals.strPerunVersion;
|
else
|
||||||
|
{
|
||||||
|
// For other cases
|
||||||
|
Globals.strPerunVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
|
}
|
||||||
|
return strBeginning + "v" + Globals.strPerunVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Perun_v1
|
namespace Perun_v1
|
||||||
@@ -10,13 +9,11 @@ namespace Perun_v1
|
|||||||
/// Main entry point to app
|
/// Main entry point to app
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
// Mutex to block multiple instances
|
|
||||||
//static Mutex mutex = new Mutex(true, "{5a710507-92e9-4664-9b91-918b8b82f107}");
|
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
|
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
// Main entry point to the app
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
|
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
|
||||||
|
|||||||
@@ -5,49 +5,49 @@ using System.Net;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
public class TCPController
|
public class TCPController
|
||||||
{
|
{
|
||||||
// Main class for TCP listener
|
// Main class for TCP listener
|
||||||
public int intListenPort; // Port to connect to
|
public int intListenPort; // Port to connect to
|
||||||
public bool bDone; // Helper to exit main loop without killing thread
|
public bool bCloseConnection; // Helper to exit main loop without killing thread
|
||||||
public string[] arrLogHistory; // Log history for GUI
|
public string[] arrGUILogHistory; // Log history for GUI
|
||||||
public string[] arrSendBuffer; // Mysql send buffer
|
public string[] arrMySQLSendBuffer; // MySQL send buffer
|
||||||
public Thread thrTCPListener; // Seperate thread for TCP
|
public Thread thrTCPListener; // Seperate thread for TCP
|
||||||
public bool bStatus; // TCP connecion status
|
|
||||||
|
|
||||||
public void Create(int par_intListenPort, ref string[] par_arrLogHistory, ref string[] par_arrSendBuffer)
|
public void Create(int par_intListenPort, ref string[] par_arrLogHistory, ref string[] par_arrSendBuffer)
|
||||||
{
|
{
|
||||||
// Create class
|
// Create class and map creation arguments to class
|
||||||
intListenPort = par_intListenPort;
|
intListenPort = par_intListenPort;
|
||||||
arrLogHistory = par_arrLogHistory;
|
arrGUILogHistory = par_arrLogHistory;
|
||||||
arrSendBuffer = par_arrSendBuffer;
|
arrMySQLSendBuffer = par_arrSendBuffer;
|
||||||
bDone = false;
|
bCloseConnection = false;
|
||||||
bStatus = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopListen()
|
public void StopListen()
|
||||||
{
|
{
|
||||||
// Finish listening
|
// Stop listening
|
||||||
bDone = true;
|
bCloseConnection = true;
|
||||||
bStatus = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
// Clear send buffer
|
||||||
|
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||||
{
|
{
|
||||||
arrSendBuffer[i] = null;
|
arrMySQLSendBuffer[i] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartListen()
|
public void StartListen()
|
||||||
{
|
{
|
||||||
NetworkStream ns=null;
|
// Start listening
|
||||||
TcpClient tcpClient=null;
|
NetworkStream nsReadStream = null;
|
||||||
|
TcpClient tcpClient = null;
|
||||||
|
bool bTCPConnectionOnline = false;
|
||||||
|
|
||||||
while (!bDone)
|
// Main loop - do until diconnect button is clicked
|
||||||
|
while (!bCloseConnection)
|
||||||
{
|
{
|
||||||
Console.WriteLine("TCP Listen start");
|
Console.WriteLine("TCP Listen start");
|
||||||
TcpListener tcpServer = new TcpListener(IPAddress.Any, intListenPort); ; // Listener object
|
TcpListener tcpServer = new TcpListener(IPAddress.Any, intListenPort); ; // Create listener object
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -56,22 +56,33 @@ public class TCPController
|
|||||||
|
|
||||||
// Start the main loop
|
// Start the main loop
|
||||||
tcpServer.Start();
|
tcpServer.Start();
|
||||||
bStatus = true;
|
|
||||||
while (!bDone)
|
// While user do not clicked Disconnect button
|
||||||
|
while (!bCloseConnection)
|
||||||
{
|
{
|
||||||
// Start listening
|
// Start listening
|
||||||
|
Console.WriteLine("TCP: Waiting for connection");
|
||||||
|
Globals.bClientConnected = false;
|
||||||
|
|
||||||
Console.WriteLine("TCP: Waiting for packet");
|
// Wait for pending connection
|
||||||
|
if (tcpServer.Pending())
|
||||||
|
{
|
||||||
|
Console.WriteLine("TCP: Connected");
|
||||||
|
bTCPConnectionOnline = true;
|
||||||
tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it
|
tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it
|
||||||
ns = tcpClient.GetStream(); //networkstream is used to send/receive messages
|
nsReadStream = tcpClient.GetStream(); //networkstream is used to send/receive messages
|
||||||
//ns.ReadTimeout = 100;
|
nsReadStream.ReadTimeout = 6000;
|
||||||
|
tcpClient.ReceiveTimeout = 6000;
|
||||||
|
|
||||||
while (tcpClient.Connected && !bDone) //while the client is connected, we look for incoming messages
|
|
||||||
|
while (tcpClient.Connected && !bCloseConnection && bTCPConnectionOnline) //while the client is connected, we look for incoming messages
|
||||||
{
|
{
|
||||||
StringBuilder CompleteMessage = new StringBuilder();
|
StringBuilder CompleteMessage = new StringBuilder();
|
||||||
|
Globals.bClientConnected = true;
|
||||||
|
|
||||||
if (ns.CanRead)
|
if (nsReadStream.CanRead)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("TCP: Can read");
|
||||||
byte[] ReadBuffer = new byte[1024];
|
byte[] ReadBuffer = new byte[1024];
|
||||||
CompleteMessage = new StringBuilder();
|
CompleteMessage = new StringBuilder();
|
||||||
int numberOfBytesRead = 0;
|
int numberOfBytesRead = 0;
|
||||||
@@ -79,57 +90,72 @@ public class TCPController
|
|||||||
// Incoming message may be larger than the buffer size.
|
// Incoming message may be larger than the buffer size.
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
numberOfBytesRead = ns.Read(ReadBuffer, 0, ReadBuffer.Length);
|
Console.WriteLine("TCP: Read");
|
||||||
|
numberOfBytesRead = nsReadStream.Read(ReadBuffer, 0, ReadBuffer.Length);
|
||||||
CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead));
|
CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead));
|
||||||
|
if (numberOfBytesRead == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while (ns.DataAvailable && !bDone);
|
}
|
||||||
|
while (nsReadStream.DataAvailable && nsReadStream.CanRead && tcpClient.Connected);
|
||||||
}
|
}
|
||||||
strReceivedData = CompleteMessage.ToString();
|
strReceivedData = CompleteMessage.ToString();
|
||||||
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
if (strReceivedData != "")
|
||||||
{
|
{
|
||||||
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
||||||
string strRawTCPFrameType = dynamicRawTCPFrame.type;
|
string strRawTCPFrameType = dynamicRawTCPFrame.type;
|
||||||
|
|
||||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP packet received, type: " + strRawTCPFrameType);
|
PerunHelper.GUILogHistoryAdd(ref arrGUILogHistory, "#" + Globals.intInstanceId + "> TCP packet received, type: " + strRawTCPFrameType);
|
||||||
|
|
||||||
// Add to mySQL send buffer (find first empty slot)
|
// Add to mySQL send buffer (find first empty slot)
|
||||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
if (Int32.Parse(strRawTCPFrameType) != 0)
|
||||||
{
|
{
|
||||||
if (arrSendBuffer[i] == null)
|
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||||
{
|
{
|
||||||
arrSendBuffer[i] = strReceivedData;
|
if (arrMySQLSendBuffer[i] == null)
|
||||||
|
{
|
||||||
|
arrMySQLSendBuffer[i] = strReceivedData;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
bTCPConnectionOnline = false;
|
||||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP ERROR incorrect JSON");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
tcpServer.Stop();
|
|
||||||
bStatus = false;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// General exception found
|
Globals.intGameErros++;
|
||||||
if (e.HResult != -2147467259)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e.ToString());
|
Console.WriteLine(e.ToString());
|
||||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP error - connection closed or port in use");
|
PerunHelper.GUILogHistoryAdd(ref arrGUILogHistory, "#" + Globals.intInstanceId + " > TCP ERROR incorrect JSON > " + e.Message);
|
||||||
|
bTCPConnectionOnline = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!(ns is null))
|
System.Threading.Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
tcpServer.Stop();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ns.Flush();
|
Globals.intGameErros++;
|
||||||
ns.Close();
|
Console.WriteLine(e.ToString());
|
||||||
|
PerunHelper.GUILogHistoryAdd(ref arrGUILogHistory, "#" + Globals.intInstanceId + " > TCP error - connection closed or port in use > " + e.Message);
|
||||||
|
bTCPConnectionOnline = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up and prepare for next connection
|
||||||
|
if (!(nsReadStream is null))
|
||||||
|
{
|
||||||
|
nsReadStream.Flush();
|
||||||
|
nsReadStream.Close();
|
||||||
}
|
}
|
||||||
if (!(tcpClient is null))
|
if (!(tcpClient is null))
|
||||||
{
|
{
|
||||||
@@ -139,7 +165,6 @@ public class TCPController
|
|||||||
{
|
{
|
||||||
tcpServer.Stop();
|
tcpServer.Stop();
|
||||||
}
|
}
|
||||||
bStatus = false;
|
|
||||||
Console.WriteLine("TCP listen stop");
|
Console.WriteLine("TCP listen stop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
115
02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
generated
115
02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
generated
@@ -34,7 +34,7 @@
|
|||||||
this.con_Button_Listen_ON = new System.Windows.Forms.Button();
|
this.con_Button_Listen_ON = new System.Windows.Forms.Button();
|
||||||
this.con_Button_Listen_OFF = new System.Windows.Forms.Button();
|
this.con_Button_Listen_OFF = new System.Windows.Forms.Button();
|
||||||
this.con_GroupBox_1 = new System.Windows.Forms.GroupBox();
|
this.con_GroupBox_1 = new System.Windows.Forms.GroupBox();
|
||||||
this.tim_1000ms = new System.Windows.Forms.Timer(this.components);
|
this.tim_GUI = new System.Windows.Forms.Timer(this.components);
|
||||||
this.con_GroupBox_2 = new System.Windows.Forms.GroupBox();
|
this.con_GroupBox_2 = new System.Windows.Forms.GroupBox();
|
||||||
this.label6 = new System.Windows.Forms.Label();
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
this.con_txt_mysql_port = new System.Windows.Forms.TextBox();
|
this.con_txt_mysql_port = new System.Windows.Forms.TextBox();
|
||||||
@@ -57,14 +57,17 @@
|
|||||||
this.trayIconMain = new System.Windows.Forms.NotifyIcon(this.components);
|
this.trayIconMain = new System.Windows.Forms.NotifyIcon(this.components);
|
||||||
this.openFileDialog_SRS = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog_SRS = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.openFileDialog_LotATC = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog_LotATC = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.tim_10000ms = new System.Windows.Forms.Timer(this.components);
|
this.tim_3rdparties = new System.Windows.Forms.Timer(this.components);
|
||||||
this.tim_200ms = new System.Windows.Forms.Timer(this.components);
|
this.tim_MySQL = new System.Windows.Forms.Timer(this.components);
|
||||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.label8 = new System.Windows.Forms.Label();
|
this.label8 = new System.Windows.Forms.Label();
|
||||||
this.con_txt_dcs_instance = new System.Windows.Forms.MaskedTextBox();
|
this.con_txt_dcs_instance = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.label7 = new System.Windows.Forms.Label();
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
this.con_txt_dcs_server_port = new System.Windows.Forms.MaskedTextBox();
|
this.con_txt_dcs_server_port = new System.Windows.Forms.MaskedTextBox();
|
||||||
|
this.label9 = new System.Windows.Forms.Label();
|
||||||
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
|
this.label11 = new System.Windows.Forms.Label();
|
||||||
|
this.label12 = new System.Windows.Forms.Label();
|
||||||
this.con_img_lotATC = new System.Windows.Forms.PictureBox();
|
this.con_img_lotATC = new System.Windows.Forms.PictureBox();
|
||||||
this.con_img_srs = new System.Windows.Forms.PictureBox();
|
this.con_img_srs = new System.Windows.Forms.PictureBox();
|
||||||
this.con_img_dcs = new System.Windows.Forms.PictureBox();
|
this.con_img_dcs = new System.Windows.Forms.PictureBox();
|
||||||
@@ -85,10 +88,11 @@
|
|||||||
this.con_List_Received.FormattingEnabled = true;
|
this.con_List_Received.FormattingEnabled = true;
|
||||||
this.con_List_Received.Items.AddRange(new object[] {
|
this.con_List_Received.Items.AddRange(new object[] {
|
||||||
"Not connected"});
|
"Not connected"});
|
||||||
this.con_List_Received.Location = new System.Drawing.Point(6, 19);
|
this.con_List_Received.Location = new System.Drawing.Point(11, 19);
|
||||||
this.con_List_Received.Name = "con_List_Received";
|
this.con_List_Received.Name = "con_List_Received";
|
||||||
this.con_List_Received.Size = new System.Drawing.Size(307, 147);
|
this.con_List_Received.Size = new System.Drawing.Size(307, 134);
|
||||||
this.con_List_Received.TabIndex = 0;
|
this.con_List_Received.TabIndex = 0;
|
||||||
|
this.con_List_Received.SelectedIndexChanged += new System.EventHandler(this.con_List_Received_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// con_Button_Listen_ON
|
// con_Button_Listen_ON
|
||||||
//
|
//
|
||||||
@@ -114,17 +118,17 @@
|
|||||||
// con_GroupBox_1
|
// con_GroupBox_1
|
||||||
//
|
//
|
||||||
this.con_GroupBox_1.Controls.Add(this.con_List_Received);
|
this.con_GroupBox_1.Controls.Add(this.con_List_Received);
|
||||||
this.con_GroupBox_1.Location = new System.Drawing.Point(12, 369);
|
this.con_GroupBox_1.Location = new System.Drawing.Point(12, 385);
|
||||||
this.con_GroupBox_1.Name = "con_GroupBox_1";
|
this.con_GroupBox_1.Name = "con_GroupBox_1";
|
||||||
this.con_GroupBox_1.Size = new System.Drawing.Size(324, 176);
|
this.con_GroupBox_1.Size = new System.Drawing.Size(324, 162);
|
||||||
this.con_GroupBox_1.TabIndex = 4;
|
this.con_GroupBox_1.TabIndex = 4;
|
||||||
this.con_GroupBox_1.TabStop = false;
|
this.con_GroupBox_1.TabStop = false;
|
||||||
this.con_GroupBox_1.Text = "Data log";
|
this.con_GroupBox_1.Text = "Data log";
|
||||||
//
|
//
|
||||||
// tim_1000ms
|
// tim_GUI
|
||||||
//
|
//
|
||||||
this.tim_1000ms.Interval = 1000;
|
this.tim_GUI.Interval = 200;
|
||||||
this.tim_1000ms.Tick += new System.EventHandler(this.timer1_Tick);
|
this.tim_GUI.Tick += new System.EventHandler(this.Tim_GUI_Tick);
|
||||||
//
|
//
|
||||||
// con_GroupBox_2
|
// con_GroupBox_2
|
||||||
//
|
//
|
||||||
@@ -323,19 +327,14 @@
|
|||||||
//
|
//
|
||||||
this.openFileDialog_LotATC.FileName = "openFileDialog1";
|
this.openFileDialog_LotATC.FileName = "openFileDialog1";
|
||||||
//
|
//
|
||||||
// tim_10000ms
|
// tim_3rdparties
|
||||||
//
|
//
|
||||||
this.tim_10000ms.Interval = 30000;
|
this.tim_3rdparties.Interval = 30000;
|
||||||
this.tim_10000ms.Tick += new System.EventHandler(this.tim_10000ms_Tick);
|
this.tim_3rdparties.Tick += new System.EventHandler(this.tim_3rdparties_Tick);
|
||||||
//
|
//
|
||||||
// tim_200ms
|
// tim_MySQL
|
||||||
//
|
//
|
||||||
this.tim_200ms.Tick += new System.EventHandler(this.tim_200ms_Tick);
|
this.tim_MySQL.Tick += new System.EventHandler(this.Tim_MySQL_Tick);
|
||||||
//
|
|
||||||
// notifyIcon1
|
|
||||||
//
|
|
||||||
this.notifyIcon1.Text = "notifyIcon1";
|
|
||||||
this.notifyIcon1.Visible = true;
|
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
@@ -382,9 +381,54 @@
|
|||||||
this.con_txt_dcs_server_port.Size = new System.Drawing.Size(207, 20);
|
this.con_txt_dcs_server_port.Size = new System.Drawing.Size(207, 20);
|
||||||
this.con_txt_dcs_server_port.TabIndex = 3;
|
this.con_txt_dcs_server_port.TabIndex = 3;
|
||||||
//
|
//
|
||||||
|
// label9
|
||||||
|
//
|
||||||
|
this.label9.AutoSize = true;
|
||||||
|
this.label9.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label9.Location = new System.Drawing.Point(21, 369);
|
||||||
|
this.label9.Name = "label9";
|
||||||
|
this.label9.Size = new System.Drawing.Size(61, 13);
|
||||||
|
this.label9.TabIndex = 1;
|
||||||
|
this.label9.Text = "Database";
|
||||||
|
//
|
||||||
|
// label10
|
||||||
|
//
|
||||||
|
this.label10.AutoSize = true;
|
||||||
|
this.label10.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label10.Location = new System.Drawing.Point(117, 369);
|
||||||
|
this.label10.Name = "label10";
|
||||||
|
this.label10.Size = new System.Drawing.Size(39, 13);
|
||||||
|
this.label10.TabIndex = 14;
|
||||||
|
this.label10.Text = "Game";
|
||||||
|
//
|
||||||
|
// label11
|
||||||
|
//
|
||||||
|
this.label11.AutoSize = true;
|
||||||
|
this.label11.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label11.Location = new System.Drawing.Point(205, 369);
|
||||||
|
this.label11.Name = "label11";
|
||||||
|
this.label11.Size = new System.Drawing.Size(32, 13);
|
||||||
|
this.label11.TabIndex = 15;
|
||||||
|
this.label11.Text = "SRS";
|
||||||
|
//
|
||||||
|
// label12
|
||||||
|
//
|
||||||
|
this.label12.AutoSize = true;
|
||||||
|
this.label12.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.label12.Location = new System.Drawing.Point(282, 369);
|
||||||
|
this.label12.Name = "label12";
|
||||||
|
this.label12.Size = new System.Drawing.Size(49, 13);
|
||||||
|
this.label12.TabIndex = 16;
|
||||||
|
this.label12.Text = "LotATC";
|
||||||
|
//
|
||||||
// con_img_lotATC
|
// con_img_lotATC
|
||||||
//
|
//
|
||||||
this.con_img_lotATC.Location = new System.Drawing.Point(307, 335);
|
this.con_img_lotATC.Image = global::Perun_v1.Properties.Resources.status_disconnected;
|
||||||
|
this.con_img_lotATC.Location = new System.Drawing.Point(292, 335);
|
||||||
this.con_img_lotATC.Name = "con_img_lotATC";
|
this.con_img_lotATC.Name = "con_img_lotATC";
|
||||||
this.con_img_lotATC.Size = new System.Drawing.Size(29, 28);
|
this.con_img_lotATC.Size = new System.Drawing.Size(29, 28);
|
||||||
this.con_img_lotATC.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.con_img_lotATC.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
@@ -393,7 +437,8 @@
|
|||||||
//
|
//
|
||||||
// con_img_srs
|
// con_img_srs
|
||||||
//
|
//
|
||||||
this.con_img_srs.Location = new System.Drawing.Point(272, 335);
|
this.con_img_srs.Image = global::Perun_v1.Properties.Resources.status_disconnected;
|
||||||
|
this.con_img_srs.Location = new System.Drawing.Point(207, 335);
|
||||||
this.con_img_srs.Name = "con_img_srs";
|
this.con_img_srs.Name = "con_img_srs";
|
||||||
this.con_img_srs.Size = new System.Drawing.Size(29, 28);
|
this.con_img_srs.Size = new System.Drawing.Size(29, 28);
|
||||||
this.con_img_srs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.con_img_srs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
@@ -402,7 +447,8 @@
|
|||||||
//
|
//
|
||||||
// con_img_dcs
|
// con_img_dcs
|
||||||
//
|
//
|
||||||
this.con_img_dcs.Location = new System.Drawing.Point(237, 335);
|
this.con_img_dcs.Image = global::Perun_v1.Properties.Resources.status_disconnected;
|
||||||
|
this.con_img_dcs.Location = new System.Drawing.Point(122, 335);
|
||||||
this.con_img_dcs.Name = "con_img_dcs";
|
this.con_img_dcs.Name = "con_img_dcs";
|
||||||
this.con_img_dcs.Size = new System.Drawing.Size(29, 28);
|
this.con_img_dcs.Size = new System.Drawing.Size(29, 28);
|
||||||
this.con_img_dcs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.con_img_dcs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
@@ -412,7 +458,8 @@
|
|||||||
// con_img_db
|
// con_img_db
|
||||||
//
|
//
|
||||||
this.con_img_db.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
this.con_img_db.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||||
this.con_img_db.Location = new System.Drawing.Point(202, 335);
|
this.con_img_db.Image = global::Perun_v1.Properties.Resources.status_disconnected;
|
||||||
|
this.con_img_db.Location = new System.Drawing.Point(37, 335);
|
||||||
this.con_img_db.Name = "con_img_db";
|
this.con_img_db.Name = "con_img_db";
|
||||||
this.con_img_db.Size = new System.Drawing.Size(29, 28);
|
this.con_img_db.Size = new System.Drawing.Size(29, 28);
|
||||||
this.con_img_db.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
this.con_img_db.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
@@ -424,6 +471,10 @@
|
|||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(349, 604);
|
this.ClientSize = new System.Drawing.Size(349, 604);
|
||||||
|
this.Controls.Add(this.label12);
|
||||||
|
this.Controls.Add(this.label11);
|
||||||
|
this.Controls.Add(this.label10);
|
||||||
|
this.Controls.Add(this.label9);
|
||||||
this.Controls.Add(this.con_img_lotATC);
|
this.Controls.Add(this.con_img_lotATC);
|
||||||
this.Controls.Add(this.con_img_srs);
|
this.Controls.Add(this.con_img_srs);
|
||||||
this.Controls.Add(this.con_img_dcs);
|
this.Controls.Add(this.con_img_dcs);
|
||||||
@@ -440,10 +491,9 @@
|
|||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
|
||||||
this.Name = "form_Main";
|
this.Name = "form_Main";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Perun for DCS World";
|
this.Text = "Perun for DCS";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.form_Main_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.form_Main_FormClosing);
|
||||||
this.Load += new System.EventHandler(this.form_Main_Load);
|
this.Load += new System.EventHandler(this.form_Main_Load);
|
||||||
this.con_GroupBox_1.ResumeLayout(false);
|
this.con_GroupBox_1.ResumeLayout(false);
|
||||||
@@ -468,7 +518,7 @@
|
|||||||
private System.Windows.Forms.Button con_Button_Listen_ON;
|
private System.Windows.Forms.Button con_Button_Listen_ON;
|
||||||
private System.Windows.Forms.Button con_Button_Listen_OFF;
|
private System.Windows.Forms.Button con_Button_Listen_OFF;
|
||||||
private System.Windows.Forms.GroupBox con_GroupBox_1;
|
private System.Windows.Forms.GroupBox con_GroupBox_1;
|
||||||
private System.Windows.Forms.Timer tim_1000ms;
|
private System.Windows.Forms.Timer tim_GUI;
|
||||||
private System.Windows.Forms.GroupBox con_GroupBox_2;
|
private System.Windows.Forms.GroupBox con_GroupBox_2;
|
||||||
private System.Windows.Forms.GroupBox con_GroupBox_3;
|
private System.Windows.Forms.GroupBox con_GroupBox_3;
|
||||||
private System.Windows.Forms.TextBox con_txt_mysql_database;
|
private System.Windows.Forms.TextBox con_txt_mysql_database;
|
||||||
@@ -489,11 +539,10 @@
|
|||||||
private System.Windows.Forms.NotifyIcon trayIconMain;
|
private System.Windows.Forms.NotifyIcon trayIconMain;
|
||||||
private System.Windows.Forms.OpenFileDialog openFileDialog_SRS;
|
private System.Windows.Forms.OpenFileDialog openFileDialog_SRS;
|
||||||
private System.Windows.Forms.OpenFileDialog openFileDialog_LotATC;
|
private System.Windows.Forms.OpenFileDialog openFileDialog_LotATC;
|
||||||
private System.Windows.Forms.Timer tim_10000ms;
|
private System.Windows.Forms.Timer tim_3rdparties;
|
||||||
private System.Windows.Forms.Label label6;
|
private System.Windows.Forms.Label label6;
|
||||||
private System.Windows.Forms.TextBox con_txt_mysql_port;
|
private System.Windows.Forms.TextBox con_txt_mysql_port;
|
||||||
private System.Windows.Forms.Timer tim_200ms;
|
private System.Windows.Forms.Timer tim_MySQL;
|
||||||
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
|
||||||
private System.Windows.Forms.GroupBox groupBox1;
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
private System.Windows.Forms.MaskedTextBox con_txt_dcs_server_port;
|
private System.Windows.Forms.MaskedTextBox con_txt_dcs_server_port;
|
||||||
private System.Windows.Forms.Label label7;
|
private System.Windows.Forms.Label label7;
|
||||||
@@ -503,6 +552,10 @@
|
|||||||
private System.Windows.Forms.PictureBox con_img_dcs;
|
private System.Windows.Forms.PictureBox con_img_dcs;
|
||||||
private System.Windows.Forms.PictureBox con_img_srs;
|
private System.Windows.Forms.PictureBox con_img_srs;
|
||||||
private System.Windows.Forms.PictureBox con_img_lotATC;
|
private System.Windows.Forms.PictureBox con_img_lotATC;
|
||||||
|
private System.Windows.Forms.Label label9;
|
||||||
|
private System.Windows.Forms.Label label10;
|
||||||
|
private System.Windows.Forms.Label label11;
|
||||||
|
private System.Windows.Forms.Label label12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Perun_v1
|
namespace Perun_v1
|
||||||
{
|
{
|
||||||
public partial class form_Main : Form
|
public partial class form_Main : Form
|
||||||
{
|
{
|
||||||
// Variable definitions
|
// Variable definitions
|
||||||
public string[] arrSendBuffer = new string[65534]; // MySQL send buffer
|
public string[] arrMySQLSendBuffer = new string[65534]; // MySQL send buffer
|
||||||
public bool bLetMeOut = false; // Helper to handle system tray
|
public bool bAllowAppClosure = false; // Helper to handle system tray
|
||||||
|
|
||||||
public DatabaseController dcConnection = new DatabaseController(); // MySQL controller
|
public DatabaseController dcConnection = new DatabaseController(); // MySQL controller
|
||||||
public TCPController tcpcServer=new TCPController(); // TCP controller
|
public TCPController tcpServer = new TCPController(); // TCP controller
|
||||||
|
|
||||||
public bool bSRSStatus; // Use empty/default SRS status
|
public bool bSRSStatus; // Use empty/default SRS status
|
||||||
public bool bLotATCStatus; // Use empty/default LotATC status
|
public bool bLotATCStatus; // Use empty/default LotATC status
|
||||||
@@ -23,18 +23,20 @@ namespace Perun_v1
|
|||||||
private void form_Main_Load(object sender, EventArgs e)
|
private void form_Main_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Form loaded - fill controls with default values
|
// Form loaded - fill controls with default values
|
||||||
Globals.arrLogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun started";
|
Globals.arrGUILogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun started";
|
||||||
|
|
||||||
Globals.strPerunTitleText = PerunHelper.GetAppVersion(this.Text + " - "); // Display build version in title bar
|
// Display build version in title bar
|
||||||
|
Globals.strPerunTitleText = PerunHelper.GetAppVersion(this.Text + " - ");
|
||||||
this.Text = Globals.strPerunTitleText;
|
this.Text = Globals.strPerunTitleText;
|
||||||
|
|
||||||
form_Main_LoadSettings(); // Load settings
|
// Load settings from registry
|
||||||
|
form_Main_LoadSettings();
|
||||||
|
|
||||||
// Use command line parameters
|
// Use command line parameters
|
||||||
string[] args = Environment.GetCommandLineArgs();
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
if (args.Length > 1)
|
if (args.Length > 1)
|
||||||
{
|
{
|
||||||
// server port
|
// Get argument server port
|
||||||
if (args[1] != null)
|
if (args[1] != null)
|
||||||
{
|
{
|
||||||
con_txt_dcs_server_port.Text = args[1];
|
con_txt_dcs_server_port.Text = args[1];
|
||||||
@@ -42,7 +44,7 @@ namespace Perun_v1
|
|||||||
}
|
}
|
||||||
if (args.Length > 2)
|
if (args.Length > 2)
|
||||||
{
|
{
|
||||||
// instance id
|
// Get argument instance id
|
||||||
if (args[2] != null)
|
if (args[2] != null)
|
||||||
{
|
{
|
||||||
con_txt_dcs_instance.Text = args[2];
|
con_txt_dcs_instance.Text = args[2];
|
||||||
@@ -50,7 +52,7 @@ namespace Perun_v1
|
|||||||
}
|
}
|
||||||
if (args.Length > 3)
|
if (args.Length > 3)
|
||||||
{
|
{
|
||||||
// srs
|
// Get argument DCS SRS file path
|
||||||
if (args[3] != null)
|
if (args[3] != null)
|
||||||
{
|
{
|
||||||
con_txt_3rd_srs.Text = args[3];
|
con_txt_3rd_srs.Text = args[3];
|
||||||
@@ -59,7 +61,7 @@ namespace Perun_v1
|
|||||||
}
|
}
|
||||||
if (args.Length > 4)
|
if (args.Length > 4)
|
||||||
{
|
{
|
||||||
// lotatc
|
// Get argument lotATC file path
|
||||||
if (args[4] != null)
|
if (args[4] != null)
|
||||||
{
|
{
|
||||||
con_txt_3rd_lotatc.Text = args[4];
|
con_txt_3rd_lotatc.Text = args[4];
|
||||||
@@ -77,7 +79,7 @@ namespace Perun_v1
|
|||||||
// ################################ Helpers ################################
|
// ################################ Helpers ################################
|
||||||
private void form_Main_LoadSettings()
|
private void form_Main_LoadSettings()
|
||||||
{
|
{
|
||||||
// Loads settings
|
// Loads registry settings
|
||||||
con_txt_mysql_database.Text = Properties.Settings.Default.MYSQL_DB;
|
con_txt_mysql_database.Text = Properties.Settings.Default.MYSQL_DB;
|
||||||
con_txt_mysql_username.Text = Properties.Settings.Default.MYSQL_User;
|
con_txt_mysql_username.Text = Properties.Settings.Default.MYSQL_User;
|
||||||
con_txt_mysql_password.Text = Properties.Settings.Default.MYSQL_Password;
|
con_txt_mysql_password.Text = Properties.Settings.Default.MYSQL_Password;
|
||||||
@@ -89,12 +91,11 @@ namespace Perun_v1
|
|||||||
con_check_3rd_srs.Checked = Properties.Settings.Default.OTHER_SRS_USE;
|
con_check_3rd_srs.Checked = Properties.Settings.Default.OTHER_SRS_USE;
|
||||||
con_txt_dcs_server_port.Text = Properties.Settings.Default.DCS_Server_Port.ToString();
|
con_txt_dcs_server_port.Text = Properties.Settings.Default.DCS_Server_Port.ToString();
|
||||||
con_txt_dcs_instance.Text = Properties.Settings.Default.DCS_Instance.ToString();
|
con_txt_dcs_instance.Text = Properties.Settings.Default.DCS_Instance.ToString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void form_Main_SaveSettings()
|
private void form_Main_SaveSettings()
|
||||||
{
|
{
|
||||||
// Saves settings
|
// Saves registry settings
|
||||||
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_database.Text;
|
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_database.Text;
|
||||||
Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text;
|
Properties.Settings.Default.MYSQL_DB = con_txt_mysql_database.Text;
|
||||||
Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text;
|
Properties.Settings.Default.MYSQL_User = con_txt_mysql_username.Text;
|
||||||
@@ -117,6 +118,7 @@ namespace Perun_v1
|
|||||||
// Disables controls
|
// Disables controls
|
||||||
con_Button_Listen_ON.Enabled = false;
|
con_Button_Listen_ON.Enabled = false;
|
||||||
con_Button_Listen_OFF.Enabled = true;
|
con_Button_Listen_OFF.Enabled = true;
|
||||||
|
con_Button_Quit.Enabled = false;
|
||||||
con_txt_mysql_database.Enabled = false;
|
con_txt_mysql_database.Enabled = false;
|
||||||
con_txt_mysql_username.Enabled = false;
|
con_txt_mysql_username.Enabled = false;
|
||||||
con_txt_mysql_password.Enabled = false;
|
con_txt_mysql_password.Enabled = false;
|
||||||
@@ -135,6 +137,7 @@ namespace Perun_v1
|
|||||||
// Enables controls
|
// Enables controls
|
||||||
con_Button_Listen_ON.Enabled = true;
|
con_Button_Listen_ON.Enabled = true;
|
||||||
con_Button_Listen_OFF.Enabled = false;
|
con_Button_Listen_OFF.Enabled = false;
|
||||||
|
con_Button_Quit.Enabled = true;
|
||||||
con_txt_mysql_database.Enabled = true;
|
con_txt_mysql_database.Enabled = true;
|
||||||
con_txt_mysql_username.Enabled = true;
|
con_txt_mysql_username.Enabled = true;
|
||||||
con_txt_mysql_password.Enabled = true;
|
con_txt_mysql_password.Enabled = true;
|
||||||
@@ -152,73 +155,97 @@ namespace Perun_v1
|
|||||||
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Start listening
|
// Start listening
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "Opening connections");
|
// Set globals
|
||||||
tcpcServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.arrLogHistory, ref arrSendBuffer);
|
Globals.intInstanceId = Int32.Parse(con_txt_dcs_instance.Text);
|
||||||
tcpcServer.thrTCPListener = new Thread(tcpcServer.StartListen);
|
Globals.bStatusIconsForce = true;
|
||||||
tcpcServer.thrTCPListener.Start();
|
|
||||||
tcpcServer.thrTCPListener.Name = "TCPThread";
|
|
||||||
|
|
||||||
form_Main_DisableControls(); // Disable controlls
|
Globals.intMysqlErros = 0; // Reset error counter
|
||||||
form_Main_SaveSettings(); // Save settings
|
Globals.intGameErros = 0; // Reset error counter
|
||||||
|
Globals.intSRSErros = 0; // Reset error counter
|
||||||
|
Globals.intLotATCErros = 0; // Reset error counter
|
||||||
|
|
||||||
// Prepare connection string
|
Globals.bClientConnected = false; // Reset connection status
|
||||||
|
|
||||||
|
// Prepare GUI
|
||||||
|
form_Main_DisableControls();
|
||||||
|
form_Main_SaveSettings();
|
||||||
|
this.Text = "[#" + con_txt_dcs_instance.Text + "] " + Globals.strPerunTitleText; // Set title bar
|
||||||
|
trayIconMain.Text = this.Text; // Set notification icon text
|
||||||
|
|
||||||
|
// Prepare MySQL connection string
|
||||||
dcConnection.strMySQLConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
|
dcConnection.strMySQLConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
|
||||||
|
|
||||||
|
// Start listening
|
||||||
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Globals.intInstanceId + " > " + "Opening connections");
|
||||||
|
tcpServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.arrGUILogHistory, ref arrMySQLSendBuffer);
|
||||||
|
tcpServer.thrTCPListener = new Thread(tcpServer.StartListen);
|
||||||
|
tcpServer.thrTCPListener.Start();
|
||||||
|
tcpServer.thrTCPListener.Name = "TCPThread";
|
||||||
|
|
||||||
// Start timmers
|
// Start timmers
|
||||||
tim_200ms.Enabled = true;
|
tim_MySQL.Enabled = true;
|
||||||
tim_1000ms.Enabled = true;
|
tim_GUI.Enabled = true;
|
||||||
tim_10000ms.Enabled = true;
|
tim_3rdparties.Enabled = true;
|
||||||
|
|
||||||
// Send initial data
|
// Send initial data
|
||||||
tim_10000ms_Tick(null, null);
|
Tim_MySQL_Tick(null, null);
|
||||||
|
tim_3rdparties_Tick(null, null);
|
||||||
// Set title bar
|
|
||||||
this.Text = "[#"+ con_txt_dcs_instance.Text + "] " + Globals.strPerunTitleText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Stop listening
|
// Stop listening
|
||||||
|
// Prepare GUI
|
||||||
// Display information
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Globals.intInstanceId + " > " + "Closing connections");
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "Closing connections");
|
|
||||||
con_Button_Listen_OFF.Enabled = false;
|
con_Button_Listen_OFF.Enabled = false;
|
||||||
timer1_Tick(null, null);
|
Tim_GUI_Tick(null, null);
|
||||||
this.Refresh();
|
this.Refresh();
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
|
// Stop timmers
|
||||||
|
tim_GUI.Enabled = false;
|
||||||
|
tim_3rdparties.Enabled = false;
|
||||||
|
tim_MySQL.Enabled = false;
|
||||||
|
|
||||||
|
// Wait untill TCP server closed connection
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tcpcServer.StopListen();
|
tcpServer.StopListen();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.ToString());
|
Console.WriteLine(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
while (tcpcServer.thrTCPListener.IsAlive)
|
while (tcpServer.thrTCPListener.IsAlive)
|
||||||
{
|
{
|
||||||
Thread.Sleep(100); //ms
|
Thread.Sleep(100); //ms
|
||||||
}
|
}
|
||||||
form_Main_EnableControls(); // Enable controls
|
form_Main_EnableControls(); // Enable controls
|
||||||
|
|
||||||
con_img_db.Image = null;
|
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||||
con_img_dcs.Image = null;
|
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||||
con_img_lotATC.Image = null;
|
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||||
con_img_srs.Image = null;
|
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||||
|
|
||||||
// Stop timmers
|
|
||||||
tim_1000ms.Enabled = false;
|
|
||||||
tim_10000ms.Enabled = false;
|
|
||||||
tim_200ms.Enabled = false;
|
|
||||||
|
|
||||||
// Display information about closed connections
|
// Display information about closed connections
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "Connections closed");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Globals.intInstanceId + " > " + "Connections closed");
|
||||||
timer1_Tick(null, null);
|
Tim_GUI_Tick(null, null);
|
||||||
|
|
||||||
// Set title bar
|
// Set title bar
|
||||||
this.Text = Globals.strPerunTitleText;
|
this.Text = Globals.strPerunTitleText;
|
||||||
|
trayIconMain.Text = this.Text;
|
||||||
|
|
||||||
|
// Set globals
|
||||||
|
Globals.intInstanceId = 0;
|
||||||
|
|
||||||
|
// Set helpers for updates
|
||||||
|
Globals.bGUILogHistoryUpdate = false;
|
||||||
|
Globals.bdcConnection = false;
|
||||||
|
Globals.bTCPServer = false;
|
||||||
|
Globals.bSRSStatus = false;
|
||||||
|
Globals.bLotATCStatus = false;
|
||||||
|
Globals.bClientConnected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
@@ -267,7 +294,7 @@ namespace Perun_v1
|
|||||||
{
|
{
|
||||||
form_Main_SaveSettings();
|
form_Main_SaveSettings();
|
||||||
|
|
||||||
bLetMeOut = true; // Save settings on exit
|
bAllowAppClosure = true; // Save settings on exit
|
||||||
this.Close(); // Allow to exit application
|
this.Close(); // Allow to exit application
|
||||||
}
|
}
|
||||||
else if (dialogResult == DialogResult.No)
|
else if (dialogResult == DialogResult.No)
|
||||||
@@ -276,16 +303,6 @@ namespace Perun_v1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
|
||||||
{
|
|
||||||
// Try to run of 2nd instance
|
|
||||||
if (m.Msg == NativeMethods.WM_SHOWME)
|
|
||||||
{
|
|
||||||
form_Main_BringFromTray();
|
|
||||||
}
|
|
||||||
base.WndProc(ref m);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void form_Main_SendToTray()
|
private void form_Main_SendToTray()
|
||||||
{
|
{
|
||||||
// Sends app to system tray
|
// Sends app to system tray
|
||||||
@@ -317,7 +334,7 @@ namespace Perun_v1
|
|||||||
private void form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
private void form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
// Minimize to try on clicking "X"
|
// Minimize to try on clicking "X"
|
||||||
if (e.CloseReason == CloseReason.UserClosing && !bLetMeOut)
|
if (e.CloseReason == CloseReason.UserClosing && !bAllowAppClosure)
|
||||||
{
|
{
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
form_Main_SendToTray(); // Send app to system tray
|
form_Main_SendToTray(); // Send app to system tray
|
||||||
@@ -331,69 +348,124 @@ namespace Perun_v1
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ################################ Timers ################################
|
// ################################ Timers ################################
|
||||||
private void timer1_Tick(object sender, EventArgs e)
|
private void Tim_GUI_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Main timer to sync GUI with background tasks and flush buffers
|
// Main timer to sync GUI with background tasks and flush buffers
|
||||||
|
|
||||||
// Refresh Log Window
|
// Refresh Log Window
|
||||||
|
if (Globals.bGUILogHistoryUpdate)
|
||||||
|
{
|
||||||
con_List_Received.Items.Clear();
|
con_List_Received.Items.Clear();
|
||||||
foreach (string i in Globals.arrLogHistory)
|
foreach (string i in Globals.arrGUILogHistory)
|
||||||
{
|
{
|
||||||
if (i != null)
|
if (i != null)
|
||||||
{
|
{
|
||||||
con_List_Received.Items.Add(i);
|
con_List_Received.Items.Add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Globals.bGUILogHistoryUpdate = false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
private void tim_200ms_Tick(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
// Send buffer to MySQL
|
// Do nothing , control does not require update
|
||||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
|
||||||
{
|
|
||||||
if (arrSendBuffer[i] != null)
|
|
||||||
{
|
|
||||||
dcConnection.SendToMySql(arrSendBuffer[i]);
|
|
||||||
arrSendBuffer[i] = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update status icons at main form
|
// Update status icons at main form
|
||||||
|
if ((dcConnection.bStatus != Globals.bdcConnection) || Globals.bStatusIconsForce)
|
||||||
|
{
|
||||||
if (dcConnection.bStatus)
|
if (dcConnection.bStatus)
|
||||||
{
|
{
|
||||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_db");
|
if (Globals.intMysqlErros == 0)
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected");
|
||||||
}
|
|
||||||
if (tcpcServer.bStatus)
|
|
||||||
{
|
|
||||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_game");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected_error");
|
||||||
}
|
}
|
||||||
if (bSRSStatus)
|
|
||||||
{
|
|
||||||
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_srs");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error");
|
||||||
}
|
}
|
||||||
if (bLotATCStatus)
|
Globals.bdcConnection = dcConnection.bStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Globals.bClientConnected != Globals.bTCPServer) || Globals.bStatusIconsForce || Globals.intGameErros != Globals.intGameErrosHistory)
|
||||||
{
|
{
|
||||||
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_lotatc");
|
if (Globals.bClientConnected)
|
||||||
|
{
|
||||||
|
if (Globals.intGameErros == 0)
|
||||||
|
{
|
||||||
|
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected_error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error");
|
||||||
|
}
|
||||||
|
Globals.bTCPServer = Globals.bClientConnected;
|
||||||
|
Globals.intGameErrosHistory = Globals.intGameErros;
|
||||||
|
}
|
||||||
|
if ((bSRSStatus != Globals.bSRSStatus) || Globals.bStatusIconsForce)
|
||||||
|
{
|
||||||
|
if (bSRSStatus && con_check_3rd_srs.Checked)
|
||||||
|
{
|
||||||
|
if (Globals.intSRSErros == 0)
|
||||||
|
{
|
||||||
|
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected_error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error");
|
||||||
|
}
|
||||||
|
Globals.bSRSStatus = bSRSStatus;
|
||||||
|
}
|
||||||
|
if ((bLotATCStatus != Globals.bLotATCStatus) || Globals.bStatusIconsForce)
|
||||||
|
{
|
||||||
|
if (bLotATCStatus && con_check_3rd_lotatc.Checked)
|
||||||
|
{
|
||||||
|
if (Globals.intLotATCErros == 0)
|
||||||
|
{
|
||||||
|
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected_error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error");
|
||||||
|
}
|
||||||
|
Globals.bLotATCStatus = bLotATCStatus;
|
||||||
|
}
|
||||||
|
Globals.bStatusIconsForce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Tim_MySQL_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// Send buffer to MySQL
|
||||||
|
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||||
|
{
|
||||||
|
if (arrMySQLSendBuffer[i] != null)
|
||||||
|
{
|
||||||
|
dcConnection.SendToMySql(arrMySQLSendBuffer[i]);
|
||||||
|
arrMySQLSendBuffer[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tim_10000ms_Tick(object sender, EventArgs e)
|
private void tim_3rdparties_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Main timer to send JSON files to MySQL
|
// Main timer to send JSON files to MySQL
|
||||||
string strSRSJson = "";
|
string strSRSJson = "";
|
||||||
@@ -451,13 +523,14 @@ namespace Perun_v1
|
|||||||
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'false'}}"; // No SRS clients connected
|
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'false'}}"; // No SRS clients connected
|
||||||
}
|
}
|
||||||
boolSRSdefault = false;
|
boolSRSdefault = false;
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data loaded");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data loaded");
|
||||||
bSRSStatus = true;
|
bSRSStatus = true;
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception exc_srs)
|
||||||
{
|
{
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data ERROR");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data ERROR > " + exc_srs.Message);
|
||||||
bSRSStatus = false;
|
bSRSStatus = false;
|
||||||
|
Globals.intSRSErros++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -478,13 +551,14 @@ namespace Perun_v1
|
|||||||
|
|
||||||
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + strLotATCJson + "'}";
|
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + strLotATCJson + "'}";
|
||||||
boolLotATCdefault = false;
|
boolLotATCdefault = false;
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data loaded");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data loaded");
|
||||||
bLotATCStatus = true;
|
bLotATCStatus = true;
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception exc_lotatc)
|
||||||
{
|
{
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data ERROR");
|
PerunHelper.GUILogHistoryAdd(ref Globals.arrGUILogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data ERROR > " + exc_lotatc.Message);
|
||||||
bLotATCStatus = false;
|
bLotATCStatus = false;
|
||||||
|
Globals.intLotATCErros++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -494,6 +568,19 @@ namespace Perun_v1
|
|||||||
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}"; // No LotATC controller connected
|
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}"; // No LotATC controller connected
|
||||||
}
|
}
|
||||||
dcConnection.SendToMySql(strLotATCJson);
|
dcConnection.SendToMySql(strLotATCJson);
|
||||||
|
|
||||||
|
// Let's do not risk int overload
|
||||||
|
Globals.intMysqlErros = (Globals.intMysqlErros > 999) ? 999 : Globals.intMysqlErros;
|
||||||
|
Globals.intGameErros = (Globals.intGameErros > 999) ? 999 : Globals.intGameErros;
|
||||||
|
Globals.intSRSErros = (Globals.intSRSErros > 999) ? 999 : Globals.intSRSErros;
|
||||||
|
Globals.intLotATCErros = (Globals.intLotATCErros > 999) ? 999 : Globals.intLotATCErros;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void con_List_Received_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="tim_1000ms.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="tim_GUI.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="trayIconMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="trayIconMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
@@ -413,15 +413,12 @@
|
|||||||
<metadata name="openFileDialog_LotATC.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="openFileDialog_LotATC.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>397, 17</value>
|
<value>397, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="tim_10000ms.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="tim_3rdparties.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>563, 19</value>
|
<value>563, 19</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="tim_200ms.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="tim_MySQL.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>687, 19</value>
|
<value>687, 19</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="notifyIcon1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>797, 19</value>
|
|
||||||
</metadata>
|
|
||||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
AAABAAEAQD8AAAEAIAAgQQAAFgAAACgAAABAAAAAfgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
AAABAAEAQD8AAAEAIAAgQQAAFgAAACgAAABAAAAAfgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||||
<WebPage>Perun.htm</WebPage>
|
<WebPage>Perun.htm</WebPage>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>0.8.0.%2a</ApplicationVersion>
|
<ApplicationVersion>0.8.2.%2a</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>SecurityRules.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -123,11 +124,11 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="01_Classes\LogController.cs" />
|
||||||
<Compile Include="01_Classes\TCPController.cs" />
|
<Compile Include="01_Classes\TCPController.cs" />
|
||||||
<Compile Include="01_Classes\Globals.cs" />
|
<Compile Include="01_Classes\Globals.cs" />
|
||||||
<Compile Include="01_Classes\DatabaseController.cs" />
|
<Compile Include="01_Classes\DatabaseController.cs" />
|
||||||
<Compile Include="01_Classes\PerunHelper.cs" />
|
<Compile Include="01_Classes\PerunHelper.cs" />
|
||||||
<Compile Include="01_Classes\NativeMethods.cs" />
|
|
||||||
<Compile Include="02_Forms\form_Main.cs">
|
<Compile Include="02_Forms\form_Main.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -181,6 +182,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="03_Resources\perun_logo.ico" />
|
<Content Include="03_Resources\perun_logo.ico" />
|
||||||
|
<None Include="Resources\status-connectedx.png" />
|
||||||
|
<None Include="Resources\status-disconnected-game.png" />
|
||||||
|
<None Include="Resources\status-disconnected-error.png" />
|
||||||
|
<None Include="Resources\status-disconnected.png" />
|
||||||
|
<None Include="Resources\status-connected.png" />
|
||||||
<None Include="Resources\ico_error.png" />
|
<None Include="Resources\ico_error.png" />
|
||||||
<None Include="Resources\ico_srs.png" />
|
<None Include="Resources\ico_srs.png" />
|
||||||
<None Include="Resources\ico_lotatc.png" />
|
<None Include="Resources\ico_lotatc.png" />
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ using System.Runtime.InteropServices;
|
|||||||
// Możesz określić wszystkie wartości lub użyć domyślnych numerów kompilacji i poprawki
|
// Możesz określić wszystkie wartości lub użyć domyślnych numerów kompilacji i poprawki
|
||||||
// przy użyciu symbolu „*”, tak jak pokazano poniżej:
|
// przy użyciu symbolu „*”, tak jak pokazano poniżej:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.8.0.0")]
|
[assembly: AssemblyVersion("0.8.2.0")]
|
||||||
[assembly: AssemblyFileVersion("0.8.0.0")]
|
[assembly: AssemblyFileVersion("0.8.2.0")]
|
||||||
[assembly: NeutralResourcesLanguage("en")]
|
[assembly: NeutralResourcesLanguage("en")]
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ namespace Perun_v1.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap ico_db {
|
internal static System.Drawing.Bitmap status_connected {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ico_db", resourceCulture);
|
object obj = ResourceManager.GetObject("status_connected", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,9 +73,9 @@ namespace Perun_v1.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap ico_error {
|
internal static System.Drawing.Bitmap status_connected_error {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ico_error", resourceCulture);
|
object obj = ResourceManager.GetObject("status_connected_error", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,9 +83,9 @@ namespace Perun_v1.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap ico_game {
|
internal static System.Drawing.Bitmap status_disconnected {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ico_game", resourceCulture);
|
object obj = ResourceManager.GetObject("status_disconnected", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,19 +93,9 @@ namespace Perun_v1.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap ico_lotatc {
|
internal static System.Drawing.Bitmap status_disconnected_error {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ico_lotatc", resourceCulture);
|
object obj = ResourceManager.GetObject("status_disconnected_error", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap ico_srs {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("ico_srs", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,19 +118,16 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
<data name="ico_db" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="status_connected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ico_db.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\status-connected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ico_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="status_connected_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ico_error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\status-connectedx.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ico_game" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="status_disconnected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ico_game.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\status-disconnected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ico_lotatc" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="status_disconnected_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ico_lotatc.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\status-disconnected-error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
|
||||||
<data name="ico_srs" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\ico_srs.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
BIN
02_Windows_App/Perun_v1/Resources/status-connected.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/status-connected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
02_Windows_App/Perun_v1/Resources/status-connectedx.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/status-connectedx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
BIN
02_Windows_App/Perun_v1/Resources/status-disconnected-error.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/status-disconnected-error.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
02_Windows_App/Perun_v1/Resources/status-disconnected-game.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/status-disconnected-game.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
02_Windows_App/Perun_v1/Resources/status-disconnected.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/status-disconnected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 909 B |
16
README.md
16
README.md
@@ -20,7 +20,7 @@ Core:
|
|||||||
* For JSON Export:
|
* For JSON Export:
|
||||||
* DCS World stable or DCS World beta
|
* DCS World stable or DCS World beta
|
||||||
* **(Optional)** For MySQL Export:
|
* **(Optional)** For MySQL Export:
|
||||||
* MySQL database with read/write access (tested with v5.7.21)
|
* MySQL database with read/write access running at min. 5.7 server (tested with v5.7.21; native JSON support is required)
|
||||||
* .NET Framework 4.8.0
|
* .NET Framework 4.8.0
|
||||||
|
|
||||||
3rd party applications support:
|
3rd party applications support:
|
||||||
@@ -71,16 +71,24 @@ C:\Perun_v1\Perun.exe 48621 1 "G:\DCS SRS\clients-list.json" "C:\Users\DCS\Saved
|
|||||||
|
|
||||||
## Data packets - send from lua to TCP port
|
## Data packets - send from lua to TCP port
|
||||||
* ```ID: 1```, contains version/diagnostic information
|
* ```ID: 1```, contains version/diagnostic information
|
||||||
|
* perun version - for server administration usage
|
||||||
|
* player count - actual number of connected players
|
||||||
* ```ID: 2```, contains status data in the following sections
|
* ```ID: 2```, contains status data in the following sections
|
||||||
* mission - minimal information about mission
|
* mission name - name of the mission file
|
||||||
|
* model time - simulation time
|
||||||
|
* real time - real time
|
||||||
|
* pause - information if server is paused
|
||||||
|
* multiplayer - information if this is multiplayer game (always true for dedicated server usage)
|
||||||
|
* theather - information about area of operation
|
||||||
|
* weather - basic weather information
|
||||||
* players - connected players
|
* players - connected players
|
||||||
* ```ID: 3```, available slots list and coalitions
|
* ```ID: 3```, available slots list and coalitions
|
||||||
* coalitions - available coalitions
|
* coalitions - available coalitions
|
||||||
* slots - available slots
|
* slots - available slots
|
||||||
* ```ID: 4```, stores mission data
|
* ```ID: 4```, stores mission data ; idea is to have whole DCS.getCurrentMission() result - currenlty commented out due to performance issues
|
||||||
* ```ID: 50```, chat event
|
* ```ID: 50```, chat event
|
||||||
* ```ID: 51```, game event
|
* ```ID: 51```, game event
|
||||||
* ```ID: 52```, player stats
|
* ```ID: 52```, player stats ; note that as DSC native stats are not reliable, seperate stats couting methods are used
|
||||||
* ```ID: 53```, player login to DCS server
|
* ```ID: 53```, player login to DCS server
|
||||||
* ```ID: 100```, DCS SRS's client-list.json
|
* ```ID: 100```, DCS SRS's client-list.json
|
||||||
* ```ID: 101```, LotATC's stats.json
|
* ```ID: 101```, LotATC's stats.json
|
||||||
|
|||||||
Reference in New Issue
Block a user