Update preliminare prima di inserire nuovi metodi
This commit is contained in:
@@ -156,6 +156,9 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Iob\Services\CommunicationService.cs" />
|
||||
<Compile Include="Iob\Services\Machine\MachineCommunicationService.cs" />
|
||||
<Compile Include="Iob\Services\Networking\ServerCommunicationService.cs" />
|
||||
<Compile Include="Objects\CachedInt.cs" />
|
||||
<Compile Include="Objects\CachedString.cs" />
|
||||
<Compile Include="Objects\DynDataItem.cs" />
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_UT_NEXT.Services.Cache;
|
||||
using IOB_UT_NEXT.Services.Networking;
|
||||
using NLog;
|
||||
|
||||
namespace IOB_UT_NEXT.Services.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// Orchestratore delle comunicazioni.
|
||||
/// Coordina HttpService e RedisIobCache per eseguire workflow di business.
|
||||
/// Riduce la profondità dello stack in Generic.cs.
|
||||
/// </summary>
|
||||
public class CommunicationService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public CommunicationService(IobConfTree config, RedisIobCache redisMan)
|
||||
{
|
||||
_config = config;
|
||||
_redisMan = redisMan;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue una chiamata HTTP e salva il risultato direttamente su Redis (Workflow orchestrato).
|
||||
/// </summary>
|
||||
public async Task<string> CallAndSaveToRedisAsync(string url, string redisKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
string result = await HttpService.CallUrlAsync(url);
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
_redisMan.setRSV(redisKey, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"Error in CallAndSaveToRedisAsync: URL={url}, Key={redisKey}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera dati da una URL e li deserializza (Workflow orchestrato).
|
||||
/// </summary>
|
||||
public async Task<T> GetAndDeserializeAsync<T>(string url)
|
||||
{
|
||||
string raw = await HttpService.CallUrlAsync(url);
|
||||
return IOB_UT_NEXT.Services.Data.DataSerializer.Deserialize<T>(raw);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue una chiamata POST e salva il payload/risposta (Workflow orchestrato).
|
||||
/// </summary>
|
||||
public async Task<string> PostAndStoreAsync(string url, string payload, string redisKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
string response = await Task.Run(() => HttpService.CallUrlPost(url, payload));
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
_redisMan.setRSV(redisKey, response);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"Error in PostAndStoreAsync: URL={url}, Key={redisKey}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IobConfTree _config;
|
||||
private readonly RedisIobCache _redisMan;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using IOB_UT_NEXT.Config;
|
||||
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).
|
||||
/// </summary>
|
||||
public class MachineCommunicationService
|
||||
{
|
||||
private readonly IobConfTree _config;
|
||||
private readonly TCMan _tcMan;
|
||||
private readonly plcMemMap _memMap;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public MachineCommunicationService(IobConfTree config, TCMan tcMan, plcMemMap 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)
|
||||
|
||||
/// <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;
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene la media dei tempi ciclo (TC) rilevati.
|
||||
/// </summary>
|
||||
public double GetAverageTc() => _tcMan.avgTC > 0 ? _tcMan.avgTC : 1.0;
|
||||
|
||||
/// <summary>
|
||||
/// Ottiene l'ultimo timestamp osservato dal PLC.
|
||||
/// </summary>
|
||||
public DateTime GetLastObservedData() => _tcMan.lastObservedData;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Memory Map Operations (Shared Memory Domain)
|
||||
|
||||
/// <summary>
|
||||
/// Scrive un valore nella memoria condivisa (MemMap) per l'invio al PLC.
|
||||
/// </summary>
|
||||
public void WriteToMemMap(string key, string value)
|
||||
{
|
||||
if (_memMap != null && _memMap.mMapWrite != null)
|
||||
{
|
||||
if (_memMap.mMapWrite.ContainsKey(key))
|
||||
{
|
||||
_memMap.mMapWrite[key].value = value;
|
||||
logger.Debug($"[MachineComm] MemMap Write: {key} = {value}");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Warn($"[MachineComm] Attempted write to non-existent MemMap key: {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_UT_NEXT.Services.Cache;
|
||||
using IOB_UT_NEXT.Services.Networking;
|
||||
using IOB_UT_NEXT.Services.Data;
|
||||
using NLog;
|
||||
|
||||
namespace IOB_UT_NEXT.Services.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// ServerCommunicationService: Orchestratore per i task del dominio SERVER (_workerTask).
|
||||
/// Gestisce il coordinamento tra chiamate HTTP, persistenza Redis e code di comunicazione.
|
||||
/// </summary>
|
||||
public class ServerCommunicationService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ServerCommunicationService(IobConfTree config, RedisIobCache redisMan)
|
||||
{
|
||||
_config = config ?? throw new ArgumentNullException(nameof(config));
|
||||
_redisMan = redisMan ?? throw new ArgumentNullException(nameof(redisMan));
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Esegue una chiamata HTTP GET e deserializza il risultato.
|
||||
/// </summary>
|
||||
public async Task<T> GetAndDeserializeAsync<T>(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
string response = await HttpService.CallUrlAsync(url);
|
||||
return JsonDeserialize<T>(response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"[ServerComm] Error in GetAndDeserializeAsync | URL: {url}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera dati da un URL e li salva su Redis.
|
||||
/// Workflow: HTTP GET -> Redis Set.
|
||||
/// </summary>
|
||||
public async Task<string> GetAndPersistAsync(string url, string redisKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
string response = await HttpService.CallUrlAsync(url);
|
||||
|
||||
if (!string.IsNullOrEmpty(response) && !string.IsNullOrEmpty(redisKey))
|
||||
{
|
||||
_redisMan.setRSV(redisKey, response);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"[ServerComm] Error in GetAndPersistAsync | URL: {url} | Key: {redisKey}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue una chiamata HTTP POST e salva il risultato su Redis.
|
||||
/// Workflow: Serialize -> HTTP POST -> Redis Set.
|
||||
/// </summary>
|
||||
public async Task<string> PostAndPersistAsync<T>(string url, T payload, string redisKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
string serializedPayload = JsonSerialize(payload);
|
||||
logger.Debug($"[ServerComm] POST to {url} | Payload: {serializedPayload}");
|
||||
|
||||
string response = await HttpService.CallUrlAsync(url, serializedPayload);
|
||||
|
||||
if (!string.IsNullOrEmpty(response) && !string.IsNullOrEmpty(redisKey))
|
||||
{
|
||||
_redisMan.setRSV(redisKey, response);
|
||||
logger.Info($"[ServerComm] Data persisted to Redis: {redisKey}");
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"[ServerComm] Error in PostAndPersistAsync | URL: {url} | Key: {redisKey}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IobConfTree _config;
|
||||
private readonly RedisIobCache _redisMan;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private T JsonDeserialize<T>(string json) => IOB_UT_NEXT.Services.Data.DataSerializer.Deserialize<T>(json);
|
||||
|
||||
// Helper per mantenere la compatibilità con la logica di serializzazione esistente
|
||||
private string JsonSerialize<T>(T obj) => IOB_UT_NEXT.Services.Data.DataSerializer.Serialize(obj);
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+57
-109
@@ -7,6 +7,7 @@ using IOB_UT_NEXT.Services.Cache;
|
||||
using IOB_UT_NEXT.Services.Core;
|
||||
using IOB_UT_NEXT.Services.Data;
|
||||
using IOB_UT_NEXT.Services.Files;
|
||||
using IOB_UT_NEXT.Services.Machine;
|
||||
using IOB_UT_NEXT.Services.Monitoring;
|
||||
using IOB_UT_NEXT.Services.Networking;
|
||||
using IOB_UT_NEXT.Services.Utility;
|
||||
@@ -40,6 +41,13 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
public partial class Generic : BaseObj
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private CommunicationService commService;
|
||||
private MachineCommunicationService machineCommService;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public int numPzReqOdl = 0;
|
||||
@@ -65,6 +73,10 @@ namespace IOB_WIN_FORM.Iob
|
||||
// init oggetto redis...
|
||||
redisMan = new RedisIobCache(IobConfNew.MapoMes.IpAddr, IobConfNew.General.FilenameIOB, $"{IobConfNew.General.IobType}", IobConfNew.General.MinDeltaSec);
|
||||
|
||||
// init communication services
|
||||
commService = new CommunicationService(IobConfNew, redisMan);
|
||||
machineCommService = new MachineCommunicationService(IobConfNew, tcMan, memMap);
|
||||
|
||||
// init code
|
||||
SetupQueue();
|
||||
|
||||
@@ -131,14 +143,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <returns></returns>
|
||||
public virtual bool connectionOk
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connOk || DemoIn;
|
||||
}
|
||||
set
|
||||
{
|
||||
_connOk = value;
|
||||
}
|
||||
get => _connOk || DemoIn;
|
||||
set => _connOk = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -146,14 +152,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
public Int32 contapezziIOB
|
||||
{
|
||||
get
|
||||
{
|
||||
return tcMan.pzCountIOB;
|
||||
}
|
||||
set
|
||||
{
|
||||
tcMan.pzCountIOB = value;
|
||||
}
|
||||
get => tcMan.pzCountIOB;
|
||||
set => tcMan.pzCountIOB = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,14 +161,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
public Int32 contapezziPLC
|
||||
{
|
||||
get
|
||||
{
|
||||
return tcMan.pzCountPLC;
|
||||
}
|
||||
set
|
||||
{
|
||||
tcMan.pzCountPLC = value;
|
||||
}
|
||||
get => tcMan.pzCountPLC;
|
||||
set => tcMan.pzCountPLC = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -176,6 +170,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// </summary>
|
||||
public int counterFLog { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Contatore x invio dati RawTransf
|
||||
/// </summary>
|
||||
@@ -291,10 +286,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// Valore massimo accettato x incremento pezzi letti dal PLC (valore moltiplicato per
|
||||
/// 100... 200% --> 200)
|
||||
/// </summary>
|
||||
public int maxPzDeltaPerc
|
||||
{
|
||||
get => IOBConfFull.Counters.MaxIncrPzCountPerc;
|
||||
}
|
||||
public int maxPzDeltaPerc => IOBConfFull.Counters.MaxIncrPzCountPerc;
|
||||
|
||||
/// <summary>
|
||||
/// Verifica SE si debba fare log periodico (ogni "verboseLogTOut" sec...)
|
||||
@@ -317,33 +309,17 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <summary>
|
||||
/// Valore medio del TC rilevato x verifica derive sul delta variazione contapezzi
|
||||
/// </summary>
|
||||
public double plcAvgTc
|
||||
{
|
||||
get
|
||||
{
|
||||
double answ = tcMan.avgTC > 0 ? tcMan.avgTC : 1;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
public double plcAvgTc => tcMan.avgTC > 0 ? tcMan.avgTC : 1;
|
||||
|
||||
/// <summary>
|
||||
/// DataOra dell'ultima lettura variabile contapezzi da CNC
|
||||
/// </summary>
|
||||
public DateTime plcLastPzRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return tcMan.lastObservedData;
|
||||
}
|
||||
}
|
||||
public DateTime plcLastPzRead => tcMan.lastObservedData;
|
||||
|
||||
/// <summary>
|
||||
/// Determina se il contapezzi plc sia valido (lo è se data avvio adapter è prima di ultimo dato registrato in contapezzi)
|
||||
/// </summary>
|
||||
public bool plcPzCountValid
|
||||
{
|
||||
get => tcMan.lastObservedData > dtAvvioAdp;
|
||||
}
|
||||
public bool plcPzCountValid => tcMan.lastObservedData > dtAvvioAdp;
|
||||
|
||||
/// <summary>
|
||||
/// Abilitazione coda segnali ingresso
|
||||
@@ -371,18 +347,12 @@ namespace IOB_WIN_FORM.Iob
|
||||
/// <summary>
|
||||
/// URL per segnalazione reboot...
|
||||
/// </summary>
|
||||
public string urlReboot
|
||||
{
|
||||
get => $@"{urlCommandIobFile("sendReboot")}?mac={NetService.GetMACAddress()}";
|
||||
}
|
||||
public string urlReboot => $@"{urlCommandIobFile("sendReboot")}?mac={NetService.GetMACAddress()}";
|
||||
|
||||
/// <summary>
|
||||
/// URL per salvataggio dati conf YAML completi IOB...
|
||||
/// </summary>
|
||||
public string urlSaveConfYaml
|
||||
{
|
||||
get => $@"{urlCommandIobFile("saveConfYaml")}";
|
||||
}
|
||||
public string urlSaveConfYaml => $@"{urlCommandIobFile("saveConfYaml")}";
|
||||
|
||||
/// <summary>
|
||||
/// Verifica SE si debba fare log verboso (verboso + ogni tot letture IN)
|
||||
@@ -1010,28 +980,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
processRecipeSyncArch();
|
||||
}
|
||||
|
||||
//// provo a riconnettere SE abilitato tryRestart...
|
||||
//if (adpTryRestart && !connectionOk)
|
||||
//{
|
||||
// // controllo se sia scaduto periodi di veto al tryConnect...
|
||||
// int waitRecMSec = utils.CRI("waitRecMSec");
|
||||
// // cerco se ci sia un valore in ovverride x il singolo IOB...
|
||||
// if (IOBConfFull.General.WaitRecMsec > 0)
|
||||
// {
|
||||
// waitRecMSec = IOBConfFull.General.WaitRecMsec;
|
||||
// }
|
||||
// DateTime dtVeto = lastConnectTry.AddMilliseconds(waitRecMSec);
|
||||
// if (DateTime.Now > dtVeto)
|
||||
// {
|
||||
// lgInfo($"Veto Time Elapsed | lastConnectTry: {lastConnectTry} | waitRecMSec {waitRecMSec} ms) | NOW tryConnect");
|
||||
// lastConnectTry = DateTime.Now;
|
||||
// tryConnect();
|
||||
// }
|
||||
//}
|
||||
//currDispData.semIn = Semaforo.SR;
|
||||
//processDisconnectedTask();
|
||||
//processMemoryDiscon();
|
||||
}
|
||||
raiseRefresh(currDispData);
|
||||
}
|
||||
@@ -1052,7 +1000,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
// deserializzo...
|
||||
JobTaskData jobTaskReq = JsonDeserialize<JobTaskData>(rawJob);
|
||||
|
||||
|
||||
// processo!
|
||||
var reqDict = JobTaskData.TaskDict(jobTaskReq.RawData);
|
||||
if (reqDict.Count > 0)
|
||||
@@ -1063,9 +1011,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
accodaServResp(jobTaskReq.CodTav, serVal);
|
||||
}
|
||||
}
|
||||
|
||||
// svuoto!
|
||||
QueueSrvReq = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueServResp", IOBConfFull.General.EnabRedisQue, redisMan);
|
||||
|
||||
// svuoto!
|
||||
QueueSrvReq = new DataQueue(IOBConfFull.General.FilenameIOB, "QueueServResp", IOBConfFull.General.EnabRedisQue, redisMan);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1825,7 +1773,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// conversione finale
|
||||
try
|
||||
{
|
||||
answ = JsonSerialize(fullFlObj);
|
||||
answ = JsonSerialize(fullFlObj);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -1856,7 +1804,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// conversione finale
|
||||
try
|
||||
{
|
||||
answ = JsonSerialize(fullEvObj);
|
||||
answ = JsonSerialize(fullEvObj);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -1915,7 +1863,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// conversione finale
|
||||
try
|
||||
{
|
||||
answ = JsonSerialize(fullUlObj);
|
||||
answ = JsonSerialize(fullUlObj);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -1942,11 +1890,11 @@ namespace IOB_WIN_FORM.Iob
|
||||
string rawVal = redisMan.redGetHashField(lastSendKey, keyReq);
|
||||
if (!string.IsNullOrEmpty(rawVal))
|
||||
{
|
||||
lastSend = JsonDeserialize<DateTime>(rawVal);
|
||||
lastSend = JsonDeserialize<DateTime>(rawVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
rawVal = JsonSerialize(lastSend);
|
||||
rawVal = JsonSerialize(lastSend);
|
||||
KeyValuePair<string, string>[] hashFields = new KeyValuePair<string, string>[1];
|
||||
hashFields[0] = new KeyValuePair<string, string>(keyReq, rawVal);
|
||||
redisMan.redSaveHash(lastSendKey, hashFields);
|
||||
@@ -1962,7 +1910,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
public bool LastSendSet(string keyReq, DateTime dtRif)
|
||||
{
|
||||
string lastSendKey = GetStatusField("LastSend");
|
||||
string rawVal = JsonSerialize(dtRif);
|
||||
string rawVal = JsonSerialize(dtRif);
|
||||
KeyValuePair<string, string>[] hashFields = new KeyValuePair<string, string>[1];
|
||||
hashFields[0] = new KeyValuePair<string, string>(keyReq, rawVal);
|
||||
bool fatto = redisMan.redSaveHash(lastSendKey, hashFields);
|
||||
@@ -4365,10 +4313,10 @@ namespace IOB_WIN_FORM.Iob
|
||||
List<GenLogRow> answ = new List<GenLogRow>();
|
||||
string redKeyFLog = redisMan.redHash($"IOB:CurrData:{IOBConfFull.General.FilenameIOB}:LogFile:FluxLog");
|
||||
var rawData = redisMan.getRSV(redKeyFLog);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
answ = JsonDeserialize<List<GenLogRow>>(rawData);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
answ = JsonDeserialize<List<GenLogRow>>(rawData);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
@@ -5771,7 +5719,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
item.updStatusVal(i, (uint)(item.alarmsMask[i] & currStatus));
|
||||
// salvo in redis...
|
||||
string alarmHash = redisMan.redHash($"IOB:ALARM_STATUS:{IOBConfFull.General.FilenameIOB}:{item.memAddr}");
|
||||
string rawAlarms = JsonSerialize(item.alarmsState);
|
||||
string rawAlarms = JsonSerialize(item.alarmsState);
|
||||
redisMan.setRSV(alarmHash, rawAlarms);
|
||||
}
|
||||
else
|
||||
@@ -6123,7 +6071,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgInfo("loadMemConf.04");
|
||||
try
|
||||
{
|
||||
memMap = JsonDeserialize<plcMemMapExt>(jsonData);
|
||||
memMap = JsonDeserialize<plcMemMapExt>(jsonData);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -6350,7 +6298,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
string rawData = File.ReadAllText(fileItem);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var convData = JsonDeserialize<Dictionary<int, BatchRec>>(rawData);
|
||||
var convData = JsonDeserialize<Dictionary<int, BatchRec>>(rawData);
|
||||
if (convData != null)
|
||||
{
|
||||
list2Send = convData;
|
||||
@@ -6409,7 +6357,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
try
|
||||
{
|
||||
writeList = JsonDeserialize<List<objItem>>(resp);
|
||||
writeList = JsonDeserialize<List<objItem>>(resp);
|
||||
// se ho da fare chiamo esecuzione..
|
||||
if (writeList.Count > 0)
|
||||
{
|
||||
@@ -6439,7 +6387,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// richiamo scrittura parametri su PLC
|
||||
plcWriteParams(ref updatedPar);
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonSerialize(updatedPar);
|
||||
string rawData = JsonSerialize(updatedPar);
|
||||
HttpService.CallUrl($"{urlUpdateWriteParams}", rawData);
|
||||
lgInfo($"Notifica a server scrittura {updatedPar.Count} parametri");
|
||||
}
|
||||
@@ -6721,7 +6669,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
CurrStatus = "Ricevute",
|
||||
ActionList = stdActList
|
||||
};
|
||||
string rawWeek = JsonSerialize(cPerInfo);
|
||||
string rawWeek = JsonSerialize(cPerInfo);
|
||||
redHashWeek.Add(cWeek, rawWeek);
|
||||
}
|
||||
// salvo in redis...
|
||||
@@ -6730,7 +6678,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
|
||||
// invio ANCHE in MP-IO l'update delle info...
|
||||
string remUrl = urlSetHashDict;
|
||||
string dictPayload = JsonSerialize(redHashWeek);
|
||||
string dictPayload = JsonSerialize(redHashWeek);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
}
|
||||
}
|
||||
@@ -7355,8 +7303,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
// invio e salvo...
|
||||
string remUrl = urlSaveMachIobConf;
|
||||
string dictPayload = JsonSerialize(currDict);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
string dictPayload = JsonSerialize(currDict);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
lgTrace("Invio MachineConf effettuato");
|
||||
}
|
||||
}
|
||||
@@ -7505,7 +7453,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (!string.IsNullOrEmpty(rawVal))
|
||||
{
|
||||
// provo a convertire
|
||||
var lastState = JsonDeserialize<uint[]>(rawVal);
|
||||
var lastState = JsonDeserialize<uint[]>(rawVal);
|
||||
if (lastState != null && lastState.Length > 0)
|
||||
{
|
||||
item.loadPrev(lastState);
|
||||
@@ -7561,7 +7509,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgDebug($"setupMemMap | trovati {memMap.mMapWrite.Count} parametri Write");
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
string rawMemConf = JsonSerialize(memMap, Formatting.Indented);
|
||||
string rawMemConf = JsonSerialize(memMap, Formatting.Indented);
|
||||
lgDebug($"setupMemMap | configurazione memoria R/W:{Environment.NewLine}{rawMemConf}");
|
||||
}
|
||||
// se ho variabili read --> genero dati TSVC...
|
||||
@@ -7601,7 +7549,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (memMap != null)
|
||||
{
|
||||
// invio su cloud conf memoria...
|
||||
string rawData = JsonSerialize(memMap, Formatting.Indented);
|
||||
string rawData = JsonSerialize(memMap, Formatting.Indented);
|
||||
// controllo ping al server...
|
||||
if (serverOk)
|
||||
{
|
||||
@@ -7677,7 +7625,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
// invio su cloud parametri SE sono connesso alla macchina... in pratica reset parametri...
|
||||
string tipoCall = urlSaveAllParams;
|
||||
rawData = JsonSerialize(allParam, Formatting.Indented);
|
||||
rawData = JsonSerialize(allParam, Formatting.Indented);
|
||||
if (serverOk)
|
||||
{
|
||||
// verifica se sia un IOB "parziale" --> salva solo update ai parametri
|
||||
@@ -9212,7 +9160,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgInfo($"Chiamata di plcWriteParams da processMem2Write: {updatedPar.Count} updatedPar");
|
||||
plcWriteParams(ref updatedPar);
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonSerialize(updatedPar);
|
||||
string rawData = JsonSerialize(updatedPar);
|
||||
HttpService.CallUrlPost($"{urlUpdateWriteParams}", rawData);
|
||||
lgInfo($"Notificato a server scrittura {updatedPar.Count} parametri");
|
||||
}
|
||||
@@ -9222,7 +9170,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (currWritePar.Count > 0 && (lastWriteParamsUpsert.AddMinutes(vetoSendWriteUpsert) < adesso))
|
||||
{
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonSerialize(currWritePar);
|
||||
string rawData = JsonSerialize(currWritePar);
|
||||
var res = HttpService.CallUrlPost($"{urlUpdateWriteParams}", rawData);
|
||||
lgInfo($"Reinviato a server stato {updatedPar.Count} parametri WRITE");
|
||||
lastWriteParamsUpsert = adesso;
|
||||
@@ -9348,7 +9296,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
string rawConfFile = File.ReadAllText(confSetupPath);
|
||||
if (!string.IsNullOrEmpty(rawConfFile))
|
||||
{
|
||||
currConf = JsonDeserialize<ConvSetup>(rawConfFile);
|
||||
currConf = JsonDeserialize<ConvSetup>(rawConfFile);
|
||||
if (currConf != null)
|
||||
{
|
||||
addHeader = currConf.addHeader;
|
||||
@@ -9510,7 +9458,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Dictionary<string, string> currDict = redisMan.redGetHashDict(fullKey);
|
||||
// invio ANCHE in MP-IO l'update delle info...
|
||||
string remUrl = urlSetHashDict;
|
||||
string dictPayload = JsonSerialize(currDict);
|
||||
string dictPayload = JsonSerialize(currDict);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, true);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, false);
|
||||
@@ -9532,7 +9480,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var rawJob in listaValori)
|
||||
{
|
||||
// deserializzo...
|
||||
JobTaskData jobTask = JsonDeserialize<JobTaskData>(rawJob);
|
||||
JobTaskData jobTask = JsonDeserialize<JobTaskData>(rawJob);
|
||||
// ora chiamo la cancellazione dei task eseguiti...
|
||||
var taskDict = JobTaskData.TaskDict(jobTask.RawData);
|
||||
foreach (var item in taskDict)
|
||||
|
||||
Reference in New Issue
Block a user