mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 20:35:39 +02:00
Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -5,34 +5,35 @@ 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.RefreshStatus = 15 -- base refresh rate in seconds to send status update (values lower than 60 may affect performance!)
|
||||
Perun.RefreshMission = 60 -- refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
|
||||
Perun.JsonStatusLocation = "Scripts\\Json\\" -- folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
|
||||
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 = 48621 -- (int) TCP port to send data to
|
||||
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
|
||||
Perun.Instance = 1 -- (int) Id number of instance (if multiple DCS instances are to run at the same PC)
|
||||
Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
|
||||
Perun.MOTD_L1 = "Welcome to our server!" -- (string) Message send to players connecting the server - Line 1
|
||||
Perun.MOTD_L2 = "Please use SRS radio." -- (string) Message send to players connecting the server - Line 2
|
||||
|
||||
-- ########### END OF SETTINGS ###########
|
||||
-- ###################### END OF SETTINGS - DO NOT MODIFY OUTSIDE THIS SECTION ######################
|
||||
|
||||
|
||||
-- Variable init
|
||||
Perun.Version = "v0.4.0"
|
||||
Perun.Version = "v0.8.0"
|
||||
Perun.StatusData = {}
|
||||
Perun.SlotsData = {}
|
||||
Perun.MissionData = {}
|
||||
Perun.ServerData = {}
|
||||
Perun.StatData = {}
|
||||
Perun.StatDataLastType = {}
|
||||
Perun.MissionHash=""
|
||||
Perun.lastSentStatus =0
|
||||
Perun.lastSentMission =0
|
||||
Perun.JsonStatusLocation = lfs.writedir() .. Perun.JsonStatusLocation
|
||||
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.IsServer = true --DCS.isServer( ) -- TBD looks like DCS API error, always returning True
|
||||
Perun.TCPSourcePort = Perun.TCPTargetPort + 10 + Perun.Instance - 1
|
||||
|
||||
-- ########### Helper function definitions ###########
|
||||
function stripChars(str)
|
||||
@@ -152,11 +153,35 @@ Perun.SideID2Name = function(id)
|
||||
end
|
||||
|
||||
-- ########### Main code ###########
|
||||
|
||||
Perun.AddLog = function(text)
|
||||
-- Adds logs to DCS.log file
|
||||
net.log("Perun : ".. text)
|
||||
end
|
||||
|
||||
Perun.ConnectToPerun = function ()
|
||||
Perun.AddLog("Connecting to TCP server")
|
||||
Perun.TCP = assert(Perun.socket.tcp())
|
||||
Perun.TCP:settimeout(2000)
|
||||
_, err = Perun.TCP:connect(Perun.TCPPerunHost, Perun.TCPTargetPort)
|
||||
if err then
|
||||
Perun.AddLog("TCP connection error : " .. err)
|
||||
else
|
||||
Perun.AddLog("Connected to TCP server")
|
||||
end
|
||||
end
|
||||
|
||||
Perun.SendPacket = function (data_id,temp)
|
||||
_, err = Perun.TCP:send(temp)
|
||||
|
||||
if err then
|
||||
Perun.AddLog("Packed drop " .. data_id .. ", error: " .. err)
|
||||
Perun.ConnectToPerun()
|
||||
else
|
||||
Perun.AddLog("Packet send " .. data_id)
|
||||
end
|
||||
end
|
||||
|
||||
Perun.UpdateJsonStatus = function()
|
||||
-- Updates status json file
|
||||
TempData={}
|
||||
@@ -170,7 +195,6 @@ Perun.UpdateJsonStatus = function()
|
||||
perun_export = io.open(Perun.JsonStatusLocation .. "perun_status_data.json", "w")
|
||||
perun_export:write(_temp .. "\n")
|
||||
perun_export:close()
|
||||
|
||||
end
|
||||
|
||||
Perun.Send = function(data_id, data_package)
|
||||
@@ -179,12 +203,12 @@ Perun.Send = function(data_id, data_package)
|
||||
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)
|
||||
temp=stripChars(temp)
|
||||
|
||||
Perun.UDP:send(temp)
|
||||
Perun.AddLog("Packet send")
|
||||
Perun.SendPacket(data_id,temp)
|
||||
end
|
||||
|
||||
Perun.UpdateStatusPart = function(part_id, data_package)
|
||||
@@ -237,6 +261,18 @@ Perun.UpdateStatus = function()
|
||||
|
||||
for j, i in pairs(Perun.SlotsData['coalitions']) do
|
||||
Perun.SlotsData['slots'][j]=DCS.getAvailableSlots(j)
|
||||
|
||||
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
|
||||
|
||||
end
|
||||
-- Send
|
||||
Perun.Send(3,Perun.SlotsData)
|
||||
@@ -246,6 +282,7 @@ end
|
||||
Perun.UpdateMission = function()
|
||||
-- Main function for mission information updates
|
||||
Perun.MissionData=DCS.getCurrentMission()
|
||||
-- Perun.Send(4,Perun.MissionData)
|
||||
end
|
||||
|
||||
Perun.LogChat = function(playerID,msg,all)
|
||||
@@ -262,11 +299,13 @@ Perun.LogChat = function(playerID,msg,all)
|
||||
Perun.Send(50,data)
|
||||
end
|
||||
|
||||
Perun.LogEvent = function(log_type,log_content)
|
||||
Perun.LogEvent = function(log_type,log_content,log_arg_1,log_arg_2)
|
||||
-- Log chat 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
|
||||
@@ -274,23 +313,142 @@ Perun.LogEvent = function(log_type,log_content)
|
||||
Perun.Send(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
|
||||
|
||||
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
|
||||
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 : not working at the moment WIP
|
||||
p_stats={}
|
||||
p_stats['PS_CAR']=net.get_stat(playerID,2)
|
||||
p_stats['PS_PLANE']=net.get_stat(playerID,3)
|
||||
p_stats['PS_SHIP']=net.get_stat(playerID,4)
|
||||
p_stats['PS_SCORE']=net.get_stat(playerID,5)
|
||||
p_stats['PS_LAND']=net.get_stat(playerID,6)
|
||||
p_stats['PS_PING']=net.get_stat(playerID,0)
|
||||
p_stats['PS_CRASH']=net.get_stat(playerID,1)
|
||||
p_stats['PS_EJECT']=net.get_stat(playerID,7)
|
||||
p_stats['debug']="ok"
|
||||
|
||||
|
||||
-- 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']=p_stats
|
||||
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_datetime']=os.date('%Y-%m-%d %H:%M:%S')
|
||||
data['stat_missionhash']=Perun.MissionHash
|
||||
@@ -313,16 +471,21 @@ end
|
||||
--- ########### Event callbacks ###########
|
||||
|
||||
Perun.onSimulationStart = function()
|
||||
Perun.MissionHash=DCS.getMissionName( ).."@"..os.date('%Y%m%d_%H%M%S');
|
||||
Perun.LogEvent("SimStart","Mission " .. Perun.MissionHash .. " started");
|
||||
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");
|
||||
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);
|
||||
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()
|
||||
@@ -347,15 +510,11 @@ Perun.onSimulationFrame = function()
|
||||
|
||||
Perun.UpdateStatus()
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
Perun.onPlayerStart = function (id)
|
||||
net.send_chat(Perun.MOTD_L1, id);
|
||||
net.send_chat(Perun.MOTD_L2, id);
|
||||
net.send_chat_to(Perun.MOTD_L1, id);
|
||||
net.send_chat_to(Perun.MOTD_L2, id);
|
||||
end
|
||||
|
||||
Perun.onPlayerTrySendChat = function (playerID, msg, all)
|
||||
@@ -367,38 +526,74 @@ Perun.onPlayerTrySendChat = function (playerID, msg, all)
|
||||
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,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);
|
||||
Perun.LogStats(arg1);
|
||||
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);
|
||||
|
||||
if arg1 ~= arg3 then
|
||||
-- Perun.LogStatsCount(arg1,"friendly_fire",DCS.getUnitType(net.get_player_info(arg1 , 'slot')))
|
||||
end
|
||||
|
||||
elseif eventName == "mission_end" then
|
||||
--"mission_end", winner, msg
|
||||
Perun.LogEvent(eventName,"Mission finished, 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
|
||||
if net.get_player_info(arg4, "name") ~= nil then
|
||||
_temp = " player ".. net.get_player_info(arg4, "name") .." ";
|
||||
Perun.LogStats(arg4);
|
||||
_tempX=""
|
||||
if net.get_player_info(arg4, "name") ~= nil then
|
||||
_tempX = " player ".. net.get_player_info(arg4, "name") .." ";
|
||||
|
||||
Perun.LogStats(arg4);
|
||||
else
|
||||
_temp = " AI ";
|
||||
_tempX = " AI ";
|
||||
end
|
||||
|
||||
if net.get_player_info(arg1, "name") ~= nil then
|
||||
_temp2 = " player ".. net.get_player_info(arg1, "name") .." ";
|
||||
Perun.LogStats(arg1);
|
||||
_temp2 = " player ".. net.get_player_info(arg1, "name") .." ";
|
||||
if Perun.GetCategory(arg5) == "Planes" then
|
||||
Perun.LogStatsCount(arg1,"kill_Planes",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Helicopters" then
|
||||
Perun.LogStatsCount(arg1,"kill_Helicopters",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Ships" then
|
||||
Perun.LogStatsCount(arg1,"kill_Ships",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Air Defence" then
|
||||
Perun.LogStatsCount(arg1,"kill_Air_Defence",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Unarmed" then
|
||||
Perun.LogStatsCount(arg1,"kill_Unarmed",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Armor" then
|
||||
Perun.LogStatsCount(arg1,"kill_Armor",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Infantry" then
|
||||
Perun.LogStatsCount(arg1,"kill_Infantry",arg2)
|
||||
elseif Perun.GetCategory(arg5) == "Fortification" then
|
||||
Perun.LogStatsCount(arg1,"kill_Fortification",arg2)
|
||||
else
|
||||
Perun.LogStatsCount(arg1,"kill_Other",arg2)
|
||||
end
|
||||
if net.get_player_info(arg4, "name") ~= nil and arg3 ~= arg6 then
|
||||
Perun.LogStatsCount(arg1,"kill_PvP",arg2)
|
||||
end
|
||||
|
||||
if arg3 == arg6 then
|
||||
Perun.LogStatsCount(arg1,"friendly_fire",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) .. _temp .. " in " .. arg5 .. " using " .. arg7 .. " [".. Perun.GetCategory(arg5).."]");
|
||||
|
||||
|
||||
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
|
||||
@@ -410,60 +605,81 @@ Perun.onGameEvent = function (eventName,arg1,arg2,arg3,arg4,arg5,arg6,arg7)
|
||||
_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);
|
||||
Perun.LogStats(arg1);
|
||||
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.LogLogin(arg1);
|
||||
Perun.LogEvent(eventName,"Player "..net.get_player_info(arg1, "name") .. " connected");
|
||||
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, Perun.SideID2Name(arg3) .. " player " ..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, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " crashed in " .. DCS.getUnitType(arg2));
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
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);
|
||||
Perun.LogStatsCount(arg1,"crash",DCS.getUnitType(arg2))
|
||||
elseif eventName == "eject" then
|
||||
--"eject", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " ejected " .. DCS.getUnitType(arg2));
|
||||
Perun.LogStats(arg1);
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " ejected " .. DCS.getUnitType(arg2),nil,nil);
|
||||
Perun.LogStatsCount(arg1,"eject",DCS.getUnitType(arg2));
|
||||
|
||||
elseif eventName == "takeoff" then
|
||||
--"takeoff", playerID, unit_missionID, airdromeName
|
||||
if arg3 then
|
||||
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);
|
||||
Perun.LogStats(arg1);
|
||||
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);
|
||||
|
||||
if string.find(arg3, "FARP",1,true) then
|
||||
Perun.LogStatsCount(arg1,"tookoff_FARP",DCS.getUnitType(arg2))
|
||||
elseif string.find(arg3, "CVN-74 John C. Stennis",1,true) or string.find(arg3, "LHA-1 Tarawa",1,true) then
|
||||
Perun.LogStatsCount(arg1,"tookoff_SHIP",DCS.getUnitType(arg2))
|
||||
elseif arg3 ~= "" then
|
||||
Perun.LogStatsCount(arg1,"tookoff_AIRFIELD",DCS.getUnitType(arg2))
|
||||
else
|
||||
Perun.LogStatsCount(arg1,"tookoff_OTHER",DCS.getUnitType(arg2))
|
||||
end
|
||||
|
||||
elseif eventName == "landing" then
|
||||
--"landing", playerID, unit_missionID, airdromeName
|
||||
if arg3 then
|
||||
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);
|
||||
Perun.LogStats(arg1);
|
||||
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);
|
||||
|
||||
if string.find(arg3, "FARP",1,true) then
|
||||
Perun.LogStatsCount(arg1,"landing_FARP",DCS.getUnitType(arg2))
|
||||
elseif string.find(arg3, "CVN-74 John C. Stennis",1,true) or string.find(arg3, "LHA-1 Tarawa",1,true) then
|
||||
Perun.LogStatsCount(arg1,"landing_SHIP",DCS.getUnitType(arg2))
|
||||
elseif arg3 ~= "" then
|
||||
Perun.LogStatsCount(arg1,"landing_AIRFIELD",DCS.getUnitType(arg2))
|
||||
else
|
||||
Perun.LogStatsCount(arg1,"landing_OTHER",DCS.getUnitType(arg2))
|
||||
end
|
||||
|
||||
elseif eventName == "pilot_death" then
|
||||
--"pilot_death", playerID, unit_missionID
|
||||
Perun.LogEvent(eventName, Perun.SideID2Name( net.get_player_info(arg1, "side")) .. " player " .. net.get_player_info(arg1, "name") .. " in " .. DCS.getUnitType(arg2) .. " died");
|
||||
Perun.LogStats(arg1);
|
||||
|
||||
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);
|
||||
Perun.LogStatsCount(arg1,"pilot_death",DCS.getUnitType(arg2))
|
||||
else
|
||||
Perun.LogEvent(eventName,"Unknown event type");
|
||||
Perun.LogEvent(eventName,"Unknown event type",nil,nil);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- ########### Finalize and set callbacks ###########
|
||||
DCS.setUserCallbacks(Perun)
|
||||
net.log("Loaded - Perun - VladMordock - " .. Perun.Version )
|
||||
if Perun.IsServer then
|
||||
DCS.setUserCallbacks(Perun)
|
||||
net.log("Perun by VladMordock was loaded: " .. Perun.Version )
|
||||
Perun.ConnectToPerun()
|
||||
end
|
||||
|
||||
@@ -1 +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
|
||||
|
||||
@@ -3,18 +3,22 @@ using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
internal class DatabaseController
|
||||
public class DatabaseController
|
||||
{
|
||||
public static string strMySQLConnectionString; // MySQL connection string
|
||||
public string strMySQLConnectionString; // MySQL connection string
|
||||
public MySqlConnection connMySQL;
|
||||
public bool bStatus;
|
||||
|
||||
public static void SendToMySql(string strRawUDPFrame)
|
||||
public void SendToMySql(string strRawUDPFrame)
|
||||
{
|
||||
// Main function to send data to mysql
|
||||
dynamic strUDPFrame = JsonConvert.DeserializeObject(strRawUDPFrame); // Deserialize raw data
|
||||
string strUDPFrameType = strUDPFrame.type;
|
||||
string strUDPFrameTimestamp = strUDPFrame.timestamp;
|
||||
string strUDPFramePayload = "";
|
||||
string strSQLQueryTxt = "";
|
||||
string strUDPFrameInstance = strUDPFrame.instance;
|
||||
string strUDPFramePayload;
|
||||
string strUDPFramePayload_Perun;
|
||||
string strSQLQueryTxt;
|
||||
|
||||
|
||||
// Some frames may come without timestamp, use database currrent timestampe then
|
||||
@@ -39,28 +43,30 @@ internal class DatabaseController
|
||||
// Add entry to chat log
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.ucid + "' );";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated` = " + strUDPFrameTimestamp + ",`pe_DataPlayers_lastname`='" + strUDPFrame.payload.player + "' WHERE `pe_DataPlayers_ucid`='" + strUDPFrame.payload.ucid + "' ;";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`) SELECT '" + strUDPFrame.payload.missionhash + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + strUDPFrame.payload.missionhash + "' );";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "';";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` ='" + strUDPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`="+ strUDPFrameInstance + ");";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + " ;";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_LogChat` (`pe_LogChat_id`,`pe_LogChat_datetime`, `pe_LogChat_playerid`, `pe_LogChat_msg`, `pe_LogChat_all`,`pe_LogChat_missionhash_id`) VALUES (NULL,'" + strUDPFrame.payload.datetime + "', (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.ucid + "'), '" + strUDPFrame.payload.msg + "', '" + strUDPFrame.payload.all + "',(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.missionhash + "'));";
|
||||
}
|
||||
else if (strUDPFrameType == "51")
|
||||
{
|
||||
// Add entry to event log
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`) SELECT '" + strUDPFrame.payload.log_missionhash + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "');";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "';";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ( NULL, '" + strUDPFrame.payload.log_datetime + "', '" + strUDPFrame.payload.log_type + "', '" + strUDPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "'));";
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.log_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ";";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_LogEvent` (`pe_LogEvent_arg1`,`pe_LogEvent_arg2`,`pe_LogEvent_id`, `pe_LogEvent_datetime`, `pe_LogEvent_type`, `pe_LogEvent_content`,`pe_LogEvent_missionhash_id`) VALUES ('"+ strUDPFrame.payload.log_arg_1 + "','"+ strUDPFrame.payload.log_arg_2 + "', NULL, '" + strUDPFrame.payload.log_datetime + "', '" + strUDPFrame.payload.log_type + "', '" + strUDPFrame.payload.log_content + "', (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.log_missionhash + "'));";
|
||||
}
|
||||
else if (strUDPFrameType == "52")
|
||||
{
|
||||
// Update user stats
|
||||
strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload.stat_data); // Deserialize payload
|
||||
strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload.stat_data_dcs); // Deserialize payload
|
||||
strUDPFramePayload_Perun = JsonConvert.SerializeObject(strUDPFrame.payload.stat_data_perun); // Deserialize payload
|
||||
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`) SELECT '" + strUDPFrame.payload.stat_missionhash + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "');";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "';";
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataMissionHashes` (`pe_DataMissionHashes_hash`,`pe_DataMissionHashes_instance`) SELECT '" + strUDPFrame.payload.stat_missionhash + "','" + strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataMissionHashes` where `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + ");";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataMissionHashes` SET `pe_DataMissionHashes_datetime` = " + strUDPFrameTimestamp + " WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "' AND `pe_DataMissionHashes_instance`=" + strUDPFrameInstance + " ;";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.stat_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "');";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET `pe_DataPlayers_updated`=" + strUDPFrameTimestamp + " WHERE `pe_DataPlayers_ucid`='" + strUDPFrame.payload.stat_ucid + "';";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_LogStats` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`) SELECT (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') 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` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "') );";
|
||||
strSQLQueryTxt += "UPDATE `pe_LogStats` SET `pe_LogStats_datetime`='" + strUDPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'),`pe_LogStats_debug`=JSON_QUOTE('" + strUDPFramePayload + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "');";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_DataTypes` (`pe_DataTypes_name`) SELECT '" + strUDPFrame.payload.stat_data_type + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + strUDPFrame.payload.stat_data_type + "');";
|
||||
strSQLQueryTxt += "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` = '" + strUDPFrame.payload.stat_ucid + "'), (SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "'), (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + strUDPFrame.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` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`= (SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + strUDPFrame.payload.stat_data_type + "'));";
|
||||
strSQLQueryTxt += "UPDATE `pe_LogStats` SET `ps_kills_fortification`=" + strUDPFrame.payload.stat_data_perun.ps_kills_fortification + ",`ps_other_landings`=" + strUDPFrame.payload.stat_data_perun.ps_other_landings + ",`ps_other_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_other_takeoffs + ",`ps_pvp`=" + strUDPFrame.payload.stat_data_perun.ps_pvp + ",`ps_deaths`=" + strUDPFrame.payload.stat_data_perun.ps_deaths + ",`ps_ejections`=" + strUDPFrame.payload.stat_data_perun.ps_ejections + ",`ps_crashes`=" + strUDPFrame.payload.stat_data_perun.ps_crashes + ",`ps_teamkills`=" + strUDPFrame.payload.stat_data_perun.ps_teamkills + ",`ps_kills_planes`=" + strUDPFrame.payload.stat_data_perun.ps_kills_planes + ",`ps_kills_helicopters`=" + strUDPFrame.payload.stat_data_perun.ps_kills_helicopters + ",`ps_kills_air_defense`=" + strUDPFrame.payload.stat_data_perun.ps_kills_air_defense + ",`ps_kills_armor`=" + strUDPFrame.payload.stat_data_perun.ps_kills_armor + ",`ps_kills_unarmed`=" + strUDPFrame.payload.stat_data_perun.ps_kills_unarmed + ",`ps_kills_infantry`=" + strUDPFrame.payload.stat_data_perun.ps_kills_infantry + ",`ps_kills_ships`=" + strUDPFrame.payload.stat_data_perun.ps_kills_ships + ",`ps_kills_other`=" + strUDPFrame.payload.stat_data_perun.ps_kills_other + ",`ps_airfield_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_airfield_takeoffs + ",`ps_airfield_landings`=" + strUDPFrame.payload.stat_data_perun.ps_airfield_landings + ",`ps_ship_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_ship_takeoffs + ",`ps_ship_landings`=" + strUDPFrame.payload.stat_data_perun.ps_ship_landings + ",`ps_farp_takeoffs`=" + strUDPFrame.payload.stat_data_perun.ps_farp_takeoffs + ",`ps_farp_landings`=" + strUDPFrame.payload.stat_data_perun.ps_farp_landings + ", `pe_LogStats_datetime`='" + strUDPFrame.payload.stat_datetime + "',`pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "'),`pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') WHERE `pe_LogStats_missionhash_id`=(SELECT `pe_DataMissionHashes_id` FROM `pe_DataMissionHashes` WHERE `pe_DataMissionHashes_hash` = '" + strUDPFrame.payload.stat_missionhash + "') AND `pe_LogStats_playerid` = (SELECT `pe_DataPlayers_id` from `pe_DataPlayers` WHERE `pe_DataPlayers_ucid` = '" + strUDPFrame.payload.stat_ucid + "') AND `pe_LogStats_typeid`=(SELECT pe_DataTypes_id FROM `pe_DataTypes` where `pe_DataTypes_name` = '" + strUDPFrame.payload.stat_data_type + "');";
|
||||
}
|
||||
else if (strUDPFrameType == "53")
|
||||
{
|
||||
@@ -68,58 +74,70 @@ internal class DatabaseController
|
||||
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataPlayers` (`pe_DataPlayers_ucid`) SELECT '" + strUDPFrame.payload.login_ucid + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataPlayers` where pe_DataPlayers_ucid='" + strUDPFrame.payload.login_ucid + "');";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataPlayers` SET pe_DataPlayers_lastip='" + strUDPFrame.payload.login_ipaddr + "', pe_DataPlayers_lastname='" + strUDPFrame.payload.login_name + "',pe_DataPlayers_updated='" + strUDPFrame.payload.login_datetime + "' WHERE `pe_DataPlayers_ucid`= '" + strUDPFrame.payload.login_ucid + "';";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`) VALUES ('" + strUDPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + strUDPFrame.payload.login_ucid + "'), '" + strUDPFrame.payload.login_name + "', '" + strUDPFrame.payload.login_ipaddr + "');";
|
||||
strSQLQueryTxt += "INSERT INTO `pe_LogLogins` (`pe_LogLogins_datetime`, `pe_LogLogins_playerid`, `pe_LogLogins_name`, `pe_LogLogins_ip`,`pe_LogLogins_instance`) VALUES ('" + strUDPFrame.payload.login_datetime + "', (SELECT pe_DataPlayers_id from pe_DataPlayers WHERE pe_DataPlayers_ucid = '" + strUDPFrame.payload.login_ucid + "'), '" + strUDPFrame.payload.login_name + "', '" + strUDPFrame.payload.login_ipaddr + "','"+ strUDPFrameInstance + "');";
|
||||
}
|
||||
else
|
||||
{
|
||||
// General definition used for 1-10 type packets
|
||||
strUDPFramePayload = JsonConvert.SerializeObject(strUDPFrame.payload); // Deserialize payload
|
||||
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`) SELECT '" + strUDPFrameType + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE pe_dataraw_type = '" + strUDPFrameType + "' );";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = JSON_QUOTE('" + strUDPFramePayload + "'), `pe_dataraw_updated`=" + strUDPFrameTimestamp + " WHERE `pe_dataraw_type`=" + strUDPFrameType + ";";
|
||||
strSQLQueryTxt = "INSERT INTO `pe_DataRaw` (`pe_dataraw_type`,`pe_dataraw_instance`) SELECT '" + strUDPFrameType + "','"+ strUDPFrameInstance + "' FROM DUAL WHERE NOT EXISTS (SELECT * FROM `pe_DataRaw` WHERE `pe_dataraw_type` = '" + strUDPFrameType + "' AND `pe_dataraw_instance` = " + strUDPFrameInstance + ");";
|
||||
strSQLQueryTxt += "UPDATE `pe_DataRaw` SET `pe_dataraw_payload` = JSON_QUOTE('" + strUDPFramePayload + "'), `pe_dataraw_updated`=" + strUDPFrameTimestamp + " WHERE `pe_dataraw_type`=" + strUDPFrameType + " AND `pe_dataraw_instance` = "+ strUDPFrameInstance + ";";
|
||||
}
|
||||
|
||||
// Connect to mysql and execute sql
|
||||
MySqlConnection connMySQL = new MySqlConnection(DatabaseController.strMySQLConnectionString);
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Sending data to MySQL - Begin");
|
||||
connMySQL.Open();
|
||||
connMySQL = new MySqlConnection(strMySQLConnectionString);
|
||||
|
||||
MySqlCommand cmdMySQL = new MySqlCommand(strSQLQueryTxt, connMySQL);
|
||||
MySqlDataReader rdrMySQL = cmdMySQL.ExecuteReader();
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Sending data to MySQL - Begin");
|
||||
connMySQL.Open();
|
||||
bStatus = true;
|
||||
MySqlCommand cmdMySQL = new MySqlCommand(strSQLQueryTxt, connMySQL);
|
||||
MySqlDataReader rdrMySQL = cmdMySQL.ExecuteReader();
|
||||
|
||||
while (rdrMySQL.Read())
|
||||
{
|
||||
Console.WriteLine(rdrMySQL[0] + " -- " + rdrMySQL[1]);
|
||||
while (rdrMySQL.Read())
|
||||
{
|
||||
Console.WriteLine(rdrMySQL[0] + " -- " + rdrMySQL[1]);
|
||||
}
|
||||
rdrMySQL.Close();
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + strUDPFrameInstance + " > MySQL updated, package type: " + strUDPFrameType);
|
||||
}
|
||||
rdrMySQL.Close();
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "MySQL updated, package type: " + strUDPFrameType);
|
||||
}
|
||||
catch (ArgumentException a_ex)
|
||||
{
|
||||
// General exception found
|
||||
Console.WriteLine(a_ex.ToString());
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType);
|
||||
}
|
||||
catch (MySqlException m_ex)
|
||||
{
|
||||
// MySQL exception found
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType);
|
||||
switch (m_ex.Number)
|
||||
catch (ArgumentException a_ex)
|
||||
{
|
||||
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - unable to connect");
|
||||
break;
|
||||
case 0: // Access denied (Check DB name,username,password)
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - access denied");
|
||||
break;
|
||||
default:
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - " + m_ex.Number);
|
||||
break;
|
||||
// General exception found
|
||||
Console.WriteLine(a_ex.ToString());
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType);
|
||||
bStatus = false;
|
||||
}
|
||||
catch (MySqlException m_ex)
|
||||
{
|
||||
// MySQL exception found
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - package type: " + strUDPFrameType);
|
||||
switch (m_ex.Number)
|
||||
{
|
||||
case 1042: // Unable to connect to any of the specified MySQL hosts (Check Server,Port)
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - unable to connect");
|
||||
break;
|
||||
case 0: // Access denied (Check DB name,username,password)
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - access denied");
|
||||
break;
|
||||
default:
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - " + m_ex.Number);
|
||||
break;
|
||||
}
|
||||
bStatus = false;
|
||||
}
|
||||
connMySQL.Close();
|
||||
Console.WriteLine("Sending data to MySQL - Done");
|
||||
}
|
||||
connMySQL.Close();
|
||||
Console.WriteLine("Sending data to MySQL - Done");
|
||||
catch (ArgumentException)
|
||||
{
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "ERROR MySQL - wrong connection parameters");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
// This class gathers all global variables
|
||||
// This class gathers all global variable
|
||||
using MySql.Data.MySqlClient;
|
||||
|
||||
internal class Globals
|
||||
{
|
||||
public static string strPerunVersion = "DEBUG"; // Helper for pulling version definition
|
||||
public static string[] arrLogHistory = new string[10]; // Log history for GUI
|
||||
}
|
||||
public static string strPerunTitleText = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -11,37 +11,21 @@ namespace Perun_v1
|
||||
/// </summary>
|
||||
|
||||
// Mutex to block multiple instances
|
||||
static Mutex mutex = new Mutex(true, "{5a710507-92e9-4664-9b91-918b8b82f107}");
|
||||
//static Mutex mutex = new Mutex(true, "{5a710507-92e9-4664-9b91-918b8b82f107}");
|
||||
|
||||
[STAThread]
|
||||
|
||||
static void Main()
|
||||
{
|
||||
// Check if no other instances running
|
||||
if (mutex.WaitOne(TimeSpan.Zero, true))
|
||||
{
|
||||
// Only instance
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
|
||||
|
||||
void Application_ApplicationExit(object sender, EventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.Save(); // We will save settings on exit
|
||||
}
|
||||
Application.Run(new form_Main()); // Run main form
|
||||
mutex.ReleaseMutex(); // Release mutex
|
||||
}
|
||||
else
|
||||
void Application_ApplicationExit(object sender, EventArgs e)
|
||||
{
|
||||
// Multiple instance - send our Win32 message to make the currently running instance jump to front
|
||||
NativeMethods.PostMessage(
|
||||
(IntPtr)NativeMethods.HWND_BROADCAST,
|
||||
NativeMethods.WM_SHOWME,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero);
|
||||
MessageBox.Show("Only one Perun instance is allowed.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
Properties.Settings.Default.Save(); // We will save settings on exit
|
||||
}
|
||||
Application.Run(new form_Main()); // Run main form
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
146
02_Windows_App/Perun_v1/01_Classes/TCPController.cs
Normal file
146
02_Windows_App/Perun_v1/01_Classes/TCPController.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
// This class handles TCP communication
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class TCPController
|
||||
{
|
||||
// Main class for TCP listener
|
||||
public int intListenPort; // Port to connect to
|
||||
public bool bDone; // Helper to exit main loop without killing thread
|
||||
public string[] arrLogHistory; // Log history for GUI
|
||||
public string[] arrSendBuffer; // Mysql send buffer
|
||||
public Thread thrTCPListener; // Seperate thread for TCP
|
||||
public bool bStatus; // TCP connecion status
|
||||
|
||||
public void Create(int par_intListenPort, ref string[] par_arrLogHistory, ref string[] par_arrSendBuffer)
|
||||
{
|
||||
// Create class
|
||||
intListenPort = par_intListenPort;
|
||||
arrLogHistory = par_arrLogHistory;
|
||||
arrSendBuffer = par_arrSendBuffer;
|
||||
bDone = false;
|
||||
bStatus = false;
|
||||
}
|
||||
|
||||
public void StopListen()
|
||||
{
|
||||
// Finish listening
|
||||
bDone = true;
|
||||
bStatus = false;
|
||||
|
||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
||||
{
|
||||
arrSendBuffer[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartListen()
|
||||
{
|
||||
NetworkStream ns=null;
|
||||
TcpClient tcpClient=null;
|
||||
|
||||
while (!bDone)
|
||||
{
|
||||
Console.WriteLine("TCP Listen start");
|
||||
TcpListener tcpServer = new TcpListener(IPAddress.Any, intListenPort); ; // Listener object
|
||||
|
||||
try
|
||||
{
|
||||
// Start listening to TCP
|
||||
string strReceivedData;
|
||||
|
||||
// Start the main loop
|
||||
tcpServer.Start();
|
||||
bStatus = true;
|
||||
while (!bDone)
|
||||
{
|
||||
// Start listening
|
||||
|
||||
Console.WriteLine("TCP: Waiting for packet");
|
||||
tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it
|
||||
ns = tcpClient.GetStream(); //networkstream is used to send/receive messages
|
||||
//ns.ReadTimeout = 100;
|
||||
|
||||
while (tcpClient.Connected && !bDone) //while the client is connected, we look for incoming messages
|
||||
{
|
||||
StringBuilder CompleteMessage = new StringBuilder();
|
||||
|
||||
if (ns.CanRead)
|
||||
{
|
||||
byte[] ReadBuffer = new byte[1024];
|
||||
CompleteMessage = new StringBuilder();
|
||||
int numberOfBytesRead = 0;
|
||||
|
||||
// Incoming message may be larger than the buffer size.
|
||||
do
|
||||
{
|
||||
numberOfBytesRead = ns.Read(ReadBuffer, 0, ReadBuffer.Length);
|
||||
CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead));
|
||||
}
|
||||
while (ns.DataAvailable && !bDone);
|
||||
}
|
||||
strReceivedData = CompleteMessage.ToString();
|
||||
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
||||
|
||||
try
|
||||
{
|
||||
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
||||
string strRawTCPFrameType = dynamicRawTCPFrame.type;
|
||||
|
||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP packet received, type: " + strRawTCPFrameType);
|
||||
|
||||
// Add to mySQL send buffer (find first empty slot)
|
||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
||||
{
|
||||
if (arrSendBuffer[i] == null)
|
||||
{
|
||||
arrSendBuffer[i] = strReceivedData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP ERROR incorrect JSON");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
tcpServer.Stop();
|
||||
bStatus = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// General exception found
|
||||
if (e.HResult != -2147467259)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "TCP error - connection closed or port in use");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!(ns is null))
|
||||
{
|
||||
ns.Flush();
|
||||
ns.Close();
|
||||
}
|
||||
if (!(tcpClient is null))
|
||||
{
|
||||
tcpClient.Close();
|
||||
}
|
||||
if (!(tcpServer is null))
|
||||
{
|
||||
tcpServer.Stop();
|
||||
}
|
||||
bStatus = false;
|
||||
Console.WriteLine("TCP listen stop");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
// This class handles UDP communication
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
internal class UDPController
|
||||
{
|
||||
// Main class for UDP listener
|
||||
public static int intListenPort; // Port to listen at
|
||||
public static bool boolDone; // Helper to exit main loop without killing thread
|
||||
public static UdpClient udpListener; // Listener object
|
||||
public static string[] arrLogHistory; // Log history for GUI
|
||||
public static string[] arrSendBuffer; // Mysql send buffer
|
||||
public static Thread thrUDPListener; // Seperate thread for UDP
|
||||
|
||||
public static void Create(int intListenPort, ref string[] arrLogHistory, ref string[] arrSendBuffer)
|
||||
{
|
||||
// Create class
|
||||
UDPController.intListenPort = intListenPort;
|
||||
UDPController.arrLogHistory = arrLogHistory;
|
||||
UDPController.arrSendBuffer = arrSendBuffer;
|
||||
}
|
||||
|
||||
public static void StopListen()
|
||||
{
|
||||
// FInish listening
|
||||
UDPController.boolDone = true;
|
||||
UDPController.udpListener.Close();
|
||||
UDPController.udpListener = null;
|
||||
|
||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
||||
{
|
||||
arrSendBuffer[i] = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void StartListen()
|
||||
{
|
||||
Console.WriteLine("UDP Listen start");
|
||||
try
|
||||
{
|
||||
// Start listening to UDP
|
||||
|
||||
udpListener = new UdpClient(intListenPort);
|
||||
IPEndPoint ipendpointGroupEP = new IPEndPoint(IPAddress.Loopback, intListenPort);
|
||||
string strReceivedData;
|
||||
byte[] arrReceiveByteArray;
|
||||
|
||||
// Start the main loop
|
||||
UDPController.boolDone = false;
|
||||
while (!UDPController.boolDone)
|
||||
{
|
||||
// Start listening
|
||||
Console.WriteLine("UDP: Waiting for packet");
|
||||
arrReceiveByteArray = udpListener.Receive(ref ipendpointGroupEP);
|
||||
strReceivedData = Encoding.ASCII.GetString(arrReceiveByteArray, 0, arrReceiveByteArray.Length);
|
||||
Console.WriteLine("Sender: {0} Payload: {1}", ipendpointGroupEP.ToString(), strReceivedData);
|
||||
|
||||
// Add to log history and rotate
|
||||
dynamic dynamicRawUDPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
||||
string strRawUDPFrameType = dynamicRawUDPFrame.type;
|
||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "UDP packet received, type: " + strRawUDPFrameType);
|
||||
|
||||
// Add to mySQL send buffer (find first empty slot)
|
||||
for (int i = 0; i < arrSendBuffer.Length - 1; i++)
|
||||
{
|
||||
if (arrSendBuffer[i] == null)
|
||||
{
|
||||
arrSendBuffer[i] = strReceivedData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
udpListener.Close(); // Close port
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// General exception found
|
||||
if (e.HResult != -2147467259) {
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "ERROR UDP - port may be in use");
|
||||
}
|
||||
}
|
||||
Console.WriteLine("UDP listen stop");
|
||||
}
|
||||
}
|
||||
145
02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
generated
145
02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs
generated
@@ -60,9 +60,23 @@
|
||||
this.tim_10000ms = new System.Windows.Forms.Timer(this.components);
|
||||
this.tim_200ms = new System.Windows.Forms.Timer(this.components);
|
||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(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.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_GroupBox_1.SuspendLayout();
|
||||
this.con_GroupBox_2.SuspendLayout();
|
||||
this.con_GroupBox_3.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((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
|
||||
@@ -70,42 +84,42 @@
|
||||
this.con_List_Received.Enabled = false;
|
||||
this.con_List_Received.FormattingEnabled = true;
|
||||
this.con_List_Received.Items.AddRange(new object[] {
|
||||
"Welcome to Perun for DCS World!"});
|
||||
"Not connected"});
|
||||
this.con_List_Received.Location = new System.Drawing.Point(6, 19);
|
||||
this.con_List_Received.Name = "con_List_Received";
|
||||
this.con_List_Received.Size = new System.Drawing.Size(307, 134);
|
||||
this.con_List_Received.Size = new System.Drawing.Size(307, 147);
|
||||
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, 553);
|
||||
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, 553);
|
||||
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, 369);
|
||||
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, 176);
|
||||
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
|
||||
//
|
||||
@@ -142,7 +156,6 @@
|
||||
//
|
||||
// con_txt_mysql_port
|
||||
//
|
||||
this.con_txt_mysql_port.Enabled = false;
|
||||
this.con_txt_mysql_port.Location = new System.Drawing.Point(106, 45);
|
||||
this.con_txt_mysql_port.Name = "con_txt_mysql_port";
|
||||
this.con_txt_mysql_port.Size = new System.Drawing.Size(207, 20);
|
||||
@@ -219,12 +232,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(12, 261);
|
||||
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
|
||||
//
|
||||
@@ -264,7 +277,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, 553);
|
||||
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;
|
||||
@@ -324,15 +337,102 @@
|
||||
this.notifyIcon1.Text = "notifyIcon1";
|
||||
this.notifyIcon1.Visible = true;
|
||||
//
|
||||
// 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(12, 187);
|
||||
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;
|
||||
//
|
||||
// con_img_lotATC
|
||||
//
|
||||
this.con_img_lotATC.Location = new System.Drawing.Point(307, 335);
|
||||
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(272, 335);
|
||||
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(237, 335);
|
||||
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(202, 335);
|
||||
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;
|
||||
//
|
||||
// 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, 604);
|
||||
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);
|
||||
@@ -351,6 +451,12 @@
|
||||
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_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();
|
||||
|
||||
@@ -388,6 +494,15 @@
|
||||
private System.Windows.Forms.TextBox con_txt_mysql_port;
|
||||
private System.Windows.Forms.Timer tim_200ms;
|
||||
private System.Windows.Forms.NotifyIcon notifyIcon1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
@@ -9,17 +10,62 @@ namespace Perun_v1
|
||||
public partial class form_Main : Form
|
||||
{
|
||||
// Variable definitions
|
||||
public string[] arrSendBuffer = new string[100]; // Mysql send buffer
|
||||
public bool boolLetMeOut = false; // Helper to handle system tray
|
||||
public string[] arrSendBuffer = new string[65534]; // MySQL send buffer
|
||||
public bool bLetMeOut = false; // Helper to handle system tray
|
||||
|
||||
public DatabaseController dcConnection = new DatabaseController(); // MySQL controller
|
||||
public TCPController tcpcServer=new TCPController(); // TCP controller
|
||||
|
||||
public bool bSRSStatus; // Use empty/default SRS status
|
||||
public bool bLotATCStatus; // Use empty/default LotATC status
|
||||
|
||||
// ################################ Main ################################
|
||||
private void form_Main_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Form loaded - fill controls with default values
|
||||
|
||||
Globals.arrLogHistory[0] = DateTime.Now.ToString("HH:mm:ss") + " > " + "Perun started";
|
||||
form_Main_LoadSettings(); // Load settings
|
||||
this.Text = PerunHelper.GetAppVersion(this.Text + " - "); // Display build version in title bar
|
||||
|
||||
Globals.strPerunTitleText = PerunHelper.GetAppVersion(this.Text + " - "); // Display build version in title bar
|
||||
this.Text = Globals.strPerunTitleText;
|
||||
|
||||
form_Main_LoadSettings(); // Load settings
|
||||
|
||||
// Use command line parameters
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
// server port
|
||||
if (args[1] != null)
|
||||
{
|
||||
con_txt_dcs_server_port.Text = args[1];
|
||||
}
|
||||
}
|
||||
if (args.Length > 2)
|
||||
{
|
||||
// instance id
|
||||
if (args[2] != null)
|
||||
{
|
||||
con_txt_dcs_instance.Text = args[2];
|
||||
}
|
||||
}
|
||||
if (args.Length > 3)
|
||||
{
|
||||
// srs
|
||||
if (args[3] != null)
|
||||
{
|
||||
con_txt_3rd_srs.Text = args[3];
|
||||
con_check_3rd_srs.Checked = true;
|
||||
}
|
||||
}
|
||||
if (args.Length > 4)
|
||||
{
|
||||
// lotatc
|
||||
if (args[4] != null)
|
||||
{
|
||||
con_txt_3rd_lotatc.Text = args[4];
|
||||
con_check_3rd_lotatc.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public form_Main()
|
||||
@@ -41,6 +87,9 @@ namespace Perun_v1
|
||||
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()
|
||||
@@ -57,6 +106,8 @@ namespace Perun_v1
|
||||
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();
|
||||
}
|
||||
@@ -75,6 +126,8 @@ namespace Perun_v1
|
||||
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_EnableControls()
|
||||
@@ -82,57 +135,90 @@ namespace Perun_v1
|
||||
// Enables 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; // TBD - protect against writting text in the port field
|
||||
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
|
||||
UDPController.Create(48620, ref Globals.arrLogHistory, ref arrSendBuffer);
|
||||
UDPController.thrUDPListener = new Thread(UDPController.StartListen);
|
||||
UDPController.thrUDPListener.Start();
|
||||
UDPController.thrUDPListener.Name = "UDPThread";
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "Opening connections");
|
||||
tcpcServer.Create(Int32.Parse(con_txt_dcs_server_port.Text), ref Globals.arrLogHistory, ref arrSendBuffer);
|
||||
tcpcServer.thrTCPListener = new Thread(tcpcServer.StartListen);
|
||||
tcpcServer.thrTCPListener.Start();
|
||||
tcpcServer.thrTCPListener.Name = "TCPThread";
|
||||
|
||||
form_Main_DisableControls(); // Disable controlls
|
||||
form_Main_SaveSettings(); // Save settings
|
||||
form_Main_DisableControls(); // Disable controlls
|
||||
form_Main_SaveSettings(); // Save settings
|
||||
|
||||
// Prepare connection string
|
||||
DatabaseController.strMySQLConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
|
||||
dcConnection.strMySQLConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text;
|
||||
|
||||
// Start timmers
|
||||
tim_200ms.Enabled = true;
|
||||
tim_1000ms.Enabled = true;
|
||||
tim_10000ms.Enabled = true;
|
||||
|
||||
// Send initial data
|
||||
tim_10000ms_Tick(null, null);
|
||||
|
||||
// Set title bar
|
||||
this.Text = "[#"+ con_txt_dcs_instance.Text + "] " + Globals.strPerunTitleText;
|
||||
}
|
||||
|
||||
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Stop listening
|
||||
|
||||
// Display information
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "Closing connections");
|
||||
con_Button_Listen_OFF.Enabled = false;
|
||||
timer1_Tick(null, null);
|
||||
this.Refresh();
|
||||
Application.DoEvents();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
UDPController.StopListen();
|
||||
tcpcServer.StopListen();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
while (tcpcServer.thrTCPListener.IsAlive)
|
||||
{
|
||||
Thread.Sleep(100); //ms
|
||||
}
|
||||
form_Main_EnableControls(); // Enable controls
|
||||
|
||||
con_img_db.Image = null;
|
||||
con_img_dcs.Image = null;
|
||||
con_img_lotATC.Image = null;
|
||||
con_img_srs.Image = null;
|
||||
|
||||
// Stop timmers
|
||||
tim_1000ms.Enabled = false;
|
||||
tim_10000ms.Enabled = false;
|
||||
tim_200ms.Enabled = false;
|
||||
|
||||
// Display information about closed connections
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "Connections closed");
|
||||
timer1_Tick(null, null);
|
||||
|
||||
// Set title bar
|
||||
this.Text = Globals.strPerunTitleText;
|
||||
}
|
||||
|
||||
private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
@@ -181,7 +267,7 @@ namespace Perun_v1
|
||||
{
|
||||
form_Main_SaveSettings();
|
||||
|
||||
boolLetMeOut = true; // Save settings on exit
|
||||
bLetMeOut = true; // Save settings on exit
|
||||
this.Close(); // Allow to exit application
|
||||
}
|
||||
else if (dialogResult == DialogResult.No)
|
||||
@@ -231,7 +317,7 @@ namespace Perun_v1
|
||||
private void form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// Minimize to try on clicking "X"
|
||||
if (e.CloseReason == CloseReason.UserClosing && !boolLetMeOut)
|
||||
if (e.CloseReason == CloseReason.UserClosing && !bLetMeOut)
|
||||
{
|
||||
e.Cancel = true;
|
||||
form_Main_SendToTray(); // Send app to system tray
|
||||
@@ -266,10 +352,45 @@ namespace Perun_v1
|
||||
{
|
||||
if (arrSendBuffer[i] != null)
|
||||
{
|
||||
DatabaseController.SendToMySql(arrSendBuffer[i]);
|
||||
dcConnection.SendToMySql(arrSendBuffer[i]);
|
||||
arrSendBuffer[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Update status icons at main form
|
||||
if (dcConnection.bStatus)
|
||||
{
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_db");
|
||||
} else
|
||||
{
|
||||
con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
||||
}
|
||||
if (tcpcServer.bStatus)
|
||||
{
|
||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_game");
|
||||
}
|
||||
else
|
||||
{
|
||||
con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
||||
}
|
||||
if (bSRSStatus)
|
||||
{
|
||||
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_srs");
|
||||
}
|
||||
else
|
||||
{
|
||||
con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
||||
}
|
||||
if (bLotATCStatus)
|
||||
{
|
||||
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_lotatc");
|
||||
}
|
||||
else
|
||||
{
|
||||
con_img_lotATC.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_error");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void tim_10000ms_Tick(object sender, EventArgs e)
|
||||
@@ -281,7 +402,7 @@ namespace Perun_v1
|
||||
bool boolSRSdefault = true;
|
||||
bool boolLotATCdefault = true;
|
||||
|
||||
// Handle SRS
|
||||
// Handle SRS
|
||||
if (con_check_3rd_srs.Checked)
|
||||
{
|
||||
try
|
||||
@@ -323,30 +444,31 @@ namespace Perun_v1
|
||||
if (raw_lotatc.Count > 0)
|
||||
{
|
||||
strSRSJson = JsonConvert.SerializeObject(raw_lotatc);
|
||||
strSRSJson = "{'type':'100','payload':'" + strSRSJson + "'}";
|
||||
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + strSRSJson + "'}";
|
||||
}
|
||||
else
|
||||
{
|
||||
strSRSJson = "{'type':'100','payload':{'ignore':'false'}}"; // No SRS clients connected
|
||||
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'false'}}"; // No SRS clients connected
|
||||
}
|
||||
boolSRSdefault = false;
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "SRS data loaded");
|
||||
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data loaded");
|
||||
bSRSStatus = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "SRS data ERROR");
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data ERROR");
|
||||
bSRSStatus = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (boolSRSdefault)
|
||||
{
|
||||
strSRSJson = "{'type':'100','payload':{'ignore':'true'}}";
|
||||
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}";
|
||||
}
|
||||
DatabaseController.SendToMySql(strSRSJson);
|
||||
dcConnection.SendToMySql(strSRSJson);
|
||||
|
||||
// Handle LotATC
|
||||
// Handle LotATC
|
||||
if (con_check_3rd_lotatc.Checked)
|
||||
{
|
||||
try
|
||||
@@ -354,23 +476,24 @@ namespace Perun_v1
|
||||
strLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||
dynamic raw_srs = JsonConvert.DeserializeObject(strLotATCJson);
|
||||
|
||||
strLotATCJson = "{'type':'101','payload':'" + strLotATCJson + "'}";
|
||||
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + strLotATCJson + "'}";
|
||||
boolLotATCdefault = false;
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "LotATC data loaded");
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data loaded");
|
||||
bLotATCStatus = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "LotATC data ERROR");
|
||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data ERROR");
|
||||
bLotATCStatus = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (boolLotATCdefault)
|
||||
{
|
||||
strLotATCJson = "{'type':'101','payload':{'ignore':'true'}}"; // No LotATC controller connected
|
||||
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}"; // No LotATC controller connected
|
||||
}
|
||||
DatabaseController.SendToMySql(strLotATCJson);
|
||||
dcConnection.SendToMySql(strLotATCJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
<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>true</IsWebBootstrapper>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>ftp://s18.mydevil.net/perun/</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Web</InstallFrom>
|
||||
@@ -32,8 +33,8 @@
|
||||
<SuiteName>Perun</SuiteName>
|
||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||
<WebPage>Perun.htm</WebPage>
|
||||
<ApplicationRevision>2</ApplicationRevision>
|
||||
<ApplicationVersion>0.4.0.%2a</ApplicationVersion>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>0.8.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
@@ -74,7 +75,7 @@
|
||||
<GenerateManifests>true</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>true</SignManifests>
|
||||
<SignManifests>false</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
@@ -87,14 +88,20 @@
|
||||
<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" />
|
||||
@@ -116,7 +123,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="01_Classes\UDPController.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" />
|
||||
@@ -144,6 +151,8 @@
|
||||
</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="Properties\app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
@@ -161,7 +170,7 @@
|
||||
<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">
|
||||
@@ -172,6 +181,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="03_Resources\perun_logo.ico" />
|
||||
<None Include="Resources\ico_error.png" />
|
||||
<None Include="Resources\ico_srs.png" />
|
||||
<None Include="Resources\ico_lotatc.png" />
|
||||
<None Include="Resources\ico_game.png" />
|
||||
<None Include="Resources\ico_db.png" />
|
||||
<None Include="Resources\img_db.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -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.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.0.0")]
|
||||
[assembly: AssemblyVersion("0.8.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.0.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 ico_db {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ico_db", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ico_error {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ico_error", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ico_game {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ico_game", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ico_lotatc {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ico_lotatc", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ico_srs {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ico_srs", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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="ico_db" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ico_db.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ico_error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ico_error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ico_game" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ico_game.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ico_lotatc" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ico_lotatc.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ico_srs" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ico_srs.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</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())));
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,5 +29,11 @@
|
||||
<Setting Name="MYSQL_Port" Type="System.String" Scope="User">
|
||||
<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/ico_db.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/ico_db.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
BIN
02_Windows_App/Perun_v1/Resources/ico_error.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/ico_error.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
BIN
02_Windows_App/Perun_v1/Resources/ico_game.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/ico_game.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
BIN
02_Windows_App/Perun_v1/Resources/ico_lotatc.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/ico_lotatc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
02_Windows_App/Perun_v1/Resources/ico_srs.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/ico_srs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
02_Windows_App/Perun_v1/Resources/img_db.png
Normal file
BIN
02_Windows_App/Perun_v1/Resources/img_db.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 233 B |
45
02_Windows_App/Perun_v1/app.config
Normal file
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>
|
||||
8
02_Windows_App/Perun_v1/packages.config
Normal file
8
02_Windows_App/Perun_v1/packages.config
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<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>
|
||||
@@ -1,72 +1,53 @@
|
||||
|
||||
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 */;
|
||||
|
||||
--
|
||||
-- Baza danych: `m1081_perun`
|
||||
--
|
||||
CREATE DATABASE IF NOT EXISTS `m1081_perun` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||
USE `m1081_perun`;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_DataMissionHashes`
|
||||
--
|
||||
|
||||
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`)
|
||||
UNIQUE KEY `UNIQUE_hash` (`pe_DataMissionHashes_hash`),
|
||||
KEY `pe_DataMissionHashes_instance` (`pe_DataMissionHashes_instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_DataPlayers`
|
||||
--
|
||||
|
||||
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_lastip` varchar(100) 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 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_DataRaw`
|
||||
--
|
||||
|
||||
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`)
|
||||
PRIMARY KEY (`pe_dataraw_type`,`pe_dataraw_instance`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogChat`
|
||||
--
|
||||
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 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogChat`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogChat` (
|
||||
@@ -76,57 +57,114 @@ CREATE TABLE IF NOT EXISTS `pe_LogChat` (
|
||||
`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`)
|
||||
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 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogEvent`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogEvent`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogEvent` (
|
||||
`pe_LogEvent_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogEvent_missionhash_id` bigint(20) DEFAULT NULL,
|
||||
`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,
|
||||
PRIMARY KEY (`pe_LogEvent_id`)
|
||||
`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 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogLogins`
|
||||
--
|
||||
|
||||
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`)
|
||||
PRIMARY KEY (`pe_LogLogins_id`),
|
||||
KEY `pe_LogLogins_playerid` (`pe_LogLogins_playerid`),
|
||||
KEY `pe_LogLogins_datetime` (`pe_LogLogins_datetime`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Struktura tabeli dla tabeli `pe_LogStats`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `pe_LogStats`;
|
||||
CREATE TABLE IF NOT EXISTS `pe_LogStats` (
|
||||
`pe_LogStats_id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`pe_LogStats_missionhash_id` bigint(20) DEFAULT NULL,
|
||||
`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_debug` text,
|
||||
`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` (`pe_LogStats_playerid`,`pe_LogStats_missionhash_id`) USING BTREE
|
||||
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 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 */;
|
||||
|
||||
96
README.md
96
README.md
@@ -1,63 +1,99 @@
|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
# Perun for DCS World
|
||||
|
||||
This toolset extracts data from DCS World server and sends information to the local Json file and UDP port for further processing.
|
||||
Included lua script extracts data from DCS World multiplayer server and sends information to TCP port and JSON file for further processing.
|
||||
|
||||
Provided windows app puts received UDP 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.
|
||||
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.
|
||||
|
||||
However, this software is intended to be used by experienced users - the output is Json data and MySQL; you will need to process/display it yourself.
|
||||
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.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
### Prerequisites
|
||||
## Prerequisites
|
||||
|
||||
Core:
|
||||
* For JSON Export:
|
||||
* DCS World stable or DCS World beta
|
||||
* **(Optional)** For MySQL Export:
|
||||
* MySQL server with read/write access (tested with v5.7.21)
|
||||
* .NET Framework 4.6.1
|
||||
* MySQL database with read/write access (tested with v5.7.21)
|
||||
* .NET Framework 4.8.0
|
||||
|
||||
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), **optionaly** together with windows binary file for MySQL export - [DOWNLOAD](http://share.porwolik.com/ftp/perun/Perun.htm)
|
||||
* 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 server using SQL script located in [03_MySQL](https://github.com/szporwolik/perun/tree/master/03_MySQL)
|
||||
* **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 in the background
|
||||
* **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
|
||||
|
||||
## 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 port
|
||||
* Data shall be filling your MySQL database
|
||||
* 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/diagnostic information
|
||||
* ID: 2, contains status data in the following sections
|
||||
### 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"
|
||||
```
|
||||
|
||||
# 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
|
||||
* ```ID: 2```, contains status data in the following sections
|
||||
* mission - minimal information about mission
|
||||
* players - connected players
|
||||
* ID: 3, available slots list and coalitions
|
||||
* ```ID: 3```, available slots list and coalitions
|
||||
* coalitions - available coalitions
|
||||
* slots - available slots
|
||||
* ID: 4, stores mission data **WIP: not yet implemented**
|
||||
* ID: 50, chat event
|
||||
* ID: 51, game event
|
||||
* ID: 52, player stats **WIP: not yet implemented**
|
||||
* ID: 53, player login to DCS server
|
||||
* ID: 100, DCS SRS's client-list.json
|
||||
* ID: 101, LotATC's stats.json
|
||||
* ```ID: 4```, stores mission data
|
||||
* ```ID: 50```, chat event
|
||||
* ```ID: 51```, game event
|
||||
* ```ID: 52```, player stats
|
||||
* ```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/)
|
||||
|
||||
## used 3rd party resources
|
||||
|
||||
* [Tango Icon Library](http://tango.freedesktop.org/Tango_Icon_Library)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user