mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 15:55:39 +02:00
Code cleanup
This commit is contained in:
@@ -86,13 +86,13 @@ internal class PerunHelper
|
||||
}
|
||||
|
||||
// Add new entry
|
||||
arrLogHistory[arrLogHistory.Length - 1] = DateTime.Now.ToString("HH:mm:ss.fff") + " " + LogDirection + " " + LogType + " " + strEntryToAdd; // Add entry at the last position
|
||||
arrLogHistory[arrLogHistory.Length - 1] = $"{DateTime.Now.ToString("HH:mm:ss.fff")} {LogDirection} {LogType} {strEntryToAdd}"; // Add entry at the last position
|
||||
|
||||
// Update control at my window
|
||||
Globals.AppUpdateGUI = true;
|
||||
}
|
||||
// Add the entry to log file
|
||||
LogController.instance.WriteLog(logLevel, DateTime.Now.ToString("yyyy-MM-dd ") + " " + DateTime.Now.ToString("HH:mm:ss.fff") + " | " + Globals.HardwareMonitor.LastCurrentCpuUsage + " | " + Globals.HardwareMonitor.LastCurrentRamUsage + " | " + Globals.AppInstanceID + " | " + LogMarker + " | " + LogDirection + " | " + strType + " | " + strEntryToAdd);
|
||||
LogController.instance.WriteLog(logLevel, $"{DateTime.Now.ToString("yyyy-MM-dd ")} {DateTime.Now.ToString("HH:mm:ss.fff")} | {Globals.HardwareMonitor.LastCurrentCpuUsage} | {Globals.HardwareMonitor.LastCurrentRamUsage} | {Globals.AppInstanceID} | {LogMarker} | {LogDirection} | {strType} | {strEntryToAdd}");
|
||||
}
|
||||
|
||||
// Gets build version
|
||||
@@ -100,9 +100,9 @@ internal class PerunHelper
|
||||
{
|
||||
Globals.VersionPerun = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
#if DEBUG
|
||||
Globals.VersionPerun = Globals.VersionPerun + "(d)";
|
||||
Globals.VersionPerun = $"{Globals.VersionPerun} (DEV)";
|
||||
#endif
|
||||
return strBeginning + "v" + Globals.VersionPerun + strEnding;
|
||||
return $"{strBeginning}v{Globals.VersionPerun}{strEnding}";
|
||||
}
|
||||
|
||||
public static int CheckVersions()
|
||||
@@ -120,7 +120,7 @@ internal class PerunHelper
|
||||
if(VersionApp != Globals.VersionDatabase)
|
||||
{
|
||||
// Incorrect database version
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR Incorrect database revision : "+ Globals.VersionDatabase, 1, 1, "?");
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, $"ERROR Incorrect database revision : {Globals.VersionDatabase}", 1, 1, "?");
|
||||
Globals.ErrorsDatabase++;
|
||||
ReturnValue = 0;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ internal class PerunHelper
|
||||
if (VersionApp != Globals.VersionDCSHook)
|
||||
{
|
||||
// Incorrect dcs script version
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, "ERROR Incorrect DCS hook revision : " + Globals.VersionDCSHook, 2, 1, "?");
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, $"ERROR Incorrect DCS hook revision: {Globals.VersionDCSHook}", 2, 1, "?");
|
||||
Globals.ErrorsGame++;
|
||||
ReturnValue = 0;
|
||||
}
|
||||
@@ -143,9 +143,4 @@ internal class PerunHelper
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string ConvertSecoundsToString (Double NumberOfSecounds){
|
||||
// TBD - convert number of secounds to HHhMMm format
|
||||
return NumberOfSecounds.ToString();
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class TCPController
|
||||
// Clear send buffer
|
||||
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||
{
|
||||
arrMySQLSendBuffer[i] = null;
|
||||
arrMySQLSendBuffer[i] = null; // Empty send buffer
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class TCPController
|
||||
if (Int32.Parse(strRawTCPFrameType) != 0)
|
||||
{
|
||||
// Add to mySQL send buffer (find first empty slot)
|
||||
PerunHelper.LogDebug(ref arrGUILogHistory, "Packet received" , 2,0, strRawTCPFrameType,true);
|
||||
PerunHelper.LogDebug(ref arrGUILogHistory, "Packet received" , 2,0, strRawTCPFrameType);
|
||||
bool AddedDataToBuffer = false;
|
||||
for (int i = 0; i < arrMySQLSendBuffer.Length - 1; i++)
|
||||
{
|
||||
@@ -139,12 +139,12 @@ public class TCPController
|
||||
}
|
||||
if (!AddedDataToBuffer)
|
||||
{
|
||||
PerunHelper.LogError(ref arrGUILogHistory, "ERROR package was dropped", 1, 1, strRawTCPFrameType);
|
||||
PerunHelper.LogError(ref arrGUILogHistory, "ERROR TCP package was dropped", 1, 1, strRawTCPFrameType);
|
||||
}
|
||||
} else
|
||||
{
|
||||
// Keep alive
|
||||
PerunHelper.LogDebug(ref arrGUILogHistory, "Keep-alive received", 2,0,"0",true);
|
||||
PerunHelper.LogDebug(ref arrGUILogHistory, "Keep-alive received", 2,0,"0");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -156,7 +156,7 @@ public class TCPController
|
||||
{
|
||||
Globals.ErrorsGame++;
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.LogError(ref arrGUILogHistory, "ERROR while message parsing , error: " + e.Message,2,1,"?");
|
||||
PerunHelper.LogError(ref arrGUILogHistory, $"ERROR TCP while message parsing , error: {e.Message}",2,1,"?");
|
||||
bTCPConnectionOnline = false;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class TCPController
|
||||
catch (SocketException e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.LogError(ref arrGUILogHistory, "TCP ERROR cannot check connection, error: " + e.Message,2,1,"?");
|
||||
PerunHelper.LogError(ref arrGUILogHistory, $"ERROR TCP cannot check connection, error: {e.Message}",2,1,"?");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public class TCPController
|
||||
{
|
||||
Globals.ErrorsGame++;
|
||||
Console.WriteLine(e.ToString());
|
||||
PerunHelper.LogError(ref arrGUILogHistory, "TCP error - connection closed or port in use, error: " + e.Message,1,1,"?");
|
||||
PerunHelper.LogError(ref arrGUILogHistory, $"ERROR TCP - connection closed or port in use, error: {e.Message}",1,1,"?");
|
||||
bTCPConnectionOnline = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace Perun_v1
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, "TCP ERROR, error: " + ex.Message, 2, 1, "?");
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, $"ERROR TCP, error: {ex.Message}", 2, 1, "?");
|
||||
Console.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ namespace Perun_v1
|
||||
private void con_Button_Add_Marker_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Added user marker
|
||||
PerunHelper.LogInfo(ref Globals.AppLogHistory, "User Marker", 0, 1);
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, "User Marker", 0, 1);
|
||||
}
|
||||
|
||||
// ################################ Form state ################################
|
||||
@@ -493,7 +493,7 @@ namespace Perun_v1
|
||||
|
||||
if (Globals.CurrentMission.Pause == "True")
|
||||
{
|
||||
label21.Text = label21.Text + " (paused)";
|
||||
label21.Text = $"{label21.Text} (paused)";
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -658,7 +658,7 @@ namespace Perun_v1
|
||||
}
|
||||
|
||||
ExtSRSJson = JsonConvert.SerializeObject(raw_dcssrs);
|
||||
ExtSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + ExtSRSJson + "'}";
|
||||
ExtSRSJson = $"{{'type':'100','instance':'{Int32.Parse(con_txt_dcs_instance.Text)}','payload':'{ExtSRSJson}'}}";
|
||||
|
||||
ExtSRSUseDefault = false;
|
||||
PerunHelper.LogInfo(ref Globals.AppLogHistory, "SRS data loaded", 3, 0, "100", true);
|
||||
@@ -666,7 +666,7 @@ namespace Perun_v1
|
||||
}
|
||||
catch (Exception exc_srs)
|
||||
{
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, "SRS data ERROR , error: " + exc_srs.Message, 3, 1, "100");
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, $"ERROR SRS Data, error: {exc_srs.Message}", 3, 1, "100");
|
||||
ExtSRSStatus = false;
|
||||
Globals.ErrorsSRS++;
|
||||
}
|
||||
@@ -675,7 +675,7 @@ namespace Perun_v1
|
||||
}
|
||||
if (ExtSRSUseDefault)
|
||||
{
|
||||
ExtSRSJson = "{'type':'100','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}";
|
||||
ExtSRSJson = $"{{'type':'100','instance':'{Int32.Parse(con_txt_dcs_instance.Text)}','payload':{{'ignore':'true'}}";
|
||||
}
|
||||
if (ExtSRSStatus)
|
||||
{
|
||||
@@ -693,14 +693,14 @@ namespace Perun_v1
|
||||
ExtLotATCJson = System.IO.File.ReadAllText(con_txt_3rd_lotatc.Text);
|
||||
dynamic raw_srs = JsonConvert.DeserializeObject(ExtLotATCJson);
|
||||
|
||||
ExtLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':'" + ExtLotATCJson + "'}";
|
||||
ExtLotATCJson = $"{{'type':'101','instance':'{Int32.Parse(con_txt_dcs_instance.Text)}','payload':'{ExtLotATCJson}'}}";
|
||||
ExtLotATCUseDefault = false;
|
||||
PerunHelper.LogInfo(ref Globals.AppLogHistory, "LotATC data loaded", 3, 0, "101", true);
|
||||
ExtLotATCStatus = true;
|
||||
}
|
||||
catch (Exception exc_lotatc)
|
||||
{
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, "LotATC data ERROR, error: " + exc_lotatc.Message, 3, 1, "101");
|
||||
PerunHelper.LogError(ref Globals.AppLogHistory, $"ERROR LotATC Data, error: {exc_lotatc.Message}", 3, 1, "101");
|
||||
ExtLotATCStatus = false;
|
||||
Globals.ErrorsLotATC++;
|
||||
}
|
||||
@@ -709,7 +709,7 @@ namespace Perun_v1
|
||||
}
|
||||
if (ExtLotATCUseDefault)
|
||||
{
|
||||
ExtLotATCJson = "{'type':'101','instance':'" + Int32.Parse(con_txt_dcs_instance.Text) + "','payload':{'ignore':'true'}}"; // No LotATC controller connected
|
||||
ExtLotATCJson = $"{{'type':'101','instance':'{Int32.Parse(con_txt_dcs_instance.Text)}','payload':{{'ignore':'true'}}}}"; // No LotATC controller connected
|
||||
}
|
||||
if (ExtLotATCStatus)
|
||||
{
|
||||
@@ -728,8 +728,8 @@ namespace Perun_v1
|
||||
private void tim_HW_status_Tick(object sender, EventArgs e)
|
||||
{
|
||||
//Handle getting of system status
|
||||
label28.Text = Globals.HardwareMonitor.getCurrentCpuUsage() + "%";
|
||||
label29.Text = Globals.HardwareMonitor.getCurrentRamUsage() + "%";
|
||||
label28.Text = $"{Globals.HardwareMonitor.getCurrentCpuUsage()}%";
|
||||
label29.Text = $"{Globals.HardwareMonitor.getCurrentRamUsage()}%";
|
||||
}
|
||||
|
||||
private void TIM_Autostart_Tick(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user