using IOB_UT_NEXT; using IOB_UT_NEXT.Config; using System; namespace IOB_WIN_MBUS.IobModbusTCP { /* -------------------------------------------------------------------------------- * Controlli ModBusTCP SAIM * - protocollo ModBus TCP * - specifico comportamento impianti sanificazione ad ozono SAIM (Giacovelli) * - gestione allarmi * * STRUTTURA MEMORIA a banchi di UInt16, convertiti successivamente in int EVENTUALMENTE divisi per 10/100/1000 * G:\Drive condivisi\30_Clienti\Giacovelli - WIL\SAIM * * -------------------------------------------------------------------------------- */ public class ModbusTCPSaim : ModbusTCP { #region Public Constructors /// /// Classe base con i metodi x ModBusTCP /// /// Form chiamante /// Configurazione (legacy) /// Configurazione (v 4.x) public ModbusTCPSaim(AdapterFormNext caller, IobConfTree IobConfFull) : base(caller, IobConfFull) { lgInfo("NEW IOB ModBus TCP Saim"); // provo lettura una prima volta i dati DYN if (currPLC != null && currPLC.Connected) { try { processDynData(); if (EnableTest) { ProcessDataSync(); testReadExt(); } } catch (Exception exc) { lgError($"Eccezione in processDynData iniziale x ModBus TCP SAIM:{Environment.NewLine}{exc}"); } } } #endregion Public Constructors #region Protected Properties /// /// Restituisce controllo IN ALLARME /// protected bool AlarmState { get { return testDisInBitCondition("AlarmBitCond"); } } /// /// Restituisce status di ESTOP triggered (triggered = premuta, altrimenti armed) /// protected bool EStopTriggered { get { return testDisInBitCondition("EStopBitCond"); } } /// /// Restituisce status di Manuale, hard coded /// protected bool ManualState { get { return testDisInBitCondition("ManualBitCond"); } } /// /// Restituisce status di LAVORA, hard coded /// protected bool Work { get { return testDisInBitCondition("WorkBitCond"); } } /// /// Restituisce status di WORK (auto + lavora), hard coded /// protected bool WorkState { get { return testDisInBitCondition("WorkBitCond"); } } #endregion Protected Properties #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 60 * B0: POWER_ON * B1: RUN * B2: pzCount * B3: allarme * B4: manuale * B5: slowTC * B6: WarmUpCoolDown * B7: EmergArmata * ----------------------------------------------------- */ var MemInt = new byte[2]; int byteSignals = 0; // bit 0 (poweron) imposto a 1 SE connected... if (currPLC.Connected) { byteSignals += (1 << 0); } // se ho qualcosa nella holding register... if (HoldingRegisterLUT != null && HoldingRegisterLUT.Count > 0) { // se emergenza NON premuta (triggered) indico OK (armata...) FARE !!! togliere true //if (!EStopTriggered) if (true) { byteSignals += (1 << 7); } // impiego controlli da setup IntConditions... processo dagli stati + gravi... if (AlarmState || hasAlarms()) { byteSignals += (1 << 3); } else if (ManualState) { byteSignals += (1 << 4); } else if (WorkState) { byteSignals += (1 << 1); } } else { lgInfo("HoldingRegisterLUT vuoto!"); } // salvo! B_input = byteSignals; } /// /// Effettua sync dati /// protected override void ProcessDataSync() { // richiesta check autoODL ProcessAutoOdl(); // richiesta generazione quotidiana dossiers ProcessAutoDossier(); // effettua gestione import file... ProcessFileImport(); } #endregion Protected Methods } }