Inizia spostamento logiche TempiCiclo
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Legge il conteggio pezzi attuale dal driver della macchina.
|
||||
/// </summary>
|
||||
public int GetPzCountIOB() => _tcMan.pzCountIOB;
|
||||
|
||||
/// <summary>
|
||||
/// Legge il conteggio pezzi attuale dal PLC.
|
||||
/// </summary>
|
||||
public int GetPzCountPLC() => _tcMan.pzCountPLC;
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene la media dei tempi ciclo (TC) rilevati.
|
||||
@@ -49,9 +38,36 @@ namespace IOB_UT_NEXT.Services.Machine
|
||||
/// </summary>
|
||||
public DateTime GetLastObservedData() => _tcMan.lastObservedData;
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Gestione conteggio pezzi attuale dal driver della macchina.
|
||||
/// </summary>
|
||||
///
|
||||
public int ContapezziIOB
|
||||
{
|
||||
get => _tcMan.pzCountIOB;
|
||||
set => _tcMan.pzCountIOB=value;
|
||||
}
|
||||
|
||||
#region Memory Map Operations (Shared Memory Domain)
|
||||
/// <summary>
|
||||
/// Gestione conteggio pezzi attuale dal PLC.
|
||||
/// </summary>
|
||||
public int ContapezziPLC
|
||||
{
|
||||
get => _tcMan.pzCountPLC;
|
||||
set => _tcMan.pzCountPLC = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Legge un valore dalla memoria condivisa (MemMap) ricevuta dal PLC.
|
||||
/// </summary>
|
||||
public string ReadFromMemMap(string key)
|
||||
{
|
||||
if (_memMap != null && _memMap.mMapRead != null && _memMap.mMapRead.ContainsKey(key))
|
||||
{
|
||||
return _memMap.mMapRead[key].value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive un valore nella memoria condivisa (MemMap) per l'invio al PLC.
|
||||
@@ -72,18 +88,15 @@ namespace IOB_UT_NEXT.Services.Machine
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Legge un valore dalla memoria condivisa (MemMap) ricevuta dal PLC.
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-19
@@ -147,24 +147,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
set => _connOk = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contapezzi attuale
|
||||
/// </summary>
|
||||
public Int32 contapezziIOB
|
||||
{
|
||||
get => tcMan.pzCountIOB;
|
||||
set => tcMan.pzCountIOB = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ultima lettura variabile contapezzi da CNC
|
||||
/// </summary>
|
||||
public Int32 contapezziPLC
|
||||
{
|
||||
get => tcMan.pzCountPLC;
|
||||
set => tcMan.pzCountPLC = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contatore x invio dati FluxLog
|
||||
/// </summary>
|
||||
@@ -306,6 +288,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Valore medio del TC rilevato x verifica derive sul delta variazione contapezzi
|
||||
/// </summary>
|
||||
@@ -316,10 +299,36 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
public DateTime plcLastPzRead => tcMan.lastObservedData;
|
||||
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Contapezzi attuale
|
||||
/// </summary>
|
||||
public Int32 contapezziIOB
|
||||
{
|
||||
get => machineCommService.ContapezziIOB;
|
||||
set => machineCommService.ContapezziIOB = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Ultima lettura variabile contapezzi da CNC
|
||||
/// </summary>
|
||||
public Int32 contapezziPLC
|
||||
{
|
||||
get => machineCommService.ContapezziPLC;
|
||||
set => machineCommService.ContapezziPLC = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Valore medio del TC rilevato x verifica derive sul delta variazione contapezzi
|
||||
/// </summary>
|
||||
public double plcAvgTc => machineCommService.GetAverageTc();
|
||||
/// <summary>
|
||||
/// DataOra dell'ultima lettura variabile contapezzi da CNC
|
||||
/// </summary>
|
||||
public DateTime plcLastPzRead => machineCommService.GetLastObservedData();
|
||||
/// <summary>
|
||||
/// Determina se il contapezzi plc sia valido (lo è se data avvio adapter è prima di ultimo dato registrato in contapezzi)
|
||||
/// </summary>
|
||||
public bool plcPzCountValid => tcMan.lastObservedData > dtAvvioAdp;
|
||||
public bool plcPzCountValid => machineCommService.GetLastObservedData() > dtAvvioAdp;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Abilitazione coda segnali ingresso
|
||||
|
||||
Reference in New Issue
Block a user