mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 21:15:39 +02:00
Switched to TCP
This commit is contained in:
@@ -41,7 +41,9 @@ internal class TCPController
|
|||||||
|
|
||||||
public static void StartListen()
|
public static void StartListen()
|
||||||
{
|
{
|
||||||
Console.WriteLine("UDP Listen start");
|
Console.WriteLine("TCP Listen start");
|
||||||
|
while (!TCPController.boolDone)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Start listening to UDP
|
// Start listening to UDP
|
||||||
@@ -94,9 +96,10 @@ internal class TCPController
|
|||||||
if (e.HResult != -2147467259)
|
if (e.HResult != -2147467259)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
Console.WriteLine(e.ToString());
|
||||||
PerunHelper.LogHistoryAdd(ref arrLogHistory, "ERROR UDP - port may be in use");
|
PerunHelper.LogHistoryAdd(ref arrLogHistory, "ERROR TCP - port may be in use");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine("TCP listen stop");
|
//Console.WriteLine("TCP listen stop");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,10 +109,15 @@ namespace Perun_v1
|
|||||||
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
private void con_Button_Listen_ON_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Start listening
|
// Start listening
|
||||||
UDPController.Create(48620, ref Globals.arrLogHistory, ref arrSendBuffer);
|
//UDPController.Create(48620, ref Globals.arrLogHistory, ref arrSendBuffer);
|
||||||
UDPController.thrUDPListener = new Thread(UDPController.StartListen);
|
//UDPController.thrUDPListener = new Thread(UDPController.StartListen);
|
||||||
UDPController.thrUDPListener.Start();
|
//UDPController.thrUDPListener.Start();
|
||||||
UDPController.thrUDPListener.Name = "UDPThread";
|
//UDPController.thrUDPListener.Name = "UDPThread";
|
||||||
|
|
||||||
|
TCPController.Create(48620, ref Globals.arrLogHistory, ref arrSendBuffer);
|
||||||
|
TCPController.thrTCPListener = new Thread(TCPController.StartListen);
|
||||||
|
TCPController.thrTCPListener.Start();
|
||||||
|
TCPController.thrTCPListener.Name = "TCPThread";
|
||||||
|
|
||||||
form_Main_DisableControls(); // Disable controlls
|
form_Main_DisableControls(); // Disable controlls
|
||||||
form_Main_SaveSettings(); // Save settings
|
form_Main_SaveSettings(); // Save settings
|
||||||
@@ -131,7 +136,8 @@ namespace Perun_v1
|
|||||||
// Stop listening
|
// Stop listening
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UDPController.StopListen();
|
//UDPController.StopListen();
|
||||||
|
TCPController.StopListen();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -334,26 +340,26 @@ namespace Perun_v1
|
|||||||
if (raw_lotatc.Count > 0)
|
if (raw_lotatc.Count > 0)
|
||||||
{
|
{
|
||||||
strSRSJson = JsonConvert.SerializeObject(raw_lotatc);
|
strSRSJson = JsonConvert.SerializeObject(raw_lotatc);
|
||||||
strSRSJson = "{'type':'100','instance':'1','payload':'" + strSRSJson + "'}";
|
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + strSRSJson + "'}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strSRSJson = "{'type':'100','instance':'1','payload':{'ignore':'false'}}"; // No SRS clients connected
|
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'false'}}"; // No SRS clients connected
|
||||||
}
|
}
|
||||||
boolSRSdefault = false;
|
boolSRSdefault = false;
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#1 > SRS data loaded");
|
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data loaded");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#1 > SRS data ERROR");
|
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > SRS data ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (boolSRSdefault)
|
if (boolSRSdefault)
|
||||||
{
|
{
|
||||||
strSRSJson = "{'type':'100','instance':'1','payload':{'ignore':'true'}}";
|
strSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}";
|
||||||
}
|
}
|
||||||
DatabaseController.SendToMySql(strSRSJson);
|
DatabaseController.SendToMySql(strSRSJson);
|
||||||
|
|
||||||
@@ -365,20 +371,20 @@ namespace Perun_v1
|
|||||||
strLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
strLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||||
dynamic raw_srs = JsonConvert.DeserializeObject(strLotATCJson);
|
dynamic raw_srs = JsonConvert.DeserializeObject(strLotATCJson);
|
||||||
|
|
||||||
strLotATCJson = "{'type':'101','instance':'1','payload':'" + strLotATCJson + "'}";
|
strLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + strLotATCJson + "'}";
|
||||||
boolLotATCdefault = false;
|
boolLotATCdefault = false;
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#1 > LotATC data loaded");
|
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data loaded");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#1 > LotATC data ERROR");
|
PerunHelper.LogHistoryAdd(ref Globals.arrLogHistory, "#" + Int32.Parse(con_txt_dcs_instance.Text) + " > LotATC data ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (boolLotATCdefault)
|
if (boolLotATCdefault)
|
||||||
{
|
{
|
||||||
strLotATCJson = "{'type':'101','instance':'1','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);
|
DatabaseController.SendToMySql(strLotATCJson);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user