Merge branch 'release/ShellyUrlReview_01'

This commit is contained in:
Samuele Locatelli
2025-02-24 16:49:13 +01:00
12 changed files with 335 additions and 699 deletions
+16 -9
View File
@@ -45,8 +45,8 @@ namespace IOB_UT_NEXT.Config.Base
/// <returns></returns>
public string GetCommand(string key)
{
// default ad implicito...
string answ = $"{BaseUri}/{key}/";
// default ad implicito con IOB...
string answ = $"{BaseUri}/IOB/{key}/";
if (CurrSetup.ContainsKey(key))
{
answ = CurrSetup[key];
@@ -57,17 +57,24 @@ namespace IOB_UT_NEXT.Config.Base
public Dictionary<string, string> StdCommands()
{
CurrSetup = new Dictionary<string, string>();
CurrSetup.Add("Alive", "IOB");
CurrSetup.Add("Base", "IOB/input/");
CurrSetup.Add("alive", "IOB");
//CurrSetup.Add("Base", "IOB/input/");
CurrSetup.Add("BaseJson", "IOB/evListJson/");
CurrSetup.Add("RawTransfJson", "IOB/rawTransfJson/");
CurrSetup.Add("Enabled", "IOB/enabled/");
CurrSetup.Add("Flog", "IOB/flog/");
//CurrSetup.Add("Enabled", "IOB/enabled/");
//CurrSetup.Add("Flog", "IOB/flog/");
CurrSetup.Add("FlogJson", "IOB/flogJson/");
CurrSetup.Add("ForcleSplitOdl", "IOB/forceSplitOdlFull/");
CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/");
CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/");
//CurrSetup.Add("fixDailyDossier", "IOB/fixDailyDossier/");
//CurrSetup.Add("fixDailyOdl", "IOB/fixDailyOdl/");
//CurrSetup.Add("fixDailyOdlConfPzCount", "IOB/fixDailyOdlConfPzCount/");
//CurrSetup.Add("forceCreatePOdl", "IOB/forceCreatePOdl/");
//CurrSetup.Add("forceSplitOdlFull", "IOB/forceSplitOdlFull/");
//CurrSetup.Add("getPOdlAct", "IOB/getPOdlAct/");
//CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/");
//CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/");
CurrSetup.Add("Reboot", "IOB/sendReboot.aspx?idxMacchina=");
//CurrSetup.Add("savePzCountInc", "IOB/savePzCountInc/");
//CurrSetup.Add("savePzCountIncAtDate", "IOB/savePzCountIncAtDate/");
// riordino
CurrSetup = CurrSetup.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
return CurrSetup;
+8
View File
@@ -17,6 +17,14 @@ namespace IOB_UT_NEXT.Config.Base
/// </summary>
public string ConfFileName { get; set; } = "";
/// <summary>
/// Filename senza desinenza del tipo di file
/// </summary>
public string FilenameIOB
{
get => baseUtils.StringBeforeLastChar(ConfFileName, '.');
}
/// <summary>
/// Tipo Adapter specifico (implementazione)
/// </summary>
+30
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YamlDotNet.Core.Tokens;
namespace IOB_UT_NEXT.Config.Base
{
@@ -23,6 +24,35 @@ namespace IOB_UT_NEXT.Config.Base
/// </summary>
public string BaseAppUrl { get; set; } = "/MP/IO/";
/// <summary>
/// Restituisce la API del comando richiesto dalla BaseUrl
/// </summary>
/// <param name="CmdReq">Comando richiesto da comporre</param>
/// <returns></returns>
public string ApiUrl(string CmdReq)
{
// default ad implicito con IOB...
string answ = $"{BaseAppUrl}IOB/{CmdReq}/";
if (Commands.ContainsKey(CmdReq))
{
answ = $"{BaseAppUrl}{Commands[CmdReq]}";
}
return answ;
#if false
string answ = BaseAppUrl;
if (Commands.ContainsKey(CmdReq))
{
answ = $"{BaseAppUrl}{Commands[CmdReq]}";
}
// altrimenti prendo cmd base IOB e compongo...
else
{
answ = $"{BaseAppUrl}/IOB/{CmdReq}";
}
return answ;
#endif
}
/// <summary>
/// Dizionario comandi configurati
/// </summary>
+59 -60
View File
@@ -69,7 +69,7 @@ namespace IOB_UT_NEXT.Config
if (newConfObj != null)
{
// ora copio in oggetto corrente...
IobConf = newConfObj.IobConf;
GenConf = newConfObj.GenConf;
DeviceConf = newConfObj.DeviceConf;
ProcInputConf = newConfObj.ProcInputConf;
OptParConf = newConfObj.OptParConf;
@@ -78,7 +78,7 @@ namespace IOB_UT_NEXT.Config
TCDataConf = newConfObj.TCDataConf;
ActionConf = newConfObj.ActionConf;
// sovrascrivo filename
IobConf.ConfFileName = fileName;
GenConf.ConfFileName = fileName;
}
}
}
@@ -100,7 +100,7 @@ namespace IOB_UT_NEXT.Config
string codIob = Path.GetFileNameWithoutExtension(iniFilePath);
// Dati generali (vendor, modello...)
newConfObj.IobConf = new IobDto()
newConfObj.GenConf = new IobDto()
{
CodIOB = fIni.ReadString("IOB", "IOB_NAME", codIob),
ConfFileName = Path.GetFileName(iniFilePath),
@@ -114,11 +114,11 @@ namespace IOB_UT_NEXT.Config
// tipo adapter// verifico tipo adapter
try
{
newConfObj.IobConf.IobType = (tipoAdapter)Enum.Parse(typeof(tipoAdapter), fIni.ReadString("IOB", "CNCTYPE", "ND"));
newConfObj.GenConf.IobType = (tipoAdapter)Enum.Parse(typeof(tipoAdapter), fIni.ReadString("IOB", "CNCTYPE", "ND"));
}
catch (Exception exc)
{
newConfObj.IobConf.IobType = tipoAdapter.ND;
newConfObj.GenConf.IobType = tipoAdapter.ND;
string rawVal = fIni.ReadString("IOB", "CNCTYPE", "DEMO");
newConfObj.lgError($"Eccezione in conversione tipo adapter: richiesto {rawVal} | tipo non codificato...{Environment.NewLine}{exc}");
}
@@ -312,63 +312,10 @@ namespace IOB_UT_NEXT.Config
return newConfObj;
}
#region Logging
/// <summary>
/// oggetto logging
/// Info generali delative all'IOB impiegato
/// </summary>
protected Logger Log;// = LogManager.GetCurrentClassLogger();
/// <summary>
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgDebug(string txt2log)
{
Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB;
Log.Debug(txt2log);
}
/// <summary>
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgError(string txt2log)
{
if (!string.IsNullOrEmpty(txt2log))
{
Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB;
Log.Error(txt2log);
}
}
/// <summary>
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgInfo(string txt2log)
{
Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB;
Log.Info(txt2log);
}
/// <summary>
/// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgTrace(string txt2log)
{
Log.Factory.Configuration.Variables["codIOB"] = IobConf.CodIOB;
Log.Trace(txt2log);
}
#endregion
/// <summary>
/// Info specifiche del programma IOB
/// </summary>
public IobDto IobConf { get; set; } = new IobDto();
public IobDto GenConf { get; set; } = new IobDto();
/// <summary>
/// Info relative al device interconnesso
@@ -485,5 +432,57 @@ namespace IOB_UT_NEXT.Config
}
#endregion
#region Logging
/// <summary>
/// oggetto logging
/// </summary>
protected Logger Log;// = LogManager.GetCurrentClassLogger();
/// <summary>
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgDebug(string txt2log)
{
Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB;
Log.Debug(txt2log);
}
/// <summary>
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgError(string txt2log)
{
if (!string.IsNullOrEmpty(txt2log))
{
Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB;
Log.Error(txt2log);
}
}
/// <summary>
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgInfo(string txt2log)
{
Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB;
Log.Info(txt2log);
}
/// <summary>
/// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
protected void lgTrace(string txt2log)
{
Log.Factory.Configuration.Variables["codIOB"] = GenConf.CodIOB;
Log.Trace(txt2log);
}
#endregion
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ namespace IOB_UT_NEXT.Config.Special
public plcMemMapExt MemMap { get; set; }
/// <summary>
/// Configurazione specifica OPC-UA
/// Configurazione specifica MTC
/// </summary>
public MtcParamConf MtcConf { get; set; }
@@ -28,7 +28,7 @@ namespace IOB_UT_NEXT.Config.Special
public OpcUaParamConf OpcUaConf { get; set; }
/// <summary>
/// Configurazione specifica OPC-UA
/// Configurazione specifica REST
/// </summary>
public RestParamConf RestConf { get; set; }
+13
View File
@@ -782,6 +782,19 @@ namespace IOB_UT_NEXT
}
}
/// <summary>
/// Restitusice la stringa prima dell'ultima occorrenza del char richiesto
/// </summary>
/// <param name="origString">string originale</param>
/// <param name="sepChar">char separatore da cercare</param>
/// <returns></returns>
public static string StringBeforeLastChar(string origString, char sepChar)
{
int index = origString.LastIndexOf(sepChar);
string answ = (index == -1) ? origString : origString.Substring(0, index);
return answ;
}
#endregion Public Methods
#region Protected Properties
+10 -7
View File
@@ -1738,7 +1738,10 @@ namespace IOB_WIN_FORM
// preparazione file conf con nuovo formato e salvataggio...
IOBConfFull = IobConfTree.LoadFromINI(iniConfFile);
IOBConfFull.IobConf.ConfFileName = IOBConfFull.IobConf.ConfFileName.Replace("ini", "yaml");
if (IOBConfFull.GenConf.ConfFileName.EndsWith("ini"))
{
IOBConfFull.GenConf.ConfFileName = IOBConfFull.GenConf.ConfFileName.Replace("ini", "yaml");
}
// salvo anche yaml...
IOBConfFull.SaveYaml(fullPath.Replace("iob", "yaml"));
@@ -1948,15 +1951,15 @@ namespace IOB_WIN_FORM
counterIob = $"pz IOB {iobObj.contapezziIOB}";
counterMac = $"pz PLC {iobObj.contapezziPLC}";
Dictionary<string, string> setPar = new Dictionary<string, string>();
setPar.Add("IP", iobObj.cIobConf.cncIpAddr);
setPar.Add("PORT", iobObj.cIobConf.cncPort);
string note = $"{iobObj.cIobConf.codIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}";
setPar.Add("IP", iobObj.IOBConfFull.DeviceConf.ConnectConf.IpAddr);
setPar.Add("PORT", iobObj.IOBConfFull.DeviceConf.ConnectConf.Port);
string note = $"{iobObj.IOBConfFull.GenConf.CodIOB} | DT ultimo avvio: {iobObj.dtAvvioAdp}";
// verifico IOB status
IobWinStatus currIobStatus = new IobWinStatus()
{
//CodIob = iobObj.cIobConf.codIOB,
CodIob = iobObj.cIobConf.filenameIOB,
IobType = iobObj.cIobConf.tipoIob.ToString(),
//CodIob = iobObj.cIobConf.filenameIOB,
CodIob = iobObj.IOBConfFull.GenConf.FilenameIOB,
IobType = $"{iobObj.IOBConfFull.GenConf.IobType}",//iobObj.cIobConf.tipoIob.ToString(),
queueAlLen = alQueueLen,
queueEvLen = evQueueLen,
queueFlLen = flQueueLen,
+14 -86
View File
@@ -37,7 +37,7 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Error(message, args);
sendToLogWatch("ERROR", message, args);
}
@@ -80,7 +80,7 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Debug(message);
if (sendToForm)
{
@@ -100,7 +100,7 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Debug(message, args);
sendToLogWatch("DEBUG", message, args);
}
@@ -112,20 +112,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="message"></param>
protected void lgError(string message, bool sendToForm = true)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(2, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Error(message);
if (sendToForm)
{
@@ -142,20 +133,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="args"></param>
protected void lgError(Exception exception, string message, params object[] args)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(2, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Error(exception, message, args);
sendToLogWatch("ERROR", message, exception, args);
}
@@ -167,20 +149,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="message"></param>
protected void lgFatal(string message, bool sendToForm = true)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(1, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Fatal(message);
if (sendToForm)
{
@@ -196,20 +169,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="args"></param>
protected void lgFatal(string message, params object[] args)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(1, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Fatal(message, args);
sendToLogWatch("FATAL", message, args);
}
@@ -223,20 +187,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="args"></param>
protected void lgFatal(Exception exception, string message, params object[] args)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(1, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Fatal(exception, message, args);
sendToLogWatch("FATAL", message, exception, args);
}
@@ -252,22 +207,13 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Info(message);
if (sendToForm)
{
sendToLogWatch("INFO", message);
}
}
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
}
/// <summary>
@@ -277,20 +223,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="args"></param>
protected void lgInfo(string message, params object[] args)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(30, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Info(message, args);
sendToLogWatch("INFO", message, args);
}
@@ -303,20 +240,11 @@ namespace IOB_WIN_FORM.Iob
/// <param name="sendToForm"></param>
protected void lgInfoStartup(string message, bool sendToForm = true)
{
#if false
try
{
}
catch
{
readErrorCurr++;
}
#endif
bool doVeto = checkLogVeto(30, ref message);
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
DateTime adesso = DateTime.Now;
if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration)
{
@@ -345,7 +273,7 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
DateTime adesso = DateTime.Now;
if (adesso.Subtract(lastLogStartup).TotalMinutes > vetoLogStartupDuration)
{
@@ -370,7 +298,7 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Trace(message);
if (sendToForm)
{
@@ -390,7 +318,7 @@ namespace IOB_WIN_FORM.Iob
// se non ho veto --> loggo
if (!doVeto)
{
lg.Factory.Configuration.Variables["codIOB"] = cIobConf.filenameIOB;
lg.Factory.Configuration.Variables["codIOB"] = IOBConfFull.GenConf.FilenameIOB;
lg.Trace(message, args);
sendToLogWatch("TRACE", message, args);
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// GenConf Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("IOB-WIN-FORM")]
+1 -1
View File
@@ -30,7 +30,7 @@
"optKVP": {
"shelly_tout": 5,
"fluxLogReduce": true,
"fluxLogRedDeadBand": 2.5,
"fluxLogRedDeadBand": 3.5,
"fluxLogResendPeriod": 60
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// GenConf Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("IOB-WIN-SHELLY")]