diff --git a/IOB-WIN-NEXT/AdapterForm.Designer.cs b/IOB-WIN-NEXT/AdapterForm.Designer.cs index 057303af..9749316f 100644 --- a/IOB-WIN-NEXT/AdapterForm.Designer.cs +++ b/IOB-WIN-NEXT/AdapterForm.Designer.cs @@ -1,4 +1,4 @@ -namespace IOB_WIN +namespace IOB_WIN_NEXT { partial class AdapterForm { diff --git a/IOB-WIN-NEXT/AdapterForm.cs b/IOB-WIN-NEXT/AdapterForm.cs index 20c971ed..0168eb4d 100644 --- a/IOB-WIN-NEXT/AdapterForm.cs +++ b/IOB-WIN-NEXT/AdapterForm.cs @@ -12,7 +12,7 @@ using System.IO; using System.Threading; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public partial class AdapterForm : Form { diff --git a/IOB-WIN-NEXT/Enums.cs b/IOB-WIN-NEXT/Enums.cs index a3f521d2..cf164466 100644 --- a/IOB-WIN-NEXT/Enums.cs +++ b/IOB-WIN-NEXT/Enums.cs @@ -3,21 +3,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - public enum StartMode - { - /// - /// modalità standard (standalone, multi IOB) - /// - STD = 0, - /// - /// Modalità managed (da IOB-MAN) - /// - MAN = 1, - /// - /// Modalità update (per aggiornare IOB-WIN) senza IOB - /// - UPD = 2 - } -} + public enum StartMode + { + /// + /// modalità standard (standalone, multi IOB) + /// + STD = 0, + + /// + /// Modalità managed (da IOB-MAN) + /// + MAN = 1, + + /// + /// Modalità update (per aggiornare IOB-WIN) senza IOB + /// + UPD = 2 + } +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/IOB-WIN.csproj b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj similarity index 100% rename from IOB-WIN-NEXT/IOB-WIN.csproj rename to IOB-WIN-NEXT/IOB-WIN-NEXT.csproj diff --git a/IOB-WIN-NEXT/IobConfiguration.cs b/IOB-WIN-NEXT/IobConfiguration.cs index b2bcd469..d2a67512 100644 --- a/IOB-WIN-NEXT/IobConfiguration.cs +++ b/IOB-WIN-NEXT/IobConfiguration.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// This Configuration class is basically just a set of diff --git a/IOB-WIN-NEXT/IobFanuc.cs b/IOB-WIN-NEXT/IobFanuc.cs index ffff3cfb..5cc33f4b 100644 --- a/IOB-WIN-NEXT/IobFanuc.cs +++ b/IOB-WIN-NEXT/IobFanuc.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Net; using System.Net.NetworkInformation; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobFanuc : IobGeneric { diff --git a/IOB-WIN-NEXT/IobFile.cs b/IOB-WIN-NEXT/IobFile.cs index c9484db3..a2c52548 100644 --- a/IOB-WIN-NEXT/IobFile.cs +++ b/IOB-WIN-NEXT/IobFile.cs @@ -12,7 +12,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Generica classe per implementare IOB basato su scambio FILE @@ -58,6 +58,39 @@ namespace IOB_WIN #endregion Public Constructors + #region Private Methods + + /// + /// Processo stati unknown... + /// + /// + private void processUnknStatus(string cKey) + { + // cerco se avevo già una key nella dictionary... + if (freqUnknStatus.ContainsKey(cKey)) + { + freqUnknStatus[cKey]++; + // se è 1 ogni 100 (%100, resto ==1) --> loggo... + if (freqUnknStatus[cKey] % 100 == 1) + { + lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}"); + // accodo come invio di tipo FLOG... + string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus); + // chiamo accodamento... + accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal)); + } + } + else + { + // creo chiave con freq = 1 + freqUnknStatus.Add(cKey, 1); + // log iniziale + lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}"); + } + } + + #endregion Private Methods + #region Internal Methods /// @@ -114,36 +147,7 @@ namespace IOB_WIN #endregion Internal Methods - #region Metodi specifici (da verificare/completare in implementazione) - - /// - /// Processo stati unknown... - /// - /// - private void processUnknStatus(string cKey) - { - // cerco se avevo già una key nella dictionary... - if (freqUnknStatus.ContainsKey(cKey)) - { - freqUnknStatus[cKey]++; - // se è 1 ogni 100 (%100, resto ==1) --> loggo... - if (freqUnknStatus[cKey] % 100 == 1) - { - lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}"); - // accodo come invio di tipo FLOG... - string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus); - // chiamo accodamento... - accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal)); - } - } - else - { - // creo chiave con freq = 1 - freqUnknStatus.Add(cKey, 1); - // log iniziale - lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}"); - } - } + #region Public Methods public void Dispose() { @@ -352,6 +356,6 @@ namespace IOB_WIN } } - #endregion Metodi specifici (da verificare/completare in implementazione) + #endregion Public Methods } } \ No newline at end of file diff --git a/IOB-WIN-NEXT/IobFileEurom63.cs b/IOB-WIN-NEXT/IobFileEurom63.cs index a05351cc..32eece07 100644 --- a/IOB-WIN-NEXT/IobFileEurom63.cs +++ b/IOB-WIN-NEXT/IobFileEurom63.cs @@ -11,7 +11,7 @@ using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobFileEurom63 : IobFile { diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index 16d96309..33fb1ec3 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -17,7 +17,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobGeneric { diff --git a/IOB-WIN-NEXT/IobKawasaki.cs b/IOB-WIN-NEXT/IobKawasaki.cs index 98d64fc7..9be68cb7 100644 --- a/IOB-WIN-NEXT/IobKawasaki.cs +++ b/IOB-WIN-NEXT/IobKawasaki.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Net.NetworkInformation; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobKawasaki : IobGeneric { diff --git a/IOB-WIN-NEXT/IobMTC.cs b/IOB-WIN-NEXT/IobMTC.cs index 2f0a908a..79bb6970 100644 --- a/IOB-WIN-NEXT/IobMTC.cs +++ b/IOB-WIN-NEXT/IobMTC.cs @@ -11,7 +11,7 @@ using System.Windows.Forms; using MTConnectDevices = MTConnect.MTConnectDevices; using MTConnectStreams = MTConnect.MTConnectStreams; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobMTC : IobGeneric { diff --git a/IOB-WIN-NEXT/IobOSAI.cs b/IOB-WIN-NEXT/IobOSAI.cs index 4e3fe929..48a38126 100644 --- a/IOB-WIN-NEXT/IobOSAI.cs +++ b/IOB-WIN-NEXT/IobOSAI.cs @@ -7,7 +7,7 @@ using System.Net; using System.Net.NetworkInformation; using CVCncLib; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobOSAI : IobGeneric { diff --git a/IOB-WIN-NEXT/IobOmron.cs b/IOB-WIN-NEXT/IobOmron.cs index ec7dfff2..0f54d837 100644 --- a/IOB-WIN-NEXT/IobOmron.cs +++ b/IOB-WIN-NEXT/IobOmron.cs @@ -6,7 +6,7 @@ using System.Net.NetworkInformation; using System.Text; using System.Threading; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobOmron : IobGeneric { diff --git a/IOB-WIN-NEXT/IobSiemens.cs b/IOB-WIN-NEXT/IobSiemens.cs index 5e11843c..db119f19 100644 --- a/IOB-WIN-NEXT/IobSiemens.cs +++ b/IOB-WIN-NEXT/IobSiemens.cs @@ -8,7 +8,7 @@ using System.Diagnostics; using System.Linq; using System.Net.NetworkInformation; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobSiemens : IobGeneric, IDisposable { diff --git a/IOB-WIN-NEXT/IobSiemensAprochim.cs b/IOB-WIN-NEXT/IobSiemensAprochim.cs index bc06848c..0627a18a 100644 --- a/IOB-WIN-NEXT/IobSiemensAprochim.cs +++ b/IOB-WIN-NEXT/IobSiemensAprochim.cs @@ -4,211 +4,217 @@ using System; using System.Collections.Generic; using System.Linq; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - /// - /// Controllo Siemens specifico x impianti Aprochim /MacDermid - /// - public class IobSiemensAprochim : IobSiemens - { - /* -------------------------------------------------------------------------------- - * Controlli SIEMENS Aprochim (impianti filtrazione in Jetco, gruppo macDermid) - * - basasto su SIEMENS - * - S7 vers 1500 - * - * STRUTTURA MEMORIA DB60: - * - parametri processo - * - DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray()); - * - DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto) - * - DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto) - * - * - BIT di stato - * - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA - * - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE - * - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO) - * - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio) - * - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu) - * - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo) - * -------------------------------------------------------------------------------- */ - /// - /// Classe base con i metodi x Siemens + /// Controllo Siemens specifico x impianti Aprochim /MacDermid /// - /// - /// - public IobSiemensAprochim(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) + public class IobSiemensAprochim : IobSiemens { - lgInfo("NEW IOB SIEMENS versione APROCHIM"); - // imposto i parametri speciali x calcolo... - var chiaviTSVC = findOptPar("TSVC"); - if (chiaviTSVC.Count > 0) - { - lgInfo($"Trovate {chiaviTSVC.Count} chiavi TSVC"); - string[] codVal; - VCData currConf; - int periodo = 0; - VC_func funz = VC_func.POINT; - // accodo nella conf... - foreach (var item in chiaviTSVC) + /* -------------------------------------------------------------------------------- + * Controlli SIEMENS Aprochim (impianti filtrazione in Jetco, gruppo macDermid) + * - basasto su SIEMENS + * - S7 vers 1500 + * + * STRUTTURA MEMORIA DB60: + * - parametri processo + * - DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray()); + * - DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto) + * - DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto) + * + * - BIT di stato + * - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA + * - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE + * - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO) + * - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio) + * - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu) + * - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo) + * -------------------------------------------------------------------------------- */ + + #region Public Constructors + + /// + /// Classe base con i metodi x Siemens + /// + /// + /// + public IobSiemensAprochim(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) { - codVal = item.Value.Split(':'); - Enum.TryParse(codVal[0], out funz); - int.TryParse(codVal[1], out periodo); - currConf = new VCData() - { - Funzione = funz, - Period = periodo, - DTStart = DateTime.Now.AddHours(-1), - dataArray = new List() - }; - TSVC_Data.Add(item.Key.Replace("TSVC_", ""), currConf); + lgInfo("NEW IOB SIEMENS versione APROCHIM"); + // imposto i parametri speciali x calcolo... + var chiaviTSVC = findOptPar("TSVC"); + if (chiaviTSVC.Count > 0) + { + lgInfo($"Trovate {chiaviTSVC.Count} chiavi TSVC"); + string[] codVal; + VCData currConf; + int periodo = 0; + VC_func funz = VC_func.POINT; + // accodo nella conf... + foreach (var item in chiaviTSVC) + { + codVal = item.Value.Split(':'); + Enum.TryParse(codVal[0], out funz); + int.TryParse(codVal[1], out periodo); + currConf = new VCData() + { + Funzione = funz, + Period = periodo, + DTStart = DateTime.Now.AddHours(-1), + dataArray = new List() + }; + TSVC_Data.Add(item.Key.Replace("TSVC_", ""), currConf); + } + // documento... + foreach (var item in TSVC_Data) + { + lgInfo($"TSVC: {item.Key} | periodo: {item.Value.Period} | funz: {item.Value.Funzione}"); + // salvo i valori PREC... + LastTSVC.Add(item.Key, 0); + } + } } - // documento... - foreach (var item in TSVC_Data) + + #endregion Public Constructors + + #region Protected Methods + + /// + /// Effettua decodifica aree memoria alla bitmap usata x MAPO + /// + protected override void decodeToBaseBitmap() { - lgInfo($"TSVC: {item.Key} | periodo: {item.Value.Period} | funz: {item.Value.Funzione}"); - // salvo i valori PREC... - LastTSVC.Add(item.Key, 0); + // init a zero... + B_input = 0; + + /* ----------------------------------------------------- + * bitmap MAPO STANDARD + * B0: POWER_ON + * B1: RUN + * B2: pzCount + * B3: allarme + * B4: manuale + * B5: emergenza + * + * + * - BIT di stato + * - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA + * - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE + * - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO) + * - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio) + * - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu) + * - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo) + ----------------------------------------------------- */ + + /* ----------------------------------------------------- + * bitmap MAPO FILTRO Aprochim + * B0: POWER_ON + * B1: RUN + * B2: AUTOMATICO + * B3: WARN_MIN_VASCA + * B4: WARN_MIN_CELL + * B5: ALARM + * B6: EMERGENZA + ----------------------------------------------------- */ + + // bit 0 (poweron) imposto a 1 SE connected... + B_input = currPLC.IsConnected ? 1 : 0; + + // recupero byte segnali... + int byteSignals = RawInput[3]; + // aggiungo "in coda" primo bit emergenza...essendo un bit negato (NON emergenza) lo cambio di segno + if ((byteSignals & (1 << 0)) == 0) + { + byteSignals += (1 << 6); + } + // cancello primo bit (faccio uno shift a dx e poi a sx di 1...) + byteSignals = ((byteSignals >> 1) << 1); + // bit 0 (poweron) imposto a 1 SE connected... + if (currPLC.IsConnected) + { + byteSignals += (1 << 0); + } + // salvo! + B_input = byteSignals; + + // log opzionale! + if (verboseLog) + { + lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}")); + } } - } - } - #region Metodi specifici (da verificare/completare in implementazione) + #endregion Protected Methods - /// - /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) - /// - public override void processOverride() - { - } + #region Public Methods - /// - /// Recupero dati dinamici in formato dictionary - /// - /// - public override Dictionary getDynData() - { - Dictionary outVal = new Dictionary(); - try - { - /* ---------------------------------------------------------- - * DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray()); - * DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto) - * DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto) - * */ - double pressCamFilt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(6).Take(4).ToArray()); - double pressLinUt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(10).Take(4).ToArray()); - double tempH2O = S7.Net.Types.Double.FromByteArray(RawInput.Skip(14).Take(4).ToArray()); - - if (utils.CRB("enableTSVC")) + /// + /// Recupero dati dinamici in formato dictionary + /// + /// + public override Dictionary getDynData() { - // salvo in stack le VC rilevate - bool scad01 = stackVal_TSVC("pressCamFilt", pressCamFilt); - bool scad02 = stackVal_TSVC("pressLinUt", pressLinUt); - bool scad03 = stackVal_TSVC("tempH2O", tempH2O); + Dictionary outVal = new Dictionary(); + try + { + /* ---------------------------------------------------------- + * DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray()); + * DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto) + * DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto) + * */ + double pressCamFilt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(6).Take(4).ToArray()); + double pressLinUt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(10).Take(4).ToArray()); + double tempH2O = S7.Net.Types.Double.FromByteArray(RawInput.Skip(14).Take(4).ToArray()); - // verifico SE devo riportare dati VC - if (scad01 || scad02 || scad03) - { - pressCamFilt = getVal_TSVC("pressCamFilt", scad01); - pressLinUt = getVal_TSVC("pressLinUt", scad02); - tempH2O = getVal_TSVC("tempH2O", scad03); - outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N6} | pressLinUt {pressLinUt:N6} | tempH2O {tempH2O:N3}"); - outVal.Add("pressCamFilt", $"{pressCamFilt:N6}"); - outVal.Add("pressLinUt", $"{pressLinUt:N6}"); - outVal.Add("tempH2O", $"{tempH2O:N3}"); - // salvo! - LastTSVC["pressCamFilt"] = pressCamFilt; - LastTSVC["pressLinUt"] = pressLinUt; - LastTSVC["tempH2O"] = tempH2O; - } - else - { - outVal.Add("DYNDATA", $"pressCamFilt {LastTSVC["pressCamFilt"]:N6} | pressLinUt {LastTSVC["pressLinUt"]:N6} | tempH2O {LastTSVC["tempH2O"]:N3}"); - } + if (utils.CRB("enableTSVC")) + { + // salvo in stack le VC rilevate + bool scad01 = stackVal_TSVC("pressCamFilt", pressCamFilt); + bool scad02 = stackVal_TSVC("pressLinUt", pressLinUt); + bool scad03 = stackVal_TSVC("tempH2O", tempH2O); + + // verifico SE devo riportare dati VC + if (scad01 || scad02 || scad03) + { + pressCamFilt = getVal_TSVC("pressCamFilt", scad01); + pressLinUt = getVal_TSVC("pressLinUt", scad02); + tempH2O = getVal_TSVC("tempH2O", scad03); + outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N6} | pressLinUt {pressLinUt:N6} | tempH2O {tempH2O:N3}"); + outVal.Add("pressCamFilt", $"{pressCamFilt:N6}"); + outVal.Add("pressLinUt", $"{pressLinUt:N6}"); + outVal.Add("tempH2O", $"{tempH2O:N3}"); + // salvo! + LastTSVC["pressCamFilt"] = pressCamFilt; + LastTSVC["pressLinUt"] = pressLinUt; + LastTSVC["tempH2O"] = tempH2O; + } + else + { + outVal.Add("DYNDATA", $"pressCamFilt {LastTSVC["pressCamFilt"]:N6} | pressLinUt {LastTSVC["pressLinUt"]:N6} | tempH2O {LastTSVC["tempH2O"]:N3}"); + } + } + else + { + outVal.Add("pressCamFilt", $"{pressCamFilt:N6}"); + outVal.Add("pressLinUt", $"{pressLinUt:N6}"); + outVal.Add("tempH2O", $"{tempH2O:N3}"); + outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N3} | pressLinUt {pressLinUt:N3} | tempH2O {tempH2O:N3}"); + } + } + catch (Exception exc) + { + lgError(exc, "Errore in getDynData x Siemens Aprochim"); + } + return outVal; } - else + + /// + /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) + /// + public override void processOverride() { - outVal.Add("pressCamFilt", $"{pressCamFilt:N6}"); - outVal.Add("pressLinUt", $"{pressLinUt:N6}"); - outVal.Add("tempH2O", $"{tempH2O:N3}"); - outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N3} | pressLinUt {pressLinUt:N3} | tempH2O {tempH2O:N3}"); } - } - catch (Exception exc) - { - lgError(exc, "Errore in getDynData x Siemens Aprochim"); - } - return outVal; + + #endregion Public Methods } - - /// - /// Effettua decodifica aree memoria alla bitmap usata x MAPO - /// - protected override void decodeToBaseBitmap() - { - // init a zero... - B_input = 0; - - /* ----------------------------------------------------- - * bitmap MAPO STANDARD - * B0: POWER_ON - * B1: RUN - * B2: pzCount - * B3: allarme - * B4: manuale - * B5: emergenza - * - * - * - BIT di stato - * - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA - * - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE - * - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO) - * - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio) - * - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu) - * - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo) - ----------------------------------------------------- */ - - - - /* ----------------------------------------------------- - * bitmap MAPO FILTRO Aprochim - * B0: POWER_ON - * B1: RUN - * B2: AUTOMATICO - * B3: WARN_MIN_VASCA - * B4: WARN_MIN_CELL - * B5: ALARM - * B6: EMERGENZA - ----------------------------------------------------- */ - - // bit 0 (poweron) imposto a 1 SE connected... - B_input = currPLC.IsConnected ? 1 : 0; - - // recupero byte segnali... - int byteSignals = RawInput[3]; - // aggiungo "in coda" primo bit emergenza...essendo un bit negato (NON emergenza) lo cambio di segno - if ((byteSignals & (1 << 0)) == 0) - { - byteSignals += (1 << 6); - } - // cancello primo bit (faccio uno shift a dx e poi a sx di 1...) - byteSignals = ((byteSignals >> 1) << 1); - // bit 0 (poweron) imposto a 1 SE connected... - if (currPLC.IsConnected) - { - byteSignals += (1 << 0); - } - // salvo! - B_input = byteSignals; - - // log opzionale! - if (verboseLog) - { - lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}")); - } - } - - #endregion - } -} +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/IobSiemensAt2001.cs b/IOB-WIN-NEXT/IobSiemensAt2001.cs index 5d316b6c..57f6c587 100644 --- a/IOB-WIN-NEXT/IobSiemensAt2001.cs +++ b/IOB-WIN-NEXT/IobSiemensAt2001.cs @@ -2,93 +2,180 @@ using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - /// - /// Controllo Siemens specifico x impianti SAET - /// - public class IobSiemensAt2001 : IobSiemens - { - /* -------------------------------------------------------------------------------- - * Controlli VIPA/SIEMENS (Interclays) di @2001 - * - VIPA, COMPATIBILE SIEMENS - * - S7 vers 300 - * - * - - * -------------------------------------------------------------------------------- */ - - protected DateTime lastPLCWatchDog; - protected int counterMes2Plc = 0; - protected int counterPlc2Mes = 0; - /// - /// Classe base con i metodi x Siemens + /// Controllo Siemens specifico x impianti SAET /// - /// - /// - public IobSiemensAt2001(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) + public class IobSiemensAt2001 : IobSiemens { - lgInfo("NEW IOB SIEMENS versione VIPA AT2001"); - lastPLCWatchDog = DateTime.Now.AddMinutes(-1); - } + /* -------------------------------------------------------------------------------- + * Controlli VIPA/SIEMENS (Interclays) di @2001 + * - VIPA, COMPATIBILE SIEMENS + * - S7 vers 300 + * + * - #region Metodi specifici (da verificare/completare in implementazione) + * -------------------------------------------------------------------------------- */ - /// - /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) - /// - public override void processOverride() - { - } + #region Protected Fields - public override void processWhatchDog() - { - //NON SERVE!!!! - } + protected int counterMes2Plc = 0; + protected int counterPlc2Mes = 0; + protected DateTime lastPLCWatchDog; - /// - /// Processo i task richiesti e li elimino dalla coda 1:1 - /// - /// - public override Dictionary executeTasks(Dictionary task2exe) - { - // Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti... - Dictionary taskDone = new Dictionary(); - bool taskOk = false; - string taskVal = ""; - // inizio VUOTO - byte[] MemBlock = new byte[1]; - string memAddrWrite = ""; - if (task2exe != null) - { - // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4 - foreach (var item in task2exe) + #endregion Protected Fields + + #region Public Constructors + + /// + /// Classe base con i metodi x Siemens + /// + /// + /// + public IobSiemensAt2001(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) { - taskOk = false; - taskVal = ""; - memAddrWrite = ""; - // converto richiesta in enum... - taskType tName = taskType.nihil; - Enum.TryParse(item.Key, out tName); - // controllo sulla KEY - switch (tName) - { - case taskType.nihil: - case taskType.fixStopSetup: - case taskType.forceSetPzCount: - case taskType.stopSetup: - taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC"; - break; - case taskType.forceResetPzCount: - case taskType.startSetup: - // alzo il bit x registrare richiesta reset contapezzi... POI quando ha eseguito abbassa il PLC il bit a zero... - MemBlock[0] = 1; - memAddrWrite = "DB1001.DBB88"; - break; - case taskType.setArt: - case taskType.setComm: - case taskType.setProg: + lgInfo("NEW IOB SIEMENS versione VIPA AT2001"); + lastPLCWatchDog = DateTime.Now.AddMinutes(-1); + } + + #endregion Public Constructors + + #region Protected Methods + + /// + /// Effettua decodifica aree memoria alla bitmap usata x MAPO + /// + protected override void decodeToBaseBitmap() + { + // init a zero... + B_input = 0; + + /* ----------------------------------------------------- + * bitmap MAPO STANDARD + * B0: POWER_ON + * B1: RUN + * B2: pzCount + * B3: allarme + * B4: manuale + * B5: avvio/spegnimento + * B6: emergenza + * + * + * - BYTE di stato + * - +0.0 AutoStatus BYTE B#16#0 Valore 0=Fermo/1->3=Avviamento/4=Avviato/5=Pausa/6->8spegnimento/9->10 allarme + * - +1.0 Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +2.0 V_Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +3.0 Nas_Lancio BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +4.0 Cilindro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +5.0 Bruciatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +6.0 Aspiratore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +7.0 Nas_Raccolta BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +8.0 Nas_Brandeg BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +9.0 Coclea_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + * - +10.0 Ciclico_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) + ----------------------------------------------------- */ + + // recupero byte segnali... + int byteSignals = RawInput[0]; + + // bit 0 (poweron) imposto a 1 SE connected... + B_input = currPLC.IsConnected ? 1 : 0; + + // avviamento --> manuale + switch (byteSignals) + { + case 0: + B_input = 1; + break; + + case 1: + case 2: + case 3: + B_input += (1 << 5); + break; + + case 4: + B_input += (1 << 1); + break; + + case 5: + B_input += (1 << 4); + break; + + case 6: + case 7: + case 8: + B_input += (1 << 5); + break; + + case 9: + B_input += (1 << 3); + break; + + case 10: + B_input += (1 << 6); + break; + + default: + break; + } + + // log opzionale! + if (verboseLog) + { + lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}")); + } + } + + #endregion Protected Methods + + #region Public Methods + + /// + /// Processo i task richiesti e li elimino dalla coda 1:1 + /// + /// + public override Dictionary executeTasks(Dictionary task2exe) + { + // Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti... + Dictionary taskDone = new Dictionary(); + bool taskOk = false; + string taskVal = ""; + // inizio VUOTO + byte[] MemBlock = new byte[1]; + string memAddrWrite = ""; + if (task2exe != null) + { + // cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4 + foreach (var item in task2exe) + { + taskOk = false; + taskVal = ""; + memAddrWrite = ""; + // converto richiesta in enum... + taskType tName = taskType.nihil; + Enum.TryParse(item.Key, out tName); + // controllo sulla KEY + switch (tName) + { + case taskType.nihil: + case taskType.fixStopSetup: + case taskType.forceSetPzCount: + case taskType.stopSetup: + taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC"; + break; + + case taskType.forceResetPzCount: + case taskType.startSetup: + // alzo il bit x registrare richiesta reset contapezzi... POI quando ha eseguito abbassa il PLC il bit a zero... + MemBlock[0] = 1; + memAddrWrite = "DB1001.DBB88"; + break; + + case taskType.setArt: + case taskType.setComm: + case taskType.setProg: #if false // imposto i valori... if (currProdData.ContainsKey(item.Key)) @@ -99,36 +186,41 @@ namespace IOB_WIN { currProdData.Add(item.Key, item.Value); } - taskVal = item.Value; + taskVal = item.Value; #endif - saveProdData(item); - int byteSize = 0; - // recupero dati da memMap... altrimenti NULLA - if (memMap.mMapWrite.ContainsKey(item.Key)) - { - dataConf currMem = memMap.mMapWrite[item.Key]; - byteSize = currMem.size; - memAddrWrite = currMem.memAddr; - MemBlock = new byte[byteSize]; - switch (currMem.tipoMem) - { - case plcDataType.Boolean: - break; - case plcDataType.Int: - saveIntOnMemBlock(ref MemBlock, item.Key, 0); - break; - case plcDataType.DInt: - saveDIntOnMemBlock(ref MemBlock, item.Key, 0); - break; - case plcDataType.Real: - saveRealOnMemBlock(ref MemBlock, item.Key, 0); - break; - case plcDataType.String: - saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize); - break; - default: - break; - } + saveProdData(item); + int byteSize = 0; + // recupero dati da memMap... altrimenti NULLA + if (memMap.mMapWrite.ContainsKey(item.Key)) + { + dataConf currMem = memMap.mMapWrite[item.Key]; + byteSize = currMem.size; + memAddrWrite = currMem.memAddr; + MemBlock = new byte[byteSize]; + switch (currMem.tipoMem) + { + case plcDataType.Boolean: + break; + + case plcDataType.Int: + saveIntOnMemBlock(ref MemBlock, item.Key, 0); + break; + + case plcDataType.DInt: + saveDIntOnMemBlock(ref MemBlock, item.Key, 0); + break; + + case plcDataType.Real: + saveRealOnMemBlock(ref MemBlock, item.Key, 0); + break; + + case plcDataType.String: + saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize); + break; + + default: + break; + } #if false if (currMem.tipoMem == plcDataType.String) { @@ -145,62 +237,65 @@ namespace IOB_WIN short valDInt = 0; short.TryParse(item.Value, out valDInt); MemBlock = S7.Net.Types.Int.ToByteArray(valDInt); - } + } #endif - } - taskVal = item.Value; - break; - case taskType.setParameter: - // richiedo da URL i parametri WRITE da popolare - lgInfo("Chiamata processMemWriteRequests"); - taskVal = processMemWriteRequests(); - // se restituiscce "" faccio altra prova... - if (!string.IsNullOrEmpty(taskVal)) - { - taskOk = true; - } - else - { - // i parametri me li aspetto come stringa composta paramName|paramvalue - if (item.Value.Contains("|")) - { - string[] paramsJob = item.Value.Split('|'); - taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}"; - } - else - { - taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value"; - } - } - // alzo il bit x registrare RICHEISTA modifica (secondo BIT)... POI quando ha eseguito abbassa il PLC il bit a zero... - MemBlock[0] = 2; - memAddrWrite = "DB1001.DBB88"; - break; - case taskType.sendWatchDogMes2Plc: - //// compogo in byte... primo bit è setup/run, ultimo è watchdog - //int valore = inSetup ? 1 : 0; - int valore = counterMes2Plc; - MemBlock[68] = (byte)valore; - taskVal = $"VALUE DB1001.68 --> {counterMes2Plc}"; - break; - default: - taskVal = "SKIPPED | NO EXEC"; - break; - } + } + taskVal = item.Value; + break; - // aggiungo task! - taskDone.Add(item.Key, taskVal); - if (!string.IsNullOrEmpty(memAddrWrite)) - { - // scrivo comunque! - taskOk = S7WriteBB(ref MemBlock, memAddrWrite); - } - if (!taskOk) - { - lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}"); - } - } - } + case taskType.setParameter: + // richiedo da URL i parametri WRITE da popolare + lgInfo("Chiamata processMemWriteRequests"); + taskVal = processMemWriteRequests(); + // se restituiscce "" faccio altra prova... + if (!string.IsNullOrEmpty(taskVal)) + { + taskOk = true; + } + else + { + // i parametri me li aspetto come stringa composta paramName|paramvalue + if (item.Value.Contains("|")) + { + string[] paramsJob = item.Value.Split('|'); + taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}"; + } + else + { + taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value"; + } + } + // alzo il bit x registrare RICHEISTA modifica (secondo BIT)... POI quando ha eseguito abbassa il PLC il bit a zero... + MemBlock[0] = 2; + memAddrWrite = "DB1001.DBB88"; + break; + + case taskType.sendWatchDogMes2Plc: + //// compogo in byte... primo bit è setup/run, ultimo è watchdog + //int valore = inSetup ? 1 : 0; + int valore = counterMes2Plc; + MemBlock[68] = (byte)valore; + taskVal = $"VALUE DB1001.68 --> {counterMes2Plc}"; + break; + + default: + taskVal = "SKIPPED | NO EXEC"; + break; + } + + // aggiungo task! + taskDone.Add(item.Key, taskVal); + if (!string.IsNullOrEmpty(memAddrWrite)) + { + // scrivo comunque! + taskOk = S7WriteBB(ref MemBlock, memAddrWrite); + } + if (!taskOk) + { + lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}"); + } + } + } #if false // controllo SE HO da scrivere articolo/commessa/programma @@ -208,9 +303,6 @@ namespace IOB_WIN saveStringOnMemBlock(ref MemBlock, "setComm", 22, 20, true); saveStringOnMemBlock(ref MemBlock, "setProg", 44, 20, true); - - - // !!!FIXME!!! rendere parametrico // SE HO un valore ART scrivo... if (currProdData.ContainsKey("setArt")) @@ -238,91 +330,24 @@ namespace IOB_WIN // fare un controllo x forzare update... // scrivo comunque! - taskOk = S7WriteBB(ref MemBlock); + taskOk = S7WriteBB(ref MemBlock); #endif - return taskDone; + return taskDone; + } + + /// + /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) + /// + public override void processOverride() + { + } + + public override void processWhatchDog() + { + //NON SERVE!!!! + } + + #endregion Public Methods } - - /// - /// Effettua decodifica aree memoria alla bitmap usata x MAPO - /// - protected override void decodeToBaseBitmap() - { - // init a zero... - B_input = 0; - - /* ----------------------------------------------------- - * bitmap MAPO STANDARD - * B0: POWER_ON - * B1: RUN - * B2: pzCount - * B3: allarme - * B4: manuale - * B5: avvio/spegnimento - * B6: emergenza - * - * - * - BYTE di stato - * - +0.0 AutoStatus BYTE B#16#0 Valore 0=Fermo/1->3=Avviamento/4=Avviato/5=Pausa/6->8spegnimento/9->10 allarme - * - +1.0 Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +2.0 V_Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +3.0 Nas_Lancio BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +4.0 Cilindro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +5.0 Bruciatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +6.0 Aspiratore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +7.0 Nas_Raccolta BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +8.0 Nas_Brandeg BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +9.0 Coclea_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - * - +10.0 Ciclico_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on) - ----------------------------------------------------- */ - - - // recupero byte segnali... - int byteSignals = RawInput[0]; - - // bit 0 (poweron) imposto a 1 SE connected... - B_input = currPLC.IsConnected ? 1 : 0; - - // avviamento --> manuale - switch (byteSignals) - { - case 0: - B_input = 1; - break; - case 1: - case 2: - case 3: - B_input += (1 << 5); - break; - case 4: - B_input += (1 << 1); - break; - case 5: - B_input += (1 << 4); - break; - case 6: - case 7: - case 8: - B_input += (1 << 5); - break; - case 9: - B_input += (1 << 3); - break; - case 10: - B_input += (1 << 6); - break; - default: - break; - } - - // log opzionale! - if (verboseLog) - { - lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}")); - } - } - - #endregion - } -} +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/IobSiemensComur.cs b/IOB-WIN-NEXT/IobSiemensComur.cs index 4ab4550c..a240f687 100644 --- a/IOB-WIN-NEXT/IobSiemensComur.cs +++ b/IOB-WIN-NEXT/IobSiemensComur.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Controllo Siemens specifico x impianti COMUR diff --git a/IOB-WIN-NEXT/IobSiemensFape.cs b/IOB-WIN-NEXT/IobSiemensFape.cs index 0f918023..6c2d6bfd 100644 --- a/IOB-WIN-NEXT/IobSiemensFape.cs +++ b/IOB-WIN-NEXT/IobSiemensFape.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobSiemensFape : IobSiemens { diff --git a/IOB-WIN-NEXT/IobSiemensIngenia.cs b/IOB-WIN-NEXT/IobSiemensIngenia.cs index 23f8a2ad..f3bd5d9f 100644 --- a/IOB-WIN-NEXT/IobSiemensIngenia.cs +++ b/IOB-WIN-NEXT/IobSiemensIngenia.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Controllo Siemens specifico x impianti Ingenia (Automazione Valvital) diff --git a/IOB-WIN-NEXT/IobSiemensLasco.cs b/IOB-WIN-NEXT/IobSiemensLasco.cs index d16e7411..9bb46609 100644 --- a/IOB-WIN-NEXT/IobSiemensLasco.cs +++ b/IOB-WIN-NEXT/IobSiemensLasco.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Controllo Siemens specifico x impianti Lasco (Pressa bilancere Valvital) diff --git a/IOB-WIN-NEXT/IobSiemensPressoilCei.cs b/IOB-WIN-NEXT/IobSiemensPressoilCei.cs index 2ffc7a76..ebdb5127 100644 --- a/IOB-WIN-NEXT/IobSiemensPressoilCei.cs +++ b/IOB-WIN-NEXT/IobSiemensPressoilCei.cs @@ -2,235 +2,253 @@ using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - /// - /// Controllo Siemens specifico x impianti Pressoil+Cei (Pressa idraulica Valvital) - /// - public class IobSiemensPressoilCei : IobSiemens - { - /* -------------------------------------------------------------------------------- - * Controlli SIEMENS CEI PRESSOIL (impianti ad induzione in VALVITAL) - * - basasto su SIEMENS - * - S7 vers 1500 - * - * STRUTTURA MEMORIA DB64 READ e DB67 WRITE, vedere file conf json - - * -------------------------------------------------------------------------------- */ - - protected DateTime lastPLCWatchDog; - protected int counterMes2Plc = 0; - protected int counterPlc2Mes = 0; - /// - /// Classe base con i metodi x Siemens + /// Controllo Siemens specifico x impianti Pressoil+Cei (Pressa idraulica Valvital) /// - /// - /// - public IobSiemensPressoilCei(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) + public class IobSiemensPressoilCei : IobSiemens { - lgInfo("NEW IOB SIEMENS versione PRESSOIL - CEI"); - } + /* -------------------------------------------------------------------------------- + * Controlli SIEMENS CEI PRESSOIL (impianti ad induzione in VALVITAL) + * - basasto su SIEMENS + * - S7 vers 1500 + * + * STRUTTURA MEMORIA DB64 READ e DB67 WRITE, vedere file conf json - #region Metodi specifici (da verificare/completare in implementazione) + * -------------------------------------------------------------------------------- */ - /// - /// Processo i task richiesti e li elimino dalla coda 1:1 - /// - /// - public override Dictionary executeTasks(Dictionary task2exe) - { - // Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti... - Dictionary taskDone = new Dictionary(); - bool taskOk = false; - string taskVal = ""; - // inizio con 1 byte di default - byte[] MemBlock = new byte[1]; - string memAddrWrite = ""; - if (task2exe != null) - { - // cerco task specifici - foreach (var item in task2exe) + #region Protected Fields + + protected int counterMes2Plc = 0; + protected int counterPlc2Mes = 0; + protected DateTime lastPLCWatchDog; + + #endregion Protected Fields + + #region Public Constructors + + /// + /// Classe base con i metodi x Siemens + /// + /// + /// + public IobSiemensPressoilCei(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) { - taskOk = false; - taskVal = ""; - // converto richiesta in enum... - taskType tName = taskType.nihil; - Enum.TryParse(item.Key, out tName); - // controllo sulla KEY - switch (tName) - { - case taskType.nihil: - case taskType.fixStopSetup: - case taskType.forceResetPzCount: - case taskType.forceSetPzCount: - case taskType.setProg: - taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC"; - break; - case taskType.setArt: - case taskType.setComm: - case taskType.setPzComm: - saveProdData(item); - int byteSize = 0; - // recupero dati da memMap... altrimenti NULLA - if (memMap.mMapWrite.ContainsKey(item.Key)) - { - dataConf currMem = memMap.mMapWrite[item.Key]; - byteSize = currMem.size; - memAddrWrite = currMem.memAddr; - MemBlock = new byte[byteSize]; - if (currMem.tipoMem == plcDataType.String) - { - saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize); - } - else if (currMem.tipoMem == plcDataType.Int) - { - short valDInt = 0; - short.TryParse(item.Value, out valDInt); - MemBlock = S7.Net.Types.Int.ToByteArray(valDInt); - } - else if (currMem.tipoMem == plcDataType.DInt) - { - int valDInt = 0; - int.TryParse(item.Value, out valDInt); - MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt); - } - else if (currMem.tipoMem == plcDataType.Word) - { - ushort valDInt = 0; - ushort.TryParse(item.Value, out valDInt); - MemBlock = S7.Net.Types.Word.ToByteArray(valDInt); - } - else if (currMem.tipoMem == plcDataType.DWord) - { - uint valDInt = 0; - uint.TryParse(item.Value, out valDInt); - MemBlock = S7.Net.Types.DWord.ToByteArray(valDInt); - } - } - taskVal = item.Value; - break; - case taskType.sendWatchDogMes2Plc: - // processo scrittura BIT su DB67.DBX0.0 - MemBlock = new byte[1]; - memAddrWrite = "DB67.DBB0"; - // compogo in byte... primo bit è setup/run, ultimo è watchdog - int valore = inSetup ? 1 : 0; - valore += (byte)(counterMes2Plc << 7); - MemBlock[0] = (byte)valore; - taskVal = $"VALUE DB67.0 --> {valore} | counter interno {counterMes2Plc}"; - break; - case taskType.setParameter: - // richiedo da URL i parametri WRITE da popolare - lgInfo("Chiamata processMemWriteRequests"); - taskVal = processMemWriteRequests(); - // se restituiscce "" faccio altra prova... - if (string.IsNullOrEmpty(taskVal)) - { - // i parametri me li aspetto come stringa composta paramName|paramvalue - if (item.Value.Contains("|")) - { - string[] paramsJob = item.Value.Split('|'); - taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}"; - } - else - { - taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value"; - } - } - break; - case taskType.startSetup: - // salvo che SONO IN SETUP! - inSetup = true; - break; - case taskType.stopSetup: - // salvo che SONO FUORI DAL SETUP! - inSetup = false; - break; - default: - taskVal = "SKIPPED | NO EXEC"; - break; - } - // aggiungo task! - taskDone.Add(item.Key, taskVal); - // scrivo comunque! - taskOk = S7WriteBB(ref MemBlock, memAddrWrite); - if (!taskOk) - { - lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}"); - } + lgInfo("NEW IOB SIEMENS versione PRESSOIL - CEI"); } - } - return taskDone; + + #endregion Public Constructors + + #region Protected Methods + + /// + /// Effettua decodifica aree memoria alla bitmap usata x MAPO + /// + protected override void decodeToBaseBitmap() + { + // init a zero... + B_input = 0; + + /* ----------------------------------------------------- + * bitmap MAPO STANDARD + * B0: POWER_ON + * B1: RUN + * B2: pzCount + * B3: allarme + * B4: manuale + * B5: emergenza + * + * + * - BIT di stato + * - DBX0.0 - Life bit + * - DBX0.1 – Macchina lavora + * - DBX0.2 – Macchina in ciclo + * - DBX0.3 – Macchina in manuale + * - DBX0.4 – Macchina in allarme + * - DBX0.5 – Macchina in emergenza + * + ----------------------------------------------------- */ + + byte mainData = RawInput[0]; + + int byteSignals = 0; + // bit 0 (poweron) imposto a 1 SE connected... + if (currPLC.IsConnected) + { + byteSignals += (1 << 0); + } + // RUN se lavora ed in ciclo + if ((mainData & (1 << 1)) != 0 && (mainData & (1 << 2)) != 0) + { + byteSignals += (1 << 1); + } + // manuale + if ((mainData & (1 << 3)) != 0) + { + byteSignals += (1 << 4); + } + // allarme + if ((mainData & (1 << 4)) != 0) + { + byteSignals += (1 << 3); + } + // emergenza + if ((mainData & (1 << 5)) != 0) + { + byteSignals += (1 << 5); + } + + // salvo! + B_input = byteSignals; + + // log opzionale! + if (verboseLog) + { + lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}"); + } + } + + #endregion Protected Methods + + #region Public Methods + + /// + /// Processo i task richiesti e li elimino dalla coda 1:1 + /// + /// + public override Dictionary executeTasks(Dictionary task2exe) + { + // Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti... + Dictionary taskDone = new Dictionary(); + bool taskOk = false; + string taskVal = ""; + // inizio con 1 byte di default + byte[] MemBlock = new byte[1]; + string memAddrWrite = ""; + if (task2exe != null) + { + // cerco task specifici + foreach (var item in task2exe) + { + taskOk = false; + taskVal = ""; + // converto richiesta in enum... + taskType tName = taskType.nihil; + Enum.TryParse(item.Key, out tName); + // controllo sulla KEY + switch (tName) + { + case taskType.nihil: + case taskType.fixStopSetup: + case taskType.forceResetPzCount: + case taskType.forceSetPzCount: + case taskType.setProg: + taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC"; + break; + + case taskType.setArt: + case taskType.setComm: + case taskType.setPzComm: + saveProdData(item); + int byteSize = 0; + // recupero dati da memMap... altrimenti NULLA + if (memMap.mMapWrite.ContainsKey(item.Key)) + { + dataConf currMem = memMap.mMapWrite[item.Key]; + byteSize = currMem.size; + memAddrWrite = currMem.memAddr; + MemBlock = new byte[byteSize]; + if (currMem.tipoMem == plcDataType.String) + { + saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize); + } + else if (currMem.tipoMem == plcDataType.Int) + { + short valDInt = 0; + short.TryParse(item.Value, out valDInt); + MemBlock = S7.Net.Types.Int.ToByteArray(valDInt); + } + else if (currMem.tipoMem == plcDataType.DInt) + { + int valDInt = 0; + int.TryParse(item.Value, out valDInt); + MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt); + } + else if (currMem.tipoMem == plcDataType.Word) + { + ushort valDInt = 0; + ushort.TryParse(item.Value, out valDInt); + MemBlock = S7.Net.Types.Word.ToByteArray(valDInt); + } + else if (currMem.tipoMem == plcDataType.DWord) + { + uint valDInt = 0; + uint.TryParse(item.Value, out valDInt); + MemBlock = S7.Net.Types.DWord.ToByteArray(valDInt); + } + } + taskVal = item.Value; + break; + + case taskType.sendWatchDogMes2Plc: + // processo scrittura BIT su DB67.DBX0.0 + MemBlock = new byte[1]; + memAddrWrite = "DB67.DBB0"; + // compogo in byte... primo bit è setup/run, ultimo è watchdog + int valore = inSetup ? 1 : 0; + valore += (byte)(counterMes2Plc << 7); + MemBlock[0] = (byte)valore; + taskVal = $"VALUE DB67.0 --> {valore} | counter interno {counterMes2Plc}"; + break; + + case taskType.setParameter: + // richiedo da URL i parametri WRITE da popolare + lgInfo("Chiamata processMemWriteRequests"); + taskVal = processMemWriteRequests(); + // se restituiscce "" faccio altra prova... + if (string.IsNullOrEmpty(taskVal)) + { + // i parametri me li aspetto come stringa composta paramName|paramvalue + if (item.Value.Contains("|")) + { + string[] paramsJob = item.Value.Split('|'); + taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}"; + } + else + { + taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value"; + } + } + break; + + case taskType.startSetup: + // salvo che SONO IN SETUP! + inSetup = true; + break; + + case taskType.stopSetup: + // salvo che SONO FUORI DAL SETUP! + inSetup = false; + break; + + default: + taskVal = "SKIPPED | NO EXEC"; + break; + } + // aggiungo task! + taskDone.Add(item.Key, taskVal); + // scrivo comunque! + taskOk = S7WriteBB(ref MemBlock, memAddrWrite); + if (!taskOk) + { + lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}"); + } + } + } + return taskDone; + } + + #endregion Public Methods } - - /// - /// Effettua decodifica aree memoria alla bitmap usata x MAPO - /// - protected override void decodeToBaseBitmap() - { - // init a zero... - B_input = 0; - - /* ----------------------------------------------------- - * bitmap MAPO STANDARD - * B0: POWER_ON - * B1: RUN - * B2: pzCount - * B3: allarme - * B4: manuale - * B5: emergenza - * - * - * - BIT di stato - * - DBX0.0 - Life bit - * - DBX0.1 – Macchina lavora - * - DBX0.2 – Macchina in ciclo - * - DBX0.3 – Macchina in manuale - * - DBX0.4 – Macchina in allarme - * - DBX0.5 – Macchina in emergenza - * - ----------------------------------------------------- */ - - byte mainData = RawInput[0]; - - int byteSignals = 0; - // bit 0 (poweron) imposto a 1 SE connected... - if (currPLC.IsConnected) - { - byteSignals += (1 << 0); - } - // RUN se lavora ed in ciclo - if ((mainData & (1 << 1)) != 0 && (mainData & (1 << 2)) != 0) - { - byteSignals += (1 << 1); - } - // manuale - if ((mainData & (1 << 3)) != 0) - { - byteSignals += (1 << 4); - } - // allarme - if ((mainData & (1 << 4)) != 0) - { - byteSignals += (1 << 3); - } - // emergenza - if ((mainData & (1 << 5)) != 0) - { - byteSignals += (1 << 5); - } - - // salvo! - B_input = byteSignals; - - // log opzionale! - if (verboseLog) - { - lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}"); - } - } - - #endregion - } -} +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/IobSiemensSaet.cs b/IOB-WIN-NEXT/IobSiemensSaet.cs index 42533569..d10b553c 100644 --- a/IOB-WIN-NEXT/IobSiemensSaet.cs +++ b/IOB-WIN-NEXT/IobSiemensSaet.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Controllo Siemens specifico x impianti SAET diff --git a/IOB-WIN-NEXT/IobSiemensSimec.cs b/IOB-WIN-NEXT/IobSiemensSimec.cs index 7bb4f332..81d72e75 100644 --- a/IOB-WIN-NEXT/IobSiemensSimec.cs +++ b/IOB-WIN-NEXT/IobSiemensSimec.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Controllo Siemens specifico x impianti Simec diff --git a/IOB-WIN-NEXT/IobSiemensTorri.cs b/IOB-WIN-NEXT/IobSiemensTorri.cs index fadd5832..43bd4d18 100644 --- a/IOB-WIN-NEXT/IobSiemensTorri.cs +++ b/IOB-WIN-NEXT/IobSiemensTorri.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobSiemensTorri : IobSiemens { diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index 26bc9f66..678a9869 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -3,7 +3,7 @@ using MapoSDK; using System; using System.Collections.Generic; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public class IobSimula : IobGeneric { diff --git a/IOB-WIN-NEXT/IobWPS.cs b/IOB-WIN-NEXT/IobWPS.cs index 69f82a7b..c1e7f7ae 100644 --- a/IOB-WIN-NEXT/IobWPS.cs +++ b/IOB-WIN-NEXT/IobWPS.cs @@ -12,47 +12,57 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { /// /// Generica classe per implementare WebPageScraping (scaricamento web pages anche js-based x recupero informazioni) /// public class IobWPS : IobGeneric, IDisposable { - /* -------------------------------------------------------------------------------- + /* -------------------------------------------------------------------------------- * Controlli dotati di GENERICA pagina WEB in cui cercare e recuperare informazioni - * + * * - il file di conf deve contenere l'URL di base * - il file di conf deve contenere COSA cercare (es il "contenitore" del dato da estrarre) - * + * * -------------------------------------------------------------------------------- */ - /// - /// Vettore della frequenza di ogni status trovato... invio ogni 100 rilevazioni (modulo 100, resto == 1) - /// - protected Dictionary freqUnknStatus = new Dictionary(); + #region Protected Fields + /// /// Pagina web da scaricare /// protected string baseUri = "http://127.0.0.1"; + /// /// Array di configurazione degli oggetti da cercare x decodifica e recupero info /// protected Dictionary dataLocatorLUT; + /// /// Driver per gestione chiamate crawling/scraping /// protected IWebDriver driver; - /// - /// Oggetti decodificati da pagina - /// - protected MonitoredItemsConf monitoredItems; /// /// Elementi da recuperare nella apgina web /// protected IWebElement element; + /// + /// Vettore della frequenza di ogni status trovato... invio ogni 100 rilevazioni (modulo 100, resto == 1) + /// + protected Dictionary freqUnknStatus = new Dictionary(); + + /// + /// Oggetti decodificati da pagina + /// + protected MonitoredItemsConf monitoredItems; + + #endregion Protected Fields + + #region Public Constructors + /// /// Estende l'init della classe base... /// @@ -63,6 +73,40 @@ namespace IOB_WIN lgInfo("INIT IobWPS"); //reloadAdapterConf(); } + + #endregion Public Constructors + + #region Private Methods + + /// + /// Processo stati unknown... + /// + /// + private void processUnknStatus(string cKey) + { + // cerco se avevo già una key nella dictionary... + if (freqUnknStatus.ContainsKey(cKey)) + { + freqUnknStatus[cKey]++; + // se è 1 ogni 100 (%100, resto ==1) --> loggo... + if (freqUnknStatus[cKey] % 100 == 1) + { + lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}"); + // accodo come invio di tipo FLOG... + string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus); + // chiamo accodamento... + accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal)); + } + } + else + { + // creo chiave con freq = 1 + freqUnknStatus.Add(cKey, 1); + // log iniziale + lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}"); + } + } + /// /// Ricarica conf adapter... /// @@ -105,66 +149,6 @@ namespace IOB_WIN raiseRefresh(currDispData); } - #region Metodi specifici (da verificare/completare in implementazione) - - public override void startAdapter(bool resetQueue) - { - // in primis RICARICO conf specifica... - reloadAdapterConf(); - // continuo con start... - base.startAdapter(resetQueue); - } - - /// - /// Override x chiusura driver... - /// - /// - /// - public override void stopAdapter(bool tryRestart, bool forceDequeue) - { - try - { - // in primis chiudo driver... - if (driver != null) - { - driver.Quit(); - } - } - catch (Exception exc) - { - lgError(exc, "Eccezione in tryDisconnect"); - } - // continuo - base.stopAdapter(tryRestart, forceDequeue); - } - /// - /// Connessione - /// - public override void tryConnect() - { - // controllo ping --> segno connected... - connectionOk = (testPingMachine == IPStatus.Success); - if (connectionOk) - { - try - { - //var t = TaskEx.Run(() => startDriver()); - //t.Wait(); - // modalità sincrona - startDriver(); - lgInfo("Completato start driver"); - } - catch (Exception exc) - { - lgError(exc, "Eccezione in tryConnect"); - } - } - else - { - // aspetto prima di riprovare... - Thread.Sleep(200); - } - } /// /// Avvio del WebDriver /// @@ -198,31 +182,15 @@ namespace IOB_WIN // imposto pagina di acquisizione driver.Navigate().GoToUrl(baseUri); } - /// - /// Disconnessione - /// - public override void tryDisconnect() - { - connectionOk = false; - try - { - // in primis chiudo driver... - if (driver != null) - //if (driver != null && driver.WindowHandles.Count > 0) - { - driver.Quit(); - } - } - catch (Exception exc) - { - lgError(exc, "Eccezione in tryDisconnect"); - } - } - /// - /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) - /// - public override void processOverride() + + #endregion Private Methods + + #region Public Methods + + public void Dispose() { + driver.Dispose(); + GC.SuppressFinalize(this); } /// @@ -274,6 +242,13 @@ namespace IOB_WIN return outVal; } + /// + /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) + /// + public override void processOverride() + { + } + /// /// Effettua lettura semafori principale /// Parametri da aggiornare x display in form @@ -328,41 +303,88 @@ namespace IOB_WIN currDispData.semIn = Semaforo.SR; } } - /// - /// Processo stati unknown... - /// - /// - private void processUnknStatus(string cKey) + + public override void startAdapter(bool resetQueue) { - // cerco se avevo già una key nella dictionary... - if (freqUnknStatus.ContainsKey(cKey)) + // in primis RICARICO conf specifica... + reloadAdapterConf(); + // continuo con start... + base.startAdapter(resetQueue); + } + + /// + /// Override x chiusura driver... + /// + /// + /// + public override void stopAdapter(bool tryRestart, bool forceDequeue) + { + try { - freqUnknStatus[cKey]++; - // se è 1 ogni 100 (%100, resto ==1) --> loggo... - if (freqUnknStatus[cKey] % 100 == 1) + // in primis chiudo driver... + if (driver != null) { - lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}"); - // accodo come invio di tipo FLOG... - string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus); - // chiamo accodamento... - accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal)); + driver.Quit(); + } + } + catch (Exception exc) + { + lgError(exc, "Eccezione in tryDisconnect"); + } + // continuo + base.stopAdapter(tryRestart, forceDequeue); + } + + /// + /// Connessione + /// + public override void tryConnect() + { + // controllo ping --> segno connected... + connectionOk = (testPingMachine == IPStatus.Success); + if (connectionOk) + { + try + { + //var t = TaskEx.Run(() => startDriver()); + //t.Wait(); + // modalità sincrona + startDriver(); + lgInfo("Completato start driver"); + } + catch (Exception exc) + { + lgError(exc, "Eccezione in tryConnect"); } } else { - // creo chiave con freq = 1 - freqUnknStatus.Add(cKey, 1); - // log iniziale - lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}"); + // aspetto prima di riprovare... + Thread.Sleep(200); } } - public void Dispose() + /// + /// Disconnessione + /// + public override void tryDisconnect() { - driver.Dispose(); - GC.SuppressFinalize(this); + connectionOk = false; + try + { + // in primis chiudo driver... + if (driver != null) + //if (driver != null && driver.WindowHandles.Count > 0) + { + driver.Quit(); + } + } + catch (Exception exc) + { + lgError(exc, "Eccezione in tryDisconnect"); + } } - #endregion + #endregion Public Methods } -} +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/MainForm.Designer.cs b/IOB-WIN-NEXT/MainForm.Designer.cs index b91e71a0..5cc9cd87 100644 --- a/IOB-WIN-NEXT/MainForm.Designer.cs +++ b/IOB-WIN-NEXT/MainForm.Designer.cs @@ -1,4 +1,4 @@ -namespace IOB_WIN +namespace IOB_WIN_NEXT { partial class MainForm { diff --git a/IOB-WIN-NEXT/MainForm.cs b/IOB-WIN-NEXT/MainForm.cs index b827dccf..8f75beeb 100644 --- a/IOB-WIN-NEXT/MainForm.cs +++ b/IOB-WIN-NEXT/MainForm.cs @@ -16,7 +16,7 @@ using System.Net.NetworkInformation; using System.Threading; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { public partial class MainForm : Form { diff --git a/IOB-WIN-NEXT/Objects.cs b/IOB-WIN-NEXT/Objects.cs index 34e3f45a..02213ddc 100644 --- a/IOB-WIN-NEXT/Objects.cs +++ b/IOB-WIN-NEXT/Objects.cs @@ -3,39 +3,44 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - public class Objects - { + /// + /// Classe di estensione x oggetti DataItems con struttura e valori + /// + public class MtcDataItemExt : MTConnect.MTConnectDevices.DataItem + { + #region Public Properties - } + /// + /// Valore (in sec) del periodo di downsampling (0 --> NON usato) + /// + public int samplePeriod { get; set; } = 60; - /// - /// Classe di estensione x oggetti DataItems con struttura e valori - /// - public class MtcDataItemExt : MTConnect.MTConnectDevices.DataItem - { - /// - /// UUID univoco dell'oggetto --> flusso - /// - public string uid { get; set; } = ""; - /// - /// Valore Registrato in formato stringa - /// - public string value { get; set; } = ""; - /// - /// Timestamp data-ora evento registrato - /// - public DateTime valueTimestamp { get; set; } = DateTime.Now; - /// - /// Valore soglia DeadBand (0 --> non usata) - /// - public double thresholdDeadBand { get; set; } = 0; - /// - /// Valore (in sec) del periodo di downsampling (0 --> NON usato) - /// - public int samplePeriod { get; set; } = 60; - } + /// + /// Valore soglia DeadBand (0 --> non usata) + /// + public double thresholdDeadBand { get; set; } = 0; + /// + /// UUID univoco dell'oggetto --> flusso + /// + public string uid { get; set; } = ""; -} + /// + /// Valore Registrato in formato stringa + /// + public string value { get; set; } = ""; + + /// + /// Timestamp data-ora evento registrato + /// + public DateTime valueTimestamp { get; set; } = DateTime.Now; + + #endregion Public Properties + } + + public class Objects + { + } +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/Program.cs b/IOB-WIN-NEXT/Program.cs index 05cd0c90..562de392 100644 --- a/IOB-WIN-NEXT/Program.cs +++ b/IOB-WIN-NEXT/Program.cs @@ -1,25 +1,29 @@ using System; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - static class Program - { - /// - /// Punto di ingresso principale dell'applicazione. - /// Parametri di avvio - /// - [STAThread] - static void Main(string[] args) + internal static class Program { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - try - { - Application.Run(new MainForm(args)); - } - catch - { } + #region Private Methods + + /// + /// Punto di ingresso principale dell'applicazione. + /// Parametri di avvio + /// + [STAThread] + private static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + try + { + Application.Run(new MainForm(args)); + } + catch + { } + } + + #endregion Private Methods } - } -} +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/Properties/Resources.Designer.cs b/IOB-WIN-NEXT/Properties/Resources.Designer.cs index 7c855b6a..fabb0b11 100644 --- a/IOB-WIN-NEXT/Properties/Resources.Designer.cs +++ b/IOB-WIN-NEXT/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace IOB_WIN.Properties { +namespace IOB_WIN_NEXT.Properties { using System; diff --git a/IOB-WIN-NEXT/Properties/Settings.Designer.cs b/IOB-WIN-NEXT/Properties/Settings.Designer.cs index d965eb57..67debe96 100644 --- a/IOB-WIN-NEXT/Properties/Settings.Designer.cs +++ b/IOB-WIN-NEXT/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace IOB_WIN.Properties { +namespace IOB_WIN_NEXT.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] diff --git a/IOB-WIN-NEXT/TestForm.Designer.cs b/IOB-WIN-NEXT/TestForm.Designer.cs index c0fe4aed..932c68df 100644 --- a/IOB-WIN-NEXT/TestForm.Designer.cs +++ b/IOB-WIN-NEXT/TestForm.Designer.cs @@ -1,4 +1,4 @@ -namespace IOB_WIN +namespace IOB_WIN_NEXT { partial class TestForm { diff --git a/IOB-WIN-NEXT/TestForm.cs b/IOB-WIN-NEXT/TestForm.cs index d104a9df..f0d4b08c 100644 --- a/IOB-WIN-NEXT/TestForm.cs +++ b/IOB-WIN-NEXT/TestForm.cs @@ -8,13 +8,17 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - public partial class TestForm : Form - { - public TestForm() + public partial class TestForm : Form { - InitializeComponent(); + #region Public Constructors + + public TestForm() + { + InitializeComponent(); + } + + #endregion Public Constructors } - } -} +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/memAddress.cs b/IOB-WIN-NEXT/memAddress.cs index 0c581f85..ebfb9945 100644 --- a/IOB-WIN-NEXT/memAddress.cs +++ b/IOB-WIN-NEXT/memAddress.cs @@ -5,87 +5,34 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - /// - /// Definizione area memoria SIEMENS - /// - public class memAreaSiemens - { - /// - /// Indice DB - /// - public int DbNum = 0; - /// - /// Tipo Memoria (DBD, DBW...) - /// - public string tipoMem = ""; - /// - /// Indice partenza memoria (es DBD0 --> 0) - /// - public int indiceMem = 0; - /// - /// Inizializza da un formato stringa - /// - /// - public memAreaSiemens(string strFormat) - { - if (!string.IsNullOrEmpty(strFormat)) - { - string[] memComp = strFormat.Split('.'); - int.TryParse(memComp[0].Replace("DB", ""), out DbNum); - //tipoMem = memComp[1].Substring(2, 1); - tipoMem = ""; - for (int i = 0; i < memComp[1].Length; i++) - { - if(char.IsLetter(memComp[1][i])) - { - tipoMem += memComp[1][i]; - } - } - // rimuovo DB iniziale.. - tipoMem = tipoMem.Replace("DB", ""); - // ciclo x trovare SOLO stringa - int.TryParse(memComp[1].Replace("DB", "").Replace(tipoMem, ""), out indiceMem); - } - } - } - - /// - /// Definizione area memoria FANUC - /// - public class memAreaFanuc - { - /// - /// Nome area memoria - /// - public string areaName; - /// - /// Indice inizio array - /// - public int startIdx; - /// - /// Dimensione array memoria - /// - public int arraySize; - } /// /// Definizione indirizzo memoria FANUC /// public class memAddressFanuc { - /// - /// Tipo memoria - /// - public FANUC.MemType mType; + #region Public Fields + /// /// Posizione memoria /// public int mPos; + + /// + /// Tipo memoria + /// + public FANUC.MemType mType; + /// /// Tipo valore /// public string vType; + + #endregion Public Fields + + #region Public Constructors + /// /// Inizializza da un formato stringa /// @@ -100,48 +47,63 @@ namespace IOB_WIN case "A": mType = FANUC.MemType.A; break; + case "C": mType = FANUC.MemType.C; break; + case "CM": mType = FANUC.MemType.CM; break; + case "D": mType = FANUC.MemType.D; break; + case "E": mType = FANUC.MemType.E; break; + case "F": mType = FANUC.MemType.F; break; + case "G": mType = FANUC.MemType.G; break; + case "K": mType = FANUC.MemType.K; break; + case "M": mType = FANUC.MemType.M; break; + case "N": mType = FANUC.MemType.N; break; + case "R": mType = FANUC.MemType.R; break; + case "T": mType = FANUC.MemType.T; break; + case "X": mType = FANUC.MemType.X; break; + case "Y": mType = FANUC.MemType.Y; break; + case "Z": mType = FANUC.MemType.Z; break; + default: break; } @@ -149,5 +111,87 @@ namespace IOB_WIN vType = memComp[2]; } } + + #endregion Public Constructors } -} + + /// + /// Definizione area memoria FANUC + /// + public class memAreaFanuc + { + #region Public Fields + + /// + /// Nome area memoria + /// + public string areaName; + + /// + /// Dimensione array memoria + /// + public int arraySize; + + /// + /// Indice inizio array + /// + public int startIdx; + + #endregion Public Fields + } + + /// + /// Definizione area memoria SIEMENS + /// + public class memAreaSiemens + { + #region Public Fields + + /// + /// Indice DB + /// + public int DbNum = 0; + + /// + /// Indice partenza memoria (es DBD0 --> 0) + /// + public int indiceMem = 0; + + /// + /// Tipo Memoria (DBD, DBW...) + /// + public string tipoMem = ""; + + #endregion Public Fields + + #region Public Constructors + + /// + /// Inizializza da un formato stringa + /// + /// + public memAreaSiemens(string strFormat) + { + if (!string.IsNullOrEmpty(strFormat)) + { + string[] memComp = strFormat.Split('.'); + int.TryParse(memComp[0].Replace("DB", ""), out DbNum); + //tipoMem = memComp[1].Substring(2, 1); + tipoMem = ""; + for (int i = 0; i < memComp[1].Length; i++) + { + if (char.IsLetter(memComp[1][i])) + { + tipoMem += memComp[1][i]; + } + } + // rimuovo DB iniziale.. + tipoMem = tipoMem.Replace("DB", ""); + // ciclo x trovare SOLO stringa + int.TryParse(memComp[1].Replace("DB", "").Replace(tipoMem, ""), out indiceMem); + } + } + + #endregion Public Constructors + } +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/specialConfig.cs b/IOB-WIN-NEXT/specialConfig.cs index 43a1d416..6a867dcf 100644 --- a/IOB-WIN-NEXT/specialConfig.cs +++ b/IOB-WIN-NEXT/specialConfig.cs @@ -1,48 +1,60 @@ using S7.Net; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - /// - /// Implementazione classe connessione SIEMENS con S7.net, - /// comprensiva dei parametri delle aree di memoria - /// - public class connParamS7 - { /// - /// Indirizzo IP del PLC + /// Implementazione classe connessione SIEMENS con S7.net, + /// comprensiva dei parametri delle aree di memoria /// - public string ipAdrr = ""; - /// - /// Tipo CPU Siemens - /// - public CpuType tipoCpu = CpuType.S7300; - /// - /// Slot comunicazione - /// - public short slot = 0; - /// - /// Rack comunicazione - /// - public short rack = 0; - /// - /// Timeout ping - /// - public int pingMsTimeout = 250; - /// - /// Base area x lettura - /// - public string memAddrRead = ""; - /// - /// Base area x scrittura - /// - public string memAddrWrite = ""; - /// - /// Size memoria lettura - /// - public int memSizeRead = 0; - /// - /// Size memoria scrittura - /// - public int memSizeWrite = 0; - } -} + public class connParamS7 + { + #region Public Fields + + /// + /// Indirizzo IP del PLC + /// + public string ipAdrr = ""; + + /// + /// Base area x lettura + /// + public string memAddrRead = ""; + + /// + /// Base area x scrittura + /// + public string memAddrWrite = ""; + + /// + /// Size memoria lettura + /// + public int memSizeRead = 0; + + /// + /// Size memoria scrittura + /// + public int memSizeWrite = 0; + + /// + /// Timeout ping + /// + public int pingMsTimeout = 250; + + /// + /// Rack comunicazione + /// + public short rack = 0; + + /// + /// Slot comunicazione + /// + public short slot = 0; + + /// + /// Tipo CPU Siemens + /// + public CpuType tipoCpu = CpuType.S7300; + + #endregion Public Fields + } +} \ No newline at end of file diff --git a/IOB-WIN-NEXT/utils.cs b/IOB-WIN-NEXT/utils.cs index 623f70dc..1a075dcb 100644 --- a/IOB-WIN-NEXT/utils.cs +++ b/IOB-WIN-NEXT/utils.cs @@ -2,118 +2,136 @@ using System.Linq; using System.Windows.Forms; -namespace IOB_WIN +namespace IOB_WIN_NEXT { - public class utils : IOB_UT.baseUtils - { - /// - /// folder archiviazione dati configurazione (DATA\CONF) - /// - public static string resxDir + public class utils : IOB_UT.baseUtils { - get - { - return string.Format(@"{0}\{1}", Application.StartupPath, CRS("resxPath")); - } + #region Public Properties + + /// + /// folder archiviazione dati configurazione (DATA\CONF) + /// + public static string confDir + { + get + { + return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath")); + } + } + + /// + /// folder archiviazione dati storici giornalieri (DATA\DAT) + /// + public static string dataDatDir + { + get + { + return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataDatPath")); + } + } + + /// + /// folder archiviazione dati (DATA) + /// + public static string dataDir + { + get + { + return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath")); + } + } + + /// + /// File icona default + /// + public static string defIconFilePath + { + get + { + return string.Format(@"{0}\SteamWare.ico", utils.resxDir); + } + } + + /// + /// File persistenza generale + /// + public static string defPersLayerFile + { + get + { + return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile")); + } + } + + /// + /// file persistenza generale + /// + public static string histPersLayerFile + { + get + { + return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now); + } + } + + /// + /// File configurazione default x MAIN + /// + public static string mainConfFilePath + { + get + { + return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("mainConfFile")); + } + } + + /// + /// folder archiviazione dati configurazione (DATA\CONF) + /// + public static string resxDir + { + get + { + return string.Format(@"{0}\{1}", Application.StartupPath, CRS("resxPath")); + } + } + + /// + /// File SimData x simulazione deterministica + /// + public static string simDataFile + { + get + { + return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("simDataFile")); + } + } + + #endregion Public Properties + + #region Public Methods + + /// + /// file persistenza generale data attuale ANTICIPATA di xx giorni + /// + /// num DD di anticipo + /// + public static string prevPersLayerFile(int numDD) + { + return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD)); + } + + /// + /// Converte un array di caratteri in una stringa valida (ovvero SOLO numeri/lettere) + /// + /// + /// + public static string purgedChar2String(char[] input) + { + string answ = new string(input.Where(c => char.IsLetter(c) || char.IsDigit(c)).ToArray()); + return answ; + } + + #endregion Public Methods } - /// - /// folder archiviazione dati configurazione (DATA\CONF) - /// - public static string confDir - { - get - { - return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath")); - } - } - /// - /// folder archiviazione dati storici giornalieri (DATA\DAT) - /// - public static string dataDatDir - { - get - { - return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataDatPath")); - } - } - /// - /// folder archiviazione dati (DATA) - /// - public static string dataDir - { - get - { - return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath")); - } - } - /// - /// File configurazione default x MAIN - /// - public static string mainConfFilePath - { - get - { - return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("mainConfFile")); - } - } - /// - /// File SimData x simulazione deterministica - /// - public static string simDataFile - { - get - { - return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("simDataFile")); - } - } - /// - /// File persistenza generale - /// - public static string defPersLayerFile - { - get - { - return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile")); - } - } - /// - /// file persistenza generale - /// - public static string histPersLayerFile - { - get - { - return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now); - } - } - /// - /// file persistenza generale data attuale ANTICIPATA di xx giorni - /// - /// num DD di anticipo - /// - public static string prevPersLayerFile(int numDD) - { - return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD)); - } - /// - /// File icona default - /// - public static string defIconFilePath - { - get - { - return string.Format(@"{0}\SteamWare.ico", utils.resxDir); - } - } - /// - /// Converte un array di caratteri in una stringa valida (ovvero SOLO numeri/lettere) - /// - /// - /// - public static string purgedChar2String(char[] input) - { - string answ = new string(input.Where(c => char.IsLetter(c) || char.IsDigit(c)).ToArray()); - return answ; - } - } -} +} \ No newline at end of file