From 87b159b167892d03b9ecfa88d87b019d0daee18a Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 23 Jun 2022 14:42:08 +0200 Subject: [PATCH] update decodifica status - errore in decodifica prog name (stringa) --- MP.MONO.DECODER/CounterManager.cs | 44 ++++++++++++++++-------------- MP.MONO.DECODER/MPStatusManager.cs | 44 ++++++++++++++++-------------- MP.MONO.DECODER/Program.cs | 10 ++++--- 3 files changed, 52 insertions(+), 46 deletions(-) diff --git a/MP.MONO.DECODER/CounterManager.cs b/MP.MONO.DECODER/CounterManager.cs index 281b22d..ea38f99 100644 --- a/MP.MONO.DECODER/CounterManager.cs +++ b/MP.MONO.DECODER/CounterManager.cs @@ -8,6 +8,26 @@ namespace MP.MONO.DECODER { public class CounterManager { + #region Public Fields + + public static string alarmStatus = ""; + + public static bool valueChanged = false; + + #endregion Public Fields + + #region Protected Fields + + protected static Logger Log = LogManager.GetCurrentClassLogger(); + + protected static string luaPath = ""; + + protected static Lua state = new Lua(); + + protected List AlarmList = new List(); + + #endregion Protected Fields + #region Private Fields /// @@ -17,22 +37,6 @@ namespace MP.MONO.DECODER #endregion Private Fields - #region Protected Fields - - protected static Logger Log = LogManager.GetCurrentClassLogger(); - protected static string luaPath = ""; - protected static Lua state = new Lua(); - protected List AlarmList = new List(); - - #endregion Protected Fields - - #region Public Fields - - public static string alarmStatus = ""; - public static bool valueChanged = false; - - #endregion Public Fields - #region Public Constructors public CounterManager() @@ -45,8 +49,8 @@ namespace MP.MONO.DECODER luaPath = Path.Combine(Directory.GetCurrentDirectory(), "lua", "ParamsDecoder.lua"); state.DoFile(luaPath); - Log.Info("ParamsManager OK"); - Console.WriteLine("ParamsManager OK"); + Log.Info("CounterManager OK"); + Console.WriteLine("CounterManager OK"); } #endregion Public Constructors @@ -121,7 +125,7 @@ namespace MP.MONO.DECODER Log.Trace($"calcVal: {calcVal}"); } } - catch(Exception exc) + catch (Exception exc) { Log.Error($"exception during processData for {item.Key}{Environment.NewLine}{exc}"); } @@ -135,7 +139,6 @@ namespace MP.MONO.DECODER MachineId = 1, ValNum = calcVal, ValStr = $"{calcVal:N3}" - }; answ.Add(dbRecord); @@ -145,7 +148,6 @@ namespace MP.MONO.DECODER } } - return answ; } diff --git a/MP.MONO.DECODER/MPStatusManager.cs b/MP.MONO.DECODER/MPStatusManager.cs index 4bc80f6..abe39ab 100644 --- a/MP.MONO.DECODER/MPStatusManager.cs +++ b/MP.MONO.DECODER/MPStatusManager.cs @@ -8,6 +8,26 @@ namespace MP.MONO.DECODER { public class MPStatusManager { + #region Public Fields + + public static string alarmStatus = ""; + + public static bool valueChanged = false; + + #endregion Public Fields + + #region Protected Fields + + protected static Logger Log = LogManager.GetCurrentClassLogger(); + + protected static string luaPath = ""; + + protected static Lua state = new Lua(); + + protected List AlarmList = new List(); + + #endregion Protected Fields + #region Private Fields /// @@ -17,22 +37,6 @@ namespace MP.MONO.DECODER #endregion Private Fields - #region Protected Fields - - protected static Logger Log = LogManager.GetCurrentClassLogger(); - protected static string luaPath = ""; - protected static Lua state = new Lua(); - protected List AlarmList = new List(); - - #endregion Protected Fields - - #region Public Fields - - public static string alarmStatus = ""; - public static bool valueChanged = false; - - #endregion Public Fields - #region Public Constructors public MPStatusManager() @@ -45,8 +49,8 @@ namespace MP.MONO.DECODER luaPath = Path.Combine(Directory.GetCurrentDirectory(), "lua", "ParamsDecoder.lua"); state.DoFile(luaPath); - Log.Info("ParamsManager OK"); - Console.WriteLine("ParamsManager OK"); + Log.Info("MPStatusManager OK"); + Console.WriteLine("MPStatusManager OK"); } #endregion Public Constructors @@ -121,7 +125,7 @@ namespace MP.MONO.DECODER Log.Trace($"calcVal: {calcVal}"); } } - catch(Exception exc) + catch (Exception exc) { Log.Error($"exception during processData for {item.Key}{Environment.NewLine}{exc}"); } @@ -135,7 +139,6 @@ namespace MP.MONO.DECODER MachineId = 1, ValNum = calcVal, ValStr = $"{calcVal:N3}" - }; answ.Add(dbRecord); @@ -145,7 +148,6 @@ namespace MP.MONO.DECODER } } - return answ; } diff --git a/MP.MONO.DECODER/Program.cs b/MP.MONO.DECODER/Program.cs index 5b217e0..2139d4f 100644 --- a/MP.MONO.DECODER/Program.cs +++ b/MP.MONO.DECODER/Program.cs @@ -516,7 +516,7 @@ void MpStatusRecvPipe_EA_NewMessage(object? sender, EventArgs e) try { // verifico codici ricevuti - var dataList = JsonConvert.DeserializeObject>(currArgs.newMessage); + var dataList = JsonConvert.DeserializeObject>(currArgs.newMessage); if (dataList != null) { /************************************************************************ @@ -572,19 +572,21 @@ void MpStatusRecvPipe_EA_NewMessage(object? sender, EventArgs e) currKey = "MACHINE STATUS"; if (dataList.ContainsKey(currKey)) { - int.TryParse(currKey, out machStatus); + int.TryParse(dataList[currKey], out machStatus); } currKey = "PROCESS STATUS"; if (dataList.ContainsKey(currKey)) { - int.TryParse(currKey, out procStatus); + int.TryParse(dataList[currKey], out procStatus); } currKey = "PROCESS MODE"; if (dataList.ContainsKey(currKey)) { - int.TryParse(currKey, out procMode); + int.TryParse(dataList[currKey], out procMode); } + // fix me todo inserire gestione program name!!! + if (machStatus == 0) { machinePlate.StatusId = 7;