Merge branch 'release/TestSimUfficio_03'
This commit is contained in:
@@ -1,143 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
|
||||
namespace IOB_UT_NEXT
|
||||
{
|
||||
public class BinaryUtils : IFormatProvider, ICustomFormatter
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
// Format number in binary (B), octal (O), or hexadecimal (H).
|
||||
public string Format(string format, object arg, IFormatProvider formatProvider)
|
||||
{
|
||||
// Handle format string.
|
||||
int baseNumber;
|
||||
// Handle null or empty format string, string with precision specifier.
|
||||
string thisFmt = String.Empty;
|
||||
// Extract first character of format string (precision specifiers are not supported).
|
||||
if (!String.IsNullOrEmpty(format))
|
||||
thisFmt = format.Length > 1 ? format.Substring(0, 1) : format;
|
||||
|
||||
// Get a byte array representing the numeric value.
|
||||
byte[] bytes;
|
||||
if (arg is sbyte)
|
||||
{
|
||||
string byteString = ((sbyte)arg).ToString("X2");
|
||||
bytes = new byte[1] { Byte.Parse(byteString, System.Globalization.NumberStyles.HexNumber) };
|
||||
}
|
||||
else if (arg is byte)
|
||||
{
|
||||
bytes = new byte[1] { (byte)arg };
|
||||
}
|
||||
else if (arg is short)
|
||||
{
|
||||
bytes = BitConverter.GetBytes((short)arg);
|
||||
}
|
||||
else if (arg is int)
|
||||
{
|
||||
bytes = BitConverter.GetBytes((int)arg);
|
||||
}
|
||||
else if (arg is long)
|
||||
{
|
||||
bytes = BitConverter.GetBytes((long)arg);
|
||||
}
|
||||
else if (arg is ushort)
|
||||
{
|
||||
bytes = BitConverter.GetBytes((ushort)arg);
|
||||
}
|
||||
else if (arg is uint)
|
||||
{
|
||||
bytes = BitConverter.GetBytes((uint)arg);
|
||||
}
|
||||
else if (arg is ulong)
|
||||
{
|
||||
bytes = BitConverter.GetBytes((ulong)arg);
|
||||
}
|
||||
else if (arg is BigInteger)
|
||||
{
|
||||
bytes = ((BigInteger)arg).ToByteArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
return HandleOtherFormats(format, arg);
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
throw new FormatException(String.Format("The format of '{0}' is invalid.", format), e);
|
||||
}
|
||||
}
|
||||
|
||||
switch (thisFmt.ToUpper())
|
||||
{
|
||||
// Binary formatting.
|
||||
case "B":
|
||||
baseNumber = 2;
|
||||
break;
|
||||
|
||||
case "O":
|
||||
baseNumber = 8;
|
||||
break;
|
||||
|
||||
case "H":
|
||||
baseNumber = 16;
|
||||
break;
|
||||
// Handle unsupported format strings.
|
||||
default:
|
||||
try
|
||||
{
|
||||
return HandleOtherFormats(format, arg);
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
throw new FormatException(String.Format("The format of '{0}' is invalid.", format), e);
|
||||
}
|
||||
}
|
||||
|
||||
// Return a formatted string.
|
||||
string numericString = String.Empty;
|
||||
for (int ctr = bytes.GetUpperBound(0); ctr >= bytes.GetLowerBound(0); ctr--)
|
||||
{
|
||||
string byteString = Convert.ToString(bytes[ctr], baseNumber);
|
||||
if (baseNumber == 2)
|
||||
byteString = new String('0', 8 - byteString.Length) + byteString;
|
||||
else if (baseNumber == 8)
|
||||
byteString = new String('0', 4 - byteString.Length) + byteString;
|
||||
// Base is 16.
|
||||
else
|
||||
byteString = new String('0', 2 - byteString.Length) + byteString;
|
||||
|
||||
numericString += byteString + " ";
|
||||
}
|
||||
return numericString.Trim();
|
||||
}
|
||||
|
||||
// IFormatProvider.GetFormat implementation.
|
||||
public object GetFormat(Type formatType)
|
||||
{
|
||||
// Determine whether custom formatting object is requested.
|
||||
if (formatType == typeof(ICustomFormatter))
|
||||
return this;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string HandleOtherFormats(string format, object arg)
|
||||
{
|
||||
if (arg is IFormattable)
|
||||
return ((IFormattable)arg).ToString(format, CultureInfo.CurrentCulture);
|
||||
else if (arg != null)
|
||||
return arg.ToString();
|
||||
else
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace IOB_UT_NEXT
|
||||
{
|
||||
public class BinaryUtils : IFormatProvider, ICustomFormatter
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public string Format(string format, object arg, IFormatProvider formatProvider)
|
||||
{
|
||||
if (arg == null) return string.Empty;
|
||||
|
||||
// 1. Estrazione del formato (B, O, H)
|
||||
string thisFmt = string.IsNullOrEmpty(format) ? string.Empty : format.Substring(0, 1).ToUpper();
|
||||
|
||||
// 2. Pattern matching supportato da C# 7.0+
|
||||
byte[] bytes;
|
||||
switch (arg)
|
||||
{
|
||||
case sbyte sb:
|
||||
bytes = new byte[] { unchecked((byte)sb) };
|
||||
break;
|
||||
|
||||
case byte b:
|
||||
bytes = new byte[] { b };
|
||||
break;
|
||||
|
||||
case short s:
|
||||
bytes = BitConverter.GetBytes(s);
|
||||
break;
|
||||
|
||||
case ushort us:
|
||||
bytes = BitConverter.GetBytes(us);
|
||||
break;
|
||||
|
||||
case int i:
|
||||
bytes = BitConverter.GetBytes(i);
|
||||
break;
|
||||
|
||||
case uint ui:
|
||||
bytes = BitConverter.GetBytes(ui);
|
||||
break;
|
||||
|
||||
case long l:
|
||||
bytes = BitConverter.GetBytes(l);
|
||||
break;
|
||||
|
||||
case ulong ul:
|
||||
bytes = BitConverter.GetBytes(ul);
|
||||
break;
|
||||
|
||||
case BigInteger bi:
|
||||
bytes = bi.ToByteArray();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Se non è un numero supportato, delega alla formattazione standard
|
||||
return HandleOtherFormats(format, arg);
|
||||
}
|
||||
|
||||
// 3. Formattazione e unione dei byte
|
||||
switch (thisFmt)
|
||||
{
|
||||
case "B":
|
||||
return FormatBytes(bytes, 2, 8);
|
||||
|
||||
case "O":
|
||||
return FormatBytes(bytes, 8, 4);
|
||||
|
||||
case "H":
|
||||
return FormatBytes(bytes, 16, 2);
|
||||
|
||||
default:
|
||||
return HandleOtherFormats(format, arg);
|
||||
}
|
||||
}
|
||||
|
||||
public object GetFormat(Type formatType)
|
||||
{
|
||||
return formatType == typeof(ICustomFormatter) ? this : null;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string FormatBytes(byte[] bytes, int baseNumber, int padding)
|
||||
{
|
||||
// Reverse per rispettare l'ordine Big-Endian dell'originale
|
||||
var formattedParts = bytes.Reverse().Select(b => Convert.ToString(b, baseNumber).PadLeft(padding, '0'));
|
||||
return string.Join(" ", formattedParts);
|
||||
}
|
||||
|
||||
private string HandleOtherFormats(string format, object arg)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Pattern matching base disponibile in C# 7.0
|
||||
if (arg is IFormattable formattable)
|
||||
{
|
||||
return formattable.ToString(format, CultureInfo.CurrentCulture);
|
||||
}
|
||||
return arg.ToString();
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
throw new FormatException($"The format of '{format}' is invalid.", e);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_UT_NEXT
|
||||
@@ -39,7 +38,7 @@ namespace IOB_UT_NEXT
|
||||
{
|
||||
parsed = JsonConvert.DeserializeObject<Dictionary<string, CallStats>>(json.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch //(Exception ex)
|
||||
{
|
||||
// Log: dati Redis corrotti o schema incompatibile. Si ignora per sicurezza.
|
||||
return;
|
||||
|
||||
@@ -45,23 +45,6 @@ namespace IOB_UT_NEXT.Config.Base
|
||||
/// </summary>
|
||||
public string CodIOB { get; set; } = "ND";
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Codice dei vari codici aggiuntivi IOB multi x funzioni slave (es autoOdl)
|
||||
/// </summary>
|
||||
public string MultiIobListRaw { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Lista dei vari IOB multi x funzioni slave (es autoOdl)
|
||||
/// </summary>
|
||||
public List<string> MultiIobList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Lista dei vari IOB multi x funzioni slave (es autoOdl)
|
||||
/// </summary>
|
||||
public bool IsMultiIobList { get; set; } = false;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Tempo di attesa (in minuti) x lettura contapezzi standard (default 30 sec)
|
||||
/// </summary>
|
||||
|
||||
@@ -65,30 +65,5 @@ namespace IOB_UT_NEXT.Config.Base
|
||||
/// </summary>
|
||||
public int ResetCountMaxPost { get; set; } = 10;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Parametri opzionali di configurazione cambio ODL, ad esempio
|
||||
/// - OdlDurationHours
|
||||
/// - IdleStateMin
|
||||
/// - ResetMinCountPre
|
||||
/// - ResetMaxCountPost
|
||||
/// </summary>
|
||||
public Dictionary<string, string> OptPar { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Recupera valore della chiave specifica richiesta
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public string OptParGet(string key)
|
||||
{
|
||||
string answ = "";
|
||||
if (OptPar != null && OptPar.Count > 0 && OptPar.ContainsKey(key))
|
||||
{
|
||||
answ = OptPar[key];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace IOB_UT_NEXT.Config
|
||||
{
|
||||
public class EnumConf
|
||||
{
|
||||
#region Public Enums
|
||||
|
||||
/// <summary>
|
||||
/// Macro tipologia sistema di comunicazione (macro-adapter)
|
||||
@@ -26,373 +27,6 @@ namespace IOB_UT_NEXT.Config
|
||||
Serial
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Tipologia di adapters ammessi
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum AdapterType
|
||||
{
|
||||
/// <summary>
|
||||
/// Adapter SIMULAZIONE
|
||||
/// </summary>
|
||||
SIMULA,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Beckhoff
|
||||
/// </summary>
|
||||
BECKHOFF,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Beckhoff x CPA (selezionatrici ex Jetco)
|
||||
/// </summary>
|
||||
BECKHOFF_CPA,
|
||||
|
||||
/// <summary>
|
||||
/// adapter FANUC
|
||||
/// </summary>
|
||||
FANUC,
|
||||
|
||||
/// <summary>
|
||||
/// File Based exchange generic adapter
|
||||
/// </summary>
|
||||
FILE_GEN,
|
||||
|
||||
/// <summary>
|
||||
/// File Based exchange Euromap63
|
||||
/// </summary>
|
||||
FILE_EUROM63,
|
||||
|
||||
///// <summary>
|
||||
///// File Based exchange SCM Xylog
|
||||
///// </summary>
|
||||
//FILE_XYLOG,
|
||||
|
||||
/// <summary>
|
||||
/// File Based Log file analisys per Soitaab
|
||||
/// </summary>
|
||||
FILE_SOITAAB,
|
||||
|
||||
/// <summary>
|
||||
/// Gestione sync FTP
|
||||
/// </summary>
|
||||
FTP,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter KAWASAKI e-controller
|
||||
/// </summary>
|
||||
KAWASAKI,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Icoel per DB (barcode, tracciatura, produzione,...)
|
||||
/// </summary>
|
||||
IcoelDb,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Icoel per WS SOAP (sizer)
|
||||
/// </summary>
|
||||
IcoelSoap,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter non specificato
|
||||
/// </summary>
|
||||
ND,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter MITSUBISHI con EZCnc lib
|
||||
/// </summary>
|
||||
MITSUBISHI,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter ModBus TCP generico
|
||||
/// </summary>
|
||||
MODBUS_TCP,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter ModBus TCP versione Cedax (Giacovelli)
|
||||
/// </summary>
|
||||
MODBUS_TCP_CEDAX,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter ModBus TCP versione Centerfrigo (Giacovelli)
|
||||
/// </summary>
|
||||
MODBUS_TCP_CENTERFRIGO,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter modbus (+ file) x FIMAT (Tenditalia)
|
||||
/// </summary>
|
||||
MODBUS_TCP_FIMAT,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter ModBus TCP versione HAM (Pizzaferri)
|
||||
/// </summary>
|
||||
MODBUS_TCP_HAM,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter ModBus TCP versione HELPI (Cererie Finassi)
|
||||
/// </summary>
|
||||
MODBUS_TCP_HELPI,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Modubus TCP versione IMAX Aeromacchine (Jetco)
|
||||
/// </summary>
|
||||
MODBUS_TCP_IMAS_AEROMEC,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Modubus TCP versione Rimor (IMI Remosa)
|
||||
/// </summary>
|
||||
MODBUS_TCP_RIMOR,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Modubus TCP versione Saim (Giacovelli)
|
||||
/// </summary>
|
||||
MODBUS_TCP_SAIM,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter Modubus TCP versione Zetapack (Giacovelli)
|
||||
/// </summary>
|
||||
MODBUS_TCP_ZETAPACK,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter MTConnect
|
||||
/// </summary>
|
||||
MTConnect,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OMRON
|
||||
/// </summary>
|
||||
OMRON,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA
|
||||
/// </summary>
|
||||
OpcUa,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA CMS
|
||||
/// </summary>
|
||||
OpcUaCMS,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per Ewon
|
||||
/// </summary>
|
||||
OpcUaEwon,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per Ewon x Adige (BLM) / STIL
|
||||
/// </summary>
|
||||
OpcUaEwonAdige,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per Ewon x BLM / Mecart
|
||||
/// </summary>
|
||||
OpcUaEwonBLM,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per Ewon x Monti / Tenditalia
|
||||
/// </summary>
|
||||
OpcUaEwonMonti,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per Ewon x Mecolpress (BLM) / STIL
|
||||
/// </summary>
|
||||
OpcUaEwonMecolpress,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per KeepWare
|
||||
/// </summary>
|
||||
OpcUaKwp,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per KeepWare, UnitechRama
|
||||
/// </summary>
|
||||
OpcUaKwpRama,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA per IMAS Aeromec / Jetco
|
||||
/// </summary>
|
||||
OpcUaImasAeromec,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter MBH (es Cimolai)
|
||||
/// </summary>
|
||||
OpcUaMBH,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter MBH implementazione Cimolai x travel lift
|
||||
/// </summary>
|
||||
OpcUaMBHCimolai,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OMRON (es ICOEL)
|
||||
/// </summary>
|
||||
OpcUaOmron,
|
||||
|
||||
/// <summary>
|
||||
/// Implementaizone OMRON specifica x ICOEL
|
||||
/// </summary>
|
||||
OpcUaOmronIcoel,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA SCM
|
||||
/// </summary>
|
||||
OpcUaSCM,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA Siemens generico
|
||||
/// </summary>
|
||||
OpcUaSiemens,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA Siemens OMP
|
||||
/// </summary>
|
||||
OpcUaSiemensOMP,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA Siemens Rama
|
||||
/// </summary>
|
||||
OpcUaSiemensRama,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OPC-UA Ulma (packaging, Giacovelli)
|
||||
/// </summary>
|
||||
OpcUaUlma,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OSAI CNDEX (Cndex)
|
||||
/// </summary>
|
||||
OSAI_CNDEX,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OSAI OPEN (ws)
|
||||
/// </summary>
|
||||
OSAI_OPEN,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter OSAI VB6
|
||||
/// </summary>
|
||||
OSAI_VB6,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter tipo watchdog via ping (per impianti spenti e non rilevati)
|
||||
/// </summary>
|
||||
PingWatchdog,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter REST (base)
|
||||
/// </summary>
|
||||
REST,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter REST Citizen
|
||||
/// </summary>
|
||||
REST_CITIZEN,
|
||||
|
||||
/// <summary>
|
||||
/// Shelly's Device (tipicamente PM series)
|
||||
/// </summary>
|
||||
Shelly,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS
|
||||
/// </summary>
|
||||
SIEMENS,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione APROCHIM (filtro liquidi rettifiche)
|
||||
/// </summary>
|
||||
SIEMENS_APROCHIM,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione VIPA @2001
|
||||
/// </summary>
|
||||
SIEMENS_AT2001,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione FAPE (punzonatrici) vers 2018
|
||||
/// </summary>
|
||||
SIEMENS_FAPE,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione FAPE (punzonatrici) vers 2024
|
||||
/// </summary>
|
||||
SIEMENS_FAPE_2,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione COMECA (impianti gestione GNL)
|
||||
/// </summary>
|
||||
SIEMENS_COMECA,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione COMUR (dentatrice)
|
||||
/// </summary>
|
||||
SIEMENS_COMUR,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione COSMAP (transfer smerigliatrice donati)
|
||||
/// </summary>
|
||||
SIEMENS_COSMAP,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione INGENIA (Valvital, Automazione)
|
||||
/// </summary>
|
||||
SIEMENS_INGENIA,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione LASCO (Valvital, Pressa Bilancere)
|
||||
/// </summary>
|
||||
SIEMENS_LASCO,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione NWSE (Giacovelli, impianto filtrazione NWS)
|
||||
/// </summary>
|
||||
SIEMENS_NWSE,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione PRESSOIL + CEI (Valvital, Pressa Idraulica)
|
||||
/// </summary>
|
||||
SIEMENS_PRESSOIL_CEI,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia verisone RobotService (Donati, smerigliatrici)
|
||||
/// </summary>
|
||||
SIEMENS_ROBOTSERVICE,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione SAET (Valvital, forni / tempra)
|
||||
/// </summary>
|
||||
SIEMENS_SAET,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione SIMEC (Valvital, taglio)
|
||||
/// </summary>
|
||||
SIEMENS_SIMEC,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS, interfaccia versione Torri
|
||||
/// </summary>
|
||||
SIEMENS_TORRI,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter SOAP x bilance Gomba
|
||||
/// </summary>
|
||||
SOAP_GOMBA,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter basato su DB scambio Microsoft SqlServer, macchine LANTEK
|
||||
/// </summary>
|
||||
SQLSERVER_LANTEK,
|
||||
|
||||
/// <summary>
|
||||
/// Adapter basato su DB scambio Microsoft SqlServer, macchine PAMA
|
||||
/// </summary>
|
||||
SQLSERVER_PAMA,
|
||||
|
||||
/// <summary>
|
||||
/// Metodi di WPS WebPageScraping (es x compressori Atlas Copco)
|
||||
/// </summary>
|
||||
WPS
|
||||
}
|
||||
#endif
|
||||
#endregion Public Enums
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_UT_NEXT.Config.Base;
|
||||
using IOB_UT_NEXT.Config.Special;
|
||||
using IOB_UT_NEXT.Iob.Services;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -659,21 +660,6 @@ namespace IOB_UT_NEXT.Config
|
||||
{
|
||||
newConfObj.Special.OpcUaConf = JsonConvert.DeserializeObject<OpcUaParamConf>(jsonData);
|
||||
newConfObj.lgDebug($"Decodifica aree OpcUaParamConf: trovati {newConfObj.Special.OpcUaConf.paramsEndThresh.Count} valori paramsEndThresh");
|
||||
#if false
|
||||
// sistemo se ci sono dati memMap...
|
||||
if (newConfObj.Memory == null)
|
||||
{
|
||||
newConfObj.Memory = new plcMemMapExt();
|
||||
}
|
||||
try
|
||||
{
|
||||
newConfObj.Memory = JsonConvert.DeserializeObject<plcMemMapExt>(jsonData);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
newConfObj.lgError($"Eccezione in decodifica conf json{Environment.NewLine}{exc}");
|
||||
}
|
||||
#endif
|
||||
|
||||
// elimino conf memoria da area OPC che tanto è già OK...
|
||||
newConfObj.Special.OpcUaConf.mMapRead = new Dictionary<string, MapoSDK.dataConfTSVC>();
|
||||
@@ -1082,7 +1068,7 @@ namespace IOB_UT_NEXT.Config
|
||||
{
|
||||
string rawData = GetYaml();
|
||||
// prova anche ad inviare il contenuto al server IO...
|
||||
string resp = utils.ExecCallPostPlain($"{urlSaveYaml}", rawData);
|
||||
string resp = HttpService.ExecCallPostPlain($"{urlSaveYaml}", rawData);
|
||||
answ = resp == "OK";
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -18,13 +18,6 @@ namespace IOB_UT_NEXT.Config.Special
|
||||
/// </summary>
|
||||
public MemBankDto BankConf { get; set; }
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Configurazione specifica per Fanuc
|
||||
/// </summary>
|
||||
public FanucDto FanucConf { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione specifica per gestione file esterni (es Saim x Giacovelli)
|
||||
/// </summary>
|
||||
|
||||
@@ -31,14 +31,6 @@ namespace IOB_UT_NEXT.Config.Special
|
||||
/// </summary>
|
||||
public string CompoValMMap { get; set; } = null;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Valore composto (a partire da altri valori in ProdData),da usare se != null
|
||||
/// Sostituzione token espressi nel formato [[token]]
|
||||
/// </summary>
|
||||
public string CompoValProdData { get; set; } = null;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Valore fix da inviare alla memoria se != null
|
||||
/// </summary>
|
||||
|
||||
@@ -202,6 +202,10 @@
|
||||
<Compile Include="iobRefreshedEventArgs.cs" />
|
||||
<Compile Include="IobWinStatus.cs" />
|
||||
<Compile Include="Iob\BaseObj.cs" />
|
||||
<Compile Include="Iob\Services\DataSerializer.cs" />
|
||||
<Compile Include="Iob\Services\HttpService.cs" />
|
||||
<Compile Include="Iob\Services\NetService.cs" />
|
||||
<Compile Include="Iob\Services\XmlDataSerializer.cs" />
|
||||
<Compile Include="JobTask2Exe.cs" />
|
||||
<Compile Include="MeasureUtils.cs" />
|
||||
<Compile Include="plcMemMapExt.cs" />
|
||||
@@ -211,7 +215,7 @@
|
||||
<Compile Include="TimeUtils.cs" />
|
||||
<Compile Include="ToMapo.cs" />
|
||||
<Compile Include="baseUtils.cs" />
|
||||
<Compile Include="BinaryFormatter.cs" />
|
||||
<Compile Include="BinaryUtils.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="fileMover.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
|
||||
@@ -371,69 +371,6 @@ namespace IOB_UT_NEXT.Iob
|
||||
|
||||
#region Public Methods
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="doAsync">invio in modalità async (NON GARANTITO ordine...)</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> callUrl(string URL, bool doAsync)
|
||||
{
|
||||
string answ = "";
|
||||
// verifica URL preliminare
|
||||
if (URL.StartsWith("http://ND"))
|
||||
{
|
||||
lg.Warn($"callUrl | wrong URL data: {URL}");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doAsync)
|
||||
{
|
||||
answ = await utils.callUrlAsync(URL);
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = await Task.Run(() => utils.callUrl(URL));
|
||||
}
|
||||
|
||||
if (urlRandWait > 0)
|
||||
{
|
||||
// NON blocca il thread, libera risorse per le altre 20 istanze
|
||||
await Task.Delay(rnd.Next(urlRandWait / 10, urlRandWait));
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="payload"></param>
|
||||
/// <param name="doAsync">invio in modalità async (NON GARANTITO ordine...)</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> callUrlWithPayloadAsync(string URL, string payload, bool doAsync)
|
||||
{
|
||||
string answ = "";
|
||||
if (doAsync)
|
||||
{
|
||||
answ = await utils.callUrlAsync(URL, payload);
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = await Task.Run(() => utils.callUrl(URL, payload));
|
||||
}
|
||||
|
||||
if (urlRandWait > 0)
|
||||
{
|
||||
// NON blocca il thread, libera risorse per le altre 20 istanze
|
||||
await Task.Delay(rnd.Next(urlRandWait / 10, urlRandWait));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// processa dataLayer e se necessario salva/mostra
|
||||
/// </summary>
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IOB_WIN_FORM.Iob.Services
|
||||
namespace IOB_UT_NEXT.Iob.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Gestisce tutte le operazioni di serializzazione e deserializzazione dei dati.
|
||||
@@ -0,0 +1,312 @@
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_UT_NEXT.Iob.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Servizio dedicato alla gestione delle chiamate HTTP.
|
||||
/// </summary>
|
||||
public class HttpService
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato, SE NON E' in veto send.
|
||||
/// </summary>
|
||||
public static string CallUrl(string url)
|
||||
{
|
||||
if (baseUtils.dtVetoSend < DateTime.Now)
|
||||
{
|
||||
return CallUrlGet(url);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato con payload.
|
||||
/// </summary>
|
||||
public static string CallUrl(string url, string payload)
|
||||
{
|
||||
if (baseUtils.dtVetoSend < DateTime.Now)
|
||||
{
|
||||
return CallUrlPost(url, payload);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo chiamata URL con POST async.
|
||||
/// </summary>
|
||||
public static async Task<string> CallUrlAsync(string url, string payload, CancellationToken ct = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
var content = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
|
||||
using (var client = new HttpClient()) // Note: In a real app, use IHttpClientFactory
|
||||
{
|
||||
HttpResponseMessage response = await client.PostAsync(url, content, ct);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
sw.Stop();
|
||||
baseUtils.TrackUrlCall(url, sw.Elapsed);
|
||||
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return "Canceled";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Error: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo chiamata URL con GET async.
|
||||
/// </summary>
|
||||
public static async Task<string> CallUrlAsync(string url, CancellationToken ct = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync(url, ct);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
sw.Stop();
|
||||
baseUtils.TrackUrlCall(url, sw.Elapsed);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return "Canceled";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return $"Error: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL IMMEDIATAMENTE (GET) e restituisce risultato.
|
||||
/// </summary>
|
||||
public static string CallUrlGet(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpClientHandler handler = new HttpClientHandler();
|
||||
if (url.Contains("10.74.82."))
|
||||
{
|
||||
handler.ServerCertificateCustomValidationCallback =
|
||||
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
||||
}
|
||||
|
||||
using (var client = new HttpClient(handler))
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
client.Timeout = TimeSpan.FromMilliseconds(5000);
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(baseUtils.CRS("appName"));
|
||||
|
||||
var response = client.GetAsync(url).Result;
|
||||
string answ = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
sw.Stop();
|
||||
baseUtils.TrackUrlCall(url, sw.Elapsed);
|
||||
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
int pauseSendMSec = baseUtils.nextPauseSendMSec;
|
||||
baseUtils.dtVetoSend = DateTime.Now.AddMilliseconds(pauseSendMSec);
|
||||
|
||||
if (baseUtils.logValuePermit(url))
|
||||
{
|
||||
baseUtils.lg.Error($"CallUrlGet | Errore chiamando {url} | wait {pauseSendMSec} ms{Environment.NewLine}Eccezione:{Environment.NewLine}{exc}");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata IMMEDIATAMENTE URL (POST) e restituisce risultato.
|
||||
/// </summary>
|
||||
public static string CallUrlPost(string url, string payload)
|
||||
{
|
||||
string answ = "";
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
try
|
||||
{
|
||||
HttpClientHandler handler = new HttpClientHandler();
|
||||
if (url.Contains("10.74."))
|
||||
{
|
||||
handler.ServerCertificateCustomValidationCallback =
|
||||
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
||||
}
|
||||
|
||||
using (var client = new HttpClient(handler))
|
||||
{
|
||||
client.Timeout = TimeSpan.FromMilliseconds(5000);
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd($"{baseUtils.CRS("appName")}-PAYLOAD");
|
||||
|
||||
var content = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
var response = client.PostAsync(url, content).Result;
|
||||
|
||||
answ = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (answ != "OK")
|
||||
{
|
||||
if (baseUtils.logValuePermit($"{url}|[{answ}]"))
|
||||
{
|
||||
baseUtils.lg.Error($"CallUrlPost | POST fallito | ans: [{answ}]:{Environment.NewLine}- URL{Environment.NewLine}{url}{Environment.NewLine}- payload{Environment.NewLine}{payload}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
int pauseSendMSec = baseUtils.nextPauseSendMSec;
|
||||
baseUtils.dtVetoSend = DateTime.Now.AddMilliseconds(pauseSendMSec);
|
||||
|
||||
if (baseUtils.logValuePermit(url))
|
||||
{
|
||||
baseUtils.lg.Error($"CallUrlPost | Errore chiamando {url} | wait {pauseSendMSec} ms | Dump Payload:{Environment.NewLine}{payload}{Environment.NewLine}Eccezione:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
baseUtils.TrackUrlCall(url, sw.Elapsed);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL tramite RestSharp (GET)
|
||||
/// </summary>
|
||||
public static string ExecCallGet(string url, bool fastCall = false)
|
||||
{
|
||||
string answ = "";
|
||||
Uri uri = new Uri(url);
|
||||
string baseUrl = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
string resource = uri.AbsolutePath;
|
||||
RestClientOptions restOptStd = new RestClientOptions
|
||||
{
|
||||
BaseUrl = new Uri(baseUrl),
|
||||
Timeout = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
if (fastCall) restOptStd.Timeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
try
|
||||
{
|
||||
using (var client = new RestClient(restOptStd))
|
||||
{
|
||||
var actReq = new RestRequest(resource, Method.Get);
|
||||
var currResp = client.Get(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
{
|
||||
answ = currResp.Content;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
baseUtils.lg.Error($"Eccezione in ExecCallGet{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL tramite RestSharp (POST JSON)
|
||||
/// </summary>
|
||||
public static string ExecCallPostJson(string url, string payload, bool fastCall = false)
|
||||
{
|
||||
string answ = "";
|
||||
Uri uri = new Uri(url);
|
||||
string baseUrl = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
string resource = uri.AbsolutePath;
|
||||
RestClientOptions restOptStd = new RestClientOptions
|
||||
{
|
||||
BaseUrl = new Uri(baseUrl),
|
||||
Timeout = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
if (fastCall) restOptStd.Timeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
try
|
||||
{
|
||||
using (var client = new RestClient(restOptStd))
|
||||
{
|
||||
var actReq = new RestRequest(resource, Method.Post);
|
||||
actReq.AddJsonBody(payload);
|
||||
var currResp = client.Post(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
{
|
||||
answ = currResp.Content;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
baseUtils.lg.Error($"Eccezione in ExecCallPostJson{Environment.NewLine}{exc}");
|
||||
}
|
||||
sw.Stop();
|
||||
baseUtils.TrackUrlCall(url, sw.Elapsed);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL tramite RestSharp (POST Plain)
|
||||
/// </summary>
|
||||
public static string ExecCallPostPlain(string url, string payload, bool fastCall = false)
|
||||
{
|
||||
string answ = "";
|
||||
Uri uri = new Uri(url);
|
||||
string baseUrl = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
string resource = uri.AbsolutePath;
|
||||
RestClientOptions restOptStd = new RestClientOptions
|
||||
{
|
||||
BaseUrl = new Uri(baseUrl),
|
||||
Timeout = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
if (fastCall) restOptStd.Timeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
try
|
||||
{
|
||||
using (var client = new RestClient(restOptStd))
|
||||
{
|
||||
var actReq = new RestRequest(resource, Method.Post);
|
||||
actReq.AddStringBody(payload, ContentType.Plain);
|
||||
var currResp = client.Post(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
{
|
||||
answ = currResp.Content;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
baseUtils.lg.Error($"Eccezione in ExecCallPostPlain | rawUrl: {url} {Environment.NewLine}{exc}");
|
||||
}
|
||||
sw.Stop();
|
||||
baseUtils.TrackUrlCall(url, sw.Elapsed);
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_UT_NEXT.Iob.Services
|
||||
{
|
||||
public class NetService
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// IP della macchina
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetIP()
|
||||
{
|
||||
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
||||
String sIpAddr = string.Empty;
|
||||
try
|
||||
{
|
||||
foreach (NetworkInterface adapter in nics)
|
||||
{
|
||||
if (sIpAddr == String.Empty)// only return IP Address from first card
|
||||
{
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
foreach (var item in properties.UnicastAddresses)
|
||||
{
|
||||
if (item.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
||||
{
|
||||
sIpAddr = item.Address.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error(exc);
|
||||
}
|
||||
return sIpAddr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Macaddress della macchina
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetMACAddress()
|
||||
{
|
||||
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
||||
String sMacAddress = string.Empty;
|
||||
foreach (NetworkInterface adapter in nics)
|
||||
{
|
||||
if (sMacAddress == String.Empty)// only return MAC Address from first card
|
||||
{
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
//sMacAddress = adapter.GetPhysicalAddress().ToString();
|
||||
sMacAddress = string.Join(":", (from z in adapter.GetPhysicalAddress().GetAddressBytes() select z.ToString("X2")).ToArray());
|
||||
}
|
||||
}
|
||||
return sMacAddress;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Fields
|
||||
|
||||
/// <summary>
|
||||
/// Classe logger
|
||||
/// </summary>
|
||||
internal static Logger lg = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Internal Fields
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -2,7 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace IOB_WIN_FORM.Iob.Services
|
||||
namespace IOB_UT_NEXT.Iob.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Gestisce le operazioni di serializzazione e deserializzazione in formato XML.
|
||||
@@ -30,8 +30,6 @@ namespace IOB_WIN_FORM.Iob.Services
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log l'errore se necessario. In un contesto di refactoring,
|
||||
// potremmo voler passare l'eccezione verso l'alto.
|
||||
throw new InvalidOperationException($"Errore durante la serializzazione XML per il tipo {typeof(T).Name}", ex);
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
using IOB_UT_NEXT;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_UT_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe principale di configurazione di base per IOB, da cui derivano configurazioni + articolate x singoli IOB
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class IobConfiguration
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Avvio configurazione DUMMY
|
||||
/// </summary>
|
||||
public IobConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avvio configurazione da file di conf
|
||||
/// </summary>
|
||||
/// <param name="pathConfFile">File di conf json/yaml valido</param>
|
||||
public IobConfiguration(string pathConfFile)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Valore intero corrispondente ai BIT da filtrare x blinking
|
||||
/// </summary>
|
||||
public int BLINK_FILT { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo Ip del CNC Controllato
|
||||
/// </summary>
|
||||
public string cncIpAddr { get; set; } = "127.0.0.1";
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo Ip per PING dell'impianto (se NON valorizzato usa cncIpAddr x ping)
|
||||
/// </summary>
|
||||
public string cncPingAddr { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Porta del CNC Controllato
|
||||
/// </summary>
|
||||
public string cncPort { get; set; } = "0";
|
||||
|
||||
/// <summary>
|
||||
/// Codice univoco IOB
|
||||
/// </summary>
|
||||
public string codIOB { get; set; } = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// TipoCPU (es: Siemens)
|
||||
/// </summary>
|
||||
public string cpuType { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indica che sono disabilitati i Task2Exe (tipicamente gestione scrittura verso PLC)
|
||||
/// </summary>
|
||||
public bool disableExeTask { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Indica che sono disabilitate le fasi controllo stato/semafori (tipicamente x impianti
|
||||
/// con PLC "suddivisi", PLC + HMI)
|
||||
/// </summary>
|
||||
public bool disableStateCh { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Indica se le code vadano gestite su redis o meno
|
||||
/// </summary>
|
||||
public bool EnableRedisQueue { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Nome del file IOB di avvio (REDIS - MAN)
|
||||
/// </summary>
|
||||
public string filenameIOB { get; set; } = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// Nome file di INI
|
||||
/// </summary>
|
||||
public string iniFileName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Array degli elementi di traduzione item
|
||||
/// </summary>
|
||||
public Dictionary<string, string> itemTranslation { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Valore MAX per countdown segnali blinking
|
||||
/// </summary>
|
||||
public int MAX_COUNTER_BLINK { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Minimo delta in sec x considerare variazioni info
|
||||
/// </summary>
|
||||
public int minDeltaSec { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Modello della macchina
|
||||
/// </summary>
|
||||
public string model { get; set; } = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei parametri opzionali
|
||||
/// </summary>
|
||||
public Dictionary<string, string> optPar { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Timeout test PING
|
||||
/// </summary>
|
||||
public int pingMsTimeout { get; set; } = 500;
|
||||
|
||||
/// <summary>
|
||||
/// Rack (Siemens S7)
|
||||
/// </summary>
|
||||
public short rack { get; set; } = 0;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Dati di conf del server MoonPro cui comunicare
|
||||
/// </summary>
|
||||
public serverMapo serverData { get; set; } = new serverMapo("127.0.0.1", "/", "/IOB/input/", "/IOB/flog/", "/IOB/ulog/", "/IOB", "/IOB/enabled/", "/sendReboot.aspx?idxMacchina=", "/IOB/getCurrOdlStart/", "SteamWare", "/IOB/forceSplitOdlFull", "/IOB/getIdlePeriod", "/IOB/rawTransfJson");
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Slot (Siemens S7)
|
||||
/// </summary>
|
||||
public short slot { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Fattore lambda (innovazione) per calcolo EWMA valore TCiclo corrente
|
||||
/// </summary>
|
||||
public double TCLambda { get; set; } = 0.4;
|
||||
|
||||
/// <summary>
|
||||
/// Fattore massimo ammesso di delay x il TCiclo
|
||||
/// </summary>
|
||||
public double TCMaxDelayFactor { get; set; } = 1.2;
|
||||
|
||||
/// <summary>
|
||||
/// Incremento amssimo pezzi per cui fare calcolo del tempociclo attuale
|
||||
/// </summary>
|
||||
public double TCMaxIncrPz { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia dell'adapter/CNC Controllato
|
||||
/// </summary>
|
||||
public tipoAdapter tipoIob { get; set; } = tipoAdapter.SIMULA;
|
||||
|
||||
/// <summary>
|
||||
/// Vendor della macchina
|
||||
/// </summary>
|
||||
public string vendor { get; set; } = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// Versione IOB
|
||||
/// </summary>
|
||||
public string versIOB { get; set; } = "0";
|
||||
|
||||
/// <summary>
|
||||
/// Attesa riconnessione standard
|
||||
/// </summary>
|
||||
public int waitRecMSec { get; set; } = 59000;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,14 +23,6 @@ namespace IOB_UT_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#if false
|
||||
public JobTaskData(string codTav, Dictionary<string, string> newDict)
|
||||
{
|
||||
CodTav = codTav;
|
||||
RawData = JsonConvert.SerializeObject(newDict);
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -874,12 +874,6 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="maxElem">num max di elementi da recuperare</param>
|
||||
public List<RedisValue> redQueuePopAll(RedisKey queueName)
|
||||
{
|
||||
// vecchio metodo (NON resetta)
|
||||
#if false
|
||||
long nCount = currDb.ListLength(queueName);
|
||||
List<RedisValue> listData = currDb.ListRange(queueName, 0, nCount).ToList();
|
||||
return listData;
|
||||
#endif
|
||||
// lettura + reset in blocco
|
||||
var listData = currDb.ListRange(queueName, 0, -1).ToList();
|
||||
if (listData.Count > 0)
|
||||
@@ -888,16 +882,6 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
return listData;
|
||||
|
||||
// in alternativa lettura 1:1
|
||||
#if false
|
||||
var results = new List<RedisValue>();
|
||||
RedisValue item;
|
||||
while ((item = currDb.ListLeftPop(queueName)) != RedisValue.Null)
|
||||
{
|
||||
results.Add(item);
|
||||
}
|
||||
return results;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -907,14 +891,6 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="maxElem">num max di elementi da recuperare</param>
|
||||
public List<RedisValue> redQueuePopList(RedisKey queueName, int maxElem)
|
||||
{
|
||||
// vecchia modalità senza rimozione
|
||||
#if false
|
||||
long nCount = currDb.ListLength(queueName);
|
||||
nCount = nCount < maxElem ? nCount : maxElem;
|
||||
List<RedisValue> listData = currDb.ListRange(queueName, 0, nCount).ToList();
|
||||
return listData;
|
||||
#endif
|
||||
|
||||
// nuovo metodo con rimozione
|
||||
var results = new List<RedisValue>(maxElem);
|
||||
|
||||
@@ -1454,21 +1430,6 @@ namespace IOB_UT_NEXT
|
||||
// Memorizza i dettagli nella Hash Table: field = eventId, value = dataQty
|
||||
await currDb.HashSetAsync(rkeyHash, eventId, dataQty.ToString());
|
||||
|
||||
#if false
|
||||
// Crea un batch per eseguire le operazioni in modo transazionale
|
||||
var batch = cache.CreateBatch();
|
||||
|
||||
// Aggiungi al Sorted Set: score = timestamp, member = eventId
|
||||
await batch.SortedSetAddAsync(EventsTimeSeriesKey, eventId, timestamp);
|
||||
|
||||
// Memorizza i dettagli nella Hash Table: field = eventId, value = dataExchanged
|
||||
await batch.HashSetAsync(EventDetailsHashKey, eventId, dataExchanged.ToString()); // StackExchange.Redis memorizza RedisValue
|
||||
|
||||
// Esegui il batch in modo sincrono (o non va...)
|
||||
batch.Execute();
|
||||
//await batch.ExecuteAsync();
|
||||
#endif
|
||||
|
||||
Logging.Instance.Debug($"Evento registrato: ID={eventId}, Timestamp={timestamp}, Dati={dataQty}");
|
||||
return eventId;
|
||||
}
|
||||
|
||||
+26
-517
@@ -73,264 +73,23 @@ namespace IOB_UT_NEXT
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// formatta un numero in forma binaria 0/1
|
||||
/// </summary>
|
||||
/// <param name="valore"></param>
|
||||
/// <returns></returns>
|
||||
public static string binaryForm(int valore)
|
||||
/// <param name="valore">Il valore numerico (int, uint, short, byte, ecc.)</param>
|
||||
/// <returns>La stringa binaria formattata</returns>
|
||||
public static string binaryForm<T>(T valore) where T : struct
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format(new BinaryUtils(), "{0:B}", valore);
|
||||
// Il compilatore passerà automaticamente il tipo corretto (int, uint, ecc.)
|
||||
// alla tua classe BinaryUtils, che lo gestirà nel suo blocco switch.
|
||||
return string.Format(new BinaryUtils(), "{0:B}", valore);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// formatta un numero in forma binaria 0/1
|
||||
/// </summary>
|
||||
/// <param name="valore"></param>
|
||||
/// <returns></returns>
|
||||
public static string binaryForm(uint valore)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format(new BinaryUtils(), "{0:B}", valore);
|
||||
return string.Empty;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato, SE NON E' in veto send (x mitigare chiamate...)
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <returns></returns>
|
||||
public static string callUrl(string URL)
|
||||
{
|
||||
string answ = "";
|
||||
// controllo se ho un VETO all'invio...
|
||||
if (dtVetoSend < DateTime.Now)
|
||||
{
|
||||
answ = CallUrlGet(URL);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="payload"></param>
|
||||
/// <returns></returns>
|
||||
public static string callUrl(string URL, string payload)
|
||||
{
|
||||
string answ = "";
|
||||
// controllo se ho un VETO all'invio...
|
||||
if (dtVetoSend < DateTime.Now)
|
||||
{
|
||||
answ = CallUrlPost(URL, payload);
|
||||
}
|
||||
// restituisco valore!
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo chiamata URL con POST async
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="payload"></param>
|
||||
/// <param name="ct"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> callUrlAsync(string URL, string payload, CancellationToken ct = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
// Se hai un payload, probabilmente è una POST
|
||||
var content = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
|
||||
// Qui il thread viene RILASCIATO. La CPU dell'istanza va a 0%
|
||||
// mentre aspetta la risposta dal server.
|
||||
HttpResponseMessage response = await _httpClient.PostAsync(URL, content, ct);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
sw.Stop();
|
||||
TrackUrlCall(URL, sw.Elapsed);
|
||||
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Gestisci la cancellazione (quando chiudi l'app o scade il timeout)
|
||||
return "Canceled";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Gestisci errori di rete
|
||||
return $"Error: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo chiamata URL con GET async
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="ct"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> callUrlAsync(string URL, CancellationToken ct = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
// Qui il thread viene RILASCIATO. La CPU dell'istanza va a 0%
|
||||
// mentre aspetta la risposta dal server.
|
||||
HttpResponseMessage response = await _httpClient.GetAsync(URL, ct);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
sw.Stop();
|
||||
TrackUrlCall(URL, sw.Elapsed);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Gestisci la cancellazione (quando chiudi l'app o scade il timeout)
|
||||
return "Canceled";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Gestisci errori di rete
|
||||
return $"Error: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL IMMEDIATAMENTE e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <returns></returns>
|
||||
public static string CallUrlGet(string URL)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Gestione certificati self-signed
|
||||
HttpClientHandler handler = new HttpClientHandler();
|
||||
if (URL.Contains("10.74.82."))
|
||||
{
|
||||
handler.ServerCertificateCustomValidationCallback =
|
||||
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
||||
}
|
||||
|
||||
using (var client = new HttpClient(handler))
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// Timeout personalizzabile
|
||||
client.Timeout = TimeSpan.FromMilliseconds(5000);
|
||||
|
||||
// Header custom
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(CRS("appName"));
|
||||
|
||||
// GET sincrona
|
||||
var response = client.GetAsync(URL).Result;
|
||||
|
||||
string answ = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
sw.Stop();
|
||||
TrackUrlCall(URL, sw.Elapsed);
|
||||
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
int pauseSendMSec = nextPauseSendMSec;
|
||||
dtVetoSend = DateTime.Now.AddMilliseconds(pauseSendMSec);
|
||||
|
||||
if (logValuePermit(URL))
|
||||
{
|
||||
lg.Error($"CallUrlGet | Errore chiamando {URL} | wait {pauseSendMSec} ms{Environment.NewLine}Eccezione:{Environment.NewLine}{exc}");
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata IMMEDIATAMENTE URL e restituisce risultato
|
||||
/// </summary>
|
||||
/// <param name="URL"></param>
|
||||
/// <param name="payload"></param>
|
||||
/// <returns></returns>
|
||||
public static string CallUrlPost(string URL, string payload)
|
||||
{
|
||||
string answ = "";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
try
|
||||
{
|
||||
// Gestione certificati self-signed
|
||||
HttpClientHandler handler = new HttpClientHandler();
|
||||
if (URL.Contains("10.74."))
|
||||
{
|
||||
handler.ServerCertificateCustomValidationCallback =
|
||||
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
||||
}
|
||||
|
||||
using (var client = new HttpClient(handler))
|
||||
{
|
||||
// Timeout personalizzabile
|
||||
client.Timeout = TimeSpan.FromMilliseconds(5000);
|
||||
|
||||
// Header custom
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd($"{CRS("appName")}-PAYLOAD");
|
||||
|
||||
// Corpo JSON
|
||||
var content = new StringContent(payload, Encoding.UTF8, "application/json");
|
||||
|
||||
// POST sincrono
|
||||
var response = client.PostAsync(URL, content).Result;
|
||||
|
||||
answ = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
// Log identico al tuo
|
||||
if (answ != "OK")
|
||||
{
|
||||
if (logValuePermit($"{URL}|[{answ}]"))
|
||||
{
|
||||
lg.Error($"CallUrlPost | POST fallito | ans: [{answ}]:{Environment.NewLine}- URL{Environment.NewLine}{URL}{Environment.NewLine}- payload{Environment.NewLine}{payload}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
int pauseSendMSec = nextPauseSendMSec;
|
||||
dtVetoSend = DateTime.Now.AddMilliseconds(pauseSendMSec);
|
||||
|
||||
if (logValuePermit(URL))
|
||||
{
|
||||
lg.Error($"CallUrlPost | Errore chiamando {URL} | wait {pauseSendMSec} ms | Dump Payload:{Environment.NewLine}{payload}{Environment.NewLine}Eccezione:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
TrackUrlCall(URL, sw.Elapsed);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -418,157 +177,6 @@ namespace IOB_UT_NEXT
|
||||
return ConfigurationManager.AppSettings[key] ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL tramite RestSharp e restituisce risultato, SE NON E' in veto send (x mitigare chiamate...)
|
||||
/// </summary>
|
||||
/// <param name="url">URI da chiamare</param>
|
||||
/// <param name="fastCall">Chiamata rapida (timeout rapido = 5sec)</param>
|
||||
/// <returns></returns>
|
||||
public static string ExecCallGet(string url, bool fastCall = false)
|
||||
{
|
||||
string answ = "";
|
||||
// divido key tra base e opzionale...
|
||||
Uri uri = new Uri(url);
|
||||
string baseUrl = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
string resource = uri.AbsolutePath;
|
||||
RestClientOptions restOptStd = new RestClientOptions
|
||||
{
|
||||
BaseUrl = new Uri(baseUrl),
|
||||
Timeout = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
if (fastCall)
|
||||
{
|
||||
restOptStd.Timeout = TimeSpan.FromSeconds(5);
|
||||
}
|
||||
try
|
||||
{
|
||||
// client chiamate rest
|
||||
using (var client = new RestClient(restOptStd))
|
||||
{
|
||||
var actReq = new RestRequest(resource, Method.Get);
|
||||
// effettuo vera chiamata
|
||||
var currResp = client.Get(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
{
|
||||
answ = currResp.Content ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error($"Eccezione in callRestUrl{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL tramite RestSharp e restituisce risultato, SE NON E' in veto send (x mitigare chiamate...)
|
||||
/// </summary>
|
||||
/// <param name="url">URI da chiamare</param>
|
||||
/// <param name="payload">Payload da allegare (già serializzato)</param>
|
||||
/// <param name="fastCall">Chiamata rapida (timeout rapido = 5sec)</param>
|
||||
/// <returns></returns>
|
||||
public static string ExecCallPostJson(string url, string payload, bool fastCall = false)
|
||||
{
|
||||
string answ = "";
|
||||
|
||||
// divido key tra base e opzionale...
|
||||
Uri uri = new Uri(url);
|
||||
string baseUrl = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
string resource = uri.AbsolutePath;
|
||||
RestClientOptions restOptStd = new RestClientOptions
|
||||
{
|
||||
BaseUrl = new Uri(baseUrl),
|
||||
Timeout = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
if (fastCall)
|
||||
{
|
||||
restOptStd.Timeout = TimeSpan.FromSeconds(5);
|
||||
}
|
||||
try
|
||||
{
|
||||
// client chiamate rest
|
||||
using (var client = new RestClient(restOptStd))
|
||||
{
|
||||
var actReq = new RestRequest(resource, Method.Post);
|
||||
actReq.AddJsonBody(payload);
|
||||
// effettuo vera chiamata
|
||||
var currResp = client.Post(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
{
|
||||
answ = currResp.Content ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error($"Eccezione in callRestUrlJson{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata URL tramite RestSharp e restituisce risultato, SE NON E' in veto send (x mitigare chiamate...)
|
||||
/// </summary>
|
||||
/// <param name="url">URI da chiamare</param>
|
||||
/// <param name="payload">Payload da allegare (già serializzato)</param>
|
||||
/// <param name="fastCall">Chiamata rapida (timeout rapido = 5sec)</param>
|
||||
/// <returns></returns>
|
||||
public static string ExecCallPostPlain(string url, string payload, bool fastCall = false)
|
||||
{
|
||||
string answ = "";
|
||||
// divido key tra base e opzionale...
|
||||
Uri uri = new Uri(url);
|
||||
string baseUrl = $"{uri.Scheme}://{uri.Host}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}";
|
||||
string resource = uri.AbsolutePath;
|
||||
RestClientOptions restOptStd = new RestClientOptions
|
||||
{
|
||||
BaseUrl = new Uri(baseUrl),
|
||||
Timeout = TimeSpan.FromSeconds(60)
|
||||
};
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
if (fastCall)
|
||||
{
|
||||
restOptStd.Timeout = TimeSpan.FromSeconds(5);
|
||||
}
|
||||
try
|
||||
{
|
||||
// client chiamate rest
|
||||
using (var client = new RestClient(restOptStd))
|
||||
{
|
||||
var actReq = new RestRequest(resource, Method.Post);
|
||||
actReq.AddStringBody(payload, ContentType.Plain);
|
||||
// effettuo vera chiamata
|
||||
var currResp = client.Post(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
{
|
||||
answ = currResp.Content ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error($"Eccezione in callRestUrlJson | rawUrl: {url} {Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
TrackUrlCall(url, sw.Elapsed);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calcolo MD5 del fine indicato
|
||||
/// </summary>
|
||||
@@ -603,62 +211,6 @@ namespace IOB_UT_NEXT
|
||||
return num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IP della macchina
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetIP()
|
||||
{
|
||||
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
||||
String sIpAddr = string.Empty;
|
||||
try
|
||||
{
|
||||
foreach (NetworkInterface adapter in nics)
|
||||
{
|
||||
if (sIpAddr == String.Empty)// only return IP Address from first card
|
||||
{
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
foreach (var item in properties.UnicastAddresses)
|
||||
{
|
||||
if (item.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
||||
{
|
||||
sIpAddr = item.Address.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
// controllo log permesso...
|
||||
if (logValuePermit("GetIP"))
|
||||
{
|
||||
lg.Error(exc);
|
||||
}
|
||||
}
|
||||
return sIpAddr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Macaddress della macchina
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetMACAddress()
|
||||
{
|
||||
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
|
||||
String sMacAddress = string.Empty;
|
||||
foreach (NetworkInterface adapter in nics)
|
||||
{
|
||||
if (sMacAddress == String.Empty)// only return MAC Address from first card
|
||||
{
|
||||
IPInterfaceProperties properties = adapter.GetIPProperties();
|
||||
//sMacAddress = adapter.GetPhysicalAddress().ToString();
|
||||
sMacAddress = string.Join(":", (from z in adapter.GetPhysicalAddress().GetAddressBytes() select z.ToString("X2")).ToArray());
|
||||
}
|
||||
}
|
||||
return sMacAddress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce una stringa di soli caratteri numerici (stripe caratteri alfabetici)
|
||||
/// </summary>
|
||||
@@ -1022,47 +574,23 @@ namespace IOB_UT_NEXT
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
#region Internal Fields
|
||||
|
||||
/// <summary>
|
||||
/// Classe logger
|
||||
/// </summary>
|
||||
protected static Logger lg = LogManager.GetCurrentClassLogger();
|
||||
internal static Logger lg = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Protected Fields
|
||||
#endregion Internal Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Client HTTP statico e riutilizzabile per tutto il ciclo di vita dell'app
|
||||
/// </summary>
|
||||
private static readonly HttpClient _httpClient = new HttpClient();
|
||||
|
||||
/// <summary>
|
||||
/// Ultima ora registrata x statistiche track urlCall
|
||||
/// </summary>
|
||||
private static string LastHourCurr = "";
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dei valori bloccati x evitare log eccessivo
|
||||
/// </summary>
|
||||
private static Dictionary<string, DateTime> vetoLogError = new Dictionary<string, DateTime>();
|
||||
|
||||
/// <summary>
|
||||
/// Periodo di veto log in minuti
|
||||
/// </summary>
|
||||
private static int vetoPeriodMin = 30;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
#region Internal Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se il log di un dato errore sia permesso
|
||||
/// </summary>
|
||||
/// <param name="logKey">ID del valore log da loggare/verificare</param>
|
||||
/// <returns></returns>
|
||||
private static bool logValuePermit(string logKey)
|
||||
internal static bool logValuePermit(string logKey)
|
||||
{
|
||||
bool doLog = false;
|
||||
if (vetoLogError.ContainsKey(logKey))
|
||||
@@ -1088,7 +616,7 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
/// <param name="rawUrl">URL chiamato</param>
|
||||
/// <param name="elapsed">durata chiamata</param>
|
||||
private static void TrackUrlCall(string rawUrl, TimeSpan elapsed)
|
||||
internal static void TrackUrlCall(string rawUrl, TimeSpan elapsed)
|
||||
{
|
||||
// per l'URL tengo solo fino a prima dei parametri (prima di ?)
|
||||
string url = StripQueryAndFragment(rawUrl);
|
||||
@@ -1118,44 +646,25 @@ namespace IOB_UT_NEXT
|
||||
CallMetricsCollector.AddCall(url, elapsed);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
#endregion Internal Methods
|
||||
|
||||
/// <summary>
|
||||
/// Override metodo WebClient con gesitone TimeOut corto
|
||||
/// </summary>
|
||||
public class WebClientWT : WebClient
|
||||
{
|
||||
#region Protected Properties
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// timeout da conf
|
||||
/// Ultima ora registrata x statistiche track urlCall
|
||||
/// </summary>
|
||||
protected int urlCallTOut
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 5000;
|
||||
answ = baseUtils.CRI("urlCallTOut");
|
||||
if (answ < 0 || answ > 10000)
|
||||
{
|
||||
answ = 3000;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
private static string LastHourCurr = "";
|
||||
|
||||
#endregion Protected Properties
|
||||
/// <summary>
|
||||
/// Dizionario dei valori bloccati x evitare log eccessivo
|
||||
/// </summary>
|
||||
private static Dictionary<string, DateTime> vetoLogError = new Dictionary<string, DateTime>();
|
||||
|
||||
#region Protected Methods
|
||||
/// <summary>
|
||||
/// Periodo di veto log in minuti
|
||||
/// </summary>
|
||||
private static int vetoPeriodMin = 30;
|
||||
|
||||
protected override WebRequest GetWebRequest(Uri address)
|
||||
{
|
||||
WebRequest wr = base.GetWebRequest(address);
|
||||
wr.Timeout = urlCallTOut; // timeout in milliseconds (ms)
|
||||
return wr;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -52,16 +52,5 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public Dictionary<string, Dictionary<string, string>> DataDecodMap { get; set; } = new Dictionary<string, Dictionary<string, string>>();
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Base del NameSpace usato per le funzionalità di translate (parametri ACT-SET), da inserire come PRE
|
||||
/// </summary>
|
||||
public string BaseKeyTranslate { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario per la traduzione delle ricette (se gestite) tra valori acquisiti in dossier e impostazioni da inviare (ACTual, SETup)
|
||||
/// </summary>
|
||||
public Dictionary<string, string> RecipeKeyTranslate { get; set; } = new Dictionary<string, string>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using IOB_UT_NEXT.Iob.Services;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@@ -34,4 +34,3 @@ CLI_INST=SteamWareSim
|
||||
STARTLIST=SIMUL_01
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
Generated
+55
-69
@@ -1,35 +1,21 @@
|
||||
namespace IOB_WIN_FORM
|
||||
{
|
||||
partial class AdapterForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
partial class AdapterForm
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdapterForm));
|
||||
this.gather = new System.Windows.Forms.Timer(this.components);
|
||||
@@ -164,7 +150,7 @@
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanel1.ColumnCount = 10;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 24F));
|
||||
@@ -197,8 +183,8 @@
|
||||
//
|
||||
// restart
|
||||
//
|
||||
this.restart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.restart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.restart.BackColor = System.Drawing.Color.Red;
|
||||
this.restart.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -213,8 +199,8 @@
|
||||
//
|
||||
// stop
|
||||
//
|
||||
this.stop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.stop.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.stop.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.stop.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
@@ -240,8 +226,8 @@
|
||||
//
|
||||
// start
|
||||
//
|
||||
this.start.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.start.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.start.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.start.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -256,8 +242,8 @@
|
||||
//
|
||||
// bIN
|
||||
//
|
||||
this.bIN.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.bIN.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.bIN.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.bIN.Location = new System.Drawing.Point(2, 2);
|
||||
@@ -271,8 +257,8 @@
|
||||
//
|
||||
// bOUT
|
||||
//
|
||||
this.bOUT.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.bOUT.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.bOUT.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.bOUT.Location = new System.Drawing.Point(879, 2);
|
||||
@@ -299,8 +285,8 @@
|
||||
//
|
||||
// lblPzCountIob
|
||||
//
|
||||
this.lblPzCountIob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblPzCountIob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblPzCountIob.AutoSize = true;
|
||||
this.lblPzCountIob.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -621,8 +607,8 @@
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel2.AutoScroll = true;
|
||||
this.panel2.Controls.Add(this.lblTaskLog);
|
||||
@@ -889,8 +875,8 @@
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flowLayoutPanel1.Controls.Add(this.lblLogfile);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(6, 22);
|
||||
@@ -924,8 +910,8 @@
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanel2.BackColor = System.Drawing.Color.Black;
|
||||
this.tableLayoutPanel2.ColumnCount = 4;
|
||||
@@ -988,7 +974,7 @@
|
||||
//
|
||||
// lblRawData
|
||||
//
|
||||
this.lblRawData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblRawData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblRawData.AutoSize = true;
|
||||
this.lblRawData.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -1025,7 +1011,7 @@
|
||||
//
|
||||
// lblOutMessage3
|
||||
//
|
||||
this.lblOutMessage3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblOutMessage3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblOutMessage3.AutoSize = true;
|
||||
this.lblOutMessage3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -1039,7 +1025,7 @@
|
||||
//
|
||||
// lblOutMessage2
|
||||
//
|
||||
this.lblOutMessage2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
this.lblOutMessage2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblOutMessage2.AutoSize = true;
|
||||
this.lblOutMessage2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
@@ -1052,8 +1038,8 @@
|
||||
//
|
||||
// tabData
|
||||
//
|
||||
this.tabData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.tabData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tabData.Controls.Add(this.tabRealtime);
|
||||
this.tabData.Controls.Add(this.tabLog);
|
||||
@@ -1111,26 +1097,26 @@
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Timer gather;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblCNC;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblSrvUrl;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Button stop;
|
||||
private System.Windows.Forms.Button start;
|
||||
private System.Windows.Forms.TextBox nLines;
|
||||
private System.Windows.Forms.Button bIN;
|
||||
private System.Windows.Forms.Timer displTimer;
|
||||
private System.Windows.Forms.Button restart;
|
||||
private System.Windows.Forms.CheckBox chkForceDequeue;
|
||||
private System.Windows.Forms.Button bOUT;
|
||||
private System.Windows.Forms.Label lblQueueLenTop;
|
||||
private System.Windows.Forms.Label lblPzCountIob;
|
||||
private System.Windows.Forms.Label lblPzCountMac;
|
||||
private System.Windows.Forms.Timer gather;
|
||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblCNC;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblSrvUrl;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
private System.Windows.Forms.Button stop;
|
||||
private System.Windows.Forms.Button start;
|
||||
private System.Windows.Forms.TextBox nLines;
|
||||
private System.Windows.Forms.Button bIN;
|
||||
private System.Windows.Forms.Timer displTimer;
|
||||
private System.Windows.Forms.Button restart;
|
||||
private System.Windows.Forms.CheckBox chkForceDequeue;
|
||||
private System.Windows.Forms.Button bOUT;
|
||||
private System.Windows.Forms.Label lblQueueLenTop;
|
||||
private System.Windows.Forms.Label lblPzCountIob;
|
||||
private System.Windows.Forms.Label lblPzCountMac;
|
||||
private System.Windows.Forms.TabPage tabMes;
|
||||
private System.Windows.Forms.Button btnForceAutoOdl;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
|
||||
+115
-330
@@ -1,6 +1,7 @@
|
||||
using IOB_UT_NEXT;
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_UT_NEXT.Config.Base;
|
||||
using IOB_UT_NEXT.Iob.Services;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -1326,6 +1327,8 @@ namespace IOB_WIN_FORM
|
||||
/// </summary>
|
||||
private readonly SemaphoreSlim _plcLock = new SemaphoreSlim(1, 1);
|
||||
|
||||
private readonly object _threadLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// Cancellation token x processi verso macchina
|
||||
/// </summary>
|
||||
@@ -1346,27 +1349,21 @@ namespace IOB_WIN_FORM
|
||||
|
||||
private FormWindowState _lastState = FormWindowState.Minimized;
|
||||
|
||||
private Thread _machineThread;
|
||||
private Task _workerTask;
|
||||
|
||||
/// <summary>
|
||||
/// Counter esecuzione WorkerLoopMachine
|
||||
/// </summary>
|
||||
private int idxWLM = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Counter esecuzione WorkerLoopServer
|
||||
/// </summary>
|
||||
private int idxWLS = 0;
|
||||
|
||||
private bool stopForced = false;
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Contatore chiamate timers x debug timing
|
||||
/// </summary>
|
||||
private Dictionary<gatherCycle, int> TimersCycleCount = new Dictionary<gatherCycle, int>();
|
||||
|
||||
/// <summary>
|
||||
/// Contatore durata exec x debug timing
|
||||
/// </summary>
|
||||
private Dictionary<gatherCycle, double> TimersCycleElaps = new Dictionary<gatherCycle, double>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario scadenza timers interni x esecuzione dei vari task a differente frequenza di chiamata
|
||||
/// </summary>
|
||||
private Dictionary<gatherCycle, DateTime> TimersVeto = new Dictionary<gatherCycle, DateTime>();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Obj gestione Timer per esecuzione Task con Machine
|
||||
/// </summary>
|
||||
@@ -1438,7 +1435,6 @@ namespace IOB_WIN_FORM
|
||||
string callKey = iobObj.redisMan.redHash($"IOB:Status:{IOBConfFull.General.FilenameIOB}:CallStats");
|
||||
await CallMetricsCollector.LoadFromRedisAsync(iobObj.redisMan.currDb, callKey);
|
||||
|
||||
|
||||
// Start timer periodico comunicazione
|
||||
gather.Interval = IOBConfFull.General.Timers.MsUI;
|
||||
gather.Enabled = true;
|
||||
@@ -1466,7 +1462,7 @@ namespace IOB_WIN_FORM
|
||||
// salvo nuovo valore invio
|
||||
iobObj.LastSendSet(sendKey, DateTime.Now);
|
||||
// segnalo reboot (programma - url file)...
|
||||
await utils.callUrlAsync(iobObj.urlReboot);
|
||||
await HttpService.CallUrlAsync(iobObj.urlReboot);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1561,64 +1557,6 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica scadenza task nell'oggetto Pool
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task checkScadPoolAsync()
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
bool sendDone = false;
|
||||
// ciclo su tutti i timers enum superiori a VHF
|
||||
var priorities = (gatherCycle[])Enum.GetValues(typeof(gatherCycle));
|
||||
// prendo solo > VHF e ordino discendenti x dare priorità ai più rari...
|
||||
var ordered = priorities.Where(x => x > gatherCycle.VHF).OrderByDescending(x => x);
|
||||
foreach (gatherCycle item in ordered)
|
||||
{
|
||||
if (TimerServer.Veto.ContainsKey(item))
|
||||
{
|
||||
if (TimerServer.Veto[item] <= adesso)
|
||||
{
|
||||
// se non ho già processato a questo giro...
|
||||
if (!sendDone)
|
||||
{
|
||||
TimerServer.CycleCount[item]++;
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
await iobObj.doServerTaskAsync(item);
|
||||
sw.Stop();
|
||||
|
||||
sendDone = true;
|
||||
// metto una piccola attesa se ho altre scadenze
|
||||
TimerServer.CycleElaps[item] += sw.Elapsed.TotalMilliseconds;
|
||||
// metto nuova scadenza perturbata 10%
|
||||
TimerServer.Veto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1));
|
||||
}
|
||||
// log + reset se ho contato ALMENO 100 exec o il tempo totale supera 1000msec
|
||||
int limMs = 10000;
|
||||
double totalMs = TimerServer.CycleElaps.ContainsKey(item) ? TimerServer.CycleElaps[item] : 0;
|
||||
if (TimerServer.CycleCount[item] >= 100 || totalMs > limMs)
|
||||
{
|
||||
int nCount = Math.Max(TimerServer.CycleCount[item], 1);
|
||||
lgDebug($"Timer.{TimerServer.Contesto} | checkScadPoolAsync | {item} | {totalMs / nCount:F1}ms x {nCount}");
|
||||
TimerServer.CycleCount[item] = 0;
|
||||
TimerServer.CycleElaps[item] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TimerServer.Veto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0)));
|
||||
TimerServer.CycleCount.Add(item, 0);
|
||||
if (!TimerServer.CycleElaps.ContainsKey(item))
|
||||
{
|
||||
TimerServer.CycleElaps.Add(item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifica scadenza task Machine
|
||||
/// </summary>
|
||||
@@ -1676,14 +1614,11 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Verifica scadenza task
|
||||
/// Verifica scadenza task nell'oggetto Pool
|
||||
/// </summary>
|
||||
/// <param name="enabPool">Indica se siano abilitate operazioni Pool (Thread Safe)</param>
|
||||
/// <param name="enabSTID">Indica se siano abilitate le operazioni Single Thread</param>
|
||||
/// <returns></returns>
|
||||
private async Task checkScad(bool enabPool, bool enabSTID)
|
||||
private async Task checkScadPoolAsync()
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
bool sendDone = false;
|
||||
@@ -1693,47 +1628,48 @@ namespace IOB_WIN_FORM
|
||||
var ordered = priorities.Where(x => x > gatherCycle.VHF).OrderByDescending(x => x);
|
||||
foreach (gatherCycle item in ordered)
|
||||
{
|
||||
if (TimersVeto.ContainsKey(item))
|
||||
if (TimerServer.Veto.ContainsKey(item))
|
||||
{
|
||||
if (TimersVeto[item] <= adesso)
|
||||
if (TimerServer.Veto[item] <= adesso)
|
||||
{
|
||||
// se non ho già processato a questo giro...
|
||||
if (!sendDone)
|
||||
{
|
||||
TimersCycleCount[item]++;
|
||||
TimerServer.CycleCount[item]++;
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
// chiamata di processing x frequenza
|
||||
await iobObj.getAndSendAsync(item, enabPool, enabSTID);
|
||||
|
||||
await iobObj.doServerTaskAsync(item);
|
||||
sw.Stop();
|
||||
|
||||
sendDone = true;
|
||||
// metto una piccola attesa se ho altre scadenze
|
||||
TimersCycleElaps[item] += sw.Elapsed.TotalMilliseconds;
|
||||
TimerServer.CycleElaps[item] += sw.Elapsed.TotalMilliseconds;
|
||||
// metto nuova scadenza perturbata 10%
|
||||
TimersVeto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1));
|
||||
TimerServer.Veto[item] = adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0.1));
|
||||
}
|
||||
// log + reset se ho contato ALMENO 100 exec o il tempo totale supera 1000msec
|
||||
int limMs = 10000;
|
||||
double totalMs = TimersCycleElaps.ContainsKey(item) ? TimersCycleElaps[item] : 0;
|
||||
if (TimersCycleCount[item] >= 100 || totalMs > limMs)
|
||||
double totalMs = TimerServer.CycleElaps.ContainsKey(item) ? TimerServer.CycleElaps[item] : 0;
|
||||
if (TimerServer.CycleCount[item] >= 100 || totalMs > limMs)
|
||||
{
|
||||
int nCount = Math.Max(TimersCycleCount[item], 1);
|
||||
lgDebug($"checkScad | {item} | {totalMs / nCount:F1}ms x {nCount}");
|
||||
TimersCycleCount[item] = 0;
|
||||
TimersCycleElaps[item] = 0;
|
||||
int nCount = Math.Max(TimerServer.CycleCount[item], 1);
|
||||
lgDebug($"Timer.{TimerServer.Contesto} | checkScadPoolAsync | {item} | {totalMs / nCount:F1}ms x {nCount}");
|
||||
TimerServer.CycleCount[item] = 0;
|
||||
TimerServer.CycleElaps[item] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TimersVeto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0)));
|
||||
TimersCycleCount.Add(item, 0);
|
||||
if (!TimersCycleElaps.ContainsKey(item)) TimersCycleElaps.Add(item, 0);
|
||||
TimerServer.Veto.Add(item, adesso.AddMilliseconds(iobObj.IOBConfFull.TimerMs(item, 0)));
|
||||
TimerServer.CycleCount.Add(item, 0);
|
||||
if (!TimerServer.CycleElaps.ContainsKey(item))
|
||||
{
|
||||
TimerServer.CycleElaps.Add(item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ChkEdit_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
@@ -1763,7 +1699,6 @@ namespace IOB_WIN_FORM
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Metodo principale esecuzione task in thread background (no interferenza con UI) x processi IO bound
|
||||
/// </summary>
|
||||
@@ -1836,7 +1771,6 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Metodo principale esecuzione task in thread background (no interferenza con UI) x processi IO bound
|
||||
/// </summary>
|
||||
@@ -1860,7 +1794,6 @@ namespace IOB_WIN_FORM
|
||||
// verifico non ci sia veto comunicazioni lettura...
|
||||
if (iobObj.queueInEnabCurr)
|
||||
{
|
||||
|
||||
// MAIN: controllo TUTTE le scadenze Server...
|
||||
await checkScadPoolAsync();
|
||||
|
||||
@@ -1876,22 +1809,6 @@ namespace IOB_WIN_FORM
|
||||
iobObj.checkVetoQueueIn();
|
||||
}
|
||||
}
|
||||
#if false
|
||||
else
|
||||
{
|
||||
// qui attende meno...
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2);
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
||||
{
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo($"Retry Time Elapsed ({waitRecMSec / 2} ms)--> tryConnect");
|
||||
}
|
||||
lastStartTry = DateTime.Now;
|
||||
iobObj.tryConnect();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1919,116 +1836,6 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Metodo principale esecuzione task in thread background (no interferenza con UI) x processi IO bound
|
||||
/// </summary>
|
||||
/// <param name="reqSingle">Richiesta esecuzone su single thread (es FANUC)</param>
|
||||
/// <returns></returns>
|
||||
private async Task DoExecTasksAsync(bool reqSingle)
|
||||
{
|
||||
// Attende il proprio turno. Se un task è già in corso, questo aspetta.
|
||||
await _plcLock.WaitAsync();
|
||||
bool doLog = iobObj.periodicLog;
|
||||
try
|
||||
{
|
||||
// imposto variabili x esecuzione separata task Single Thread / Pooled Thread
|
||||
bool reqSTE = iobObj.IOBConfFull.General.MachWLoopSingleThread;
|
||||
bool enabSTID = reqSTE ? reqSingle : true;
|
||||
bool enabPool = !reqSTE;
|
||||
|
||||
if (enabPool)
|
||||
{
|
||||
// check esecuzione SendTask (MsVHF) COMUNQUE...
|
||||
await iobObj.getAndSendAsync(gatherCycle.VHF, enabPool, enabSTID);
|
||||
}
|
||||
// eseguo cicli attivi SOLO se adapter è in EFFETTIVO running...
|
||||
if (iobObj.adpRunning)
|
||||
{
|
||||
if (iobObj.connectionOk)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
// verifico non ci sia veto comunicazioni lettura...
|
||||
if (iobObj.queueInEnabCurr)
|
||||
{
|
||||
if (enabSTID)
|
||||
{
|
||||
// se richiesto faccio memory DUMP INIZIALE!
|
||||
if (iobObj.doStartMemDump)
|
||||
{
|
||||
lgInfo("Inizio dump memoria");
|
||||
iobObj.saveMemDump(dumpType.STARTUP);
|
||||
// fatto! non ripeto...
|
||||
iobObj.doStartMemDump = false;
|
||||
lgInfo("Finito dump memoria");
|
||||
}
|
||||
}
|
||||
if (enabPool)
|
||||
{
|
||||
// controllo se sia abilitato sampleDump della meoria (periodico)
|
||||
if (iobObj.doSampleMemory)
|
||||
{
|
||||
checkSampleMem();
|
||||
}
|
||||
}
|
||||
|
||||
// MAIN: controllo TUTTE le scadenze...
|
||||
await checkScad(enabPool, enabSTID);
|
||||
|
||||
// wait opzionale in coda
|
||||
if (utils.CRI("waitEndCycle") > 0)
|
||||
{
|
||||
await Task.Delay(utils.CRI("waitEndCycle"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"VETO queueInEnabCurr | veto attivo | {adesso:yyyy.MM.dd HH:mm:ss}");
|
||||
iobObj.checkVetoQueueIn();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// qui attende meno...
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2);
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
||||
{
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo($"Retry Time Elapsed ({waitRecMSec / 2} ms)--> tryConnect");
|
||||
}
|
||||
lastStartTry = DateTime.Now;
|
||||
iobObj.tryConnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doLog)
|
||||
{
|
||||
lgInfo("Adapter stopped");
|
||||
}
|
||||
// verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart
|
||||
// e non ho riprovato x oltre waitRecMSec
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec);
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
||||
{
|
||||
lastStartTry = DateTime.Now;
|
||||
AvviaAdapter(chkForceDequeue.Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError($"Eccezione in fase di DoExecTasksAsync: {Environment.NewLine}{exc}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_plcLock.Release();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Ferma tutti i componenti adapter + update buttons
|
||||
/// </summary>
|
||||
@@ -2465,16 +2272,16 @@ namespace IOB_WIN_FORM
|
||||
if (utils.CRB("ConfToCloud"))
|
||||
{
|
||||
// invio su cloud...
|
||||
answ = await utils.callUrlAsync($"{urlUploadFileCloud}{CurrIOB}", rawData);
|
||||
answ = await HttpService.CallUrlAsync($"{urlUploadFileCloud}{CurrIOB}", rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// provo invio locale
|
||||
answ = utils.callUrl($"{urlUploadFile}{CurrIOB}", rawData);
|
||||
answ = HttpService.CallUrl($"{urlUploadFile}{CurrIOB}", rawData);
|
||||
// se va male invio cloud...
|
||||
if (answ.ToUpper() != "OK")
|
||||
{
|
||||
answ = await utils.callUrlAsync($"{urlUploadFileCloud}{CurrIOB}", rawData);
|
||||
answ = await HttpService.CallUrlAsync($"{urlUploadFileCloud}{CurrIOB}", rawData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2527,7 +2334,6 @@ namespace IOB_WIN_FORM
|
||||
/// </summary>
|
||||
private void StartWorker()
|
||||
{
|
||||
|
||||
//// FixMe ToDo !!! togliere o fare alternativa pooled
|
||||
//if (iobObj.IOBConfFull.General.MachWLoopSingleThread || true)
|
||||
//{
|
||||
@@ -2577,19 +2383,8 @@ namespace IOB_WIN_FORM
|
||||
_workerTask = Task.Run(() => WorkerLoopAsync(_ctsServer.Token));
|
||||
lgInfo("--- WORKER SERVER AVVIATO ---");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Thread _machineThread;
|
||||
private readonly object _threadLock = new object();
|
||||
|
||||
|
||||
#if false
|
||||
private BlockingCollection<Action> _workQueue = new BlockingCollection<Action>();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// fermata dell'adapter
|
||||
/// </summary>
|
||||
@@ -2656,13 +2451,81 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counter esecuzione WorkerLoopMachine
|
||||
/// Loop di gestione worker
|
||||
/// </summary>
|
||||
private int idxWLM = 0;
|
||||
/// <summary>
|
||||
/// Counter esecuzione WorkerLoopServer
|
||||
/// </summary>
|
||||
private int idxWLS = 0;
|
||||
/// <param name="ct"></param>
|
||||
/// <returns></returns>
|
||||
private async Task WorkerLoopAsync(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] Inizio WorkerLoopAsync");
|
||||
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
// incremento indice x mostrare esecuzione...
|
||||
idxWLS++;
|
||||
idxWLS = idxWLS > 999 ? 0 : idxWLS;
|
||||
//lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync");
|
||||
if (!_isSuspended)
|
||||
{
|
||||
try
|
||||
{
|
||||
await DoExecServerTasksAsync(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] Errore durante i task: " + ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync suspended");
|
||||
// se non fosse stop richiesto da utente...
|
||||
if (!stopForced)
|
||||
{
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2);
|
||||
// verifica scadenza controllo SE fosse offline x eseguire test riconnessione...
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto) && iobObj.adpRunning && !iobObj.connectionOk)
|
||||
{
|
||||
lgTrace($"WorkerLoopAsync sospeso: tentativo riavvio periodico");
|
||||
lastStartTry = DateTime.Now;
|
||||
iobObj.tryConnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"WorkerLoopAsync sospeso: NON esegue task specifici | _isSuspended: {_isSuspended}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calcolo del delay dinamico tra standard e suspended da Timers.MsVHF
|
||||
int currentDelay = _isSuspended ? 10 * IOBConfFull.General.Timers.MsVHF : IOBConfFull.General.Timers.MsVHF;
|
||||
|
||||
// se ho error delay --> log!
|
||||
if (_errorDelay > 0)
|
||||
{
|
||||
currentDelay += _errorDelay;
|
||||
lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync | delay: {currentDelay}");
|
||||
}
|
||||
|
||||
// 4. ATTESA INTERROMPIBILE
|
||||
// Il delay asincrono permette al sistema di riutilizzare il thread se necessario,
|
||||
// ma il 'while' garantisce che non inizieremo il prossimo DoExecTasksAsync prematuramente.
|
||||
//await Task.Delay(currentDelay, ct).ConfigureAwait(false);
|
||||
await Task.Delay(currentDelay, ct);
|
||||
|
||||
// Logga l'ID Thread
|
||||
//lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync | End");
|
||||
}
|
||||
lgInfo("WorkerLoopAsync interrotto per cancellation token.");
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Eccezione normale quando si preme Stop/Cancel
|
||||
lgInfo("WorkerLoopAsync interrotto correttamente.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loop di gestione worker comunicazione con la macchina (single threaded)
|
||||
@@ -2745,84 +2608,6 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loop di gestione worker
|
||||
/// </summary>
|
||||
/// <param name="ct"></param>
|
||||
/// <returns></returns>
|
||||
private async Task WorkerLoopAsync(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] Inizio WorkerLoopAsync");
|
||||
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
// incremento indice x mostrare esecuzione...
|
||||
idxWLS++;
|
||||
idxWLS = idxWLS > 999 ? 0 : idxWLS;
|
||||
//lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync");
|
||||
if (!_isSuspended)
|
||||
{
|
||||
try
|
||||
{
|
||||
await DoExecServerTasksAsync(false);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] Errore durante i task: " + ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync suspended");
|
||||
// se non fosse stop richiesto da utente...
|
||||
if (!stopForced)
|
||||
{
|
||||
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec / 2);
|
||||
// verifica scadenza controllo SE fosse offline x eseguire test riconnessione...
|
||||
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto) && iobObj.adpRunning && !iobObj.connectionOk)
|
||||
{
|
||||
lgTrace($"WorkerLoopAsync sospeso: tentativo riavvio periodico");
|
||||
lastStartTry = DateTime.Now;
|
||||
iobObj.tryConnect();
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"WorkerLoopAsync sospeso: NON esegue task specifici | _isSuspended: {_isSuspended}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calcolo del delay dinamico tra standard e suspended da Timers.MsVHF
|
||||
int currentDelay = _isSuspended ? 10 * IOBConfFull.General.Timers.MsVHF : IOBConfFull.General.Timers.MsVHF;
|
||||
|
||||
// se ho error delay --> log!
|
||||
if (_errorDelay > 0)
|
||||
{
|
||||
currentDelay += _errorDelay;
|
||||
lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync | delay: {currentDelay}");
|
||||
}
|
||||
|
||||
// 4. ATTESA INTERROMPIBILE
|
||||
// Il delay asincrono permette al sistema di riutilizzare il thread se necessario,
|
||||
// ma il 'while' garantisce che non inizieremo il prossimo DoExecTasksAsync prematuramente.
|
||||
//await Task.Delay(currentDelay, ct).ConfigureAwait(false);
|
||||
await Task.Delay(currentDelay, ct);
|
||||
|
||||
// Logga l'ID Thread
|
||||
//lgTrace($"[Thread: {Thread.CurrentThread.ManagedThreadId} ({idxWLS})] WorkerLoopAsync | End");
|
||||
}
|
||||
lgInfo("WorkerLoopAsync interrotto per cancellation token.");
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Eccezione normale quando si preme Stop/Cancel
|
||||
lgInfo("WorkerLoopAsync interrotto correttamente.");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -133,8 +133,6 @@
|
||||
<Compile Include="Iob\BaseObj.cs" />
|
||||
<Compile Include="Iob\Generic.cs" />
|
||||
<Compile Include="Iob\PingWatchDog.cs" />
|
||||
<Compile Include="Iob\Services\DataSerializer.cs" />
|
||||
<Compile Include="Iob\Services\XmlDataSerializer.cs" />
|
||||
<Compile Include="Iob\Simula.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
||||
+60
-60
@@ -1,7 +1,7 @@
|
||||
using EgwProxy.Ftp;
|
||||
using IOB_UT_NEXT;
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_WIN_FORM.Iob.Services;
|
||||
using IOB_UT_NEXT.Iob.Services;
|
||||
using MapoSDK;
|
||||
using MathNet.Numerics.Statistics;
|
||||
using Newtonsoft.Json;
|
||||
@@ -1426,7 +1426,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (!isMulti)
|
||||
{
|
||||
// invio chiamata URL x reset ODL su macchina
|
||||
rawSplit = await utils.callUrlAsync(urlForceSplit);
|
||||
rawSplit = await HttpService.CallUrlAsync(urlForceSplit);
|
||||
fatto = (rawSplit != "KO") ? true : false;
|
||||
}
|
||||
// se multi gestisco il bit delle tavole...
|
||||
@@ -1437,7 +1437,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// invio chiamata URL x reset ODL su macchina, ATTENZIONE scriviamo
|
||||
// | al posto di "#" che in URL sarebbe filtrato...
|
||||
fullUrl = $"{urlForceSplit}&multi={item}";
|
||||
rawSplit = await utils.callUrlAsync(fullUrl);
|
||||
rawSplit = await HttpService.CallUrlAsync(fullUrl);
|
||||
lgDebug($"Esecuzione forceSplit | URL: {fullUrl} | esito: {rawSplit}");
|
||||
}
|
||||
fatto = (rawSplit == "OK") ? true : false;
|
||||
@@ -2063,7 +2063,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
|
||||
lgTrace("AutoSnapshotDossier abilitato");
|
||||
// chiamo stored x creare Snapshot Dossier giornalieri fino alla data...
|
||||
callResp = utils.callUrl(urlFixDailyDossier);
|
||||
callResp = HttpService.CallUrl(urlFixDailyDossier);
|
||||
fatto = callResp == "OK";
|
||||
lgDebug($"Esecuzione ProcessAutoDossier completata --> esito: {callResp}");
|
||||
}
|
||||
@@ -2143,7 +2143,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (dtStart.Date < adesso.Date)
|
||||
{
|
||||
// chiamo stored x creare ODL giornalieri alla data...
|
||||
string autoOdlRes = utils.callUrl(urlFixDailyOdl);
|
||||
string autoOdlRes = HttpService.CallUrl(urlFixDailyOdl);
|
||||
fatto = autoOdlRes == "OK";
|
||||
// imposto x prox controllo veto a 10 min
|
||||
VetoProcessAutoOdl = adesso.AddMinutes(10);
|
||||
@@ -2165,7 +2165,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (!isMulti)
|
||||
{
|
||||
// chiamo stored x creare ODL giornalieri alla data + conferma pezzi...
|
||||
autoOdlRes = utils.callUrl(urlFixDailyOdlConfPzCount);
|
||||
autoOdlRes = HttpService.CallUrl(urlFixDailyOdlConfPzCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2173,7 +2173,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var item in IOBConfFull.Device.MultiIobList)
|
||||
{
|
||||
fullUrl = $@"{urlCommand("fixDailyOdlConfPzCount")}{item}";
|
||||
autoOdlRes = await utils.callUrlAsync(fullUrl);
|
||||
autoOdlRes = await HttpService.CallUrlAsync(fullUrl);
|
||||
}
|
||||
}
|
||||
fatto = autoOdlRes == "OK";
|
||||
@@ -2197,7 +2197,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
rawDataInizio = "";
|
||||
if (!isMulti)
|
||||
{
|
||||
rawDataInizio = await utils.callUrlAsync(urlInizioOdlIob);
|
||||
rawDataInizio = await HttpService.CallUrlAsync(urlInizioOdlIob);
|
||||
DateTime.TryParse(rawDataInizio, out inizioOdl);
|
||||
}
|
||||
else
|
||||
@@ -2207,7 +2207,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var item in IOBConfFull.Device.MultiIobList)
|
||||
{
|
||||
fullUrl = $"{urlInizioOdlIob}|{item}";
|
||||
rawDataInizio = await utils.callUrlAsync(fullUrl);
|
||||
rawDataInizio = await HttpService.CallUrlAsync(fullUrl);
|
||||
DateTime.TryParse(rawDataInizio, out tmpData);
|
||||
inizioOdl = (tmpData < inizioOdl) ? tmpData : inizioOdl;
|
||||
}
|
||||
@@ -2221,7 +2221,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
// controllo SE sono fermo (spento o in manuale) per il
|
||||
// periodo minimo richiesto...
|
||||
rawIdle = await utils.callUrlAsync(urlIdleTime);
|
||||
rawIdle = await HttpService.CallUrlAsync(urlIdleTime);
|
||||
int.TryParse(rawIdle, out idlePeriod);
|
||||
}
|
||||
else
|
||||
@@ -2231,7 +2231,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
foreach (var item in IOBConfFull.Device.MultiIobList)
|
||||
{
|
||||
fullUrl = $"{urlIdleTime}|{item}";
|
||||
rawIdle = await utils.callUrlAsync(fullUrl);
|
||||
rawIdle = await HttpService.CallUrlAsync(fullUrl);
|
||||
int.TryParse(rawIdle, out tmpIdle);
|
||||
idlePeriod = tmpIdle > idlePeriod ? tmpIdle : idlePeriod;
|
||||
}
|
||||
@@ -2246,7 +2246,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// fare, se sfora (RANDOM) > +(50...110)% --> cambia!
|
||||
if (!callChangeODL && IOBConfFull.Odl.ChangeOdlMode == "SIMUL")
|
||||
{
|
||||
var rawCount = await utils.callUrlAsync(urlGetNumPzCurrODL);
|
||||
var rawCount = await HttpService.CallUrlAsync(urlGetNumPzCurrODL);
|
||||
if (int.TryParse(rawCount, out var numPzReqOdl))
|
||||
{
|
||||
int limitQty = (numPzReqOdl * rndGen.Next(150, 210)) / 100;
|
||||
@@ -2756,21 +2756,21 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
// leggo PRIMA ODL ....
|
||||
calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetCurrODL : urlGetCurrODL.Replace(IOBConfFull.General.CodIOB, forceMach);
|
||||
lastIdxODL = utils.callUrl(calcUrl);
|
||||
lastIdxODL = HttpService.CallUrl(calcUrl);
|
||||
lgTrace($"Lettura ODL dall'url {calcUrl} --> {lastIdxODL}");
|
||||
// se ho valori in coda da trasmettere uso dati REDIS
|
||||
if (forceCountRec)
|
||||
{
|
||||
// uso dati da TCiclo registrati...
|
||||
calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetPzCountRec : urlGetPzCountRec.Replace(IOBConfFull.General.CodIOB, forceMach);
|
||||
currServerCount = utils.callUrl(calcUrl);
|
||||
currServerCount = HttpService.CallUrl(calcUrl);
|
||||
lgInfo($"Lettura contapezzi da TCiclo registrati dall'url {calcUrl} --> num pz: {currServerCount}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// uso il contapezzi dichiarato dall'IOB stesso
|
||||
calcUrl = string.IsNullOrEmpty(forceMach) ? urlGetPzCount : urlGetPzCount.Replace(IOBConfFull.General.CodIOB, forceMach);
|
||||
currServerCount = utils.callUrl(calcUrl);
|
||||
currServerCount = HttpService.CallUrl(calcUrl);
|
||||
lgInfo($"Lettura contapezzi dall'url {calcUrl} --> {currServerCount}");
|
||||
}
|
||||
// controllo: SE NON HO ODL...
|
||||
@@ -3213,8 +3213,8 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
|
||||
string rawData = JsonConvert.SerializeObject(ActiveAlarmList);
|
||||
string resp = utils.CallUrlPost(lastUrl, rawData);
|
||||
//string resp = utils.callUrlAsync(lastUrl, rawData);
|
||||
string resp = HttpService.CallUrlPost(lastUrl, rawData);
|
||||
//string resp = HttpService.CallUrlAsync(lastUrl, rawData);
|
||||
if (resp != null)
|
||||
{
|
||||
if (resp.ToUpper() == "OK")
|
||||
@@ -3258,7 +3258,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (await CheckServerAliveAsync())
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = await utils.callUrlAsync(lastUrl, payload);
|
||||
string answ = await HttpService.CallUrlAsync(lastUrl, payload);
|
||||
|
||||
// loggo!
|
||||
lgInfo($"[SEND payload] TipoURL: {tipoUrl} | {listQueueVal.Count} records --> {answ}");
|
||||
@@ -3346,7 +3346,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
if (await CheckServerAliveAsync())
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = await utils.callUrlAsync(lastUrl);
|
||||
string answ = await HttpService.CallUrlAsync(lastUrl);
|
||||
// loggo!
|
||||
lgDebug(string.Format("[SEND] {0} -> {1}", queueVal, answ));
|
||||
// se oltre 1 min NON era online --> check pezzi!
|
||||
@@ -3870,7 +3870,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
await Task.Delay(rand.Next(150, 500));
|
||||
}
|
||||
|
||||
string resp = await utils.callUrlAsync(urlAlive);
|
||||
string resp = await HttpService.CallUrlAsync(urlAlive);
|
||||
if (resp == "OK") return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -5252,7 +5252,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// vieto controllo prima di 5 sec... da configurare?
|
||||
if (DateTime.Now.Subtract(vetoCheckOdl).TotalSeconds > IOBConfFull.Odl.VetoCheckOdlSec)
|
||||
{
|
||||
string sCurrODL = utils.CallUrlGet(urlGetCurrODL);
|
||||
string sCurrODL = HttpService.CallUrlGet(urlGetCurrODL);
|
||||
int.TryParse(sCurrODL, out cODL);
|
||||
currIdxODL = cODL;
|
||||
vetoCheckOdl = DateTime.Now;
|
||||
@@ -5594,7 +5594,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
lgInfo("chiamata URL " + url2call);
|
||||
}
|
||||
var rawData = utils.CallUrlGet(url2call);
|
||||
var rawData = HttpService.CallUrlGet(url2call);
|
||||
// deserializzo e recupero KVP...
|
||||
var dictArtSrv = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
|
||||
// se fosse una chiamata con valore vuoto --> salvo intera tabella...
|
||||
@@ -5641,7 +5641,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgInfo("chiamata URL " + url2call);
|
||||
}
|
||||
// è direttamente il risultato!
|
||||
answ = utils.CallUrlGet(url2call);
|
||||
answ = HttpService.CallUrlGet(url2call);
|
||||
}
|
||||
// restituisco
|
||||
return answ;
|
||||
@@ -5659,11 +5659,11 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
lgInfo("chiamata URL " + url2call);
|
||||
}
|
||||
answ = utils.CallUrlGet(url2call);
|
||||
answ = HttpService.CallUrlGet(url2call);
|
||||
// se vuoto faccio seconda prova...
|
||||
if (string.IsNullOrEmpty(answ) || answ == "[]")
|
||||
{
|
||||
answ = utils.CallUrlGet(url2call);
|
||||
answ = HttpService.CallUrlGet(url2call);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -5704,7 +5704,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
lgInfo("chiamata URL " + url2call);
|
||||
}
|
||||
answ = await utils.callUrlAsync(url2call);
|
||||
answ = await HttpService.CallUrlAsync(url2call);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -6182,7 +6182,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
var rawListPODL = await HttpService.CallUrlAsync(urlGetNextPODL);
|
||||
if (!string.IsNullOrEmpty(rawListPODL))
|
||||
{
|
||||
reqPOdlList = JsonConvert.DeserializeObject<List<PODLModel>>(rawListPODL) ?? new List<PODLModel>();
|
||||
@@ -6324,7 +6324,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
DateTime dataDoc = DateTime.Today;
|
||||
DateTime.TryParse(fileName, out dataDoc);
|
||||
// cerco lotto x giornata...
|
||||
string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
|
||||
string sIdxODL = HttpService.CallUrl(urlGetOdlAtDate(dataDoc));
|
||||
int.TryParse(sIdxODL, out idxODL);
|
||||
// chiamo conversione
|
||||
TimeSpan timeElaps = fpm.doProcess(fileItem, idxODL);
|
||||
@@ -6435,7 +6435,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
plcWriteParams(ref updatedPar);
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonConvert.SerializeObject(updatedPar);
|
||||
utils.callUrl($"{urlUpdateWriteParams}", rawData);
|
||||
HttpService.CallUrl($"{urlUpdateWriteParams}", rawData);
|
||||
lgInfo($"Notifica a server scrittura {updatedPar.Count} parametri");
|
||||
}
|
||||
}
|
||||
@@ -6726,7 +6726,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// invio ANCHE in MP-IO l'update delle info...
|
||||
string remUrl = urlSetHashDict;
|
||||
string dictPayload = JsonConvert.SerializeObject(redHashWeek);
|
||||
await utils.callUrlAsync(remUrl, dictPayload);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6986,7 +6986,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
var rawListPODL = await HttpService.CallUrlAsync(urlGetNextPODL);
|
||||
if (!string.IsNullOrEmpty(rawListPODL))
|
||||
{
|
||||
try
|
||||
@@ -7128,7 +7128,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
url2call = $"{urlRemTask2ExeTav(codTav)}{taskName}";
|
||||
}
|
||||
|
||||
await utils.callUrlAsync(url2call);
|
||||
await HttpService.CallUrlAsync(url2call);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -7179,7 +7179,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
bool answ = false;
|
||||
DateTime dtCurr = DateTime.Now;
|
||||
string resp = await utils.callUrlAsync($"{urlODLClose}{idxOdl}&dtEve={dtRif}&dtCurr={dtCurr}");
|
||||
string resp = await HttpService.CallUrlAsync($"{urlODLClose}{idxOdl}&dtEve={dtRif}&dtCurr={dtCurr}");
|
||||
answ = resp == "OK";
|
||||
return answ;
|
||||
}
|
||||
@@ -7200,7 +7200,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
answ = callResp == "OK";
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -7277,7 +7277,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// salvo nuovo valore invio
|
||||
LastSendSet(sendKey, DateTime.Now);
|
||||
// procedo
|
||||
var result = await utils.callUrlAsync(urlSetM2IOB);
|
||||
var result = await HttpService.CallUrlAsync(urlSetM2IOB);
|
||||
lgInfo($"chiamata URL {urlSetM2IOB} | result: {result}");
|
||||
}
|
||||
}
|
||||
@@ -7351,7 +7351,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// invio e salvo...
|
||||
string remUrl = urlSaveMachIobConf;
|
||||
string dictPayload = JsonConvert.SerializeObject(currDict);
|
||||
await utils.callUrlAsync(remUrl, dictPayload);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
lgTrace("Invio MachineConf effettuato");
|
||||
}
|
||||
}
|
||||
@@ -7377,7 +7377,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
string url2call = $"{urlSetOptVal}pName={paramName}&pValue={paramValue}";
|
||||
lgInfo("chiamata URL " + url2call);
|
||||
await utils.callUrlAsync(url2call);
|
||||
await HttpService.CallUrlAsync(url2call);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7410,7 +7410,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
answ = callResp == "OK";
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -7440,7 +7440,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
answ = callResp == "OK";
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -7606,7 +7606,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// se abilitato faccio invio e salvo nuovo valore
|
||||
if (sendEnab)
|
||||
{
|
||||
var resp = utils.callUrl($"{urlSaveMemMap}", rawData);
|
||||
var resp = HttpService.CallUrl($"{urlSaveMemMap}", rawData);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -7681,7 +7681,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// versione upsert
|
||||
tipoCall = urlUpdateWriteParams;
|
||||
}
|
||||
var resp = utils.callUrl($"{tipoCall}", rawData);
|
||||
var resp = HttpService.CallUrl($"{tipoCall}", rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -7993,7 +7993,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8037,7 +8037,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8083,7 +8083,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8107,7 +8107,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8139,7 +8139,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// invio chiamata URL x chiusura ODL su macchina
|
||||
string callResp = await utils.callUrlAsync(fullUrl);
|
||||
string callResp = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (callResp != "KO") ? true : false;
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8168,7 +8168,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
string resp = await utils.callUrlAsync(urlEncoded);
|
||||
string resp = await HttpService.CallUrlAsync(urlEncoded);
|
||||
int.TryParse(resp, out answ);
|
||||
})
|
||||
.GetAwaiter()
|
||||
@@ -8214,7 +8214,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
numIncr = delta > maxSendPzCountBlock + minSendPzCountBlock ? maxSendPzCountBlock : delta - minSendPzCountBlock;
|
||||
// invio il num max di pezzi ammesso in blocco!
|
||||
lastUrl = $"{urlAddPzCount}{numIncr}".Replace(IOBConfFull.General.CodIOB, fullCode);
|
||||
string resp = utils.CallUrlGet(lastUrl);
|
||||
string resp = HttpService.CallUrlGet(lastUrl);
|
||||
if (!string.IsNullOrEmpty(resp))
|
||||
{
|
||||
// dalla risposta (come numero) capisco SE ha aggiunto i pezzi (e quanti)
|
||||
@@ -8226,7 +8226,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgInfo($"SEND incremento contapezzi: send: {numIncr} | resp: {qtyAdded} | contapezziMES: {pzCountMes}");
|
||||
// invio conferma contapezzi..
|
||||
string fullUrl = $"{urlSetPzCount}{pzCountMes}".Replace(IOBConfFull.General.CodIOB, fullCode);
|
||||
string retVal = utils.callUrl(fullUrl);
|
||||
string retVal = HttpService.CallUrl(fullUrl);
|
||||
// verifica se tutto OK
|
||||
if (retVal != $"{pzCountMes}")
|
||||
{
|
||||
@@ -8288,7 +8288,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
numIncr = delta > maxSendPzCountBlock + minSendPzCountBlock ? maxSendPzCountBlock : delta - minSendPzCountBlock;
|
||||
// invio il num max di pezzi ammesso in blocco!
|
||||
lastUrl = $"{urlAddPzCount}{numIncr}";
|
||||
string resp = utils.CallUrlGet(lastUrl);
|
||||
string resp = HttpService.CallUrlGet(lastUrl);
|
||||
if (!string.IsNullOrEmpty(resp))
|
||||
{
|
||||
// dalla risposta (come numero) capisco SE ha aggiunto i pezzi (e quanti)
|
||||
@@ -8300,7 +8300,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
lgInfo($"SEND incremento contapezzi: send: {numIncr} | resp: {qtyAdded} | contapezziIOB: {contapezziIOB}");
|
||||
// invio conferma contapezzi..
|
||||
string fullUrl = $"{urlSetPzCount}{contapezziIOB}";
|
||||
string retVal = utils.callUrl(fullUrl);
|
||||
string retVal = HttpService.CallUrl(fullUrl);
|
||||
// verifica se tutto OK
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
@@ -8434,7 +8434,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x avvio PODL su macchina
|
||||
string rawSplit = await utils.callUrlAsync(fullUrl);
|
||||
string rawSplit = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (rawSplit != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8459,7 +8459,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
try
|
||||
{
|
||||
// invio chiamata URL x avvio PODL su macchina
|
||||
string rawSplit = await utils.callUrlAsync(fullUrl);
|
||||
string rawSplit = await HttpService.CallUrlAsync(fullUrl);
|
||||
fatto = (rawSplit != "KO") ? true : false;
|
||||
}
|
||||
catch
|
||||
@@ -8760,7 +8760,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
private async Task<DateTime> currOdlStart()
|
||||
{
|
||||
DateTime inizioOdl = DateTime.Now;
|
||||
string rawDataInizio = await utils.callUrlAsync(urlInizioOdlIob);
|
||||
string rawDataInizio = await HttpService.CallUrlAsync(urlInizioOdlIob);
|
||||
DateTime.TryParse(rawDataInizio, out inizioOdl);
|
||||
return inizioOdl;
|
||||
}
|
||||
@@ -8900,7 +8900,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
await Task.Delay(delay);
|
||||
}
|
||||
|
||||
string callResp = await utils.callUrlAsync(urlIobEnabled);
|
||||
string callResp = await HttpService.CallUrlAsync(urlIobEnabled);
|
||||
if (callResp == "OK") return true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
@@ -9208,7 +9208,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
plcWriteParams(ref updatedPar);
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonConvert.SerializeObject(updatedPar);
|
||||
utils.CallUrlPost($"{urlUpdateWriteParams}", rawData);
|
||||
HttpService.CallUrlPost($"{urlUpdateWriteParams}", rawData);
|
||||
lgInfo($"Notificato a server scrittura {updatedPar.Count} parametri");
|
||||
}
|
||||
else
|
||||
@@ -9218,7 +9218,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
// invio su cloud parametri!
|
||||
string rawData = JsonConvert.SerializeObject(currWritePar);
|
||||
var res = utils.CallUrlPost($"{urlUpdateWriteParams}", rawData);
|
||||
var res = HttpService.CallUrlPost($"{urlUpdateWriteParams}", rawData);
|
||||
lgInfo($"Reinviato a server stato {updatedPar.Count} parametri WRITE");
|
||||
lastWriteParamsUpsert = adesso;
|
||||
}
|
||||
@@ -9473,12 +9473,12 @@ namespace IOB_WIN_FORM.Iob
|
||||
// prova ad avviare/chiudere PODL relativo (eventualmente duplicandolo)
|
||||
dtEve = $"{dtStartPOdl:yyyyMMddHHmmssfff}";
|
||||
dtCurr = $"{DateTime.Now:yyyyMMddHHmmssfff}";
|
||||
await utils.callUrlAsync($"{urlOdlStartFromPOdl}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}");
|
||||
await HttpService.CallUrlAsync($"{urlOdlStartFromPOdl}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}");
|
||||
|
||||
// ora chiamo chiusura...
|
||||
dtEve = $"{dtEndPOdl:yyyyMMddHHmmssfff}";
|
||||
dtCurr = $"{DateTime.Now:yyyyMMddHHmmssfff}";
|
||||
await utils.callUrlAsync($"{urlPODLClose}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}");
|
||||
await HttpService.CallUrlAsync($"{urlPODLClose}{idxPOdl}&dtEve={dtEve}&dtCurr={dtCurr}");
|
||||
})
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
@@ -9506,7 +9506,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
// invio ANCHE in MP-IO l'update delle info...
|
||||
string remUrl = urlSetHashDict;
|
||||
string dictPayload = JsonConvert.SerializeObject(currDict);
|
||||
await utils.callUrlAsync(remUrl, dictPayload);
|
||||
await HttpService.CallUrlAsync(remUrl, dictPayload);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, true);
|
||||
//await callUrlWithPayloadAsync(remUrl, dictPayload, false);
|
||||
}
|
||||
|
||||
+14
-17
@@ -1,5 +1,6 @@
|
||||
using IOB_UT_NEXT;
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_UT_NEXT.Iob.Services;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
@@ -737,10 +738,6 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
case urlType.ULog:
|
||||
string[] elencoMulti = null;
|
||||
#if false
|
||||
// devo chiamare cambio ODL x OGNI tavola: mi servono i parametri opzionali...
|
||||
elencoMulti = IOBConfFull.Device.MultiIobListRaw.Split(',');
|
||||
#endif
|
||||
elencoMulti = IOBConfFull.Device.MultiIobList.ToArray();
|
||||
// aggiungo tav 1 / 2 a caso secondo secondi attuali, se pari/dispari
|
||||
int idxTav = DateTime.Now.Second % 2;
|
||||
@@ -1049,7 +1046,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
DateTime adesso = DateTime.Now;
|
||||
// faccio cmq tutto...
|
||||
|
||||
string autoOdlRes = utils.callUrl(urlFixDailyOdl);
|
||||
string autoOdlRes = HttpService.CallUrl(urlFixDailyOdl);
|
||||
|
||||
// salvo lettura
|
||||
lastReadPLC = adesso;
|
||||
@@ -1271,7 +1268,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
fullUrl = $"{urlSetPzCount.Replace(IOBConfFull.General.CodIOB, $"{IOBConfFull.General.CodIOB}|TAV_{nP}")}{contapezziPLC}";
|
||||
}
|
||||
string retVal = utils.callUrl(fullUrl);
|
||||
string retVal = HttpService.CallUrl(fullUrl);
|
||||
// verifica salvataggio
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
@@ -1283,7 +1280,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
}
|
||||
else
|
||||
{
|
||||
string retVal = utils.callUrl($"{urlSetPzCount}{contapezziIOB}");
|
||||
string retVal = HttpService.CallUrl($"{urlSetPzCount}{contapezziIOB}");
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
@@ -1446,7 +1443,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
{
|
||||
fullUrl = $"{urlSetPzCount.Replace(IOBConfFull.General.CodIOB, $"{IOBConfFull.General.CodIOB}|TAV_{nP}")}{contapezziIOB}";
|
||||
}
|
||||
string retVal = utils.callUrl(fullUrl);
|
||||
string retVal = HttpService.CallUrl(fullUrl);
|
||||
// verifica se tutto OK
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
@@ -1500,7 +1497,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
contapezziPLC++;
|
||||
// invio contapezzi...
|
||||
string fullUrl = $"{urlSetPzCount.Replace(IOBConfFull.General.CodIOB, $"{IOBConfFull.General.CodIOB}|TAV_{nP}")}{contapezziIOB}";
|
||||
string retVal = utils.callUrl(fullUrl);
|
||||
string retVal = HttpService.CallUrl(fullUrl);
|
||||
}
|
||||
// se cP > 0 --> segnalo bit tavola...
|
||||
if (cP == 1)
|
||||
@@ -1603,10 +1600,10 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListArt = await utils.callUrlAsync(urlGetCurrArt);
|
||||
var rawListDOSS = await utils.callUrlAsync(urlGetCurrDOSS);
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
var rawLVFasi = await utils.callUrlAsync(urlGetListValFasiPodl);
|
||||
var rawListArt = await HttpService.CallUrlAsync(urlGetCurrArt);
|
||||
var rawListDOSS = await HttpService.CallUrlAsync(urlGetCurrDOSS);
|
||||
var rawListPODL = await HttpService.CallUrlAsync(urlGetNextPODL);
|
||||
var rawLVFasi = await HttpService.CallUrlAsync(urlGetListValFasiPodl);
|
||||
|
||||
if (!string.IsNullOrEmpty(rawListArt))
|
||||
{
|
||||
@@ -1754,9 +1751,9 @@ namespace IOB_WIN_FORM.Iob
|
||||
// PONTE SYNC/ASYNC: Ora sw.Stop() aspetterà la fine reale dell'operazione
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var rawListArt = await utils.callUrlAsync(urlGetCurrArt);
|
||||
var rawListDOSS = await utils.callUrlAsync(urlGetCurrDOSS);
|
||||
var rawListPODL = await utils.callUrlAsync(urlGetNextPODL);
|
||||
var rawListArt = await HttpService.CallUrlAsync(urlGetCurrArt);
|
||||
var rawListDOSS = await HttpService.CallUrlAsync(urlGetCurrDOSS);
|
||||
var rawListPODL = await HttpService.CallUrlAsync(urlGetNextPODL);
|
||||
if (!string.IsNullOrEmpty(rawListArt))
|
||||
{
|
||||
try
|
||||
@@ -2169,7 +2166,7 @@ namespace IOB_WIN_FORM.Iob
|
||||
private void sendDataItemsList(List<machDataItem> dataItems)
|
||||
{
|
||||
string rawData = JsonConvert.SerializeObject(dataItems);
|
||||
utils.CallUrlPost($"{urlSaveDataItems}", rawData);
|
||||
HttpService.CallUrlPost($"{urlSaveDataItems}", rawData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Generated
-10
@@ -45,7 +45,6 @@
|
||||
this.closeChildToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.closeALLAdaptersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.restartALLAdaptersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.uploadIOBConfToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.downloadIOBConfToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sendIOBAssignmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.getIOBAssignmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -162,7 +161,6 @@
|
||||
this.closeChildToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.closeALLAdaptersToolStripMenuItem,
|
||||
this.restartALLAdaptersToolStripMenuItem,
|
||||
this.uploadIOBConfToolStripMenuItem,
|
||||
this.downloadIOBConfToolStripMenuItem,
|
||||
this.sendIOBAssignmentsToolStripMenuItem,
|
||||
this.getIOBAssignmentsToolStripMenuItem});
|
||||
@@ -186,13 +184,6 @@
|
||||
this.restartALLAdaptersToolStripMenuItem.Text = "&Restart ALL Adapters";
|
||||
this.restartALLAdaptersToolStripMenuItem.Click += new System.EventHandler(this.restartALLAdaptersToolStripMenuItem_Click);
|
||||
//
|
||||
// uploadIOBConfToolStripMenuItem
|
||||
//
|
||||
this.uploadIOBConfToolStripMenuItem.Name = "uploadIOBConfToolStripMenuItem";
|
||||
this.uploadIOBConfToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
|
||||
this.uploadIOBConfToolStripMenuItem.Text = "Upload IOB Conf files";
|
||||
this.uploadIOBConfToolStripMenuItem.Click += new System.EventHandler(this.uploadIOBConfToolStripMenuItem_Click);
|
||||
//
|
||||
// downloadIOBConfToolStripMenuItem
|
||||
//
|
||||
this.downloadIOBConfToolStripMenuItem.Name = "downloadIOBConfToolStripMenuItem";
|
||||
@@ -302,7 +293,6 @@
|
||||
private System.Windows.Forms.ToolStripStatusLabel tslRunTime;
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeChildToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem uploadIOBConfToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem downloadIOBConfToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem sendIOBAssignmentsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem getIOBAssignmentsToolStripMenuItem;
|
||||
|
||||
+75
-114
@@ -1,5 +1,6 @@
|
||||
using IOB_UT_NEXT;
|
||||
using IOB_UT_NEXT.Config;
|
||||
using IOB_UT_NEXT.Iob.Services;
|
||||
using MapoSDK;
|
||||
using MathNet.Numerics.Distributions;
|
||||
using Newtonsoft.Json;
|
||||
@@ -29,6 +30,11 @@ namespace IOB_WIN_FORM
|
||||
/// </summary>
|
||||
public static Logger lg;
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione gerarchica completa (v 4.x.x.x)
|
||||
/// </summary>
|
||||
public IobConfTree IOBConfFull = new IobConfTree();
|
||||
|
||||
/// <summary>
|
||||
/// Data ultimo controllo comunicazione
|
||||
/// </summary>
|
||||
@@ -113,7 +119,6 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (utils.dtVetoPing < DateTime.Now)
|
||||
{
|
||||
IPStatus pingStatus = GetPingStatus();
|
||||
@@ -123,7 +128,7 @@ namespace IOB_WIN_FORM
|
||||
try
|
||||
{
|
||||
// chiamo URL, se restituisce "OK" è alive!
|
||||
string callResp = utils.callUrl(urlAlive);
|
||||
string callResp = HttpService.CallUrl(urlAlive);
|
||||
answ = (callResp == "OK");
|
||||
}
|
||||
catch (Exception exc)
|
||||
@@ -403,39 +408,17 @@ namespace IOB_WIN_FORM
|
||||
/// <summary>
|
||||
/// URL per recuperare i file dell'IOB (SENZA IOB)
|
||||
/// </summary>
|
||||
protected string urlDownloadFile
|
||||
{
|
||||
get => $"http://{MPIP}{MPURL}/IOB/getFiles/";
|
||||
}
|
||||
protected string urlDownloadFile => $"http://{MPIP}{MPURL}/IOB/getFiles/";
|
||||
|
||||
/// <summary>
|
||||
/// URL per recuperare i file dell'IOB su CLOUD (SENZA IOB)
|
||||
/// </summary>
|
||||
protected string urlDownloadFileCloud
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"{baseUrl}IOB/getFiles/";
|
||||
}
|
||||
}
|
||||
protected string urlDownloadFileCloud => $"{baseUrl}IOB/getFiles/";
|
||||
|
||||
/// <summary>
|
||||
/// URL per chiedere quale sia la IOB da acquisire/gestire (se c'è...)
|
||||
/// </summary>
|
||||
protected string urlIob2call
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format(@"http://{0}{1}{2}{3}", MPIP, MPURL, CMDIOB2CALL, utils.GetIP());
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
protected string urlIob2call => $"http://{MPIP}{MPURL}{CMDIOB2CALL}{NetService.GetIP()}";
|
||||
|
||||
/// <summary>
|
||||
/// URL per segnalazione reboot...
|
||||
@@ -444,34 +427,31 @@ namespace IOB_WIN_FORM
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
// 1. Creiamo l'URL base (chiamando GetIP una sola volta)
|
||||
string baseUrl = $"http://{MPIP}{MPURL}{CMDREBO}{NetService.GetIP()}";
|
||||
|
||||
try
|
||||
{
|
||||
answ = string.Format(@"http://{0}{1}{2}{3}&mac={4}", MPIP, MPURL, CMDREBO, utils.GetIP(), utils.GetMACAddress());
|
||||
// 2. Proviamo ad accodare il MAC Address
|
||||
return $"{baseUrl}&mac={NetService.GetMACAddress()}";
|
||||
}
|
||||
catch
|
||||
{
|
||||
answ = string.Format(@"http://{0}{1}{2}{3}", MPIP, MPURL, CMDREBO, utils.GetIP());
|
||||
// 3. Se GetMACAddress() fallisce, restituiamo l'URL senza MAC
|
||||
return baseUrl;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per salvare i file dell'IOB (SENZA IOB)
|
||||
/// </summary>
|
||||
protected string urlUploadFile
|
||||
{
|
||||
get => $"http://{MPIP}{MPURL}/IOB/uploadFile/";
|
||||
}
|
||||
protected string urlUploadFile => $"http://{MPIP}{MPURL}/IOB/uploadFile/";
|
||||
|
||||
/// <summary>
|
||||
/// URL per salvare i file dell'IOB su CLOUD (SENZA IOB)
|
||||
/// </summary>
|
||||
protected string urlUploadFileCloud
|
||||
{
|
||||
get => $"{baseUrl}IOB/uploadFile/";
|
||||
}
|
||||
protected string urlUploadFileCloud => $"{baseUrl}IOB/uploadFile/";
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -496,6 +476,7 @@ namespace IOB_WIN_FORM
|
||||
lg.Factory.Configuration.Variables["codIOB"] = "MAIN";
|
||||
lg.Info(txt2log);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging WARN corretto impostando anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
@@ -526,14 +507,6 @@ namespace IOB_WIN_FORM
|
||||
this.LayoutMdi(MdiLayout.TileHorizontal);
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
MainTimer?.Stop();
|
||||
MainTimer?.Dispose();
|
||||
closeActiveChild();
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiude le finestre child attive
|
||||
/// </summary>
|
||||
@@ -629,7 +602,7 @@ namespace IOB_WIN_FORM
|
||||
if (pingStatus == IPStatus.Success)
|
||||
{
|
||||
// segnalo reboot (programma)...
|
||||
utils.callUrl(urlReboot);
|
||||
HttpService.CallUrl(urlReboot);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -643,6 +616,14 @@ namespace IOB_WIN_FORM
|
||||
displayTaskAndLog("Main Form OK");
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
MainTimer?.Stop();
|
||||
MainTimer?.Dispose();
|
||||
closeActiveChild();
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apre la finestra child con conf
|
||||
/// </summary>
|
||||
@@ -702,6 +683,8 @@ namespace IOB_WIN_FORM
|
||||
/// </summary>
|
||||
private static bool closed = false;
|
||||
|
||||
private FormWindowState _lastState = FormWindowState.Minimized;
|
||||
|
||||
/// <summary>
|
||||
/// Nome applicazione (da app.config)
|
||||
/// </summary>
|
||||
@@ -709,58 +692,6 @@ namespace IOB_WIN_FORM
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione gerarchica completa (v 4.x.x.x)
|
||||
/// </summary>
|
||||
public IobConfTree IOBConfFull = new IobConfTree();
|
||||
|
||||
/// <summary>
|
||||
/// test ping all'indirizzo impostato nei parametri
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IPStatus GetPingStatus()
|
||||
{
|
||||
IPStatus answ = IPStatus.Unknown;
|
||||
// se disabilitato salto...
|
||||
if (IOBConfFull != null && IOBConfFull.MapoMes.DisabPing)
|
||||
{
|
||||
answ = IPStatus.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPAddress address;
|
||||
PingReply reply;
|
||||
using (Ping pingSender = new Ping())
|
||||
{
|
||||
address = IPAddress.Loopback;
|
||||
string ipAdrr = MPIP;
|
||||
IPAddress.TryParse(ipAdrr, out address);
|
||||
try
|
||||
{
|
||||
// se != null --> uso address...
|
||||
if (address != null)
|
||||
{
|
||||
reply = pingSender.Send(address, 500);
|
||||
}
|
||||
else
|
||||
{
|
||||
reply = pingSender.Send(MPIP, 500);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
reply = pingSender.Send(IPAddress.Loopback, 100);
|
||||
}
|
||||
}
|
||||
answ = reply.Status;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void arrangeWindowsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -904,7 +835,7 @@ namespace IOB_WIN_FORM
|
||||
// invio in locale!
|
||||
url2call = $"{urlDownloadFile}{currIob}";
|
||||
}
|
||||
rawData = utils.CallUrlGet(url2call);
|
||||
rawData = HttpService.CallUrlGet(url2call);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
// deserializzo
|
||||
@@ -956,6 +887,49 @@ namespace IOB_WIN_FORM
|
||||
// file MAIN di avvio ripartendo...)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// test ping all'indirizzo impostato nei parametri
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IPStatus GetPingStatus()
|
||||
{
|
||||
IPStatus answ = IPStatus.Unknown;
|
||||
// se disabilitato salto...
|
||||
if (IOBConfFull != null && IOBConfFull.MapoMes.DisabPing)
|
||||
{
|
||||
answ = IPStatus.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPAddress address;
|
||||
PingReply reply;
|
||||
using (Ping pingSender = new Ping())
|
||||
{
|
||||
address = IPAddress.Loopback;
|
||||
string ipAdrr = MPIP;
|
||||
IPAddress.TryParse(ipAdrr, out address);
|
||||
try
|
||||
{
|
||||
// se != null --> uso address...
|
||||
if (address != null)
|
||||
{
|
||||
reply = pingSender.Send(address, 500);
|
||||
}
|
||||
else
|
||||
{
|
||||
reply = pingSender.Send(MPIP, 500);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
reply = pingSender.Send(IPAddress.Loopback, 100);
|
||||
}
|
||||
}
|
||||
answ = reply.Status;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Carica file ini della configurazione richiesta
|
||||
/// </summary>
|
||||
@@ -1049,8 +1023,6 @@ namespace IOB_WIN_FORM
|
||||
_lastState = this.WindowState;
|
||||
}
|
||||
|
||||
private FormWindowState _lastState = FormWindowState.Minimized;
|
||||
|
||||
/// <summary>
|
||||
/// evento visualizzazione
|
||||
/// </summary>
|
||||
@@ -1183,10 +1155,6 @@ namespace IOB_WIN_FORM
|
||||
{
|
||||
openChild(item);
|
||||
}
|
||||
#if false
|
||||
// effettuo upload dei file di configurazione...
|
||||
uploadIobConfFile();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1214,13 +1182,6 @@ namespace IOB_WIN_FORM
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadIOBConfToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
#if false
|
||||
uploadIobConfFile();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -20,4 +20,3 @@ CLI_INST=SteamWareSim
|
||||
STARTLIST=FTP_SONATEST
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -27,4 +27,3 @@ STARTLIST=3024
|
||||
;STARTLIST=LVF652
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -34,4 +34,3 @@ STARTLIST=3026
|
||||
;STARTLIST=SIMUL_01
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -20,4 +20,3 @@ STARTLIST=SIMUL_01
|
||||
;STARTLIST=3023-PING
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -42,4 +42,3 @@ CLI_INST=SteamWareSim
|
||||
STARTLIST=3010
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
@@ -24,4 +24,3 @@ STARTLIST=3018
|
||||
;STARTLIST=SIMUL_06
|
||||
|
||||
MAXCNC=10
|
||||
|
||||
|
||||
+12
-9
@@ -1,6 +1,6 @@
|
||||
# WIP: Refactoring Phase 1 - Infrastructure Extraction
|
||||
|
||||
## Status: COMPLETED
|
||||
## Status: IN_PROGRESS
|
||||
|
||||
## Objective
|
||||
Extract infrastructure and helper components from `Generic.cs` to improve modularity and reduce the monolithic footprint.
|
||||
@@ -10,7 +10,7 @@ Extract infrastructure and helper components from `Generic.cs` to improve modula
|
||||
### 1. Communication Service Extraction (COMPLETED/REFACTORED)
|
||||
- [x] Identify redundant `callUrl` and `callUrlWithPayloadAsync` wrappers in `BaseObj.cs`.
|
||||
- [x] Instead of creating a new service, cleaned up `BaseObj.cs` by removing pass-through methods that merely delegated to `utils`.
|
||||
- [x] Updated `Generic.cs` to call `utils.callUrl` directly, removing the unnecessary indirection layer.
|
||||
- [x] Updated `Generic.cs` to call `utils.callUrl` directly, eliminating the unnecessary indirection layer.
|
||||
|
||||
### 2. Redis Service Extraction (COMPLETED)
|
||||
- [x] Encapsulate all `redisMan` calls into a `RedisService`.
|
||||
@@ -18,9 +18,13 @@ Extract infrastructure and helper components from `Generic.cs` to improve modula
|
||||
- [x] **Refactored**: Moved semantic key construction from `RedisService` to `BaseObj` to eliminate redundant service layer.
|
||||
- [x] Eliminated `RedisService.cs` as it was absorbed by the `BaseObj` identity-aware implementation.
|
||||
|
||||
### 3. Data Serializer Extraction
|
||||
- [ ] Move all `JsonConvert` and custom string formatting (e.g., `qEncodeFLog`, `qEncodeIN`) to a `DataSerializer` service.
|
||||
- [ ] Centralize `CultureInfo.InvariantCulture` usage.
|
||||
### 3. Data Serializer Extraction (IN_PROGRESS)
|
||||
- [x] Analyzed current `DataSerializer.cs` (JSON) and `XmlDataSerializer.cs` (XML) in `IOB-WIN-FORM`.
|
||||
- [x] Decided to move these to `IOB_UT_NEXT` to make them available to the entire IOB hierarchy.
|
||||
- [ ] Move files to `IOB_UT_NEXT\Iob\Services\`.
|
||||
- [ ] Update namespaces and references.
|
||||
- [ ] Integrate into `BaseObj.cs` via `protected` helper methods (e.g., `JsonSerialize<T>`, `XmlSerialize<T>`).
|
||||
- [ ] Update `Generic.cs` to use the new `BaseObj` helpers.
|
||||
|
||||
### 4. BaseObj Simplification (COMPLETED)
|
||||
- [x] Analyze `BaseObj` responsibilities (State, Config, Messaging, Diagnostics).
|
||||
@@ -29,8 +33,7 @@ Extract infrastructure and helper components from `Generic.cs` to improve modula
|
||||
|
||||
## Progress Log
|
||||
- [x] Created WIP document.
|
||||
- [x] Analyzed `Generic.cs` for Phase 1 candidates.
|
||||
- [x] Completed Redis Semantic Refactoring.
|
||||
- [x] Completed BaseObj Cleanup (Removal of redundant wrappers and commented code).
|
||||
- [x] Verified compilation stability after removing `BaseObj` wrappers.
|
||||
- [ ] **Next Task**: Data Serializer Extraction.
|
||||
- [x] Completed BaseObj Cleanup.
|
||||
- [x] Identified Data Serializer components for extraction.
|
||||
- [ ] Started migration of Serializers to `IOB_UT_NEXT`.
|
||||
|
||||
Reference in New Issue
Block a user