From c434b14944c5235508fade0d7204ddba04efbc9d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 30 Jun 2025 10:27:19 +0200 Subject: [PATCH] Update x testare invio YAMl e pubblicazione versNumb corretta --- IOB-UT-NEXT/Config/IobConfTree.cs | 61 +++++++++++++++++++-------- IOB-WIN-FORM/AdapterForm.cs | 3 +- IOB-WIN-FORM/Iob/Generic.Protected.cs | 2 +- IOB-WIN-FORM/Iob/Generic.Public.cs | 11 ++++- IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini | 4 +- IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj | 12 ++++-- 6 files changed, 68 insertions(+), 25 deletions(-) diff --git a/IOB-UT-NEXT/Config/IobConfTree.cs b/IOB-UT-NEXT/Config/IobConfTree.cs index 8123b768..14b7b931 100644 --- a/IOB-UT-NEXT/Config/IobConfTree.cs +++ b/IOB-UT-NEXT/Config/IobConfTree.cs @@ -1,20 +1,22 @@ -using Newtonsoft.Json; -using YamlDotNet.Serialization.NamingConventions; -using YamlDotNet.Serialization; -using NLog; -using System.IO; -using System; -using static IOB_UT_NEXT.Config.EnumConf; -using System.Collections.Generic; -using System.Linq; -using IOB_UT_NEXT.Config; +using IOB_UT_NEXT.Config; using IOB_UT_NEXT.Config.Base; using IOB_UT_NEXT.Config.Special; -using static System.Net.Mime.MediaTypeNames; -using System.Threading; +using MapoSDK; +using Newtonsoft.Json; +using NLog; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; +using System.Threading; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.NamingConventions; using static IOB_UT_NEXT.BaseAlarmConf; +using static IOB_UT_NEXT.Config.EnumConf; +using static System.Net.Mime.MediaTypeNames; // // This is here so CodeMaid doesn't reorganize this document @@ -111,6 +113,8 @@ namespace IOB_UT_NEXT.Config { maxErrCheck = utils.CRI("maxErroriCheck"); } + Assembly entryAssembly = Assembly.GetEntryAssembly(); + string relVers = entryAssembly != null ? $"{entryAssembly?.GetName().Version}" : $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"; newConfObj.General = new IobDto() { CodIOB = fIni.ReadString("IOB", "IOB_NAME", codIob), @@ -124,7 +128,7 @@ namespace IOB_UT_NEXT.Config MaxPingRetry = fIni.ReadInteger("OPTPAR", "MAX_PING_RETRY", 5), MinDeltaSec = fIni.ReadInteger("IOB", "MinDeltaSec", 6), MultiIobList = fIni.ReadString("OPTPAR", "IOB_MULTI_CNAME", ""), - RelVers = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}", + RelVers = relVers,// $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}", ResetAlarmOnStart = bool.Parse(fIni.ReadString("OPTPAR", "SEND_ALARM_RESET", "false")), SenMachineConf = bool.Parse(fIni.ReadString("OPTPAR", "SEND_MACHINE_CONF", "true")), WaitRecMsec = Convert.ToInt32(fIni.ReadString("OPTPAR", "WAIT_REC_MSEC", "90000")), @@ -259,7 +263,7 @@ namespace IOB_UT_NEXT.Config MinRespTimeMs = fIni.ReadInteger("OPTPAR", "MIN_RESP_TIME_MS", 5), NumArtMode = fIni.ReadString("OPTPAR", "SET_NUM_ART", ""), NumOdlMode = fIni.ReadString("OPTPAR", "SET_NUM_COM", ""), - PoweroffTimeOutSec= fIni.ReadInteger("OPTPAR", "POWEROFF_TIMEOUT_SEC", 120), + PoweroffTimeOutSec = fIni.ReadInteger("OPTPAR", "POWEROFF_TIMEOUT_SEC", 120), PzCadMode = fIni.ReadString("OPTPAR", "PZCAD_MODE", ""), PzCountDelay = utils.CRI("pzCountDelay"), PzCountMode = fIni.ReadString("OPTPAR", "PZCOUNT_MODE", ""), @@ -341,7 +345,7 @@ namespace IOB_UT_NEXT.Config // copio conf ping come x server... newConfObj.MapoMes.DisabPing = newConfObj.Device.DisabPing; // verifico opzione per disabilitare FeepAlive (es non voglio keepalive e info IOB da acquisitori potenza che sovrascrivono dati IOB macchina) - newConfObj.MapoMes.DisabKeepAlive= bool.Parse(fIni.ReadString("OPTPAR", "DISAB_KEEPALIVE", "false")); + newConfObj.MapoMes.DisabKeepAlive = bool.Parse(fIni.ReadString("OPTPAR", "DISAB_KEEPALIVE", "false")); exclOptPar.Add("DISAB_KEEPALIVE"); // Gestione contapezzi... @@ -374,11 +378,11 @@ namespace IOB_UT_NEXT.Config string ftpServer = fIni.ReadString("OPTPAR", "FTP_SERVER", ""); if (!string.IsNullOrEmpty(ftpServer)) { - if(newConfObj.Special.FtpConf==null) + if (newConfObj.Special.FtpConf == null) { newConfObj.Special.FtpConf = new FtpDto() { - Server=ftpServer, + Server = ftpServer, User = fIni.ReadString("OPTPAR", "FTP_USER", ""), Passwd = fIni.ReadString("OPTPAR", "FTP_PWD", ""), CertValue = fIni.ReadString("OPTPAR", "FTP_CERT", ""), @@ -1046,6 +1050,7 @@ namespace IOB_UT_NEXT.Config { var rawdata = GetYaml(); File.WriteAllText(filePath, rawdata); + answ = true; } catch @@ -1053,6 +1058,28 @@ namespace IOB_UT_NEXT.Config return answ; } + /// + /// Invia a server conf serializzata in formato YAML + /// + /// URL x chiamata salvtaggio yaml + /// + public bool SendConfYaml(string urlSaveYaml) + { + bool answ = false; + try + { + string rawData = GetYaml(); + // prova anche ad inviare il contenuto al server IO... + string resp = utils.callUrl($"{urlSaveYaml}", rawData); + answ = resp == "OK"; + } + catch + { } + return answ; + } + + + #endregion #region Logging diff --git a/IOB-WIN-FORM/AdapterForm.cs b/IOB-WIN-FORM/AdapterForm.cs index eea9f70c..67a958e3 100644 --- a/IOB-WIN-FORM/AdapterForm.cs +++ b/IOB-WIN-FORM/AdapterForm.cs @@ -1606,7 +1606,7 @@ namespace IOB_WIN_FORM { // out di cosa faccio... displayTaskAndLog($"[STARTUP] Loading ConfFile: {iniConfFile}"); - var appVers = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var appVers = Assembly.GetExecutingAssembly().GetName().Version; string path = fileMover.GetExecutingDirectoryName(); // Directory.GetCurrentDirectory(); string fileName = Path.GetFileName(iniConfFile).Replace(".ini", ".iob"); string dirPath = Path.Combine(path, "DATA", "CONF_RUN"); @@ -1621,6 +1621,7 @@ namespace IOB_WIN_FORM } // salvo anche yaml... IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml")); + IOBConfFull.SendConfYaml(iobObj.urlSaveConfYaml); loadIobType(); // avvio macchina con adapter specificato... diff --git a/IOB-WIN-FORM/Iob/Generic.Protected.cs b/IOB-WIN-FORM/Iob/Generic.Protected.cs index 4578cf8b..d9481758 100644 --- a/IOB-WIN-FORM/Iob/Generic.Protected.cs +++ b/IOB-WIN-FORM/Iob/Generic.Protected.cs @@ -1037,7 +1037,7 @@ namespace IOB_WIN_FORM.Iob /// protected string urlSaveMemMap { - get => $@"{urlCommandIob("saveConf")}"; + get => $@"{urlCommandIobFile("saveConf")}"; } /// diff --git a/IOB-WIN-FORM/Iob/Generic.Public.cs b/IOB-WIN-FORM/Iob/Generic.Public.cs index 16ad2922..d0d351a7 100644 --- a/IOB-WIN-FORM/Iob/Generic.Public.cs +++ b/IOB-WIN-FORM/Iob/Generic.Public.cs @@ -447,6 +447,14 @@ namespace IOB_WIN_FORM.Iob get => $@"{urlCommandIobFile("sendReboot")}?mac={GetMACAddress()}"; } + /// + /// URL per salvataggio dati conf YAML completi IOB... + /// + public string urlSaveConfYaml + { + get => $@"{urlCommandIobFile("saveConfYaml")}"; + } + /// /// Verifica SE si debba fare log verboso (verboso + ogni tot letture IN) /// @@ -3571,7 +3579,8 @@ namespace IOB_WIN_FORM.Iob answ += $@"&&dtEve={valori[0]}&&dtCurr={DateTime.Now:yyyyMMddHHmmssfff}&&cnt={valori[3]}"; // se è disabilitato keepalive aggiungo opzione if (IOBConfFull.MapoMes.DisabKeepAlive) - {; + { + ; answ += $"&&disabKA=true"; } return answ; diff --git a/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini b/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini index 5a7d722a..ab82fc7b 100644 --- a/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini +++ b/IOB-WIN-OPC-UA/DATA/CONF/MAIN.ini @@ -23,13 +23,13 @@ CLI_INST=SteamWareSim ;STARTLIST=2014 ;STARTLIST=3026 ;STARTLIST=2015 -;STARTLIST=SIMUL_01 +STARTLIST=SIMUL_01 ;STARTLIST=TEND_250_53 ;STARTLIST=Tend_RAMA_10_47 ;STARTLIST=3026 ;STARTLIST=TFT_RAMA_001 ;STARTLIST=SIM_DP_02 ;STARTLIST=2015 -STARTLIST=1042 +;STARTLIST=1042 MAXCNC=10 diff --git a/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj b/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj index 8cb96daa..3b39d310 100644 --- a/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj +++ b/IOB-WIN-OPC-UA/IOB-WIN-OPC-UA.csproj @@ -288,9 +288,15 @@ Always - - - + + Always + + + Always + + + Always +