Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a807834d2 | ||
|
|
e1cfdba2cc | ||
|
|
9770c26b93 | ||
|
|
a0c9a249f6 | ||
|
|
53aade262e | ||
|
|
a78ad87312 | ||
|
|
ab86b3bcec | ||
|
|
b8087f6333 | ||
|
|
83ce2bd490 | ||
|
|
1f110321b4 | ||
|
|
efc215f58a | ||
|
|
4e1456e432 | ||
|
|
5908f8f332 | ||
|
|
5889bc6ddf | ||
|
|
2084d88117 | ||
|
|
49495ba9c4 | ||
|
|
1a73404c4c | ||
|
|
c66daec294 | ||
|
|
38853937be | ||
|
|
488d4dfcac | ||
|
|
fb96745ede | ||
|
|
9d06065d70 | ||
|
|
464261f09f | ||
|
|
9123619ad1 | ||
|
|
cabd8d28bb | ||
|
|
67eda5d79b | ||
|
|
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 | ||
|
|
255eb35e7f | ||
|
|
22168d281f | ||
|
|
1438e55686 | ||
|
|
fd92b1c287 | ||
|
|
548281a3d7 | ||
|
|
e8d3338d9b | ||
|
|
40302fed4b | ||
|
|
edc1133023 | ||
|
|
bdb89a4bf9 | ||
|
|
0bb396eae4 | ||
|
|
f58c24be74 | ||
|
|
a58eced7bf | ||
|
|
22d87b8a62 | ||
|
|
ff9ae98887 | ||
|
|
44da46083e | ||
|
|
5916ccedb3 | ||
|
|
35d63d072c | ||
|
|
09d379d611 | ||
|
|
fcb189a4cd | ||
|
|
9d42ccc1d4 | ||
|
|
238f6e29ae | ||
|
|
ddb2527eb8 | ||
|
|
97a4c0aa45 | ||
|
|
4b975b1892 | ||
|
|
74e227ae27 | ||
|
|
69501b4623 | ||
|
|
36c713ba3f | ||
|
|
17a2905b14 | ||
|
|
df7155f061 | ||
|
|
52ecfda6c5 | ||
|
|
4900ef4888 | ||
|
|
150a9ab502 | ||
|
|
d3ba6c008a | ||
|
|
f1eb4b64d1 | ||
|
|
976feec650 | ||
|
|
073b9a72e2 | ||
|
|
ad299b227b | ||
|
|
7d3b99c1fd | ||
|
|
57771d94b7 | ||
|
|
d1bedf3e1c | ||
|
|
c4eb824c32 | ||
|
|
ab1e19b340 | ||
|
|
ba646a6c22 | ||
|
|
7e8b01c2aa | ||
|
|
7b907190f9 | ||
|
|
7f484bc1a1 | ||
|
|
c053d5d461 | ||
|
|
5b3d19e134 | ||
|
|
d885d2cd90 | ||
|
|
9f50bb1397 | ||
|
|
f7f688d1a5 | ||
|
|
81ff34014a | ||
|
|
9e0c515af0 | ||
|
|
9391d8778f | ||
|
|
1cfe5a1ea9 | ||
|
|
8d1835f6f5 | ||
|
|
3be5a8765f | ||
|
|
0f01624380 | ||
|
|
3ff2fff728 | ||
|
|
f383f3c056 | ||
|
|
69f995bd6d | ||
|
|
64a550e8e8 | ||
|
|
31ed9ee875 | ||
|
|
0722a9ca26 | ||
|
|
a21bbd4459 | ||
|
|
4ff546b105 | ||
|
|
2463d4267d | ||
|
|
6b37b05dbf | ||
|
|
d34fdf00b3 | ||
|
|
37543ec167 | ||
|
|
7dda6a224d | ||
|
|
993ae2a755 | ||
|
|
c79dc039e6 | ||
|
|
a26c9d8f08 | ||
|
|
f55a117051 | ||
|
|
e05cee514c | ||
|
|
d63c0fbfdf | ||
|
|
f49734560e | ||
|
|
5d3f7148bb | ||
|
|
2629295f93 | ||
|
|
a6ad17dbe1 | ||
|
|
b7022c22c1 | ||
|
|
907d8d01d6 | ||
|
|
fc82c43072 | ||
|
|
37b6f3419e | ||
|
|
b96affd4fd | ||
|
|
8d733f83ab | ||
|
|
58cc8a7b39 | ||
|
|
e09926aa80 | ||
|
|
13969a95cc | ||
|
|
5c9fa4e284 | ||
|
|
3512f7f5cf | ||
|
|
6847a1e262 | ||
|
|
c917d0ef04 | ||
|
|
784ad9947f | ||
|
|
91c629ed81 | ||
|
|
5d415812fa |
@@ -1,82 +1,251 @@
|
||||
-- Perun for DCS World https://github.com/szporwolik/perun -> DCS Hook component
|
||||
|
||||
-- Initial init
|
||||
local Perun = {}
|
||||
package.path = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua"
|
||||
package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
|
||||
local Perun = {}
|
||||
package.path = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua"
|
||||
package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
|
||||
|
||||
-- ########### SETTINGS ###########
|
||||
-- ###################### SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION #############################
|
||||
|
||||
Perun.Refresh = 15 -- base refresh rate in secounds (values lower than 60 may affect performance!)
|
||||
Perun.JsonLocation = "Scripts\\Json\\perun_export.json" -- relatve do user's SaveGames DCS folder
|
||||
Perun.UDPTargetPort = 48620 -- UDP port to send data to
|
||||
Perun.MOTD_L1 = "Witamy na serwerze Gildia.org !" -- Message send to players connecting the server - Line 1
|
||||
Perun.MOTD_L2 = "Wymagamy obecnosci na 255Mhz (DCS SRS)" -- Message send to players connecting the server - Line 2
|
||||
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.TCPTargetPort = 48622 -- (int) TCP port to send data to
|
||||
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
|
||||
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.MOTD_L1 = "Witamy na serwerze Gildia.org !" -- (string) Message send to players connecting the server - Line 1
|
||||
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 ###########
|
||||
|
||||
-- Variable init
|
||||
Perun.Version = "v0.3.0"
|
||||
Perun.StatusData = {}
|
||||
Perun.SlotsData = {}
|
||||
Perun.VersionData = {}
|
||||
Perun.lastSent =0
|
||||
Perun.JsonLocation = lfs.writedir() .. Perun.JsonLocation
|
||||
Perun.socket = require("socket")
|
||||
Perun.UDP = assert(Perun.socket.udp())
|
||||
Perun.UDP:settimeout(0)
|
||||
Perun.UDP:setsockname("*", 48621)
|
||||
Perun.UDP:setpeername("127.0.0.1",Perun.UDPTargetPort)
|
||||
Perun.Version = "v0.8.3"
|
||||
Perun.StatusData = {}
|
||||
Perun.SlotsData = {}
|
||||
Perun.MissionData = {}
|
||||
Perun.ServerData = {}
|
||||
Perun.StatData = {}
|
||||
Perun.StatDataLastType = {}
|
||||
Perun.MissionHash=""
|
||||
Perun.lastSentStatus =0
|
||||
Perun.lastSentMission =0
|
||||
Perun.lastSentKeepAlive =0
|
||||
Perun.lastReconnect = 0
|
||||
Perun.JsonStatusLocation = lfs.writedir() .. Perun.JsonStatusLocation
|
||||
Perun.socket = require("socket")
|
||||
Perun.IsServer = true --DCS.isServer( ) -- TBD looks like DCS API error, always returning True
|
||||
|
||||
-- Function definition
|
||||
Perun.AddLog = function(text)
|
||||
-- ########### Helper function definitions ###########
|
||||
function stripChars(str)
|
||||
-- remove accents characters from string
|
||||
-- via https://stackoverflow.com/questions/50459102/replace-accented-characters-in-string-to-standard-with-lua
|
||||
tableAccents = {}
|
||||
tableAccents["à"] = "a"
|
||||
tableAccents["á"] = "a"
|
||||
tableAccents["â"] = "a"
|
||||
tableAccents["ã"] = "a"
|
||||
tableAccents["ä"] = "a"
|
||||
tableAccents["ç"] = "c"
|
||||
tableAccents["è"] = "e"
|
||||
tableAccents["é"] = "e"
|
||||
tableAccents["ê"] = "e"
|
||||
tableAccents["ë"] = "e"
|
||||
tableAccents["ì"] = "i"
|
||||
tableAccents["í"] = "i"
|
||||
tableAccents["î"] = "i"
|
||||
tableAccents["ï"] = "i"
|
||||
tableAccents["ñ"] = "n"
|
||||
tableAccents["ò"] = "o"
|
||||
tableAccents["ó"] = "o"
|
||||
tableAccents["ô"] = "o"
|
||||
tableAccents["õ"] = "o"
|
||||
tableAccents["ö"] = "o"
|
||||
tableAccents["ù"] = "u"
|
||||
tableAccents["ú"] = "u"
|
||||
tableAccents["û"] = "u"
|
||||
tableAccents["ü"] = "u"
|
||||
tableAccents["ý"] = "y"
|
||||
tableAccents["ÿ"] = "y"
|
||||
tableAccents["À"] = "A"
|
||||
tableAccents["Á"] = "A"
|
||||
tableAccents["Â"] = "A"
|
||||
tableAccents["Ã"] = "A"
|
||||
tableAccents["Ä"] = "A"
|
||||
tableAccents["Ç"] = "C"
|
||||
tableAccents["È"] = "E"
|
||||
tableAccents["É"] = "E"
|
||||
tableAccents["Ê"] = "E"
|
||||
tableAccents["Ë"] = "E"
|
||||
tableAccents["Ì"] = "I"
|
||||
tableAccents["Í"] = "I"
|
||||
tableAccents["Î"] = "I"
|
||||
tableAccents["Ï"] = "I"
|
||||
tableAccents["Ñ"] = "N"
|
||||
tableAccents["Ò"] = "O"
|
||||
tableAccents["Ó"] = "O"
|
||||
tableAccents["Ô"] = "O"
|
||||
tableAccents["Õ"] = "O"
|
||||
tableAccents["Ö"] = "O"
|
||||
tableAccents["Ù"] = "U"
|
||||
tableAccents["Ú"] = "U"
|
||||
tableAccents["Û"] = "U"
|
||||
tableAccents["Ü"] = "U"
|
||||
tableAccents["Ý"] = "Y"
|
||||
|
||||
-- Polish accents
|
||||
tableAccents["ę"] = "e"
|
||||
tableAccents["Ę"] = "Ę"
|
||||
tableAccents["ó"] = "o"
|
||||
tableAccents["Ó"] = "O"
|
||||
tableAccents["ą"] = "a"
|
||||
tableAccents["Ą"] = "A"
|
||||
tableAccents["ś"] = "s"
|
||||
tableAccents["Ś"] = "S"
|
||||
tableAccents["ć"] = "c"
|
||||
tableAccents["Ć"] = "C"
|
||||
tableAccents["ż"] = "z"
|
||||
tableAccents["Ż"] = "Z"
|
||||
tableAccents["ź"] = "z"
|
||||
tableAccents["Ź"] = "Z"
|
||||
tableAccents["ł"] = "l"
|
||||
tableAccents["Ł"] = "L"
|
||||
|
||||
-- TBD additonal characters
|
||||
|
||||
normalizedString = ''
|
||||
|
||||
for strChar in string.gmatch(str, "([%z\1-\127\194-\244][\128-\191]*)") do
|
||||
if tableAccents[strChar] ~= nil then
|
||||
normalizedString = normalizedString..tableAccents[strChar]
|
||||
else
|
||||
normalizedString = normalizedString..strChar
|
||||
end
|
||||
end
|
||||
return normalizedString
|
||||
end
|
||||
|
||||
Perun.GetCategory = function(id)
|
||||
-- Returns object category basing on ID
|
||||
-- Helper function via https://pastebin.com/GUAXrd2U TBD: rewrite
|
||||
local _killed_target_category = DCS.getUnitTypeAttribute(id, "category")
|
||||
if _killed_target_category == nil then
|
||||
local _killed_target_cat_check_ship = DCS.getUnitTypeAttribute(id, "DeckLevel")
|
||||
local _killed_target_cat_check_plane = DCS.getUnitTypeAttribute(id, "WingSpan")
|
||||
if _killed_target_cat_check_ship ~= nil and _killed_target_cat_check_plane == nil then
|
||||
_killed_target_category = "Ships"
|
||||
elseif _killed_target_cat_check_ship == nil and _killed_target_cat_check_plane ~= nil then
|
||||
_killed_target_category = "Planes"
|
||||
else
|
||||
_killed_target_category = "Helicopters"
|
||||
end
|
||||
end
|
||||
return _killed_target_category
|
||||
end
|
||||
|
||||
Perun.SideID2Name = function(id)
|
||||
-- Helper function returns side name per side (coalition) id
|
||||
local sides = {
|
||||
[0] = 'SPECTATOR',
|
||||
[1] = 'RED',
|
||||
[2] = 'BLUE',
|
||||
}
|
||||
return sides[id]
|
||||
end
|
||||
|
||||
Perun.UpdateStatusPart = function(part_id, data_package)
|
||||
-- Helper for status update container
|
||||
Perun.StatusData[part_id] = data_package
|
||||
end
|
||||
|
||||
-- ########### Main code ###########
|
||||
|
||||
Perun.AddLog = function(text)
|
||||
-- Adds logs to DCS.log file
|
||||
net.log("Perun : ".. text)
|
||||
end
|
||||
end
|
||||
|
||||
Perun.UpdateJson = function()
|
||||
-- Updates main json file
|
||||
Perun.UpdateJsonStatus = function()
|
||||
-- Updates status json file
|
||||
TempData={}
|
||||
TempData["1"]=Perun.VersionData
|
||||
TempData["1"]=Perun.ServerData
|
||||
TempData["2"]=Perun.StatusData
|
||||
TempData["3"]=Perun.SlotsData
|
||||
-- TempData["4"]=Perun.MissionData -- TBD: hangs for some large missions
|
||||
|
||||
io.open(Perun.JsonLocation,"w"):close()
|
||||
perun_export = io.open(Perun.JsonLocation, "w")
|
||||
perun_export:write(net.lua2json(TempData) .. "\n")
|
||||
_temp=net.lua2json(TempData)
|
||||
|
||||
perun_export = io.open(Perun.JsonStatusLocation .. "perun_status_data.json", "w")
|
||||
perun_export:write(_temp .. "\n")
|
||||
perun_export:close()
|
||||
end
|
||||
Perun.AddLog("Updated JSON")
|
||||
end
|
||||
|
||||
Perun.Send = function(data_id, data_package)
|
||||
-- Sends data package
|
||||
Perun.ConnectToPerun = function ()
|
||||
-- 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("ERROR - TCP connection error : " .. err)
|
||||
else
|
||||
Perun.AddLog("Sucess - 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["type"]=data_id
|
||||
TempData["payload"]=data_package
|
||||
TempData["timestamp"]=os.date('%Y-%m-%d %H:%M:%S')
|
||||
TempData["instance"]=Perun.Instance
|
||||
|
||||
temp=net.lua2json(TempData)
|
||||
Perun.UDP:send(temp)
|
||||
Perun.AddLog("Packet send")
|
||||
temp="<SOT>" .. stripChars(temp) .. "<EOT>"
|
||||
|
||||
-- TCP Part - sending
|
||||
intStatus = nil
|
||||
intTries =0
|
||||
err=nil
|
||||
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
|
||||
|
||||
Perun.UpdateStatusPart = function(part_id, data_package)
|
||||
-- Helper for status update container
|
||||
Perun.StatusData[part_id] = data_package
|
||||
intTries=intTries+1
|
||||
err = nil
|
||||
end
|
||||
|
||||
Perun.UpdateVersion = function()
|
||||
-- Main function for debug/version information
|
||||
|
||||
-- Update Mission data
|
||||
Perun.VersionData['v_dcs_hook']=Perun.Version
|
||||
|
||||
-- Send
|
||||
Perun.Send(1,Perun.VersionData)
|
||||
if err then
|
||||
Perun.AddLog("ERROR - packed dropped : " .. data_id)
|
||||
end
|
||||
end
|
||||
|
||||
Perun.UpdateStatus = function()
|
||||
Perun.UpdateStatus = function()
|
||||
-- Main function for status updates
|
||||
|
||||
-- Update all subsections
|
||||
-- Diagnostic data
|
||||
-- Update version data
|
||||
Perun.ServerData['v_dcs_hook']=Perun.Version
|
||||
|
||||
-- Update clients data data
|
||||
_table=net.get_player_list()
|
||||
_count = 0
|
||||
for _ in pairs(_table) do _count = _count + 1 end
|
||||
Perun.ServerData['c_players']=_count
|
||||
|
||||
-- Send
|
||||
Perun.SendToPerun(1,Perun.ServerData)
|
||||
|
||||
-- Status data - update all subsections
|
||||
-- 1 - Mission
|
||||
temp={}
|
||||
temp['name']=DCS.getMissionName()
|
||||
@@ -84,141 +253,526 @@
|
||||
temp['realtime']=DCS.getRealTime()
|
||||
temp['pause']=DCS.getPause()
|
||||
temp['multiplayer']=DCS.isMultiplayer()
|
||||
temp['theatre'] = Perun.MissionData['mission']['theatre']
|
||||
temp['weather'] = Perun.MissionData['mission']['weather']
|
||||
Perun.UpdateStatusPart("mission",temp)
|
||||
|
||||
-- 2 - Players
|
||||
temp = net.get_player_list()
|
||||
for _, i in ipairs(temp) do
|
||||
temp[i]=net.get_player_info(i)
|
||||
_temp = net.get_player_list()
|
||||
_temp2={}
|
||||
for k, i in ipairs(_temp) do
|
||||
_temp2[k]=net.get_player_info(i)
|
||||
end
|
||||
Perun.UpdateStatusPart("players",temp)
|
||||
Perun.UpdateStatusPart("players",_temp2)
|
||||
|
||||
-- Send
|
||||
Perun.Send(2,Perun.StatusData)
|
||||
end
|
||||
Perun.SendToPerun(2,Perun.StatusData)
|
||||
|
||||
Perun.UpdateMission = function()
|
||||
-- Main function for mission information updates
|
||||
|
||||
-- Update Mission data
|
||||
-- Update slots data
|
||||
Perun.SlotsData['coalitions']=DCS.getAvailableCoalitions()
|
||||
Perun.SlotsData['slots']={}
|
||||
|
||||
for j, i in pairs(Perun.SlotsData['coalitions']) do
|
||||
Perun.SlotsData['slots'][j]=DCS.getAvailableSlots(j)
|
||||
end
|
||||
-- Send
|
||||
Perun.Send(3,Perun.SlotsData)
|
||||
|
||||
for sj, si in pairs(Perun.SlotsData['slots'][j]) do
|
||||
Perun.SlotsData['slots'][j][sj]['countryName']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['onboard_num']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['groupSize']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['groupName']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['callsign']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['task']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['airdromeId']= nil
|
||||
Perun.SlotsData['slots'][j][sj]['helipadName']= nil
|
||||
end
|
||||
|
||||
Perun.LogChat = function(playerID,msg,all)
|
||||
-- Log chat messages
|
||||
end
|
||||
-- Send
|
||||
Perun.SendToPerun(3,Perun.SlotsData)
|
||||
end
|
||||
|
||||
|
||||
Perun.UpdateMission = function()
|
||||
-- Main function for mission information updates
|
||||
Perun.MissionData=DCS.getCurrentMission()
|
||||
-- Perun.SendToPerun(4,Perun.MissionData) -- TBD can cause data transmission troubles
|
||||
end
|
||||
|
||||
Perun.LogChat = function(playerID,msg,all)
|
||||
-- Logs chat messages
|
||||
|
||||
data={}
|
||||
data['player']= net.get_player_info(playerID, "name")
|
||||
data['msg']=msg
|
||||
data['msg']=stripChars(msg)
|
||||
data['all']=all
|
||||
data['ucid']=net.get_player_info(playerID, 'ucid')
|
||||
data['datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['missionhash']=Perun.MissionHash
|
||||
|
||||
Perun.Send(50,data)
|
||||
end
|
||||
Perun.SendToPerun(50,data)
|
||||
end
|
||||
|
||||
Perun.LogEvent = function(log_type,log_content)
|
||||
-- Log chat messages
|
||||
Perun.LogEvent = function(log_type,log_content,log_arg_1,log_arg_2)
|
||||
-- Logs events messages
|
||||
|
||||
data={}
|
||||
data['log_type']= log_type
|
||||
data['log_arg_1']= log_arg_1
|
||||
data['log_arg_2']= log_arg_2
|
||||
data['log_content']=log_content
|
||||
data['log_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['log_missionhash']=Perun.MissionHash
|
||||
|
||||
Perun.Send(51,data)
|
||||
Perun.SendToPerun(51,data)
|
||||
end
|
||||
|
||||
Perun.LogStatsCount = function(argPlayerID,argAction,argType)
|
||||
-- Creates or updates Perun statistics array
|
||||
_ucid=net.get_player_info(argPlayerID, 'ucid')..argType
|
||||
|
||||
if Perun.StatData[_ucid] == nil then
|
||||
-- Create empty element
|
||||
_temp={}
|
||||
_temp['ps_type'] = argType
|
||||
_temp['ps_pvp'] = 0
|
||||
_temp['ps_deaths'] = 0
|
||||
_temp['ps_ejections'] = 0
|
||||
_temp['ps_crashes'] = 0
|
||||
_temp['ps_teamkills'] = 0
|
||||
_temp['ps_kills_planes'] = 0
|
||||
_temp['ps_kills_helicopters'] = 0
|
||||
_temp['ps_kills_air_defense'] = 0
|
||||
_temp['ps_kills_armor'] = 0
|
||||
_temp['ps_kills_unarmed'] = 0
|
||||
_temp['ps_kills_infantry'] = 0
|
||||
_temp['ps_kills_ships'] = 0
|
||||
_temp['ps_kills_fortification'] = 0
|
||||
_temp['ps_kills_other'] = 0
|
||||
_temp['ps_airfield_takeoffs'] = 0
|
||||
_temp['ps_airfield_landings'] = 0
|
||||
_temp['ps_ship_takeoffs'] = 0
|
||||
_temp['ps_ship_landings'] = 0
|
||||
_temp['ps_farp_takeoffs'] = 0
|
||||
_temp['ps_farp_landings'] = 0
|
||||
_temp['ps_other_takeoffs'] = 0
|
||||
_temp['ps_other_landings'] = 0
|
||||
|
||||
Perun.StatData[_ucid]=_temp
|
||||
end
|
||||
|
||||
--- Event callbacks
|
||||
Perun.onSimulationFrame = function()
|
||||
if argType ~= nil then
|
||||
Perun.StatData[_ucid]['ps_type']=argType;
|
||||
Perun.StatDataLastType[net.get_player_info(argPlayerID, 'ucid')]=_ucid
|
||||
else
|
||||
-- Do nothing
|
||||
end
|
||||
|
||||
if argAction == "eject" then
|
||||
Perun.StatData[_ucid]['ps_ejections']=Perun.StatData[_ucid]['ps_ejections']+1
|
||||
elseif argAction == "pilot_death" 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
|
||||
end
|
||||
elseif argAction == "friendly_fire" then
|
||||
Perun.StatData[_ucid]['ps_teamkills']=Perun.StatData[_ucid]['ps_teamkills']+1
|
||||
elseif argAction == "crash" then
|
||||
Perun.StatData[_ucid]['ps_crashes']=Perun.StatData[_ucid]['ps_crashes']+1
|
||||
elseif argAction == "landing_FARP" then
|
||||
Perun.StatData[_ucid]['ps_farp_landings']=Perun.StatData[_ucid]['ps_farp_landings']+1
|
||||
elseif argAction == "landing_SHIP" then
|
||||
Perun.StatData[_ucid]['ps_ship_landings']=Perun.StatData[_ucid]['ps_ship_landings']+1
|
||||
elseif argAction == "landing_AIRFIELD" then
|
||||
Perun.StatData[_ucid]['ps_airfield_landings']=Perun.StatData[_ucid]['ps_airfield_landings']+1
|
||||
elseif argAction == "tookoff_FARP" then
|
||||
Perun.StatData[_ucid]['ps_farp_takeoffs']=Perun.StatData[_ucid]['ps_farp_takeoffs']+1
|
||||
elseif argAction == "tookoff_SHIP" then
|
||||
Perun.StatData[_ucid]['ps_ship_takeoffs']=Perun.StatData[_ucid]['ps_ship_takeoffs']+1
|
||||
elseif argAction == "tookoff_AIRFIELD" then
|
||||
Perun.StatData[_ucid]['ps_airfield_takeoffs']=Perun.StatData[_ucid]['ps_airfield_takeoffs']+1
|
||||
elseif argAction == "kill_Planes" then
|
||||
Perun.StatData[_ucid]['ps_kills_planes']=Perun.StatData[_ucid]['ps_kills_planes']+1
|
||||
elseif argAction == "kill_Helicopters" then
|
||||
Perun.StatData[_ucid]['ps_kills_helicopters']=Perun.StatData[_ucid]['ps_kills_helicopters']+1
|
||||
elseif argAction == "kill_Ships" then
|
||||
Perun.StatData[_ucid]['ps_kills_ships']=Perun.StatData[_ucid]['ps_kills_ships']+1
|
||||
elseif argAction == "kill_Air_Defence" then
|
||||
Perun.StatData[_ucid]['ps_kills_air_defense']=Perun.StatData[_ucid]['ps_kills_air_defense']+1
|
||||
elseif argAction == "kill_Unarmed" then
|
||||
Perun.StatData[_ucid]['ps_kills_unarmed']=Perun.StatData[_ucid]['ps_kills_unarmed']+1
|
||||
elseif argAction == "kill_Armor" then
|
||||
Perun.StatData[_ucid]['ps_kills_armor']=Perun.StatData[_ucid]['ps_kills_armor']+1
|
||||
elseif argAction == "kill_Infantry" then
|
||||
Perun.StatData[_ucid]['ps_kills_infantry']=Perun.StatData[_ucid]['ps_kills_infantry']+1
|
||||
elseif argAction == "kill_Fortification" then
|
||||
Perun.StatData[_ucid]['ps_kills_fortification']=Perun.StatData[_ucid]['ps_kills_fortification']+1
|
||||
elseif argAction == "kill_Other" then
|
||||
Perun.StatData[_ucid]['ps_kills_other']=Perun.StatData[_ucid]['ps_kills_other']+1
|
||||
elseif argAction == "kill_PvP" then
|
||||
Perun.StatData[_ucid]['ps_pvp']=Perun.StatData[_ucid]['ps_pvp']+1
|
||||
elseif argAction == "landing_OTHER" then
|
||||
Perun.StatData[_ucid]['ps_other_landings']=Perun.StatData[_ucid]['ps_other_landings']+1
|
||||
elseif argAction == "tookoff_OTHER" then
|
||||
Perun.StatData[_ucid]['ps_other_takeoffs']=Perun.StatData[_ucid]['ps_other_takeoffs']+1
|
||||
end
|
||||
|
||||
Perun.LogStats(argPlayerID);
|
||||
end
|
||||
|
||||
Perun.LogStatsGet = function(playerID)
|
||||
-- Gets Perun statistics array per player
|
||||
|
||||
local next = next
|
||||
if next(Perun.StatDataLastType) == nil then
|
||||
_ucid=net.get_player_info(playerID, 'ucid')..DCS.getUnitType(playerID)
|
||||
elseif Perun.StatDataLastType[net.get_player_info(playerID, 'ucid')]== nil then
|
||||
_ucid=net.get_player_info(playerID, 'ucid')..DCS.getUnitType(playerID)
|
||||
else
|
||||
_ucid=Perun.StatDataLastType[net.get_player_info(playerID, 'ucid')]
|
||||
end
|
||||
|
||||
local next = next
|
||||
if next(Perun.StatData) == nil then
|
||||
Perun.LogStatsCount(playerID,'init')
|
||||
|
||||
end
|
||||
if Perun.StatData[_ucid]== nil then
|
||||
Perun.LogStatsCount(playerID,'init')
|
||||
end
|
||||
return Perun.StatData[_ucid];
|
||||
end
|
||||
|
||||
|
||||
|
||||
Perun.LogStats = function(playerID)
|
||||
-- Log player status
|
||||
|
||||
-- TBD : DCS stats not working at the moment WIP
|
||||
p_stats_dcs={}
|
||||
p_stats_dcs['PS_CAR']=net.get_stat(playerID,2)
|
||||
p_stats_dcs['PS_PLANE']=net.get_stat(playerID,3)
|
||||
p_stats_dcs['PS_SHIP']=net.get_stat(playerID,4)
|
||||
p_stats_dcs['PS_SCORE']=net.get_stat(playerID,5)
|
||||
p_stats_dcs['PS_LAND']=net.get_stat(playerID,6)
|
||||
p_stats_dcs['PS_PING']=net.get_stat(playerID,0)
|
||||
p_stats_dcs['PS_CRASH']=net.get_stat(playerID,1)
|
||||
p_stats_dcs['PS_EJECT']=net.get_stat(playerID,7)
|
||||
|
||||
_temp=Perun.LogStatsGet(playerID)
|
||||
data={}
|
||||
data['stat_data_dcs']=p_stats_dcs
|
||||
data['stat_data_perun']=_temp
|
||||
data['stat_data_type']=_temp['ps_type'];
|
||||
data['stat_ucid']=net.get_player_info(playerID, 'ucid')
|
||||
data['stat_name']=net.get_player_info(playerID, 'name')
|
||||
data['stat_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['stat_missionhash']=Perun.MissionHash
|
||||
|
||||
Perun.SendToPerun(52,data)
|
||||
end
|
||||
|
||||
Perun.LogLogin = function(playerID)
|
||||
-- Player logged in
|
||||
|
||||
data={}
|
||||
data['login_ucid']=net.get_player_info(playerID, 'ucid')
|
||||
data['login_ipaddr']=net.get_player_info(playerID, 'ipaddr')
|
||||
data['login_name']=net.get_player_info(playerID, 'name')
|
||||
data['login_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
Perun.SendToPerun(53,data)
|
||||
end
|
||||
|
||||
Perun.CheckMulticrew = function (owner_playerID,owner_unittype)
|
||||
-- Check multicrew and return list of co-player
|
||||
|
||||
_coplayers = {}
|
||||
table.insert(_coplayers, owner_playerID)
|
||||
if owner_unittype == "F-14B" or owner_unittype == "Yak-52" or owner_unittype == "L-39C" or owner_unittype == "SA342M" or owner_unittype =="SA342Minigun" or owner_unittype == "SA342Mistral" or owner_unittype == "SA342L" then -- TBD add additional multicrew model types
|
||||
|
||||
_owner_slot=net.get_player_info(owner_playerID, 'slot')
|
||||
_owner_side=net.get_player_info(owner_playerID, 'side')
|
||||
|
||||
-- Check if we are co-player
|
||||
_t_start, _t_end = string.find(_owner_slot, '_%d+')
|
||||
_sub_slot = nil
|
||||
if _t_start then
|
||||
-- This is co-player
|
||||
_master_slot = string.sub(_owner_slot, 0 , _t_start -1 )
|
||||
_sub_slot = string.sub(_owner_slot, _t_start + 1, _t_end )
|
||||
else
|
||||
_master_slot = _owner_slot
|
||||
|
||||
end
|
||||
|
||||
if _master_slot ~= "" then
|
||||
-- Search for all players to account for event
|
||||
_all_players = net.get_player_list()
|
||||
for PlayerIDIndex, playerID in ipairs(_all_players) do
|
||||
local _playerDetails = net.get_player_info( playerID )
|
||||
|
||||
if _playerDetails.side == _owner_side and (_playerDetails.slot == _master_slot or _playerDetails.slot == _master_slot .. "_1" or _playerDetails.slot == _master_slot .. "_2") and playerID ~= owner_playerID then
|
||||
-- Let's build coplayers list
|
||||
table.insert(_coplayers, playerID)
|
||||
else
|
||||
-- No coplayers
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return _coplayers
|
||||
end
|
||||
|
||||
|
||||
--- ########### Event callbacks ###########
|
||||
|
||||
Perun.onSimulationStart = function()
|
||||
Perun.MissionHash=DCS.getMissionName( ).."@".. Perun.Instance .. "@"..os.date('%Y%m%d_%H%M%S');
|
||||
Perun.LogEvent("SimStart","Mission " .. Perun.MissionHash .. " started",nil,nil);
|
||||
Perun.StatData = {}
|
||||
Perun.StatDataLastType = {}
|
||||
end
|
||||
|
||||
Perun.onSimulationStop = function()
|
||||
Perun.LogEvent("SimStop","Mission " .. Perun.MissionHash .. " finished",nil,nil);
|
||||
Perun.MissionHash="";
|
||||
Perun.StatData = {}
|
||||
Perun.StatDataLastType = {}
|
||||
end
|
||||
|
||||
Perun.onPlayerDisconnect = function(id, err_code)
|
||||
Perun.LogEvent("disconnect", "Player " .. net.get_player_info(id, "name") .. " disconnected; " .. err_code,net.get_player_info(id, "name"),err_code);
|
||||
end
|
||||
|
||||
Perun.onSimulationFrame = function()
|
||||
local _now = DCS.getRealTime()
|
||||
|
||||
if _now > Perun.lastSent + Perun.Refresh then
|
||||
Perun.lastSent = _now
|
||||
-- First run
|
||||
if Perun.lastSentMission ==0 and Perun.lastSentStatus ==0 then
|
||||
Perun.UpdateMission()
|
||||
end
|
||||
|
||||
-- Send mission update and update JSON
|
||||
if _now > Perun.lastSentMission + Perun.RefreshMission then
|
||||
Perun.lastSentMission = _now
|
||||
|
||||
Perun.UpdateMission()
|
||||
Perun.UpdateJsonStatus()
|
||||
end
|
||||
|
||||
-- Send status update
|
||||
if _now > Perun.lastSentStatus + Perun.RefreshStatus then
|
||||
Perun.lastSentStatus = _now
|
||||
|
||||
Perun.UpdateStatus()
|
||||
Perun.UpdateVersion()
|
||||
Perun.UpdateJson()
|
||||
end
|
||||
|
||||
-- Send keepalive
|
||||
if _now > Perun.lastSentKeepAlive + 3 then
|
||||
Perun.lastSentKeepAlive = _now
|
||||
Perun.SendToPerun(0,nil)
|
||||
end
|
||||
end
|
||||
|
||||
Perun.onMissionLoadEnd = function()
|
||||
Perun.UpdateMission()
|
||||
Perun.UpdateJson()
|
||||
end
|
||||
Perun.onPlayerStart = function (id)
|
||||
net.send_chat_to(Perun.MOTD_L1, id);
|
||||
net.send_chat_to(Perun.MOTD_L2, id);
|
||||
end
|
||||
|
||||
Perun.onPlayerStart = function (id)
|
||||
net.send_chat(Perun.MOTD_L1, id);
|
||||
net.send_chat(Perun.MOTD_L2, id);
|
||||
end
|
||||
|
||||
Perun.onPlayerTrySendChat = function (playerID, msg, all)
|
||||
Perun.onPlayerTrySendChat = function (playerID, msg, all)
|
||||
if msg~=Perun.MOTD_L1 and msg~=Perun.MOTD_L2 then
|
||||
Perun.LogChat(playerID,msg,all)
|
||||
return msg
|
||||
end
|
||||
|
||||
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4)
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
|
||||
if eventName == "friendly_fire" then
|
||||
--"friendly_fire", playerID, weaponName, victimPlayerID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name").." killed " .. net.get_player_info(arg3, "name") .. " using " .. arg2);
|
||||
if arg2 == "" then
|
||||
arg2 = "Cannon"
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName,Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name").." killed friendy " .. net.get_player_info(arg3, "name") .. " using " .. arg2,nil,nil);
|
||||
|
||||
elseif eventName == "mission_end" then
|
||||
--"mission_end", winner, msg
|
||||
Perun.LogEvent(eventName,"Mission end, winner " .. arg1 .. " message: " .. arg2);
|
||||
Perun.LogEvent(eventName,"Mission finished, winner " .. arg1 .. " message: " .. arg2,nil,nil);
|
||||
|
||||
elseif eventName == "kill" then
|
||||
--"kill", killerPlayerID, killerUnitType, killerSide, victimPlayerID, victimUnitType, victimSide, weaponName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name").. " in " .. arg3 .. " " .. arg2 .. " killed " .. net.get_player_info(arg4, "name") .. " in " .. arg6 .. " " .. arg5 .. " using " .. arg7);
|
||||
_tempX=""
|
||||
if net.get_player_info(arg4, "name") ~= nil then
|
||||
_tempX = " player ".. net.get_player_info(arg4, "name") .." ";
|
||||
|
||||
Perun.LogStats(arg4);
|
||||
else
|
||||
_tempX = " AI ";
|
||||
end
|
||||
|
||||
if net.get_player_info(arg1, "name") ~= nil then
|
||||
_temp2 = " player ".. net.get_player_info(arg1, "name") .." ";
|
||||
|
||||
_temp_event_type=""
|
||||
if arg3 ~= arg6 then
|
||||
if Perun.GetCategory(arg5) == "Planes" then
|
||||
_temp_event_type="kill_Planes"
|
||||
elseif Perun.GetCategory(arg5) == "Helicopters" then
|
||||
_temp_event_type="kill_Helicopters"
|
||||
elseif Perun.GetCategory(arg5) == "Ships" then
|
||||
_temp_event_type="kill_Ships"
|
||||
elseif Perun.GetCategory(arg5) == "Air Defence" then
|
||||
_temp_event_type="kill_Air_Defence"
|
||||
elseif Perun.GetCategory(arg5) == "Unarmed" then
|
||||
_temp_event_type="kill_Unarmed"
|
||||
elseif Perun.GetCategory(arg5) == "Armor" then
|
||||
_temp_event_type="kill_Armor"
|
||||
elseif Perun.GetCategory(arg5) == "Infantry" then
|
||||
_temp_event_type="kill_Infantry"
|
||||
elseif Perun.GetCategory(arg5) == "Fortification" then
|
||||
_temp_event_type="kill_Fortification"
|
||||
else
|
||||
_temp_event_type="kill_Other"
|
||||
end
|
||||
if net.get_player_info(arg4, "name") ~= nil and arg3 ~= arg6 then
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,arg2)
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,"kill_PvP",DCS.getUnitType(arg2));
|
||||
end
|
||||
end
|
||||
else
|
||||
_temp_event_type="friendly_fire"
|
||||
end
|
||||
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,arg2)
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,_temp_event_type,DCS.getUnitType(arg2));
|
||||
end
|
||||
|
||||
else
|
||||
_temp2 = " AI ";
|
||||
end
|
||||
|
||||
if arg7 == "" then
|
||||
arg7 = "Cannon"
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName,Perun.SideID2Name(arg3) .. _temp2 .. " in " .. arg2 .. " killed " .. Perun.SideID2Name(arg6) .. _tempX .. " in " .. arg5 .. " using " .. arg7 .. " [".. Perun.GetCategory(arg5).."]",arg7,Perun.GetCategory(arg5));
|
||||
elseif eventName == "self_kill" then
|
||||
--"self_kill", playerID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " killed himself");
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " killed himself",nil,nil);
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "change_slot" then
|
||||
--"change_slot", playerID, slotID, prevSide
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " changed slot to " .. arg2);
|
||||
|
||||
if DCS.getUnitType(arg2) ~= nil and DCS.getUnitType(arg2) ~= "" then
|
||||
_temp = DCS.getUnitType(arg2);
|
||||
else
|
||||
_temp = "SPECTATOR";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName,Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " changed slot to " .. _temp,nil,nil);
|
||||
Perun.LogStatsCount(arg1,"init",_temp)
|
||||
|
||||
elseif eventName == "connect" then
|
||||
--"connect", playerID, name
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " connected");
|
||||
Perun.LogLogin(arg1);
|
||||
Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected",nil,nil);
|
||||
|
||||
elseif eventName == "disconnect" then
|
||||
--"disconnect", playerID, name, playerSide, reason_code
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " disconnected");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name(arg3) .. " player " ..net.get_player_info(arg1, "name") .. " disconnected",nil,nil);
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
elseif eventName == "crash" then
|
||||
--"crash", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " crashed");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " crashed in " .. DCS.getUnitType(arg2),nil,nil);
|
||||
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,DCS.getUnitType(arg2))
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,"crash",DCS.getUnitType(arg2));
|
||||
end
|
||||
elseif eventName == "eject" then
|
||||
--"eject", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " ejected");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " ejected " .. DCS.getUnitType(arg2),nil,nil);
|
||||
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,DCS.getUnitType(arg2))
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,"eject",DCS.getUnitType(arg2));
|
||||
end
|
||||
|
||||
elseif eventName == "takeoff" then
|
||||
--"takeoff", playerID, unit_missionID, airdromeName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " took off from " .. arg3);
|
||||
if arg3 ~= "" then
|
||||
_temp = " from " .. arg3;
|
||||
else
|
||||
_temp = "";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " took off in ".. DCS.getUnitType(arg2) .. _temp,arg3,nil);
|
||||
|
||||
_type = ""
|
||||
if string.find(arg3, "FARP",1,true) then
|
||||
_type="tookoff_FARP"
|
||||
elseif string.find(arg3, "CVN-74 John C. Stennis",1,true) or string.find(arg3, "LHA-1 Tarawa",1,true) then
|
||||
_type="tookoff_SHIP"
|
||||
elseif arg3 ~= "" then
|
||||
_type="tookoff_AIRFIELD"
|
||||
else
|
||||
_type="tookoff_OTHER"
|
||||
end
|
||||
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,DCS.getUnitType(arg2))
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,_type,DCS.getUnitType(arg2))
|
||||
end
|
||||
|
||||
elseif eventName == "landing" then
|
||||
--"landing", playerID, unit_missionID, airdromeName
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " landed at " .. arg3);
|
||||
if arg3 ~= "" then
|
||||
_temp = " at " .. arg3;
|
||||
else
|
||||
_temp ="";
|
||||
end
|
||||
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " landed in " .. DCS.getUnitType(arg2).. _temp,arg3,nil);
|
||||
|
||||
_type = ""
|
||||
if string.find(arg3, "FARP",1,true) then
|
||||
_type = "landing_FARP"
|
||||
elseif string.find(arg3, "CVN-74 John C. Stennis",1,true) or string.find(arg3, "LHA-1 Tarawa",1,true) then
|
||||
_type = "landing_SHIP"
|
||||
elseif arg3 ~= "" then
|
||||
_type = "landing_AIRFIELD"
|
||||
else
|
||||
_type = "landing_OTHER"
|
||||
end
|
||||
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,DCS.getUnitType(arg2))
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,_type,DCS.getUnitType(arg2))
|
||||
end
|
||||
|
||||
elseif eventName == "pilot_death" then
|
||||
--"pilot_death", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName,net.get_player_info(arg1, "name") .. " died");
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " in " .. DCS.getUnitType(arg2) .. " died",nil,nil);
|
||||
|
||||
pilots_accounted = Perun.CheckMulticrew(arg1,DCS.getUnitType(arg2))
|
||||
for _, pilotID in ipairs(pilots_accounted) do
|
||||
Perun.LogStatsCount(pilotID,"pilot_death",DCS.getUnitType(arg2))
|
||||
end
|
||||
|
||||
else
|
||||
Perun.LogEvent(eventName,"Unknown event type");
|
||||
Perun.LogEvent(eventName,"Unknown event type",nil,nil);
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- Finalize and set callbacks
|
||||
-- ########### Finalize and set callbacks ###########
|
||||
if Perun.IsServer then
|
||||
DCS.setUserCallbacks(Perun)
|
||||
net.log("Loaded - Perun - VladMordock - " .. Perun.Version )
|
||||
net.log("Perun by VladMordock was loaded: " .. Perun.Version )
|
||||
Perun.ConnectToPerun()
|
||||
end
|
||||
|
||||
1
01_DCS/Json/perun_status_data.json
Normal file
@@ -0,0 +1 @@
|
||||
[]
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.421
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29306.81
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perun_v1", "Perun_v1\Perun_v1.csproj", "{5A710507-92E9-4664-9B91-918B8B82F107}"
|
||||
EndProject
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="MYSQL_Port" serializeAs="String">
|
||||
<value />
|
||||
<value>3306</value>
|
||||
</setting>
|
||||
</Perun_v1.Properties.Settings>
|
||||
<Perun.Properties.Settings>
|
||||
6
02_Windows_App/Perun_v1/00_Config/packages.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Google.Protobuf" version="3.5.1" targetFramework="net461" />
|
||||
<package id="MySql.Data" version="8.0.15" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net461" />
|
||||
</packages>
|
||||
209
02_Windows_App/Perun_v1/01_Classes/DatabaseController.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
// This class handles MySQL communication
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
public class DatabaseController
|
||||
{
|
||||
public string DatabaseConnectionString; // MySQL connection string
|
||||
public MySqlConnection DatabaseConnection;
|
||||
public bool DatabaseStatus;
|
||||
|
||||
public int SendToMySql(string RawTCPFrame, bool CheckConnection = false)
|
||||
{
|
||||
// Main function to send data to mysql
|
||||
if (CheckConnection)
|
||||
{
|
||||
RawTCPFrame = "{\"type\": \"-1\"}";
|
||||
}
|
||||
dynamic TCPFrame = JsonConvert.DeserializeObject(RawTCPFrame); // Deserialize raw data
|
||||
string TCPFrameType = TCPFrame.type;
|
||||
string TCPFrameTimestamp = TCPFrame.timestamp;
|
||||
string TCPFrameInstance = TCPFrame.instance;
|
||||
string TCPFramePayload;
|
||||
string TCPFramePayload_Perun;
|
||||
string SQLQueryTxt;
|
||||
int ReturnValue = 1;
|
||||
|
||||
// Some frames may come without timestamp, use database currrent timestampe then
|
||||
if (TCPFrameTimestamp != null)
|
||||
{
|
||||
TCPFrameTimestamp = "'" + TCPFrameTimestamp + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
TCPFrameTimestamp = "CURRENT_TIMESTAMP()";
|
||||
}
|
||||
|
||||
// Modify specific types
|
||||
if (TCPFrameType == "1")
|
||||
{
|
||||
TCPFrame.payload["v_win"] = "v" + Globals.VersionPerun; // Inject app version information
|
||||
|
||||
// Pull DCS hook version
|
||||
Globals.VersionDCSHook = TCPFrame.payload.v_dcs_hook;
|
||||
}
|
||||
|
||||
// Specific SQL per each frame type
|
||||
if (TCPFrameType == "50")
|
||||
{
|
||||
// Add entry to chat log
|
||||
SQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + TCPFrame.payload.ucid + "' );";
|
||||
SQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated` = " + TCPFrameTimestamp + ",`pe_DataPlayers_lastname`='" + TCPFrame.payload.player + "' WHERE `pe_DataPlayers_ucid`='" + TCPFrame.payload.ucid + "' ;";
|
||||
SQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + TCPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");";
|
||||
SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + " ;";
|
||||
SQLQueryTxt += "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,'" + TCPFrame.payload.datetime + "', (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.ucid + "'), '" + TCPFrame.payload.msg + "', '" + TCPFrame.payload.all + "',(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.missionhash + "'));";
|
||||
}
|
||||
else if (TCPFrameType == "51")
|
||||
{
|
||||
// Add entry to event log
|
||||
SQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.log_missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");";
|
||||
SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ";";
|
||||
SQLQueryTxt += "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 ('" + TCPFrame.payload.log_arg_1 + "','" + TCPFrame.payload.log_arg_2 + "', NULL, '" + TCPFrame.payload.log_datetime + "', '" + TCPFrame.payload.log_type + "', '" + TCPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.log_missionhash + "'));";
|
||||
}
|
||||
else if (TCPFrameType == "52")
|
||||
{
|
||||
// Update user stats
|
||||
TCPFramePayload = JsonConvert.SerializeObject(TCPFrame.payload.stat_data_dcs); // Deserialize payload
|
||||
TCPFramePayload_Perun = JsonConvert.SerializeObject(TCPFrame.payload.stat_data_perun); // Deserialize payload
|
||||
|
||||
SQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + TCPFrame.payload.stat_missionhash + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + ");";
|
||||
SQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + TCPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + TCPFrameInstance + " ;";
|
||||
SQLQueryTxt += "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.stat_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "');";
|
||||
SQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated`=" + TCPFrameTimestamp + " WHERE `pe_DataPlayers_ucid`='" + TCPFrame.payload.stat_ucid + "';";
|
||||
SQLQueryTxt += "INSERT INTO `pe_DataTypes` (`pe_DataTypes_name`) SELECT '" + TCPFrame.payload.stat_data_type + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "');";
|
||||
SQLQueryTxt += "INSERT INTO `pe_LogStats` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`,`pe_LogStats_typeid`) SELECT (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "'), (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "') FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_LogStats` WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`= (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "'));";
|
||||
SQLQueryTxt += "UPDATE `pe_LogStats` SET `ps_kills_fortification`=" + TCPFrame.payload.stat_data_perun.ps_kills_fortification + ",`ps_other_landings`=" + TCPFrame.payload.stat_data_perun.ps_other_landings + ",`ps_other_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_other_takeoffs + ",`ps_pvp`=" + TCPFrame.payload.stat_data_perun.ps_pvp + ",`ps_deaths`=" + TCPFrame.payload.stat_data_perun.ps_deaths + ",`ps_ejections`=" + TCPFrame.payload.stat_data_perun.ps_ejections + ",`ps_crashes`=" + TCPFrame.payload.stat_data_perun.ps_crashes + ",`ps_teamkills`=" + TCPFrame.payload.stat_data_perun.ps_teamkills + ",`ps_kills_planes`=" + TCPFrame.payload.stat_data_perun.ps_kills_planes + ",`ps_kills_helicopters`=" + TCPFrame.payload.stat_data_perun.ps_kills_helicopters + ",`ps_kills_air_defense`=" + TCPFrame.payload.stat_data_perun.ps_kills_air_defense + ",`ps_kills_armor`=" + TCPFrame.payload.stat_data_perun.ps_kills_armor + ",`ps_kills_unarmed`=" + TCPFrame.payload.stat_data_perun.ps_kills_unarmed + ",`ps_kills_infantry`=" + TCPFrame.payload.stat_data_perun.ps_kills_infantry + ",`ps_kills_ships`=" + TCPFrame.payload.stat_data_perun.ps_kills_ships + ",`ps_kills_other`=" + TCPFrame.payload.stat_data_perun.ps_kills_other + ",`ps_airfield_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_airfield_takeoffs + ",`ps_airfield_landings`=" + TCPFrame.payload.stat_data_perun.ps_airfield_landings + ",`ps_ship_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_ship_takeoffs + ",`ps_ship_landings`=" + TCPFrame.payload.stat_data_perun.ps_ship_landings + ",`ps_farp_takeoffs`=" + TCPFrame.payload.stat_data_perun.ps_farp_takeoffs + ",`ps_farp_landings`=" + TCPFrame.payload.stat_data_perun.ps_farp_landings + ", `pe_LogStats_datetime`='" + TCPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + TCPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + TCPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`=(SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + TCPFrame.payload.stat_data_type + "');";
|
||||
}
|
||||
else if (TCPFrameType == "53")
|
||||
{
|
||||
// User logged in to DCS server
|
||||
|
||||
SQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + TCPFrame.payload.login_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where pe_DataPlayers_ucid='" + TCPFrame.payload.login_ucid + "');";
|
||||
SQLQueryTxt += "UPDATE `pe_DataPlayers` SET pe_DataPlayers_lastip='" + TCPFrame.payload.login_ipaddr + "', pe_DataPlayers_lastname='" + TCPFrame.payload.login_name + "',pe_DataPlayers_updated='" + TCPFrame.payload.login_datetime + "' WHERE `pe_DataPlayers_ucid`= '" + TCPFrame.payload.login_ucid + "';";
|
||||
SQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`,`pe_LogLogins_instance`) VALUES ('" + TCPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + TCPFrame.payload.login_ucid + "'), '" + TCPFrame.payload.login_name + "', '" + TCPFrame.payload.login_ipaddr + "','" + TCPFrameInstance + "');";
|
||||
}
|
||||
else if (TCPFrameType == "-1")
|
||||
{
|
||||
// Keep alive message
|
||||
SQLQueryTxt = "SELECT `pe_Config_payload` FROM `pe_Config` WHERE `pe_Config_id` = 1;";
|
||||
}
|
||||
else
|
||||
{
|
||||
// General definition used for 1-10 type packets
|
||||
TCPFramePayload = JsonConvert.SerializeObject(TCPFrame.payload); // Deserialize payload
|
||||
|
||||
SQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`,`pe_dataraw_instance`) SELECT '" + TCPFrameType + "','" + TCPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE `pe_dataraw_type` = '" + TCPFrameType + "' AND `pe_dataraw_instance` = " + TCPFrameInstance + ");";
|
||||
SQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = JSON_QUOTE('" + TCPFramePayload + "'), `pe_dataraw_updated`=" + TCPFrameTimestamp + " WHERE `pe_dataraw_type`=" + TCPFrameType + " AND `pe_dataraw_instance` = " + TCPFrameInstance + ";";
|
||||
}
|
||||
|
||||
// Connect to mysql and execute sql
|
||||
try
|
||||
{
|
||||
DatabaseConnection = new MySqlConnection(DatabaseConnectionString);
|
||||
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Sending data to MySQL - Begin");
|
||||
DatabaseConnection.Open();
|
||||
DatabaseStatus = true;
|
||||
MySqlCommand DatabaseCommand = new MySqlCommand(SQLQueryTxt, DatabaseConnection);
|
||||
MySqlDataReader DatabaseReader = DatabaseCommand.ExecuteReader();
|
||||
|
||||
if (DatabaseReader.HasRows)
|
||||
{
|
||||
while (DatabaseReader.Read())
|
||||
{
|
||||
if (TCPFrameType == "-1")
|
||||
{
|
||||
Globals.VersionDatabase= DatabaseReader.GetString(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
DatabaseReader.Close();
|
||||
|
||||
switch (Int32.Parse(TCPFrameType))
|
||||
{
|
||||
case 1:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Connected players: " + TCPFrame.payload["c_players"], 1,0,"1");
|
||||
break;
|
||||
case 2:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Mission: \"" + TCPFrame.payload["mission"]["name"]+"\""+ ", time:" + TCPFrame.payload["mission"]["modeltime"], 1, 0, "2");
|
||||
break;
|
||||
case 3:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Slots data updated", 1, 0, "3");
|
||||
break;
|
||||
case 50:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Player's \""+ TCPFrame.payload.player + "\" chat message saved", 1, 0, "50");
|
||||
break;
|
||||
case 51:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Game event: \""+ TCPFrame.payload.log_content +"\"", 1, 0, "51");
|
||||
break;
|
||||
case 52:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Player's \""+ TCPFrame.payload.stat_name + "\" stats saved", 1, 0, "52");
|
||||
break;
|
||||
case 53:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Player \""+ TCPFrame.payload.login_name + "\" logged in", 1, 0, "53");
|
||||
break;
|
||||
case 100:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "SRS data send", 1,0,"100");
|
||||
break;
|
||||
case 101:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "LotATC data send", 1,0,"101");
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
default:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Data send", 1,0, TCPFrameType);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (ArgumentException a_ex)
|
||||
{
|
||||
// General exception found
|
||||
Console.WriteLine(a_ex.ToString());
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error: " + a_ex.Message,1,1, TCPFrameType);
|
||||
Globals.ErrorsGame++;
|
||||
DatabaseStatus = false;
|
||||
ReturnValue = 0;
|
||||
}
|
||||
catch (MySqlException m_ex)
|
||||
{
|
||||
// MySQL exception found
|
||||
switch (m_ex.Number)
|
||||
{
|
||||
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - unable to connect, error: " + m_ex.Message,1,1, TCPFrameType);
|
||||
break;
|
||||
case 0: // Access denied (Check DB name,username,password)
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - access denied, error: " + m_ex.Message,1,1, TCPFrameType);
|
||||
break;
|
||||
default:
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error id: " + m_ex.Number,1,1, TCPFrameType);
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - query: " + SQLQueryTxt, 1, 1, TCPFrameType);
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - error: " + m_ex.Message,1,1, TCPFrameType);
|
||||
break;
|
||||
}
|
||||
Globals.ErrorsGame++;
|
||||
DatabaseStatus = false;
|
||||
ReturnValue = 0;
|
||||
}
|
||||
DatabaseConnection.Close();
|
||||
Console.WriteLine("Sending data to MySQL - Done");
|
||||
}
|
||||
catch (ArgumentException x_ex)
|
||||
{
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR MySQL - unable to connect, error: " + x_ex.Message,1,1, TCPFrameType);
|
||||
ReturnValue = 0;
|
||||
Globals.ErrorsGame++;
|
||||
}
|
||||
|
||||
return ReturnValue;
|
||||
}
|
||||
}
|
||||
26
02_Windows_App/Perun_v1/01_Classes/Globals.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// This class gathers all global variable
|
||||
|
||||
internal class Globals
|
||||
{
|
||||
public static string[] AppLogHistory = new string[10]; // Log history for GUI
|
||||
public static bool AppUpdateGUI = true; // Flag if log control requires update
|
||||
public static string AppTitle = ""; // Helper to update title
|
||||
public static int AppInstanceID = 0; // Kepp the instance ID
|
||||
public static bool AppForceIconReload = true; // Force main window icons reload
|
||||
|
||||
public static bool StatusDatabase = false; // Historic db connection status
|
||||
public static bool StatusSRS = false; // Historic srs connection status
|
||||
public static bool StatusLotATC = false; // Historic lotatc connection status
|
||||
public static bool StatusHistoryConnection = false; // Historic tcp connection status
|
||||
public static bool StatusConnection = false; // Flag if is TCP connectionstill alive
|
||||
public static int ErrorsDatabase = 0; // MySQL - Error counter
|
||||
public static int ErrorsGame = 0; // TCP connection - Error counter
|
||||
public static int ErrorsHistoryGame = 0; // TCP connection - historic value of Error counter
|
||||
public static int ErrorsSRS = 0; // DCS SRS - error counter
|
||||
public static int ErrorsLotATC = 0; // LotATC - error counter
|
||||
|
||||
public static string VersionDCSHook = ""; // Version - DCS hook
|
||||
public static string VersionDatabase = ""; // Version - Database
|
||||
public static string VersionPerun = "DEBUG"; // Version - Perun
|
||||
}
|
||||
|
||||
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 LogStreamWriter;
|
||||
FileStream LogFileStream = null;
|
||||
DirectoryInfo LogDirectoryInfo = 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);
|
||||
LogDirectoryInfo = new DirectoryInfo(LogFileInfo.DirectoryName);
|
||||
if (!LogDirectoryInfo.Exists) LogDirectoryInfo.Create();
|
||||
if (!LogFileInfo.Exists)
|
||||
{
|
||||
LogFileStream = LogFileInfo.Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
LogFileStream = new FileStream(LogFilePath, FileMode.Append);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
LogStreamWriter = new StreamWriter(LogFileStream);
|
||||
LogStreamWriter.WriteLine(strLog);
|
||||
LogStreamWriter.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
94
02_Windows_App/Perun_v1/01_Classes/PerunHelper.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
// This class gathers all helper functions
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
internal class PerunHelper
|
||||
{
|
||||
public static void AddLog(ref string[] arrLogHistory, string strEntryToAdd, int intDirection = 0, int intMarker = 0, string strType = " ", bool bSkipGui = false)
|
||||
{
|
||||
// Declare values
|
||||
string LogDirection;
|
||||
string LogMarker;
|
||||
// Set direction marker
|
||||
switch (intDirection)
|
||||
{
|
||||
case 1:
|
||||
LogDirection = ">";
|
||||
break;
|
||||
case 2:
|
||||
LogDirection = "<";
|
||||
break;
|
||||
case 3:
|
||||
LogDirection = "^";
|
||||
break;
|
||||
default:
|
||||
LogDirection = " ";
|
||||
break;
|
||||
}
|
||||
|
||||
// Set marker for user flags (markers)
|
||||
LogMarker = (intMarker>0) ? "X" : " ";
|
||||
|
||||
// Set frame type
|
||||
strType=strType.PadLeft(3, ' ');
|
||||
|
||||
if (!bSkipGui)
|
||||
{
|
||||
// Rotate log history
|
||||
for (int i = 0; i < arrLogHistory.Length - 1; i++)
|
||||
{
|
||||
arrLogHistory[i] = arrLogHistory[i + 1]; // Shift one down
|
||||
}
|
||||
|
||||
// Add new entry
|
||||
arrLogHistory[arrLogHistory.Length - 1] = DateTime.Now.ToString("HH:mm:ss") + " " + LogDirection + " " + strEntryToAdd; // Add entry at the last position
|
||||
|
||||
// Update control at my window
|
||||
Globals.AppUpdateGUI = true;
|
||||
}
|
||||
// Add the entry to log file
|
||||
LogController.WriteLog(DateTime.Now.ToString("yyyy-dd-MM ") + " " + DateTime.Now.ToString("HH:mm:ss") + " | Instance: "+ Globals.AppInstanceID + " | " + LogMarker + " | "+ LogDirection + " | "+ strType + " | " + strEntryToAdd);
|
||||
}
|
||||
|
||||
public static string GetAppVersion(string strBeginning)
|
||||
{
|
||||
// Gets build version
|
||||
Globals.VersionPerun = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
return strBeginning + "v" + Globals.VersionPerun;
|
||||
}
|
||||
|
||||
public static int CheckVersions()
|
||||
{
|
||||
// Checks the versions of APP, DCS Hook and MySQL database
|
||||
Match match = Regex.Match(Globals.VersionPerun, @"^\d+.\d+.\d+", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
string VersionApp = "v" + match.Groups[0].Value;
|
||||
|
||||
int ReturnValue = 1;
|
||||
if (!String.IsNullOrEmpty(Globals.VersionDatabase))
|
||||
{
|
||||
// Check database
|
||||
if(VersionApp != Globals.VersionDatabase)
|
||||
{
|
||||
// Incorrect database version
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR Incorrect database revision : "+ Globals.VersionDatabase, 1, 1, "?");
|
||||
Globals.ErrorsDatabase++;
|
||||
ReturnValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(Globals.VersionDCSHook))
|
||||
{
|
||||
// Check database
|
||||
if (VersionApp != Globals.VersionDCSHook)
|
||||
{
|
||||
// Incorrect dcs script version
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "ERROR Incorrect DCS hook revision : " + Globals.VersionDCSHook, 2, 1, "?");
|
||||
Globals.ErrorsGame++;
|
||||
ReturnValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnValue;
|
||||
}
|
||||
}
|
||||
@@ -3,30 +3,26 @@ using System.Windows.Forms;
|
||||
|
||||
namespace Perun_v1
|
||||
{
|
||||
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Główny punkt wejścia dla aplikacji.
|
||||
/// Main entry point to app
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
|
||||
[STAThread]
|
||||
|
||||
static void Main()
|
||||
{
|
||||
// Main entry point to the app
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
|
||||
|
||||
void Application_ApplicationExit(object sender, EventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.Save();
|
||||
Properties.Settings.Default.Save(); // We will save settings on exit
|
||||
}
|
||||
|
||||
Application.Run(new form_Main());
|
||||
Application.Run(new form_Main()); // Run main form
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
206
02_Windows_App/Perun_v1/01_Classes/TCPController.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
// This class handles TCP communication
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
|
||||
public class TCPController
|
||||
{
|
||||
// Main class for TCP listener
|
||||
public int intListenPort; // Port to connect to
|
||||
public bool bCloseConnection; // Helper to exit main loop without killing thread
|
||||
public string[] arrGUILogHistory; // Log history for GUI
|
||||
public string[] arrMySQLSendBuffer; // MySQL send buffer
|
||||
public Thread thrTCPListener; // Seperate thread for TCP
|
||||
|
||||
public void Create(int par_intListenPort, ref string[] par_arrLogHistory, ref string[] par_arrSendBuffer)
|
||||
{
|
||||
// Create class and map creation arguments to class
|
||||
intListenPort = par_intListenPort;
|
||||
arrGUILogHistory = par_arrLogHistory;
|
||||
arrMySQLSendBuffer = par_arrSendBuffer;
|
||||
bCloseConnection = false;
|
||||
}
|
||||
|
||||
public void StopListen()
|
||||
{
|
||||
// Stop listening
|
||||
bCloseConnection = true;
|
||||
|
||||
// Clear send buffer
|
||||
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||
{
|
||||
arrMySQLSendBuffer[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartListen()
|
||||
{
|
||||
// Start listening
|
||||
NetworkStream nsReadStream = null;
|
||||
TcpClient tcpClient = null;
|
||||
bool bTCPConnectionOnline = false;
|
||||
string strReceiveBuffer;
|
||||
|
||||
// Main loop - do until diconnect button is clicked
|
||||
while (!bCloseConnection)
|
||||
{
|
||||
Console.WriteLine("TCP Listen start");
|
||||
TcpListener tcpServer = new TcpListener(IPAddress.Any, intListenPort); ; // Create listener object
|
||||
|
||||
try
|
||||
{
|
||||
// Start listening to TCP
|
||||
string strReceivedData;
|
||||
|
||||
// Start the main loop
|
||||
tcpServer.Start();
|
||||
|
||||
// While user do not clicked Disconnect button
|
||||
while (!bCloseConnection)
|
||||
{
|
||||
// Start listening
|
||||
Console.WriteLine("TCP: Waiting for connection");
|
||||
Globals.StatusConnection = false;
|
||||
|
||||
// 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
|
||||
nsReadStream = tcpClient.GetStream(); //networkstream is used to send/receive messages
|
||||
nsReadStream.ReadTimeout = 10000;
|
||||
tcpClient.ReceiveTimeout = 10000;
|
||||
|
||||
|
||||
while (tcpClient.Connected && !bCloseConnection && bTCPConnectionOnline) //while the client is connected, we look for incoming messages
|
||||
{
|
||||
StringBuilder CompleteMessage = new StringBuilder();
|
||||
Globals.StatusConnection = true;
|
||||
|
||||
if (nsReadStream.CanRead)
|
||||
{
|
||||
Console.WriteLine("TCP: Can read");
|
||||
byte[] ReadBuffer = new byte[1024];
|
||||
CompleteMessage = new StringBuilder();
|
||||
int numberOfBytesRead = 0;
|
||||
|
||||
// Incoming message may be larger than the buffer size.
|
||||
do
|
||||
{
|
||||
Console.WriteLine("TCP: Read");
|
||||
numberOfBytesRead = nsReadStream.Read(ReadBuffer, 0, ReadBuffer.Length);
|
||||
CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead));
|
||||
if (numberOfBytesRead == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (nsReadStream.DataAvailable && nsReadStream.CanRead && tcpClient.Connected);
|
||||
}
|
||||
strReceivedData = CompleteMessage.ToString();
|
||||
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
||||
|
||||
string pattern = @"(\<SOT\>)+?.*?(\<EOT\>)+?";
|
||||
|
||||
foreach (Match match in Regex.Matches(strReceivedData, pattern))
|
||||
{
|
||||
strReceiveBuffer = match.Value;
|
||||
|
||||
Console.WriteLine("Found '{0}' at position {1} end {2}",match.Value, match.Index,match.Length);
|
||||
Console.WriteLine("Prepared {0}", strReceiveBuffer.Substring(5, match.Length-10));
|
||||
|
||||
strReceivedData = strReceiveBuffer.Substring(5, match.Length - 10);
|
||||
try
|
||||
{
|
||||
if (strReceivedData != "")
|
||||
{
|
||||
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
||||
string strRawTCPFrameType = dynamicRawTCPFrame.type;
|
||||
|
||||
// Check if this is NOT keep alive
|
||||
if (Int32.Parse(strRawTCPFrameType) != 0)
|
||||
{
|
||||
// Add to mySQL send buffer (find first empty slot)
|
||||
PerunHelper.AddLog(ref arrGUILogHistory, "Packet received" , 2,0, strRawTCPFrameType,true);
|
||||
bool AddedDataToBuffer = false;
|
||||
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||
{
|
||||
if (arrMySQLSendBuffer[i] == null)
|
||||
{
|
||||
arrMySQLSendBuffer[i] = strReceivedData;
|
||||
AddedDataToBuffer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!AddedDataToBuffer)
|
||||
{
|
||||
PerunHelper.AddLog(ref arrGUILogHistory, "ERROR package was dropped", 1, 1, strRawTCPFrameType);
|
||||
}
|
||||
} else
|
||||
{
|
||||
// Keep alive
|
||||
PerunHelper.AddLog(ref arrGUILogHistory, "Keep-alive received", 2,0,"0",true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bTCPConnectionOnline = false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Globals.ErrorsGame++;
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.AddLog(ref arrGUILogHistory, "ERROR while message parsing , error: " + e.Message,2,1,"?");
|
||||
bTCPConnectionOnline = false;
|
||||
}
|
||||
|
||||
// Send empty byte to check if connection is still alive
|
||||
try
|
||||
{
|
||||
tcpClient.Client.Send(new byte[] { 0 }, 1, 0);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.AddLog(ref arrGUILogHistory, "TCP ERROR cannot check connection, error: " + e.Message,2,1,"?");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
tcpServer.Stop();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Globals.ErrorsGame++;
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.AddLog(ref arrGUILogHistory, "TCP error - connection closed or port in use, error: " + e.Message,1,1,"?");
|
||||
bTCPConnectionOnline = false;
|
||||
}
|
||||
|
||||
// Clean up and prepare for next connection
|
||||
if (!(nsReadStream is null))
|
||||
{
|
||||
nsReadStream.Flush();
|
||||
nsReadStream.Close();
|
||||
}
|
||||
if (!(tcpClient is null))
|
||||
{
|
||||
tcpClient.Close();
|
||||
}
|
||||
if (!(tcpServer is null))
|
||||
{
|
||||
tcpServer.Stop();
|
||||
}
|
||||
Console.WriteLine("TCP listen stop");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@
|
||||
this.con_Button_Listen_ON = 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.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.label6 = new System.Windows.Forms.Label();
|
||||
this.con_txt_mysql_port = new System.Windows.Forms.TextBox();
|
||||
@@ -57,10 +57,35 @@
|
||||
this.trayIconMain = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.openFileDialog_SRS = 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_MySQL = new System.Windows.Forms.Timer(this.components);
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.con_txt_dcs_instance = new System.Windows.Forms.MaskedTextBox();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
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_Button_Reset_Flags = new System.Windows.Forms.Button();
|
||||
this.label13 = new System.Windows.Forms.Label();
|
||||
this.label14 = new System.Windows.Forms.Label();
|
||||
this.con_img_logo = 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_dcs = new System.Windows.Forms.PictureBox();
|
||||
this.con_img_db = new System.Windows.Forms.PictureBox();
|
||||
this.con_Button_Add_Marker = new System.Windows.Forms.Button();
|
||||
this.con_GroupBox_1.SuspendLayout();
|
||||
this.con_GroupBox_2.SuspendLayout();
|
||||
this.con_GroupBox_3.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_logo)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_lotATC)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_srs)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_dcs)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_db)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// con_List_Received
|
||||
@@ -68,56 +93,47 @@
|
||||
this.con_List_Received.Enabled = false;
|
||||
this.con_List_Received.FormattingEnabled = true;
|
||||
this.con_List_Received.Items.AddRange(new object[] {
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading",
|
||||
"Loading"});
|
||||
this.con_List_Received.Location = new System.Drawing.Point(6, 19);
|
||||
"Not connected"});
|
||||
this.con_List_Received.Location = new System.Drawing.Point(11, 19);
|
||||
this.con_List_Received.Name = "con_List_Received";
|
||||
this.con_List_Received.Size = new System.Drawing.Size(307, 134);
|
||||
this.con_List_Received.TabIndex = 0;
|
||||
//
|
||||
// con_Button_Listen_ON
|
||||
//
|
||||
this.con_Button_Listen_ON.Location = new System.Drawing.Point(12, 434);
|
||||
this.con_Button_Listen_ON.Location = new System.Drawing.Point(12, 602);
|
||||
this.con_Button_Listen_ON.Name = "con_Button_Listen_ON";
|
||||
this.con_Button_Listen_ON.Size = new System.Drawing.Size(86, 39);
|
||||
this.con_Button_Listen_ON.TabIndex = 2;
|
||||
this.con_Button_Listen_ON.Text = "Connect";
|
||||
this.con_Button_Listen_ON.Text = "Start";
|
||||
this.con_Button_Listen_ON.UseVisualStyleBackColor = true;
|
||||
this.con_Button_Listen_ON.Click += new System.EventHandler(this.con_Button_Listen_ON_Click);
|
||||
//
|
||||
// con_Button_Listen_OFF
|
||||
//
|
||||
this.con_Button_Listen_OFF.Enabled = false;
|
||||
this.con_Button_Listen_OFF.Location = new System.Drawing.Point(104, 434);
|
||||
this.con_Button_Listen_OFF.Location = new System.Drawing.Point(104, 602);
|
||||
this.con_Button_Listen_OFF.Name = "con_Button_Listen_OFF";
|
||||
this.con_Button_Listen_OFF.Size = new System.Drawing.Size(86, 39);
|
||||
this.con_Button_Listen_OFF.TabIndex = 3;
|
||||
this.con_Button_Listen_OFF.Text = "Disconnect";
|
||||
this.con_Button_Listen_OFF.Text = "Stop";
|
||||
this.con_Button_Listen_OFF.UseVisualStyleBackColor = true;
|
||||
this.con_Button_Listen_OFF.Click += new System.EventHandler(this.con_Button_Listen_OFF_Click);
|
||||
//
|
||||
// con_GroupBox_1
|
||||
//
|
||||
this.con_GroupBox_1.Controls.Add(this.con_List_Received);
|
||||
this.con_GroupBox_1.Location = new System.Drawing.Point(12, 261);
|
||||
this.con_GroupBox_1.Location = new System.Drawing.Point(12, 434);
|
||||
this.con_GroupBox_1.Name = "con_GroupBox_1";
|
||||
this.con_GroupBox_1.Size = new System.Drawing.Size(324, 167);
|
||||
this.con_GroupBox_1.Size = new System.Drawing.Size(324, 162);
|
||||
this.con_GroupBox_1.TabIndex = 4;
|
||||
this.con_GroupBox_1.TabStop = false;
|
||||
this.con_GroupBox_1.Text = "UDP log";
|
||||
this.con_GroupBox_1.Text = "Data log";
|
||||
//
|
||||
// tim_1000ms
|
||||
// tim_GUI
|
||||
//
|
||||
this.tim_1000ms.Interval = 1000;
|
||||
this.tim_1000ms.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
this.tim_GUI.Interval = 200;
|
||||
this.tim_GUI.Tick += new System.EventHandler(this.Tim_GUI_Tick);
|
||||
//
|
||||
// con_GroupBox_2
|
||||
//
|
||||
@@ -131,7 +147,7 @@
|
||||
this.con_GroupBox_2.Controls.Add(this.con_txt_mysql_database);
|
||||
this.con_GroupBox_2.Controls.Add(this.con_txt_mysql_server);
|
||||
this.con_GroupBox_2.Controls.Add(this.con_txt_mysql_password);
|
||||
this.con_GroupBox_2.Location = new System.Drawing.Point(12, 27);
|
||||
this.con_GroupBox_2.Location = new System.Drawing.Point(14, 54);
|
||||
this.con_GroupBox_2.Name = "con_GroupBox_2";
|
||||
this.con_GroupBox_2.Size = new System.Drawing.Size(324, 154);
|
||||
this.con_GroupBox_2.TabIndex = 5;
|
||||
@@ -225,12 +241,12 @@
|
||||
this.con_GroupBox_3.Controls.Add(this.con_txt_3rd_srs);
|
||||
this.con_GroupBox_3.Controls.Add(this.con_check_3rd_lotatc);
|
||||
this.con_GroupBox_3.Controls.Add(this.con_check_3rd_srs);
|
||||
this.con_GroupBox_3.Location = new System.Drawing.Point(12, 187);
|
||||
this.con_GroupBox_3.Location = new System.Drawing.Point(14, 288);
|
||||
this.con_GroupBox_3.Name = "con_GroupBox_3";
|
||||
this.con_GroupBox_3.Size = new System.Drawing.Size(324, 68);
|
||||
this.con_GroupBox_3.TabIndex = 6;
|
||||
this.con_GroupBox_3.TabStop = false;
|
||||
this.con_GroupBox_3.Text = "3rd Party";
|
||||
this.con_GroupBox_3.Text = "3rd party";
|
||||
//
|
||||
// con_txt_3rd_lotatc
|
||||
//
|
||||
@@ -270,7 +286,7 @@
|
||||
//
|
||||
// con_Button_Quit
|
||||
//
|
||||
this.con_Button_Quit.Location = new System.Drawing.Point(250, 434);
|
||||
this.con_Button_Quit.Location = new System.Drawing.Point(251, 602);
|
||||
this.con_Button_Quit.Name = "con_Button_Quit";
|
||||
this.con_Button_Quit.Size = new System.Drawing.Size(86, 39);
|
||||
this.con_Button_Quit.TabIndex = 7;
|
||||
@@ -281,9 +297,10 @@
|
||||
// con_lab_github
|
||||
//
|
||||
this.con_lab_github.AutoSize = true;
|
||||
this.con_lab_github.Location = new System.Drawing.Point(141, 9);
|
||||
this.con_lab_github.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.con_lab_github.Location = new System.Drawing.Point(183, 39);
|
||||
this.con_lab_github.Name = "con_lab_github";
|
||||
this.con_lab_github.Size = new System.Drawing.Size(181, 13);
|
||||
this.con_lab_github.Size = new System.Drawing.Size(155, 12);
|
||||
this.con_lab_github.TabIndex = 8;
|
||||
this.con_lab_github.TabStop = true;
|
||||
this.con_lab_github.Text = "https://github.com/szporwolik/perun";
|
||||
@@ -292,9 +309,10 @@
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(15, 9);
|
||||
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label5.Location = new System.Drawing.Point(183, 27);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(120, 13);
|
||||
this.label5.Size = new System.Drawing.Size(102, 12);
|
||||
this.label5.TabIndex = 9;
|
||||
this.label5.Text = "Manual and bugtracker:";
|
||||
//
|
||||
@@ -316,20 +334,219 @@
|
||||
//
|
||||
this.openFileDialog_LotATC.FileName = "openFileDialog1";
|
||||
//
|
||||
// tim_10000ms
|
||||
// tim_3rdparties
|
||||
//
|
||||
this.tim_10000ms.Interval = 30000;
|
||||
this.tim_10000ms.Tick += new System.EventHandler(this.tim_10000ms_Tick);
|
||||
this.tim_3rdparties.Interval = 30000;
|
||||
this.tim_3rdparties.Tick += new System.EventHandler(this.tim_3rdparties_Tick);
|
||||
//
|
||||
// tim_MySQL
|
||||
//
|
||||
this.tim_MySQL.Tick += new System.EventHandler(this.Tim_MySQL_Tick);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.label8);
|
||||
this.groupBox1.Controls.Add(this.con_txt_dcs_instance);
|
||||
this.groupBox1.Controls.Add(this.label7);
|
||||
this.groupBox1.Controls.Add(this.con_txt_dcs_server_port);
|
||||
this.groupBox1.Location = new System.Drawing.Point(14, 214);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(324, 68);
|
||||
this.groupBox1.TabIndex = 7;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "DCS Connection";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(41, 45);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(62, 13);
|
||||
this.label8.TabIndex = 12;
|
||||
this.label8.Text = "Instance ID";
|
||||
//
|
||||
// con_txt_dcs_instance
|
||||
//
|
||||
this.con_txt_dcs_instance.Location = new System.Drawing.Point(106, 42);
|
||||
this.con_txt_dcs_instance.Name = "con_txt_dcs_instance";
|
||||
this.con_txt_dcs_instance.Size = new System.Drawing.Size(207, 20);
|
||||
this.con_txt_dcs_instance.TabIndex = 11;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(41, 19);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(59, 13);
|
||||
this.label7.TabIndex = 10;
|
||||
this.label7.Text = "Server port";
|
||||
//
|
||||
// con_txt_dcs_server_port
|
||||
//
|
||||
this.con_txt_dcs_server_port.Location = new System.Drawing.Point(106, 16);
|
||||
this.con_txt_dcs_server_port.Name = "con_txt_dcs_server_port";
|
||||
this.con_txt_dcs_server_port.Size = new System.Drawing.Size(207, 20);
|
||||
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, 396);
|
||||
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, 396);
|
||||
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, 396);
|
||||
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, 396);
|
||||
this.label12.Name = "label12";
|
||||
this.label12.Size = new System.Drawing.Size(49, 13);
|
||||
this.label12.TabIndex = 16;
|
||||
this.label12.Text = "LotATC";
|
||||
//
|
||||
// con_Button_Reset_Flags
|
||||
//
|
||||
this.con_Button_Reset_Flags.Enabled = false;
|
||||
this.con_Button_Reset_Flags.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.con_Button_Reset_Flags.Location = new System.Drawing.Point(224, 414);
|
||||
this.con_Button_Reset_Flags.Name = "con_Button_Reset_Flags";
|
||||
this.con_Button_Reset_Flags.Size = new System.Drawing.Size(114, 20);
|
||||
this.con_Button_Reset_Flags.TabIndex = 17;
|
||||
this.con_Button_Reset_Flags.Text = "Reset error flags";
|
||||
this.con_Button_Reset_Flags.UseVisualStyleBackColor = true;
|
||||
this.con_Button_Reset_Flags.Click += new System.EventHandler(this.con_Button_Reset_Flags_Click);
|
||||
//
|
||||
// label13
|
||||
//
|
||||
this.label13.AutoSize = true;
|
||||
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label13.Location = new System.Drawing.Point(63, 7);
|
||||
this.label13.Name = "label13";
|
||||
this.label13.Size = new System.Drawing.Size(74, 25);
|
||||
this.label13.TabIndex = 19;
|
||||
this.label13.Text = "Perun";
|
||||
//
|
||||
// label14
|
||||
//
|
||||
this.label14.AutoSize = true;
|
||||
this.label14.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label14.Location = new System.Drawing.Point(65, 32);
|
||||
this.label14.Name = "label14";
|
||||
this.label14.Size = new System.Drawing.Size(88, 13);
|
||||
this.label14.TabIndex = 20;
|
||||
this.label14.Text = "for DCS World";
|
||||
//
|
||||
// con_img_logo
|
||||
//
|
||||
this.con_img_logo.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.con_img_logo.Image = global::Perun_v1.Properties.Resources.perun_logo;
|
||||
this.con_img_logo.Location = new System.Drawing.Point(12, 7);
|
||||
this.con_img_logo.Name = "con_img_logo";
|
||||
this.con_img_logo.Size = new System.Drawing.Size(45, 41);
|
||||
this.con_img_logo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.con_img_logo.TabIndex = 18;
|
||||
this.con_img_logo.TabStop = false;
|
||||
//
|
||||
// con_img_lotATC
|
||||
//
|
||||
this.con_img_lotATC.Location = new System.Drawing.Point(292, 362);
|
||||
this.con_img_lotATC.Name = "con_img_lotATC";
|
||||
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.TabIndex = 13;
|
||||
this.con_img_lotATC.TabStop = false;
|
||||
//
|
||||
// con_img_srs
|
||||
//
|
||||
this.con_img_srs.Location = new System.Drawing.Point(207, 362);
|
||||
this.con_img_srs.Name = "con_img_srs";
|
||||
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.TabIndex = 12;
|
||||
this.con_img_srs.TabStop = false;
|
||||
//
|
||||
// con_img_dcs
|
||||
//
|
||||
this.con_img_dcs.Location = new System.Drawing.Point(122, 362);
|
||||
this.con_img_dcs.Name = "con_img_dcs";
|
||||
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.TabIndex = 11;
|
||||
this.con_img_dcs.TabStop = false;
|
||||
//
|
||||
// con_img_db
|
||||
//
|
||||
this.con_img_db.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.con_img_db.Location = new System.Drawing.Point(37, 362);
|
||||
this.con_img_db.Name = "con_img_db";
|
||||
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.TabIndex = 10;
|
||||
this.con_img_db.TabStop = false;
|
||||
//
|
||||
// con_Button_Add_Marker
|
||||
//
|
||||
this.con_Button_Add_Marker.Enabled = false;
|
||||
this.con_Button_Add_Marker.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.con_Button_Add_Marker.Location = new System.Drawing.Point(12, 414);
|
||||
this.con_Button_Add_Marker.Name = "con_Button_Add_Marker";
|
||||
this.con_Button_Add_Marker.Size = new System.Drawing.Size(114, 20);
|
||||
this.con_Button_Add_Marker.TabIndex = 21;
|
||||
this.con_Button_Add_Marker.Text = "Add log marker";
|
||||
this.con_Button_Add_Marker.UseVisualStyleBackColor = true;
|
||||
this.con_Button_Add_Marker.Click += new System.EventHandler(this.con_Button_Add_Marker_Click);
|
||||
//
|
||||
// form_Main
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(349, 483);
|
||||
this.ClientSize = new System.Drawing.Size(349, 653);
|
||||
this.Controls.Add(this.con_Button_Add_Marker);
|
||||
this.Controls.Add(this.label14);
|
||||
this.Controls.Add(this.label13);
|
||||
this.Controls.Add(this.con_img_logo);
|
||||
this.Controls.Add(this.con_Button_Reset_Flags);
|
||||
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_srs);
|
||||
this.Controls.Add(this.con_img_dcs);
|
||||
this.Controls.Add(this.con_img_db);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.con_GroupBox_3);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.con_lab_github);
|
||||
this.Controls.Add(this.con_Button_Quit);
|
||||
this.Controls.Add(this.con_GroupBox_3);
|
||||
this.Controls.Add(this.con_GroupBox_2);
|
||||
this.Controls.Add(this.con_GroupBox_1);
|
||||
this.Controls.Add(this.con_Button_Listen_OFF);
|
||||
@@ -337,10 +554,9 @@
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "form_Main";
|
||||
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.Load += new System.EventHandler(this.form_Main_Load);
|
||||
this.con_GroupBox_1.ResumeLayout(false);
|
||||
@@ -348,6 +564,13 @@
|
||||
this.con_GroupBox_2.PerformLayout();
|
||||
this.con_GroupBox_3.ResumeLayout(false);
|
||||
this.con_GroupBox_3.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_logo)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_lotATC)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_srs)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_dcs)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.con_img_db)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -359,7 +582,7 @@
|
||||
private System.Windows.Forms.Button con_Button_Listen_ON;
|
||||
private System.Windows.Forms.Button con_Button_Listen_OFF;
|
||||
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_3;
|
||||
private System.Windows.Forms.TextBox con_txt_mysql_database;
|
||||
@@ -380,9 +603,28 @@
|
||||
private System.Windows.Forms.NotifyIcon trayIconMain;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog_SRS;
|
||||
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.TextBox con_txt_mysql_port;
|
||||
private System.Windows.Forms.Timer tim_MySQL;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.MaskedTextBox con_txt_dcs_server_port;
|
||||
private System.Windows.Forms.Label label7;
|
||||
private System.Windows.Forms.Label label8;
|
||||
private System.Windows.Forms.MaskedTextBox con_txt_dcs_instance;
|
||||
private System.Windows.Forms.PictureBox con_img_db;
|
||||
private System.Windows.Forms.PictureBox con_img_dcs;
|
||||
private System.Windows.Forms.PictureBox con_img_srs;
|
||||
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;
|
||||
private System.Windows.Forms.Button con_Button_Reset_Flags;
|
||||
private System.Windows.Forms.PictureBox con_img_logo;
|
||||
private System.Windows.Forms.Label label13;
|
||||
private System.Windows.Forms.Label label14;
|
||||
private System.Windows.Forms.Button con_Button_Add_Marker;
|
||||
}
|
||||
}
|
||||
|
||||
640
02_Windows_App/Perun_v1/02_Forms/form_Main.cs
Normal file
@@ -0,0 +1,640 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Perun_v1
|
||||
{
|
||||
public partial class form_Main : Form
|
||||
{
|
||||
// Variable definitions
|
||||
public string[] DatabaseSendBuffer = new string[50]; // MySQL send buffer
|
||||
public bool AppCanClose = false; // Helper to handle system tray - true needed to quit the app
|
||||
|
||||
public DatabaseController DatabaseConnection = new DatabaseController(); // Main MySQL controller
|
||||
public TCPController TCPServer = new TCPController(); // Main TCP controller
|
||||
|
||||
public bool ExtSRSStatus; // True if to use empty/default SRS status
|
||||
public bool ExtLotATCStatus; // True if to use empty/default LotATC status
|
||||
|
||||
// ################################ Main ################################
|
||||
private void form_Main_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Form loaded
|
||||
Globals.AppLogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun started"; // Add information to the log control
|
||||
form_Main_LoadSettings(); // Load settings from registry
|
||||
|
||||
// Display build version in title bar
|
||||
Globals.AppTitle = PerunHelper.GetAppVersion(this.Text + " - ");
|
||||
this.Text = Globals.AppTitle;
|
||||
|
||||
// Use command line parameters
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
// Get argument server port
|
||||
if (args[1] != null)
|
||||
{
|
||||
con_txt_dcs_server_port.Text = args[1];
|
||||
}
|
||||
}
|
||||
if (args.Length > 2)
|
||||
{
|
||||
// Get argument instance id
|
||||
if (args[2] != null)
|
||||
{
|
||||
con_txt_dcs_instance.Text = args[2];
|
||||
}
|
||||
}
|
||||
if (args.Length > 3)
|
||||
{
|
||||
// Get argument DCS SRS file path
|
||||
if (args[3] != null)
|
||||
{
|
||||
con_txt_3rd_srs.Text = args[3];
|
||||
con_check_3rd_srs.Checked = true;
|
||||
}
|
||||
}
|
||||
if (args.Length > 4)
|
||||
{
|
||||
// Get argument lotATC file path
|
||||
if (args[4] != null)
|
||||
{
|
||||
con_txt_3rd_lotatc.Text = args[4];
|
||||
con_check_3rd_lotatc.Checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize controls
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
}
|
||||
|
||||
public form_Main()
|
||||
{
|
||||
// Form init
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// ################################ Helpers ################################
|
||||
private void form_Main_LoadSettings()
|
||||
{
|
||||
// Loads registry settings
|
||||
con_txt_mysql_database.Text = Properties.Settings.Default.MYSQL_DB;
|
||||
con_txt_mysql_username.Text = Properties.Settings.Default.MYSQL_User;
|
||||
con_txt_mysql_password.Text = Properties.Settings.Default.MYSQL_Password;
|
||||
con_txt_mysql_server.Text = Properties.Settings.Default.MYSQL_Server;
|
||||
con_txt_mysql_port.Text = Properties.Settings.Default.MYSQL_Port;
|
||||
con_txt_3rd_lotatc.Text = Properties.Settings.Default.OTHER_LOTATC_FILE;
|
||||
con_txt_3rd_srs.Text = Properties.Settings.Default.OTHER_SRS_FILE;
|
||||
con_check_3rd_lotatc.Checked = Properties.Settings.Default.OTHER_LOTATC_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_instance.Text = Properties.Settings.Default.DCS_Instance.ToString();
|
||||
}
|
||||
|
||||
private void form_Main_SaveSettings()
|
||||
{
|
||||
// Saves registry settings
|
||||
Properties.Settings.Default.MYSQL_Server = 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_Password = con_txt_mysql_password.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_server.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_FILE = con_txt_3rd_lotatc.Text;
|
||||
Properties.Settings.Default.OTHER_SRS_FILE = con_txt_3rd_srs.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
|
||||
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
|
||||
Properties.Settings.Default.DCS_Server_Port = Int32.Parse(con_txt_dcs_server_port.Text);
|
||||
Properties.Settings.Default.DCS_Instance = Int32.Parse(con_txt_dcs_instance.Text);
|
||||
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void form_Main_SetControlsToConnected()
|
||||
{
|
||||
// Disables controls
|
||||
con_Button_Add_Marker.Enabled = true;
|
||||
con_Button_Listen_OFF.Enabled = true;
|
||||
con_Button_Listen_ON.Enabled = false;
|
||||
con_Button_Quit.Enabled = false;
|
||||
con_Button_Reset_Flags.Enabled = true;
|
||||
con_txt_mysql_database.Enabled = false;
|
||||
con_txt_mysql_username.Enabled = false;
|
||||
con_txt_mysql_password.Enabled = false;
|
||||
con_txt_mysql_server.Enabled = false;
|
||||
con_txt_mysql_port.Enabled = false;
|
||||
con_txt_3rd_lotatc.Enabled = false;
|
||||
con_txt_3rd_srs.Enabled = false;
|
||||
con_check_3rd_lotatc.Enabled = false;
|
||||
con_check_3rd_srs.Enabled = false;
|
||||
con_txt_dcs_server_port.Enabled = false;
|
||||
con_txt_dcs_instance.Enabled = false;
|
||||
}
|
||||
|
||||
private void form_Main_SetControlsToDisconnected()
|
||||
{
|
||||
// Enables controls
|
||||
con_Button_Reset_Flags.Enabled = false;
|
||||
con_Button_Listen_OFF.Enabled = false;
|
||||
con_Button_Listen_ON.Enabled = true;
|
||||
con_Button_Quit.Enabled = true;
|
||||
con_Button_Add_Marker.Enabled = false;
|
||||
con_txt_mysql_database.Enabled = true;
|
||||
con_txt_mysql_username.Enabled = true;
|
||||
con_txt_mysql_password.Enabled = true;
|
||||
con_txt_mysql_port.Enabled = true;
|
||||
con_txt_mysql_server.Enabled = true;
|
||||
con_txt_3rd_lotatc.Enabled = true;
|
||||
con_txt_3rd_srs.Enabled = true;
|
||||
con_check_3rd_lotatc.Enabled = true;
|
||||
con_check_3rd_srs.Enabled = true;
|
||||
con_txt_dcs_server_port.Enabled = true;
|
||||
con_txt_dcs_instance.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
// ################################ User input ################################
|
||||
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Start listening
|
||||
// Set globals
|
||||
Globals.AppInstanceID = Int32.Parse(con_txt_dcs_instance.Text);
|
||||
Globals.AppForceIconReload = true;
|
||||
Globals.ErrorsDatabase = 0; // Reset error counter
|
||||
Globals.ErrorsGame = 0; // Reset error counter
|
||||
Globals.ErrorsSRS = 0; // Reset error counter
|
||||
Globals.ErrorsLotATC = 0; // Reset error counter
|
||||
Globals.StatusConnection = false; // Reset connection status
|
||||
|
||||
// Prepare GUI
|
||||
form_Main_SetControlsToConnected();
|
||||
form_Main_SaveSettings();
|
||||
this.Text = "[#" + con_txt_dcs_instance.Text + "] " + Globals.AppTitle; // Set title bar
|
||||
trayIconMain.Text = this.Text; // Set notification icon text
|
||||
|
||||
// Prepare MySQL connection string
|
||||
DatabaseConnection.DatabaseConnectionString = "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.AddLog(ref Globals.AppLogHistory, "Opening connections",0,1);
|
||||
TCPServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.AppLogHistory, ref DatabaseSendBuffer);
|
||||
TCPServer.thrTCPListener = new Thread(TCPServer.StartListen);
|
||||
TCPServer.thrTCPListener.Start();
|
||||
TCPServer.thrTCPListener.Name = "TCPThread";
|
||||
|
||||
// Start timmers
|
||||
tim_MySQL.Enabled = true;
|
||||
tim_GUI.Enabled = true;
|
||||
tim_3rdparties.Enabled = true;
|
||||
|
||||
// Send initial data
|
||||
Tim_MySQL_Tick(null, null);
|
||||
tim_3rdparties_Tick(null, null);
|
||||
}
|
||||
|
||||
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Stop listening
|
||||
// Prepare GUI
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Closing connections",0,1);
|
||||
con_Button_Listen_OFF.Enabled = false;
|
||||
Tim_GUI_Tick(null, null);
|
||||
this.Refresh();
|
||||
Application.DoEvents();
|
||||
|
||||
// Stop timmers
|
||||
tim_GUI.Enabled = false;
|
||||
tim_3rdparties.Enabled = false;
|
||||
tim_MySQL.Enabled = false;
|
||||
|
||||
try
|
||||
{
|
||||
// Stop the server
|
||||
TCPServer.StopListen();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "TCP ERROR, error: " + ex.Message, 2, 1, "?");
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
while (TCPServer.thrTCPListener.IsAlive)
|
||||
{
|
||||
// Wait untill TCP server closed connection
|
||||
Thread.Sleep(200); //ms
|
||||
}
|
||||
form_Main_SetControlsToDisconnected(); // Enable controls
|
||||
|
||||
// Load status images
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected");
|
||||
|
||||
// Display information about closed connections
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Connections closed",0,1);
|
||||
Tim_GUI_Tick(null, null);
|
||||
|
||||
// Set title bar
|
||||
this.Text = Globals.AppTitle;
|
||||
trayIconMain.Text = this.Text;
|
||||
|
||||
// Set globals
|
||||
Globals.AppInstanceID = 0;
|
||||
Globals.AppUpdateGUI = false;
|
||||
Globals.StatusDatabase = false;
|
||||
Globals.StatusHistoryConnection = false;
|
||||
Globals.StatusSRS = false;
|
||||
Globals.StatusLotATC = false;
|
||||
Globals.StatusConnection = false;
|
||||
}
|
||||
|
||||
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
// Open default browser with link to Perun repo
|
||||
ProcessStartInfo sInfo = new ProcessStartInfo("https://github.com/szporwolik/perun");
|
||||
Process.Start(sInfo);
|
||||
}
|
||||
|
||||
private void con_txt_3rd_srs_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Chose SRS Json file
|
||||
if (openFileDialog_SRS.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
con_txt_3rd_srs.Text = openFileDialog_SRS.FileName;
|
||||
con_check_3rd_srs.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
con_txt_3rd_srs.Text = "";
|
||||
con_check_3rd_srs.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void con_txt_3rd_lotatc_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Chose LotATC Json file
|
||||
if (openFileDialog_LotATC.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
con_txt_3rd_lotatc.Text = openFileDialog_LotATC.FileName;
|
||||
con_check_3rd_lotatc.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
con_txt_3rd_lotatc.Text = "";
|
||||
con_check_3rd_lotatc.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ################################ Form state ################################
|
||||
private void con_Button_Quit_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Try to close app
|
||||
DialogResult dialogResult = MessageBox.Show("Are you sure to exit Perun?", "Question", MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
form_Main_SaveSettings();
|
||||
|
||||
AppCanClose = true; // Save settings on exit
|
||||
this.Close(); // Allow to exit application
|
||||
}
|
||||
else if (dialogResult == DialogResult.No)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void form_Main_SendToTray()
|
||||
{
|
||||
// Sends app to system tray
|
||||
trayIconMain.Visible = true;
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
this.ShowInTaskbar = false;
|
||||
}
|
||||
|
||||
private void form_Main_BringFromTray()
|
||||
{
|
||||
// Sends app from system tray
|
||||
trayIconMain.Visible = false;
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.ShowInTaskbar = true;
|
||||
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
}
|
||||
// get our current "TopMost" value (ours will always be false though)
|
||||
bool top = TopMost;
|
||||
// make our form jump to the top of everything
|
||||
TopMost = true;
|
||||
// set it back to whatever it was
|
||||
TopMost = top;
|
||||
}
|
||||
|
||||
private void form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// Minimize to try on clicking "X"
|
||||
if (e.CloseReason == CloseReason.UserClosing && !AppCanClose)
|
||||
{
|
||||
e.Cancel = true;
|
||||
form_Main_SendToTray(); // Send app to system tray
|
||||
}
|
||||
}
|
||||
|
||||
private void trayIconMain_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Maximize from tray
|
||||
form_Main_BringFromTray(); // Bring app from system tray
|
||||
}
|
||||
|
||||
// ################################ Timers ################################
|
||||
private void Tim_GUI_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Main timer to sync GUI with background tasks and flush buffers
|
||||
|
||||
// Refresh Log Window
|
||||
if (Globals.AppUpdateGUI)
|
||||
{
|
||||
con_List_Received.Items.Clear();
|
||||
foreach (string i in Globals.AppLogHistory)
|
||||
{
|
||||
if (i != null)
|
||||
{
|
||||
con_List_Received.Items.Add(i);
|
||||
}
|
||||
}
|
||||
Globals.AppUpdateGUI = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do nothing , control does not require update
|
||||
}
|
||||
|
||||
// Update status icons at main form - MySQL
|
||||
if ((DatabaseConnection.DatabaseStatus != Globals.StatusDatabase) || Globals.AppForceIconReload)
|
||||
{
|
||||
if (DatabaseConnection.DatabaseStatus)
|
||||
{
|
||||
if (Globals.ErrorsDatabase == 0)
|
||||
{
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected_error");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_disconnected_error");
|
||||
}
|
||||
Globals.StatusDatabase = DatabaseConnection.DatabaseStatus;
|
||||
}
|
||||
// Update status icons at main form - DCS
|
||||
if ((Globals.StatusConnection != Globals.StatusHistoryConnection) || Globals.AppForceIconReload || Globals.ErrorsGame != Globals.ErrorsHistoryGame)
|
||||
{
|
||||
if (Globals.StatusConnection)
|
||||
{
|
||||
if (Globals.ErrorsGame == 0)
|
||||
{
|
||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("status_connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
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.StatusHistoryConnection = Globals.StatusConnection;
|
||||
Globals.ErrorsHistoryGame = Globals.ErrorsGame;
|
||||
}
|
||||
// Update status icons at main form - SRS
|
||||
if ((ExtSRSStatus != Globals.StatusSRS) || Globals.AppForceIconReload)
|
||||
{
|
||||
if (ExtSRSStatus && con_check_3rd_srs.Checked)
|
||||
{
|
||||
if (Globals.ErrorsSRS == 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.StatusSRS = ExtSRSStatus;
|
||||
}
|
||||
// Update status icons at main form - LotATC
|
||||
if ((ExtLotATCStatus != Globals.StatusLotATC) || Globals.AppForceIconReload)
|
||||
{
|
||||
if (ExtLotATCStatus && con_check_3rd_lotatc.Checked)
|
||||
{
|
||||
if (Globals.ErrorsLotATC == 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.StatusLotATC = ExtLotATCStatus;
|
||||
}
|
||||
Globals.AppForceIconReload = false;
|
||||
}
|
||||
|
||||
private void Tim_MySQL_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Send buffer to MySQL
|
||||
for (int i = 0; i < DatabaseSendBuffer.Length - 1; i++)
|
||||
{
|
||||
if (DatabaseSendBuffer[i] != null)
|
||||
{
|
||||
if (DatabaseConnection.SendToMySql(DatabaseSendBuffer[i]) > 0)
|
||||
{
|
||||
DatabaseSendBuffer[i] = null; // If packet was send then delete it from send buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tim_3rdparties_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Main timer to check MySQL connection and send JSON files to MySQL
|
||||
|
||||
// Send ping to check for possible connection issues
|
||||
DatabaseConnection.SendToMySql("", true);
|
||||
|
||||
if (PerunHelper.CheckVersions()==0)
|
||||
{
|
||||
MessageBox.Show("Version mismatch detected - please check log files and update.\n\nPerun will now terminate.", "Perun ERROR!",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||
con_Button_Listen_OFF_Click(null, null);
|
||||
}
|
||||
|
||||
// Take care of 3rd party stuff
|
||||
string ExtSRSJson = "";
|
||||
string ExtLotATCJson = "";
|
||||
|
||||
bool ExtSRSUseDefault = true;
|
||||
bool ExtLotATCUseDefault = true;
|
||||
|
||||
// Handle SRS
|
||||
if (Globals.StatusConnection)
|
||||
{
|
||||
if (con_check_3rd_srs.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExtSRSJson = System.IO.File.ReadAllText(con_txt_3rd_srs.Text);
|
||||
dynamic raw_lotatc = JsonConvert.DeserializeObject(ExtSRSJson);
|
||||
|
||||
for (int i = 0; i < raw_lotatc.Count; i++)
|
||||
{
|
||||
|
||||
if (raw_lotatc[i].RadioInfo != null)
|
||||
{
|
||||
|
||||
int temp = raw_lotatc[i].RadioInfo.radios.Count - 1;
|
||||
for (int j = temp; j >= 0; j--)
|
||||
{
|
||||
raw_lotatc[i].RadioInfo.radios[j].enc.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].encKey.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].encMode.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].freqMax.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].freqMin.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].modulation.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].freqMode.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].volMode.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].expansion.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].channel.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].simul.Parent.Remove();
|
||||
|
||||
if (raw_lotatc[i].RadioInfo.radios[j].name == "No Radio")
|
||||
{
|
||||
raw_lotatc[i].RadioInfo.radios[j].Remove();
|
||||
}
|
||||
}
|
||||
raw_lotatc[i].ClientChannelId.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.simultaneousTransmission.Parent.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (raw_lotatc.Count > 0)
|
||||
{
|
||||
ExtSRSJson = JsonConvert.SerializeObject(raw_lotatc);
|
||||
ExtSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + ExtSRSJson + "'}";
|
||||
}
|
||||
else
|
||||
{
|
||||
ExtSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'false'}}"; // No SRS clients connected
|
||||
}
|
||||
ExtSRSUseDefault = false;
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "SRS data loaded", 3, 0, "100", true);
|
||||
ExtSRSStatus = true;
|
||||
}
|
||||
catch (Exception exc_srs)
|
||||
{
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "SRS data ERROR , error: " + exc_srs.Message, 3, 1, "100");
|
||||
ExtSRSStatus = false;
|
||||
Globals.ErrorsSRS++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (ExtSRSUseDefault)
|
||||
{
|
||||
ExtSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}";
|
||||
}
|
||||
DatabaseConnection.SendToMySql(ExtSRSJson);
|
||||
}
|
||||
|
||||
// Handle LotATC
|
||||
if (Globals.StatusConnection)
|
||||
{
|
||||
if (con_check_3rd_lotatc.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExtLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||
dynamic raw_srs = JsonConvert.DeserializeObject(ExtLotATCJson);
|
||||
|
||||
ExtLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + ExtLotATCJson + "'}";
|
||||
ExtLotATCUseDefault = false;
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "LotATC data loaded", 3, 0, "101", true);
|
||||
ExtLotATCStatus = true;
|
||||
}
|
||||
catch (Exception exc_lotatc)
|
||||
{
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "LotATC data ERROR, error: " + exc_lotatc.Message, 3, 1, "101");
|
||||
ExtLotATCStatus = false;
|
||||
Globals.ErrorsLotATC++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (ExtLotATCUseDefault)
|
||||
{
|
||||
ExtLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}"; // No LotATC controller connected
|
||||
}
|
||||
DatabaseConnection.SendToMySql(ExtLotATCJson);
|
||||
}
|
||||
|
||||
// Let's do not risk int overload
|
||||
Globals.ErrorsDatabase = (Globals.ErrorsDatabase > 999) ? 999 : Globals.ErrorsDatabase;
|
||||
Globals.ErrorsGame = (Globals.ErrorsGame > 999) ? 999 : Globals.ErrorsGame;
|
||||
Globals.ErrorsSRS = (Globals.ErrorsSRS > 999) ? 999 : Globals.ErrorsSRS;
|
||||
Globals.ErrorsLotATC = (Globals.ErrorsLotATC > 999) ? 999 : Globals.ErrorsLotATC;
|
||||
|
||||
}
|
||||
|
||||
private void con_Button_Reset_Flags_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Reset error flags
|
||||
DialogResult dialogResult = MessageBox.Show("Are you sure to reset error flags?", "Question", MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
// Reset errors counter
|
||||
Globals.ErrorsDatabase = 0; // MySQL - Error counter
|
||||
Globals.ErrorsGame = 0; // TCP connection - Error counter
|
||||
Globals.ErrorsHistoryGame = 0; // TCP connection - historic value of Error counter
|
||||
Globals.ErrorsSRS = 0; // DCS SRS - error counter
|
||||
Globals.ErrorsLotATC = 0; // LotATC - error counter
|
||||
|
||||
// Force icons reload
|
||||
Globals.AppForceIconReload = true;
|
||||
|
||||
// Add information
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "Resetted error counter",0,1);
|
||||
}
|
||||
else if (dialogResult == DialogResult.No)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void con_Button_Add_Marker_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Added user marker
|
||||
PerunHelper.AddLog(ref Globals.AppLogHistory, "User Marker",0,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</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>
|
||||
</metadata>
|
||||
<metadata name="trayIconMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
@@ -413,9 +413,15 @@
|
||||
<metadata name="openFileDialog_LotATC.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>397, 17</value>
|
||||
</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>
|
||||
</metadata>
|
||||
<metadata name="tim_MySQL.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>687, 19</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>26</value>
|
||||
</metadata>
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAEAQD8AAAEAIAAgQQAAFgAAACgAAABAAAAAfgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
BIN
02_Windows_App/Perun_v1/03_Resources/perun_logo.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
02_Windows_App/Perun_v1/03_Resources/status-connected-error.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
02_Windows_App/Perun_v1/03_Resources/status-connected.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
BIN
02_Windows_App/Perun_v1/03_Resources/status-disconnected.png
Normal file
|
After Width: | Height: | Size: 909 B |
@@ -8,25 +8,35 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Perun_v1</RootNamespace>
|
||||
<AssemblyName>Perun</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>C:\Users\simpo\Desktop\Perun\</PublishUrl>
|
||||
<IsWebBootstrapper>true</IsWebBootstrapper>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>ftp://s18.mydevil.net/perun/</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
<UpdateEnabled>true</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<AutorunEnabled>true</AutorunEnabled>
|
||||
<ApplicationRevision>1</ApplicationRevision>
|
||||
<ApplicationVersion>0.3.0.%2a</ApplicationVersion>
|
||||
<InstallUrl>http://share.porwolik.com/ftp/perun/</InstallUrl>
|
||||
<SupportUrl>https://github.com/szporwolik/perun</SupportUrl>
|
||||
<ErrorReportUrl>https://github.com/szporwolik/perun</ErrorReportUrl>
|
||||
<TargetCulture>en</TargetCulture>
|
||||
<ProductName>Perun for DCS World</ProductName>
|
||||
<PublisherName>szporwolik</PublisherName>
|
||||
<SuiteName>Perun</SuiteName>
|
||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||
<WebPage>Perun.htm</WebPage>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>0.8.3.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
@@ -39,6 +49,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>SecurityRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -52,7 +63,7 @@
|
||||
</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>perun_logo.ico</ApplicationIcon>
|
||||
<ApplicationIcon>03_Resources\perun_logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestCertificateThumbprint>2ACE4C8C2C325A04CA5986B1CD76744B4B03755D</ManifestCertificateThumbprint>
|
||||
@@ -65,7 +76,7 @@
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>true</SignManifests>
|
||||
<SignManifests>false</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
@@ -73,18 +84,25 @@
|
||||
<PropertyGroup>
|
||||
<TargetZone>LocalIntranet</TargetZone>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Protobuf.3.5.1\lib\net45\Google.Protobuf.dll</HintPath>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
|
||||
<HintPath>..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=8.0.15.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.8.0.15\lib\net452\MySql.Data.dll</HintPath>
|
||||
<Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=8.0.17.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.8.0.17\lib\net452\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel" />
|
||||
@@ -106,34 +124,44 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="form_Main.cs">
|
||||
<Compile Include="01_Classes\LogController.cs" />
|
||||
<Compile Include="01_Classes\TCPController.cs" />
|
||||
<Compile Include="01_Classes\Globals.cs" />
|
||||
<Compile Include="01_Classes\DatabaseController.cs" />
|
||||
<Compile Include="01_Classes\PerunHelper.cs" />
|
||||
<Compile Include="02_Forms\form_Main.cs">
|
||||
<SubType>Form</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="form_Main.Designer.cs">
|
||||
<Compile Include="02_Forms\form_Main.Designer.cs">
|
||||
<DependentUpon>form_Main.cs</DependentUpon>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="01_Classes\Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="form_Main.resx">
|
||||
<EmbeddedResource Include="02_Forms\form_Main.resx">
|
||||
<DependentUpon>form_Main.cs</DependentUpon>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="00_Config\packages.config" />
|
||||
<None Include="00_Config\Perun_v1_TemporaryKey.pfx" />
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Perun_v1_TemporaryKey.pfx" />
|
||||
<None Include="Properties\app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
@@ -141,12 +169,12 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="00_Config\App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 i x64%29</ProductName>
|
||||
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
@@ -156,10 +184,14 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="perun_logo.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
<Content Include="03_Resources\perun_logo.ico" />
|
||||
<None Include="03_Resources\perun_logo.png" />
|
||||
<None Include="Resources\perun_logo.png" />
|
||||
<None Include="Resources\status-connected-error.png" />
|
||||
<None Include="Resources\status-disconnected-error.png" />
|
||||
<None Include="Resources\status-disconnected.png" />
|
||||
<None Include="Resources\status-connected.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -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
|
||||
// przy użyciu symbolu „*”, tak jak pokazano poniżej:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.3.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.3.0.0")]
|
||||
[assembly: AssemblyVersion("0.8.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.3.0")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Ten kod został wygenerowany przez narzędzie.
|
||||
// Wersja wykonawcza:4.0.30319.42000
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Zmiany w tym pliku mogą spowodować nieprawidłowe zachowanie i zostaną utracone, jeśli
|
||||
// kod zostanie ponownie wygenerowany.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -13,13 +13,13 @@ namespace Perun_v1.Properties {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Klasa zasobu wymagająca zdefiniowania typu do wyszukiwania zlokalizowanych ciągów itd.
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// Ta klasa została automatycznie wygenerowana za pomocą klasy StronglyTypedResourceBuilder
|
||||
// przez narzędzie, takie jak ResGen lub Visual Studio.
|
||||
// Aby dodać lub usunąć składową, edytuj plik ResX, a następnie ponownie uruchom narzędzie ResGen
|
||||
// z opcją /str lub ponownie utwórz projekt VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
@@ -33,7 +33,7 @@ namespace Perun_v1.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zwraca buforowane wystąpienie ResourceManager używane przez tę klasę.
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
@@ -47,8 +47,8 @@ namespace Perun_v1.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Przesłania właściwość CurrentUICulture bieżącego wątku dla wszystkich
|
||||
/// przypadków przeszukiwania zasobów za pomocą tej klasy zasobów wymagającej zdefiniowania typu.
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
@@ -59,5 +59,55 @@ namespace Perun_v1.Properties {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap perun_logo {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("perun_logo", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap status_connected {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("status_connected", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap status_connected_error {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("status_connected_error", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap status_disconnected {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("status_disconnected", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap status_disconnected_error {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("status_disconnected_error", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,4 +117,20 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="perun_logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\03_Resources\perun_logo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="status_connected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\03_Resources\status-connected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="status_connected_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\03_Resources\status-connected-error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="status_disconnected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\03_Resources\status-disconnected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="status_disconnected_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\03_Resources\status-disconnected-error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,10 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Ten kod został wygenerowany przez narzędzie.
|
||||
// Wersja wykonawcza:4.0.30319.42000
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Zmiany w tym pliku mogą spowodować nieprawidłowe zachowanie i zostaną utracone, jeśli
|
||||
// kod zostanie ponownie wygenerowany.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Perun_v1.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -121,7 +121,7 @@ namespace Perun_v1.Properties {
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("3306")]
|
||||
public string MYSQL_Port {
|
||||
get {
|
||||
return ((string)(this["MYSQL_Port"]));
|
||||
@@ -130,5 +130,29 @@ namespace Perun_v1.Properties {
|
||||
this["MYSQL_Port"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("48620")]
|
||||
public int DCS_Server_Port {
|
||||
get {
|
||||
return ((int)(this["DCS_Server_Port"]));
|
||||
}
|
||||
set {
|
||||
this["DCS_Server_Port"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("1")]
|
||||
public int DCS_Instance {
|
||||
get {
|
||||
return ((int)(this["DCS_Instance"]));
|
||||
}
|
||||
set {
|
||||
this["DCS_Instance"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,13 @@
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="MYSQL_Port" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
<Value Profile="(Default)">3306</Value>
|
||||
</Setting>
|
||||
<Setting Name="DCS_Server_Port" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">48620</Value>
|
||||
</Setting>
|
||||
<Setting Name="DCS_Instance" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">1</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
BIN
02_Windows_App/Perun_v1/Resources/perun_logo.png
Normal file
|
After Width: | Height: | Size: 233 B |
45
02_Windows_App/Perun_v1/app.config
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="Perun_v1.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<Perun_v1.Properties.Settings>
|
||||
<setting name="MYSQL_Server" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MYSQL_User" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MYSQL_Password" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MYSQL_DB" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OTHER_LOTATC_FILE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OTHER_SRS_FILE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="OTHER_LOTATC_USE" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="OTHER_SRS_USE" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="MYSQL_Port" serializeAs="String">
|
||||
<value>3306</value>
|
||||
</setting>
|
||||
<setting name="DCS_Server_Port" serializeAs="String">
|
||||
<value>48620</value>
|
||||
</setting>
|
||||
<setting name="DCS_Instance" serializeAs="String">
|
||||
<value>1</value>
|
||||
</setting>
|
||||
</Perun_v1.Properties.Settings>
|
||||
</userSettings>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
@@ -1,460 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Perun_v1
|
||||
{
|
||||
public partial class form_Main : Form
|
||||
{
|
||||
|
||||
// Variable definitions
|
||||
public Thread thread_UDPListener; // Seperate thread for UDP
|
||||
public class_UDPListener UDPListener; // Helper class for UDP comunication
|
||||
public string[] LogHistory=new string[10]; // Log history for GUI
|
||||
public string[] SendBuffer=new string[10]; // Mysql send buffer
|
||||
public bool LetMeOut=false; // Helper to handle system tray
|
||||
public string MySql_connStr; // MySQL connection string
|
||||
|
||||
public static void LogHistoryAdd(ref string[] LogHistory, string Comment)
|
||||
{
|
||||
// Add to log history and rotate
|
||||
for (int i = 0; i < LogHistory.Length - 1; i++)
|
||||
{
|
||||
LogHistory[i] = LogHistory[i + 1];
|
||||
}
|
||||
LogHistory[9] = DateTime.Now.ToString("HH:mm:ss") + " > " + Comment;
|
||||
}
|
||||
|
||||
public void SendToMySql(string raw_udp_frame)
|
||||
{
|
||||
// Main function to send data to mysql
|
||||
dynamic udp_frame = JsonConvert.DeserializeObject(raw_udp_frame);
|
||||
|
||||
// Cut raw data to type and paylod for proper mysql insert
|
||||
string type = udp_frame.type;
|
||||
string payload = "";
|
||||
string sql = "";
|
||||
|
||||
// Modify specific
|
||||
if (type == "1") // Inject app version information
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
string version = fileVersionInfo.ProductVersion;
|
||||
udp_frame.payload["v_win"] = "v"+version;
|
||||
}
|
||||
|
||||
// Specific SQL
|
||||
if(type == "50")
|
||||
{
|
||||
sql = "INSERT INTO `pe_LogChat` (`pe_LogChat_id`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`) VALUES (NULL, '"+udp_frame.payload.player+ "', '" + udp_frame.payload.msg + "', '" + udp_frame.payload.all + "');";
|
||||
}
|
||||
else if(type == "51")
|
||||
{
|
||||
sql = "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`) VALUES (NULL, CURRENT_TIMESTAMP, '" + udp_frame.payload.log_type + "', '" + udp_frame.payload.log_content + "');";
|
||||
}
|
||||
else
|
||||
{
|
||||
payload = JsonConvert.SerializeObject(udp_frame.payload);
|
||||
sql = "INSERT INTO pe_DataRaw(pe_dataraw_type,pe_dataraw_payload) VALUES (" + type + ",JSON_QUOTE('" + payload + "')) ON DUPLICATE KEY UPDATE pe_dataraw_payload = JSON_QUOTE('" + payload + "')";
|
||||
}
|
||||
|
||||
// Connect to mysql
|
||||
MySqlConnection conn = new MySqlConnection(MySql_connStr);
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Sending data to MySQL - Begin");
|
||||
conn.Open();
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(sql, conn);
|
||||
MySqlDataReader rdr = cmd.ExecuteReader();
|
||||
|
||||
while (rdr.Read())
|
||||
{
|
||||
Console.WriteLine(rdr[0] + " -- " + rdr[1]);
|
||||
}
|
||||
rdr.Close();
|
||||
LogHistoryAdd(ref LogHistory, "MySQL updated, package type: "+ type);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
LogHistoryAdd(ref LogHistory, "ERROR: MySQL");
|
||||
}
|
||||
|
||||
conn.Close();
|
||||
Console.WriteLine("Sending data to MySQL - Done");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class class_UDPListener
|
||||
{
|
||||
// Main class for UDP listener
|
||||
int listenPort; // Port to listen at
|
||||
public bool done; // Helper to exit main loop without killing thread
|
||||
public UdpClient listener; // Listener object
|
||||
public string[] LogHistory; // Log history for GUI
|
||||
public string[] SendBuffer; // Mysql send buffer
|
||||
|
||||
public class_UDPListener(int port, ref string[] LogHistory, ref string[] SendBuffer)
|
||||
{
|
||||
// Create clas - NOTE that there is reference passing
|
||||
this.listenPort = port;
|
||||
this.LogHistory = LogHistory;
|
||||
this.SendBuffer = SendBuffer;
|
||||
}
|
||||
|
||||
public void StartListen()
|
||||
{
|
||||
// Start listening to UDP
|
||||
this.done = false;
|
||||
listener = new UdpClient(listenPort);
|
||||
IPEndPoint groupEP = new IPEndPoint(IPAddress.Loopback, listenPort);
|
||||
string received_data;
|
||||
byte[] receive_byte_array;
|
||||
|
||||
Console.WriteLine("UDP Listen start");
|
||||
try
|
||||
{
|
||||
while (!done)
|
||||
{
|
||||
Console.WriteLine("UDP: Waiting for packet");
|
||||
receive_byte_array = listener.Receive(ref groupEP);
|
||||
received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length);
|
||||
|
||||
Console.WriteLine("Sender: {0} Payload: {1}", groupEP.ToString(), received_data);
|
||||
|
||||
// Add to log history and rotate
|
||||
dynamic udp_frame = JsonConvert.DeserializeObject(received_data);
|
||||
string type = udp_frame.type;
|
||||
LogHistoryAdd(ref LogHistory, "UDP packet received, type: "+ type);
|
||||
|
||||
// Add to mySQL send buffer and rotate
|
||||
for (int i = 0; i < SendBuffer.Length - 1; i++)
|
||||
{
|
||||
SendBuffer[i] = SendBuffer[i + 1];
|
||||
}
|
||||
SendBuffer[9] = received_data;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
Console.WriteLine("UDP listen stop");
|
||||
listener.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public form_Main()
|
||||
{
|
||||
// Form init
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void form_Main_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Form loaded - fill controls with default values
|
||||
LogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun loaded...";
|
||||
|
||||
// Load settings
|
||||
con_txt_mysql_database.Text = Properties.Settings.Default.MYSQL_DB;
|
||||
con_txt_mysql_username.Text = Properties.Settings.Default.MYSQL_User;
|
||||
con_txt_mysql_password.Text = Properties.Settings.Default.MYSQL_Password;
|
||||
con_txt_mysql_server.Text = Properties.Settings.Default.MYSQL_Server;
|
||||
con_txt_mysql_port.Text = Properties.Settings.Default.MYSQL_Port;
|
||||
con_txt_3rd_lotatc.Text = Properties.Settings.Default.OTHER_LOTATC_FILE;
|
||||
con_txt_3rd_srs.Text = Properties.Settings.Default.OTHER_SRS_FILE;
|
||||
con_check_3rd_lotatc.Checked = Properties.Settings.Default.OTHER_LOTATC_USE;
|
||||
con_check_3rd_srs.Checked = Properties.Settings.Default.OTHER_SRS_USE;
|
||||
|
||||
// Version to title header
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
this.Text = this.Text + " - v" + fileVersionInfo.ProductVersion;
|
||||
}
|
||||
|
||||
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Start listening
|
||||
UDPListener = new class_UDPListener(48620,ref LogHistory, ref SendBuffer);
|
||||
thread_UDPListener = new Thread(UDPListener.StartListen);
|
||||
thread_UDPListener.Start();
|
||||
|
||||
// Update form controls
|
||||
con_Button_Listen_ON.Enabled = false;
|
||||
con_Button_Listen_OFF.Enabled = true;
|
||||
con_txt_mysql_database.Enabled = false;
|
||||
con_txt_mysql_username.Enabled = false;
|
||||
con_txt_mysql_password.Enabled = false;
|
||||
con_txt_mysql_server.Enabled = false;
|
||||
con_txt_mysql_port.Enabled = false;
|
||||
con_txt_3rd_lotatc.Enabled = false;
|
||||
con_txt_3rd_srs.Enabled = false;
|
||||
con_check_3rd_lotatc.Enabled = false;
|
||||
con_check_3rd_srs.Enabled = false;
|
||||
|
||||
// Save settings
|
||||
Properties.Settings.Default.MYSQL_Server = 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_Password = con_txt_mysql_password.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_server.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_FILE = con_txt_3rd_lotatc.Text;
|
||||
Properties.Settings.Default.OTHER_SRS_FILE = con_txt_3rd_srs.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
|
||||
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
|
||||
|
||||
// Prepare connection string
|
||||
MySql_connStr = "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 timmers
|
||||
tim_1000ms.Enabled = true;
|
||||
tim_10000ms.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Stop listening
|
||||
UDPListener.listener.Close();
|
||||
|
||||
// Update form controls
|
||||
con_Button_Listen_ON.Enabled = true;
|
||||
con_Button_Listen_OFF.Enabled = false;
|
||||
|
||||
con_txt_mysql_database.Enabled = true;
|
||||
con_txt_mysql_username.Enabled = true;
|
||||
con_txt_mysql_password.Enabled = true;
|
||||
con_txt_mysql_port.Enabled = true;
|
||||
con_txt_mysql_server.Enabled = true;
|
||||
con_txt_3rd_lotatc.Enabled = true;
|
||||
con_txt_3rd_srs.Enabled = true;
|
||||
con_check_3rd_lotatc.Enabled = true;
|
||||
con_check_3rd_srs.Enabled = true;
|
||||
|
||||
// Stop timmers
|
||||
tim_1000ms.Enabled = false;
|
||||
tim_10000ms.Enabled = false;
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Main timer to sync GUI with background tasks and flush buffers
|
||||
// Refresh Log Window
|
||||
con_List_Received.Items.Clear();
|
||||
foreach (string i in LogHistory)
|
||||
{
|
||||
if (i != null)
|
||||
{
|
||||
con_List_Received.Items.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Send buffer to MySQL
|
||||
for (int i = 0; i < SendBuffer.Length - 1; i++)
|
||||
{
|
||||
if (SendBuffer[i] != null)
|
||||
{
|
||||
SendToMySql(SendBuffer[i]);
|
||||
SendBuffer[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
// Open default browser with link to Perun repo
|
||||
ProcessStartInfo sInfo = new ProcessStartInfo("https://github.com/szporwolik/perun");
|
||||
Process.Start(sInfo);
|
||||
}
|
||||
|
||||
private void con_Button_Quit_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Close app
|
||||
|
||||
DialogResult dialogResult = MessageBox.Show("Are you sure to exit Perun?", "Question", MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
// Save settings on exit
|
||||
Properties.Settings.Default.MYSQL_Server = 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_Password = con_txt_mysql_password.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.MYSQL_Server = con_txt_mysql_server.Text;
|
||||
Properties.Settings.Default.MYSQL_Port = con_txt_mysql_port.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_FILE = con_txt_3rd_lotatc.Text;
|
||||
Properties.Settings.Default.OTHER_SRS_FILE = con_txt_3rd_srs.Text;
|
||||
Properties.Settings.Default.OTHER_LOTATC_USE = con_check_3rd_lotatc.Checked;
|
||||
Properties.Settings.Default.OTHER_SRS_USE = con_check_3rd_srs.Checked;
|
||||
|
||||
Properties.Settings.Default.Save();
|
||||
|
||||
LetMeOut = true;
|
||||
this.Close();
|
||||
}
|
||||
else if (dialogResult == DialogResult.No)
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// Minimize to try
|
||||
if (e.CloseReason == CloseReason.UserClosing && !LetMeOut)
|
||||
{
|
||||
e.Cancel = true;
|
||||
trayIconMain.Visible = true;
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
this.ShowInTaskbar = false;
|
||||
//this.Hide();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void trayIconMain_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Maximize from try
|
||||
trayIconMain.Visible = false;
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.ShowInTaskbar = true;
|
||||
|
||||
}
|
||||
|
||||
private void con_txt_3rd_srs_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Chose SRS Json file
|
||||
if (openFileDialog_SRS.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
con_txt_3rd_srs.Text = openFileDialog_SRS.FileName;
|
||||
con_check_3rd_srs.Checked = true;
|
||||
} else
|
||||
{
|
||||
con_txt_3rd_srs.Text = "";
|
||||
con_check_3rd_srs.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void con_txt_3rd_lotatc_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Chose LotATC Json file
|
||||
if (openFileDialog_LotATC.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
con_txt_3rd_lotatc.Text = openFileDialog_LotATC.FileName;
|
||||
con_check_3rd_lotatc.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
con_txt_3rd_lotatc.Text = "";
|
||||
con_check_3rd_lotatc.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void tim_10000ms_Tick(object sender, EventArgs e)
|
||||
{
|
||||
// Main timer to send JSON files to MySQL
|
||||
string strSRSJson ="";
|
||||
string strLotATCJson="";
|
||||
|
||||
bool SRSdefault = true;
|
||||
bool LotATCdefault = true;
|
||||
|
||||
// Handle SRS
|
||||
if (con_check_3rd_srs.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
strSRSJson = System.IO.File.ReadAllText(con_txt_3rd_srs.Text);
|
||||
dynamic raw_lotatc = JsonConvert.DeserializeObject(strSRSJson);
|
||||
|
||||
for (int i = 0; i < raw_lotatc.Count; i++)
|
||||
{
|
||||
|
||||
int temp = raw_lotatc[i].RadioInfo.radios.Count - 1;
|
||||
for (int j = temp; j >= 0; j--)
|
||||
{
|
||||
raw_lotatc[i].RadioInfo.radios[j].enc.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].encKey.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].encMode.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].freqMax.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].freqMin.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].modulation.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].freqMode.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].volMode.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].expansion.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].channel.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.radios[j].simul.Parent.Remove();
|
||||
|
||||
if (raw_lotatc[i].RadioInfo.radios[j].name == "No Radio")
|
||||
{
|
||||
raw_lotatc[i].RadioInfo.radios[j].Remove();
|
||||
}
|
||||
}
|
||||
raw_lotatc[i].ClientChannelId.Parent.Remove();
|
||||
raw_lotatc[i].RadioInfo.simultaneousTransmission.Parent.Remove();
|
||||
}
|
||||
|
||||
strSRSJson = JsonConvert.SerializeObject(raw_lotatc);
|
||||
strSRSJson = "{'type':'100','payload':'" + strSRSJson + "'}";
|
||||
SRSdefault = false;
|
||||
LogHistoryAdd(ref LogHistory, "SRS data loaded");
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
LogHistoryAdd(ref LogHistory, "SRS data ERROR");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(SRSdefault)
|
||||
{
|
||||
strSRSJson = "{'type':'100','payload':{'ignore':'true'}}";
|
||||
}
|
||||
SendToMySql(strSRSJson);
|
||||
|
||||
// Handle LotATC
|
||||
if (con_check_3rd_lotatc.Checked)
|
||||
{
|
||||
try
|
||||
{
|
||||
strLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||
dynamic raw_srs = JsonConvert.DeserializeObject(strLotATCJson);
|
||||
|
||||
strLotATCJson = "{'type':'101','payload':'" + strLotATCJson + "'}";
|
||||
LotATCdefault = false;
|
||||
LogHistoryAdd(ref LogHistory, "LotATC data loaded");
|
||||
}
|
||||
catch
|
||||
{
|
||||
LogHistoryAdd(ref LogHistory, "LotATC data ERROR");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (LotATCdefault)
|
||||
{
|
||||
strLotATCJson = "{'type':'101','payload':{'ignore':'true'}}";
|
||||
}
|
||||
SendToMySql(strLotATCJson);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Google.Protobuf" version="3.5.1" targetFramework="net461" />
|
||||
<package id="MySql.Data" version="8.0.15" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net461" />
|
||||
<package id="BouncyCastle" version="1.8.3.1" targetFramework="net48" />
|
||||
<package id="Google.Protobuf" version="3.6.1" targetFramework="net48" />
|
||||
<package id="MySql.Data" version="8.0.17" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net48" />
|
||||
<package id="SSH.NET" version="2016.1.0" targetFramework="net48" />
|
||||
</packages>
|
||||
211
03_MySQL/m1081_perun.sql
Normal file
@@ -0,0 +1,211 @@
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS `m1081_perun` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
USE `m1081_perun`;
|
||||
|
||||
DELIMITER $$
|
||||
DROP PROCEDURE IF EXISTS `sp_CleanDatabase`$$
|
||||
CREATE DEFINER=`m1081`@`%.devil` PROCEDURE `sp_CleanDatabase` () MODIFIES SQL DATA
|
||||
BEGIN
|
||||
DELETE FROM pe_DataMissionHashes;
|
||||
DELETE FROM pe_DataPlayers;
|
||||
DELETE FROM pe_DataRaw;
|
||||
DELETE FROM pe_LogChat;
|
||||
DELETE FROM pe_LogEvent;
|
||||
DELETE FROM pe_LogLogins;
|
||||
DELETE FROM pe_LogStats;
|
||||
|
||||
ALTER TABLE pe_DataMissionHashes AUTO_INCREMENT = 1;
|
||||
ALTER TABLE pe_DataPlayers AUTO_INCREMENT = 1;
|
||||
ALTER TABLE pe_DataRaw AUTO_INCREMENT = 1;
|
||||
ALTER TABLE pe_LogChat AUTO_INCREMENT = 1;
|
||||
ALTER TABLE pe_LogEvent AUTO_INCREMENT = 1;
|
||||
ALTER TABLE pe_LogLogins AUTO_INCREMENT = 1;
|
||||
ALTER TABLE pe_LogStats AUTO_INCREMENT = 1;
|
||||
|
||||
END$$
|
||||
|
||||
DROP PROCEDURE IF EXISTS `sp_SyncForumGame`$$
|
||||
$$
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_Config`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_Config` (
|
||||
`pe_Config_id` int(11) NOT NULL,
|
||||
`pe_Config_payload` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`pe_Config_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `pe_Config` (`pe_Config_id`, `pe_Config_payload`) VALUES
|
||||
(1, 'v0.8.3');
|
||||
|
||||
DROP TABLE IF EXISTS `pe_DataMissionHashes`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_DataMissionHashes` (
|
||||
`pe_DataMissionHashes_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_DataMissionHashes_instance` smallint(5) UNSIGNED NOT NULL,
|
||||
`pe_DataMissionHashes_hash` varchar(150) NOT NULL,
|
||||
`pe_DataMissionHashes_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`pe_DataMissionHashes_id`),
|
||||
UNIQUE KEY `UNIQUE_hash` (`pe_DataMissionHashes_hash`),
|
||||
KEY `pe_DataMissionHashes_instance` (`pe_DataMissionHashes_instance`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=818 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_DataPlayers`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_DataPlayers` (
|
||||
`pe_DataPlayers_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_DataPlayers_ucid` varchar(150) NOT NULL,
|
||||
`pe_DataPlayers_lastname` varchar(150) NOT NULL,
|
||||
`pe_DataPlayers_lastip` varchar(100) NOT NULL,
|
||||
`pe_DataPlayers_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`pe_DataPlayers_id`),
|
||||
UNIQUE KEY `UNIQUE_UCID` (`pe_DataPlayers_ucid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=219 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_DataRaw`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_DataRaw` (
|
||||
`pe_dataraw_type` tinyint(4) NOT NULL,
|
||||
`pe_dataraw_instance` smallint(5) UNSIGNED NOT NULL,
|
||||
`pe_dataraw_payload` text NOT NULL,
|
||||
`pe_dataraw_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`pe_dataraw_type`,`pe_dataraw_instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_DataTypes`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_DataTypes` (
|
||||
`pe_DataTypes_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`pe_DataTypes_name` varchar(100) NOT NULL,
|
||||
`pe_DataTypes_update` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`pe_DataTypes_id`),
|
||||
UNIQUE KEY `UNIQUE_TYPE_NAME` (`pe_DataTypes_name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogChat`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogChat` (
|
||||
`pe_LogChat_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogChat_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogChat_missionhash_id` bigint(20) DEFAULT NULL,
|
||||
`pe_LogChat_playerid` varchar(100) NOT NULL,
|
||||
`pe_LogChat_msg` text NOT NULL,
|
||||
`pe_LogChat_all` varchar(10) NOT NULL,
|
||||
PRIMARY KEY (`pe_LogChat_id`),
|
||||
KEY `pe_LogChat_missionhash_id` (`pe_LogChat_missionhash_id`),
|
||||
KEY `pe_LogChat_playerid` (`pe_LogChat_playerid`),
|
||||
KEY `pe_LogChat_datetime` (`pe_LogChat_datetime`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19739 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogEvent`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogEvent` (
|
||||
`pe_LogEvent_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogEvent_datetime` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogEvent_missionhash_id` bigint(20) DEFAULT NULL,
|
||||
`pe_LogEvent_type` varchar(100) NOT NULL,
|
||||
`pe_LogEvent_content` text NOT NULL,
|
||||
`pe_LogEvent_arg1` varchar(150) DEFAULT NULL,
|
||||
`pe_LogEvent_arg2` varchar(150) DEFAULT NULL,
|
||||
PRIMARY KEY (`pe_LogEvent_id`),
|
||||
KEY `pe_LogEvent_missionhash_id` (`pe_LogEvent_missionhash_id`),
|
||||
KEY `pe_LogEvent_datetime` (`pe_LogEvent_datetime`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=93657 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogLogins`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogLogins` (
|
||||
`pe_LogLogins_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogLogins_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogLogins_instance` smallint(5) UNSIGNED NOT NULL,
|
||||
`pe_LogLogins_playerid` bigint(20) DEFAULT NULL,
|
||||
`pe_LogLogins_name` varchar(150) NOT NULL,
|
||||
`pe_LogLogins_ip` varchar(100) NOT NULL,
|
||||
PRIMARY KEY (`pe_LogLogins_id`),
|
||||
KEY `pe_LogLogins_playerid` (`pe_LogLogins_playerid`),
|
||||
KEY `pe_LogLogins_datetime` (`pe_LogLogins_datetime`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10742 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogStats`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogStats` (
|
||||
`pe_LogStats_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogStats_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`pe_LogStats_missionhash_id` bigint(20) DEFAULT NULL,
|
||||
`pe_LogStats_playerid` bigint(20) DEFAULT NULL,
|
||||
`pe_LogStats_typeid` int(11) DEFAULT NULL,
|
||||
`ps_kills` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_pvp` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_deaths` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_ejections` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_crashes` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_teamkills` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_planes` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_helicopters` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_air_defense` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_armor` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_unarmed` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_infantry` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_ships` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_fortification` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_kills_other` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_airfield_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_airfield_landings` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_ship_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_ship_landings` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_farp_takeoffs` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_farp_landings` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_other_landings` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`ps_other_takeoffs` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`pe_LogStats_mstatus` enum('?','RTB','MIA','KIA') DEFAULT NULL,
|
||||
`ps_takeoffs` int(10) UNSIGNED DEFAULT '0',
|
||||
`ps_landings` int(10) UNSIGNED DEFAULT '0',
|
||||
`ps_kills_AA` int(10) UNSIGNED DEFAULT '0',
|
||||
`ps_kills_AG` int(10) UNSIGNED DEFAULT '0',
|
||||
`ps_kills_AS` int(10) UNSIGNED DEFAULT '0',
|
||||
`ps_kills_AAA` int(10) UNSIGNED DEFAULT '0',
|
||||
PRIMARY KEY (`pe_LogStats_id`),
|
||||
UNIQUE KEY `UNIQUE_STATS_PER_MISSION_AND_UCID_AND_TYPE` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`,`pe_LogStats_typeid`) USING BTREE,
|
||||
KEY `pe_LogStats_missionhash_id` (`pe_LogStats_missionhash_id`),
|
||||
KEY `pe_LogStats_playerid` (`pe_LogStats_playerid`),
|
||||
KEY `pe_LogStats_typeid` (`pe_LogStats_typeid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9595 DEFAULT CHARSET=utf8;
|
||||
DROP TRIGGER IF EXISTS `pe_LogStats_UPDATE`;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER `pe_LogStats_UPDATE` BEFORE UPDATE ON `pe_LogStats` FOR EACH ROW BEGIN
|
||||
|
||||
SET NEW.ps_takeoffs = NEW.ps_airfield_takeoffs + NEW.ps_farp_takeoffs + NEW.ps_other_takeoffs + NEW.ps_ship_takeoffs;
|
||||
SET NEW.ps_landings = NEW.ps_airfield_landings + NEW.ps_farp_landings + NEW.ps_other_landings + NEW.ps_ship_landings;
|
||||
SET NEW.ps_kills_AA = NEW.ps_kills_planes + NEW.ps_kills_helicopters;
|
||||
SET NEW.ps_kills_AG = NEW.ps_kills_armor + NEW.ps_kills_unarmed + NEW.ps_kills_fortification;
|
||||
SET NEW.ps_kills_AS = NEW.ps_kills_ships;
|
||||
SET NEW.ps_kills_AAA = NEW.ps_kills_air_defense;
|
||||
|
||||
IF NEW.ps_ejections > 0 THEN
|
||||
SET NEW.pe_LogStats_mstatus = "MIA";
|
||||
ELSEIF NEW.ps_deaths > 0 THEN
|
||||
SET NEW.pe_LogStats_mstatus = "KIA";
|
||||
ELSEIF NEW.ps_landings >= NEW.ps_takeoffs THEN
|
||||
IF NEW.ps_takeoffs > 0 or NEW.ps_landings > 0 THEN
|
||||
SET NEW.pe_LogStats_mstatus = "RTB";
|
||||
ELSE
|
||||
SET NEW.pe_LogStats_mstatus = "?";
|
||||
END IF;
|
||||
ELSEIF NEW.ps_takeoffs > NEW.ps_landings and NEW.ps_ejections=0 and NEW.ps_deaths=0 THEN
|
||||
SET NEW.pe_LogStats_mstatus = "MIA";
|
||||
ELSE
|
||||
SET NEW.pe_LogStats_mstatus = "?";
|
||||
END IF;
|
||||
END
|
||||
$$
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
ALTER TABLE `pe_DataPlayers` ADD FULLTEXT KEY `pe_DataPlayers_ucid` (`pe_DataPlayers_ucid`);
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
128
README.md
@@ -1,75 +1,125 @@
|
||||

|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
# Perun for DCS World
|
||||
Included lua script extracts data from DCS World multiplayer server and sends information to TCP port and JSON file for further processing.
|
||||
|
||||
This toolset extracts data from DCS World server and export it to local json file and UDP port. **Optional** windows app puts JSON data to MySQL database.
|
||||
Additionaly windows app can be used to merge LotATC and DCS SRS data in one database making Perun for DCS World ultimate integration tool for server admins.
|
||||
Provided windows app puts received TCP packets to MySQL database; additionaly Perun windows application can be used to merge LotATC and DCS SRS data in one database making Perun for DCS World wannabe ultimate integration tool for the server admins.
|
||||
|
||||
## Getting Started
|
||||
However, this software is intended to be used by experienced users - the output is MySQL data and/or JSON file; you will need to process/display it yourself.
|
||||
|
||||
You can use this toolkit with or without Windows app. Simple DCS export scripts will create JSON file which can be used for further processing, by default this file is created in Scripts\Json folder located in your Saved Games DCS folder tree.
|
||||
|
||||
### Prerequisites
|
||||

|
||||

|
||||
|
||||
## Prerequisites
|
||||
Core:
|
||||
* For JSON Export:
|
||||
* DCS World stable or DCS World beta
|
||||
* **(Optional)** For MySQL Export:
|
||||
* MySQL server with read/write access
|
||||
* 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
|
||||
|
||||
3rd party support:
|
||||
* for [DCS SRS](https://github.com/ciribob/DCS-SimpleRadioStandalone/releases) integration location of the clients-list.json file and SRS configuration with JSON data export enabled - see [SRS documentation](https://github.com/ciribob/DCS-SimpleRadioStandalone/wiki)
|
||||
* for [LotATC](https://www.lotatc.com/) integration location of the stats.json file and LotATC configuration with JSON data export enabled - see [LotATC documentation](https://www.lotatc.com/documentation/server_configuration.html)
|
||||
3rd party applications support:
|
||||
* for [DCS SRS](https://github.com/ciribob/DCS-SimpleRadioStandalone/releases) integration location of the clients-list.json file will be required (by default: SRS Server folder), "Auto Export List" option has to be enabled - see [SRS documentation](https://github.com/ciribob/DCS-SimpleRadioStandalone/wiki)
|
||||
* for [LotATC](https://www.lotatc.com/) you will need location of stats.json file and proper LotATC configuration with JSON data export enabled - see [LotATC documentation](https://www.lotatc.com/documentation/server_configuration.html)
|
||||
|
||||
### Installing
|
||||
## Installing
|
||||
* Download latest [release](https://github.com/szporwolik/perun/releases)
|
||||
* Copy contents of [01_DCS](https://github.com/szporwolik/perun/tree/master/01_DCS) to your \Scripts folder (located inside DCS folder in your Saved Games)
|
||||
* **optionaly** create MySQL database using SQL script located in [03_MySQL](https://github.com/szporwolik/perun/tree/master/03_MySQL); note that you need just a one database per DCS server machine - multiple instances pushing data to the one database are supported
|
||||
|
||||
* Download latest [release](https://github.com/szporwolik/perun/releases) **optionaly** together with Win32 binary file for MySQL export
|
||||
* Copy contents of DCS folder to you \Scripts folder (inside DCS folder in your Saved Games)
|
||||
* create MySQL server 03_MySQL folder contains creation SQL file
|
||||
* **optionaly** Run the Win32 application
|
||||
* set MySQL connection data
|
||||
* point LotATC json file location
|
||||
* point DCS SRS json file location
|
||||
* click connect and leave the app running
|
||||
## Running
|
||||
* Start DCS World and host multiplayer session
|
||||
* by default the JSON is written into Scripts\Json folder located in your Saved Games DCS folder tree
|
||||
* by default the UDP port 48620 is in use as target
|
||||
* by default the TCP port 48620 is in use as target port
|
||||
* **optionaly** run the Win32 application
|
||||
* set MySQL connection data
|
||||
* **optionaly** point LotATC json file location
|
||||
* **optionaly** point DCS SRS json file location
|
||||
* click connect and leave the app running in the background
|
||||
* **data shall now be filling your MySQL database**
|
||||
|
||||
## Data packets
|
||||
* ID: 1, contains version information
|
||||
* ID: 2, contains status data in the following sections
|
||||
* mission
|
||||
* players
|
||||
* ID: 3, available slots list and coalitions
|
||||
* coalitions
|
||||
* slots
|
||||
* ID: 50, chat event
|
||||
* ID: 51, game event
|
||||
* ID: 100, DCS SRS's client-list.json
|
||||
* ID: 101, LotATC's stats.json
|
||||
### Windows APP - command line arguments (for expert users)
|
||||
Windows app supports command line arguments, what may be handy in case of multiple instance of DCS servers running at the same machine.
|
||||
|
||||
The following arguments are accepted (keep the order!):
|
||||
* server port (shall be the same as in the lua file!)
|
||||
* instance ID (shall be the same as in the lua file!)
|
||||
* path to SRS client-list.json
|
||||
* path to LotATC stats.json
|
||||
|
||||
Example for windows shortcut:
|
||||
```
|
||||
C:\Perun_v1\Perun.exe 48621 1 "G:\DCS SRS\clients-list.json" "C:\Users\DCS\Saved Games\DCS\Mods\tech\LotAtc\stats.json"
|
||||
```
|
||||
## Troubleshooting - FAQ
|
||||
- [I keep getting 1305 MySQL error](#i-keep-getting-1305-mysql-error)
|
||||
- [Carrier landing are not tracked correctly](#carrier-landing-are-not-tracked-correctly)
|
||||
|
||||
### I keep getting 1305 MySQL error
|
||||
That probably means that your database does not support JSON functions, you shall upgrade your MySQL server to at lease 5.7 version.
|
||||
|
||||
### Carrier landing are not tracked correctly
|
||||
DCS API does not track carrier landing natively, so there is a trick to achive that. You shall set your carrier to a propoer group name to have landings tracked.
|
||||
|
||||
# API documentation (for expert users)
|
||||
## MySQL database structure
|
||||
* table: pe_DataMissionHashes - holds mission hashes, unique hashes created per each mission start at server
|
||||
* table: pe_DataPlayers - holds players UCIDs together with last login information
|
||||
* table: pe_DataRaw - holds raw data received from perun windows app, containing debug/version information together with DCS SRS and LotATC data
|
||||
* table: pe_DataTypes - names of all model depende class names detected in DCS
|
||||
* table: pe_LogChat - holds chat history
|
||||
* table: pe_LogEvent - holds event history
|
||||
* table: pe_LogLogins - holds login to server event history
|
||||
* table: pe_LogStats - holds static information
|
||||
|
||||
## Data packets - send from lua to TCP port
|
||||
* ```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
|
||||
* 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
|
||||
* ```ID: 3```, available slots list and coalitions
|
||||
* coalitions - available coalitions
|
||||
* slots - available slots
|
||||
* ```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: 51```, game event
|
||||
* ```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: 100```, DCS SRS's client-list.json
|
||||
* ```ID: 101```, LotATC's stats.json
|
||||
|
||||
# Project information
|
||||
## Built With
|
||||
|
||||
* [VisualStudio 2017 Community](https://visualstudio.microsoft.com/vs/community/)
|
||||
* [Notepad++](https://notepad-plus-plus.org/)
|
||||
* [TortoiseGit](https://tortoisegit.org/)
|
||||
|
||||
## Contributing
|
||||
|
||||
Please contact me if you'd like to contribute.
|
||||
|
||||
## Versioning
|
||||
|
||||
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/szporwolik/perun/tags).
|
||||
|
||||
## Authors
|
||||
|
||||
* **Szymon Porwolik** - *Initial work* - [szporwolik](https://github.com/szporwolik)
|
||||
|
||||
See also the list of [contributors](https://github.com/szporwolik/perun/contributors) who participated in this project.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
|
||||
|
||||
## Acknowledgments
|
||||

|
||||
|
||||
* Thanks to [Gildia DCS](https://forum.gildia.org) Polish community of DCS World pilots.
|
||||
Thanks to [Gildia DCS](https://forum.gildia.org) Polish community of DCS World pilots.
|
||||
|
||||