From 0fc8bb4ea0ae55079b8111e1f3511054e53a3f0c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 24 Mar 2021 15:10:55 +0100 Subject: [PATCH] Route logging changed. --- TBF/Properties/AssemblyInfo.cs | 4 +-- TBF/Rig/ControlBoard/Papouch/PapouchCB.cs | 2 +- TBF/Rig/ControlBoard/Uni/GeneralData.cs | 4 +-- TBF/Rig/ControlBoard/Uni/UniCB.cs | 30 +++-------------------- TBF/Utils.cs | 25 +++++++++++++++++++ 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 79d69d114..413e8f35d 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("3.1.1609.0")] -[assembly: AssemblyFileVersion("3.1.1609.0")] +[assembly: AssemblyVersion("3.1.1610.0")] +[assembly: AssemblyFileVersion("3.1.1610.0")] diff --git a/TBF/Rig/ControlBoard/Papouch/PapouchCB.cs b/TBF/Rig/ControlBoard/Papouch/PapouchCB.cs index a03b48b48..5a2e0f301 100644 --- a/TBF/Rig/ControlBoard/Papouch/PapouchCB.cs +++ b/TBF/Rig/ControlBoard/Papouch/PapouchCB.cs @@ -282,7 +282,7 @@ namespace TBF.Rig.ControlBoard.Papouch UInt128 oldRoute = benchModelRoute; benchModelRoute = (((benchModelRoute ^ valvesToInvert) | valvesToOpen) & (~valvesToClose)) ^ valvesToInvert; foreach (var extV in extendedValves) extV.UpdateRoute(ref benchModelRoute); - log.DebugFormat("SetValves(x,x), new route = {0}", Utils.RouteToStr(benchModelRoute)); + log.DebugFormat("SetValves(x,x), new route = {0}", Utils.ToBin40((ulong)benchModelRoute)); UInt128 retVal = oldRoute ^ benchModelRoute; log.DebugFormat("{0}.SetValves({1}, {2}) returns {3}", Name, valvesToOpen.ToString("X"), valvesToClose.ToString("X"), retVal.ToString("X")); diff --git a/TBF/Rig/ControlBoard/Uni/GeneralData.cs b/TBF/Rig/ControlBoard/Uni/GeneralData.cs index 4af21b229..55e2cd753 100644 --- a/TBF/Rig/ControlBoard/Uni/GeneralData.cs +++ b/TBF/Rig/ControlBoard/Uni/GeneralData.cs @@ -196,8 +196,8 @@ namespace TBF.Rig.ControlBoard.Uni EtPulses2 = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.ETX2)); /// Byte 294,295,296 EtPulses3 = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.ETX3)); /// Byte 297,298.299 !!!!!!!!!!!!!!! - log.InfoFormat("Et={0} State={1:X14} Freq={2} EtPulses={3} TTime={4} WMPulses[3]={5} WMRefPulses[3]={6}, Time[3]={7}", - (State & 7), State, ReferenceFreq[0], EtPulses[0], Ttime, WMeterPuls[3], EtPulses[3], ImpulseTime[3]); + log.InfoFormat("Et={0} State={1:X14} Route={2} Freq={3} EtPulses={4} TTime={5} WMPulses[3]={6} WMRefPulses[3]={7}, Time[3]={8}", + (State & 7), State, Utils.ToBin40(((UInt64)Vystupy) >> 8), ReferenceFreq[0], EtPulses[0], Ttime, WMeterPuls[3], EtPulses[3], ImpulseTime[3]); } } diff --git a/TBF/Rig/ControlBoard/Uni/UniCB.cs b/TBF/Rig/ControlBoard/Uni/UniCB.cs index 4e8cc3ec7..4836c2ec0 100644 --- a/TBF/Rig/ControlBoard/Uni/UniCB.cs +++ b/TBF/Rig/ControlBoard/Uni/UniCB.cs @@ -41,8 +41,8 @@ namespace TBF.Rig.ControlBoard.Uni { altString.Clear(); altString.AppendFormat("State: {0}.{1}.{2}.{3}\n", (State >> 48) & 0xFF, (State >> 40) & 0xFF, (State >> 32) & 0xFF, Convert.ToUInt32(State & 0xFFFFFFFF).ToString("X6")); - altString.AppendFormat("DI: {0}\n", ToBin40(DigitalInputs)); - altString.AppendFormat("DO: {0}\n", ToBin40(((UInt64)Route) >> 8)); + altString.AppendFormat("DI: {0}\n", Utils.ToBin40(DigitalInputs)); + altString.AppendFormat("DO: {0}\n", Utils.ToBin40((ulong)Route >> 8)); altString.AppendFormat("AI0: {0:D3} AI1: {1:D3} AI2: {2:D3} AI3: {3:D3} AI4: {4:D3} AI5: {5:D3}\n", AnalogInput(0), AnalogInput(1), AnalogInput(2), AnalogInput(3), AnalogInput(4), AnalogInput(5)); altString.AppendFormat("AI8: {0:D3} AI9: {1:D3} AI10: {2:D3} AI11: {3:D3}\n", @@ -54,28 +54,6 @@ namespace TBF.Rig.ControlBoard.Uni } } - string ToBin40(UInt64 val) - { - return string.Format("{0}-{1}-{2}-{3}-{4}", ToBin8((val >> 32) & 0xFF), ToBin8((val >> 24) & 0xFF), - ToBin8((val >> 16) & 0xFF), ToBin8((val >> 8) & 0xFF), ToBin8(val & 0xFF)); - } - - string ToBin8(UInt64 val) - { - string str = Convert.ToString((byte)val, 2); - switch (str.Length) - { - case 1: return "0000000" + str; - case 2: return "000000" + str; - case 3: return "00000" + str; - case 4: return "0000" + str; - case 5: return "000" + str; - case 6: return "00" + str; - case 7: return "0" + str; - default: return str; - } - } - /// /// Serial communication /// @@ -378,7 +356,7 @@ namespace TBF.Rig.ControlBoard.Uni } isEmergencyStop = newEmergencyStop; - log.DebugFormat("Route synced with RRoute and UI changes, new route = {0}", Utils.RouteToStr(route)); + log.DebugFormat("Route synced with RRoute and UI changes, new route = {0}", Utils.ToBin40((ulong)route >> 8)); } /// @@ -533,7 +511,7 @@ namespace TBF.Rig.ControlBoard.Uni UInt128 oldRoute = route; route = (route | valvesToOpen) & (~valvesToClose); foreach (var logFnV in logicalFnValves) logFnV.UpdateRoute(ref route); - log.DebugFormat("SetValves(x,x), new route = {0}", Utils.RouteToStr(route)); + log.DebugFormat("SetValves(x,x), new route = {0}", Utils.ToBin40((ulong)route >> 8)); UInt128 retVal = oldRoute ^ route; log.DebugFormat("{0}.SetValves({1}, {2}) returns {3}", Name, valvesToOpen.ToString("X"), valvesToClose.ToString("X"), retVal.ToString("X")); diff --git a/TBF/Utils.cs b/TBF/Utils.cs index d8829ff59..337cc24ba 100644 --- a/TBF/Utils.cs +++ b/TBF/Utils.cs @@ -336,6 +336,31 @@ namespace TBF (route & 0xFFFF).ToString("X4")); /// 5 } + public static string ToBin40(UInt64 val) + { + return string.Format("{0}-{1}-{2}-{3}-{4}", ToBin8((val >> 32) & 0xFF), + ToBin8((val >> 24) & 0xFF), + ToBin8((val >> 16) & 0xFF), + ToBin8((val >> 8) & 0xFF), + ToBin8(val & 0xFF)); + } + + public static string ToBin8(UInt64 val) + { + string str = Convert.ToString((byte)val, 2); + switch (str.Length) + { + case 1: return "0000000" + str; + case 2: return "000000" + str; + case 3: return "00000" + str; + case 4: return "0000" + str; + case 5: return "000" + str; + case 6: return "00" + str; + case 7: return "0" + str; + default: return str; + } + } + public static string ToMyString(DateTime dateTime) { return string.Format("{0}{1}{2}_{3}{4}",