diff --git a/IOB-UT-NEXT/Iob/Services/Machine/MachineCommunicationService.cs b/IOB-UT-NEXT/Iob/Services/Machine/MachineCommunicationService.cs
index 364b622b..68a97de7 100644
--- a/IOB-UT-NEXT/Iob/Services/Machine/MachineCommunicationService.cs
+++ b/IOB-UT-NEXT/Iob/Services/Machine/MachineCommunicationService.cs
@@ -2,42 +2,31 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using IOB_UT_NEXT.Config;
+using IOB_UT_NEXT.Config.Mem;
using IOB_UT_NEXT.Objects;
using IOB_UT_NEXT.Services.Core;
-using MapoSDK;
using NLog;
namespace IOB_UT_NEXT.Services.Machine
{
///
/// MachineCommunicationService: Orchestratore per il dominio MACCHINA (_machineThread).
- /// Gestisce l'interazione a bassa latenza con PLC/CNC e la gestione della memoria condivisa (MemMap).
+ /// Gestisce l'interazione con tcMan e memMap, incapsulando la logica di "maneggio" dei dati.
///
public class MachineCommunicationService
{
- private readonly IobConfTree _config;
- private readonly TCMan _tcMan;
- private readonly plcMemMap _memMap;
- private static readonly Logger logger = LogManager.GetCurrentClassLogger();
+ #region Public Constructors
- public MachineCommunicationService(IobConfTree config, TCMan tcMan, plcMemMap memMap)
+ public MachineCommunicationService(IobConfTree config, TCMan tcMan, plcMemMapExt memMap)
{
_config = config ?? throw new ArgumentNullException(nameof(config));
_tcMan = tcMan ?? throw new ArgumentNullException(nameof(tcMan));
_memMap = memMap ?? throw new ArgumentNullException(nameof(memMap));
}
- #region PLC / CNC Operations (Real-Time Domain)
+ #endregion Public Constructors
- ///
- /// Legge il conteggio pezzi attuale dal driver della macchina.
- ///
- public int GetPzCountIOB() => _tcMan.pzCountIOB;
-
- ///
- /// Legge il conteggio pezzi attuale dal PLC.
- ///
- public int GetPzCountPLC() => _tcMan.pzCountPLC;
+ #region Public Methods
///
/// Ottiene la media dei tempi ciclo (TC) rilevati.
@@ -49,9 +38,36 @@ namespace IOB_UT_NEXT.Services.Machine
///
public DateTime GetLastObservedData() => _tcMan.lastObservedData;
- #endregion
+ ///
+ /// Gestione conteggio pezzi attuale dal driver della macchina.
+ ///
+ ///
+ public int ContapezziIOB
+ {
+ get => _tcMan.pzCountIOB;
+ set => _tcMan.pzCountIOB=value;
+ }
- #region Memory Map Operations (Shared Memory Domain)
+ ///
+ /// Gestione conteggio pezzi attuale dal PLC.
+ ///
+ public int ContapezziPLC
+ {
+ get => _tcMan.pzCountPLC;
+ set => _tcMan.pzCountPLC = value;
+ }
+
+ ///
+ /// Legge un valore dalla memoria condivisa (MemMap) ricevuta dal PLC.
+ ///
+ public string ReadFromMemMap(string key)
+ {
+ if (_memMap != null && _memMap.mMapRead != null && _memMap.mMapRead.ContainsKey(key))
+ {
+ return _memMap.mMapRead[key].value;
+ }
+ return null;
+ }
///
/// Scrive un valore nella memoria condivisa (MemMap) per l'invio al PLC.
@@ -72,18 +88,15 @@ namespace IOB_UT_NEXT.Services.Machine
}
}
- ///
- /// Legge un valore dalla memoria condivisa (MemMap) ricevuta dal PLC.
- ///
- public string ReadFromMemMap(string key)
- {
- if (_memMap != null && _memMap.mMapRead != null && _memMap.mMapRead.ContainsKey(key))
- {
- return _memMap.mMapRead[key].value;
- }
- return null;
- }
+ #endregion Public Methods
- #endregion
+ #region Private Fields
+
+ private static readonly Logger logger = LogManager.GetCurrentClassLogger();
+ private readonly IobConfTree _config;
+ private readonly plcMemMapExt _memMap;
+ private readonly TCMan _tcMan;
+
+ #endregion Private Fields
}
-}
+}
\ No newline at end of file
diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs
index 279849d4..100fd8a1 100644
--- a/IOB-WIN-FORM/Iob/Generic.cs
+++ b/IOB-WIN-FORM/Iob/Generic.cs
@@ -147,24 +147,6 @@ namespace IOB_WIN_FORM.Iob
set => _connOk = value;
}
- ///
- /// Contapezzi attuale
- ///
- public Int32 contapezziIOB
- {
- get => tcMan.pzCountIOB;
- set => tcMan.pzCountIOB = value;
- }
-
- ///
- /// Ultima lettura variabile contapezzi da CNC
- ///
- public Int32 contapezziPLC
- {
- get => tcMan.pzCountPLC;
- set => tcMan.pzCountPLC = value;
- }
-
///
/// Contatore x invio dati FluxLog
///
@@ -306,6 +288,7 @@ namespace IOB_WIN_FORM.Iob
}
}
+#if false
///
/// Valore medio del TC rilevato x verifica derive sul delta variazione contapezzi
///
@@ -316,10 +299,36 @@ namespace IOB_WIN_FORM.Iob
///
public DateTime plcLastPzRead => tcMan.lastObservedData;
+#endif
+ ///
+ /// Contapezzi attuale
+ ///
+ public Int32 contapezziIOB
+ {
+ get => machineCommService.ContapezziIOB;
+ set => machineCommService.ContapezziIOB = value;
+ }
+ ///
+ /// Ultima lettura variabile contapezzi da CNC
+ ///
+ public Int32 contapezziPLC
+ {
+ get => machineCommService.ContapezziPLC;
+ set => machineCommService.ContapezziPLC = value;
+ }
+ ///
+ /// Valore medio del TC rilevato x verifica derive sul delta variazione contapezzi
+ ///
+ public double plcAvgTc => machineCommService.GetAverageTc();
+ ///
+ /// DataOra dell'ultima lettura variabile contapezzi da CNC
+ ///
+ public DateTime plcLastPzRead => machineCommService.GetLastObservedData();
///
/// Determina se il contapezzi plc sia valido (lo è se data avvio adapter è prima di ultimo dato registrato in contapezzi)
///
- public bool plcPzCountValid => tcMan.lastObservedData > dtAvvioAdp;
+ public bool plcPzCountValid => machineCommService.GetLastObservedData() > dtAvvioAdp;
+
///
/// Abilitazione coda segnali ingresso