538 lines
14 KiB
C#
538 lines
14 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MapoSDK
|
|
{
|
|
/// <summary>
|
|
/// nuovo stato ingressi e eventuale evento da inviare
|
|
/// </summary>
|
|
public struct hwMachineState
|
|
{
|
|
#region Public Fields
|
|
|
|
public int IdxTipoEvento;
|
|
public int next_IdxMicroStato;
|
|
|
|
#endregion Public Fields
|
|
|
|
#region Public Methods
|
|
|
|
public static bool operator !=(hwMachineState left, hwMachineState right)
|
|
{
|
|
return !(left == right);
|
|
}
|
|
|
|
public static bool operator ==(hwMachineState left, hwMachineState right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (!(obj is hwMachineState item))
|
|
return false;
|
|
|
|
if (IdxTipoEvento != item.IdxTipoEvento)
|
|
return false;
|
|
if (next_IdxMicroStato != item.next_IdxMicroStato)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
|
|
/// <summary>
|
|
/// Struttura gestione comandi di input
|
|
/// </summary>
|
|
public struct inputComandoMapo
|
|
{
|
|
#region Public Fields
|
|
|
|
/// <summary>
|
|
/// descrizione comando
|
|
/// </summary>
|
|
public string descrComando;
|
|
|
|
/// <summary>
|
|
/// idx evento associato al comando
|
|
/// </summary>
|
|
public int idxTipoEvento;
|
|
|
|
/// <summary>
|
|
/// input comando valido si/no
|
|
/// </summary>
|
|
public bool isValid;
|
|
|
|
/// <summary>
|
|
/// refresh stato macchina encessario si/no
|
|
/// </summary>
|
|
public bool needStatusRefresh;
|
|
|
|
/// <summary>
|
|
/// valore di output dal comando
|
|
/// </summary>
|
|
public string outValue;
|
|
|
|
/// <summary>
|
|
/// input precedente
|
|
/// </summary>
|
|
public string precInput;
|
|
|
|
/// <summary>
|
|
/// testo da mostrare all'utente
|
|
/// </summary>
|
|
public string text2show;
|
|
|
|
/// <summary>
|
|
/// lista del nome dei WebBrowserBox e delle relative url, nel formato {0}##{1} {0}=nome
|
|
/// WebBrowserBox (es. box01), {1}=url relativo (es. http://server/MoonPro/Produzione.aspx?idxMacchina=99)
|
|
/// </summary>
|
|
public string[] wBrowsBoxUrls;
|
|
|
|
#endregion Public Fields
|
|
|
|
#region Public Methods
|
|
|
|
public static bool operator !=(inputComandoMapo left, inputComandoMapo right)
|
|
{
|
|
return !(left == right);
|
|
}
|
|
|
|
public static bool operator ==(inputComandoMapo left, inputComandoMapo right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (!(obj is inputComandoMapo item))
|
|
return false;
|
|
|
|
if (descrComando != item.descrComando)
|
|
return false;
|
|
if (idxTipoEvento != item.idxTipoEvento)
|
|
return false;
|
|
if (isValid != item.isValid)
|
|
return false;
|
|
if (needStatusRefresh != item.needStatusRefresh)
|
|
return false;
|
|
if (outValue != item.outValue)
|
|
return false;
|
|
if (precInput != item.precInput)
|
|
return false;
|
|
if (text2show != item.text2show)
|
|
return false;
|
|
if (wBrowsBoxUrls != item.wBrowsBoxUrls)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe di base per trasferimento informazioni di tipo RawTransfer
|
|
/// </summary>
|
|
public class BaseRawTransf
|
|
{
|
|
#region Public Constructors
|
|
|
|
/// <summary>
|
|
/// Costruttore senza parametri
|
|
/// </summary>
|
|
public BaseRawTransf()
|
|
{
|
|
this.dataRif = DateTime.Now;
|
|
this.mesContent = new JObject();
|
|
this.mesType = rawTransfType.ND;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Costruttore oggetto
|
|
/// </summary>
|
|
/// <param name="dataRif"></param>
|
|
/// <param name="mesContent"></param>
|
|
/// <param name="mesType"></param>
|
|
public BaseRawTransf(DateTime dataRif, JObject mesContent, rawTransfType mesType)
|
|
{
|
|
this.dataRif = dataRif;
|
|
this.mesContent = mesContent;
|
|
this.mesType = mesType;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Data-Ora riferimento (x ordinamento fifo)
|
|
/// </summary>
|
|
public DateTime dataRif { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// Messaggio in modalità raw/stringa
|
|
/// </summary>
|
|
public JObject mesContent { get; set; } = new JObject();
|
|
|
|
/// <summary>
|
|
/// Tipo di messaggio trasmesso
|
|
/// </summary>
|
|
public rawTransfType mesType { get; set; } = rawTransfType.ND;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe x inviare messaggi di tipo esecuzione di una generica esecuzione
|
|
/// </summary>
|
|
public class exeResult
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Esito del risultato
|
|
/// </summary>
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public esitoExec esito { get; set; } = esitoExec.undone;
|
|
|
|
/// <summary>
|
|
/// Messaggio associato
|
|
/// </summary>
|
|
public string message { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dati resoconto IOB
|
|
/// </summary>
|
|
public class IOB_data
|
|
{
|
|
#region Public Fields
|
|
|
|
public bool CNC_Counter;
|
|
public string IP;
|
|
public IobType iType;
|
|
public string name;
|
|
public string typeCss;
|
|
|
|
#endregion Public Fields
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rappresentazione dello stato corrente dell'IOB
|
|
/// </summary>
|
|
public class IobWinCurrentState
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Contatore IOB
|
|
/// </summary>
|
|
public float counterIOB { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Contatore Macchina
|
|
/// </summary>
|
|
public float counterMAC { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Ultimo stato noto dei parametri in memoria letti da PLC
|
|
/// </summary>
|
|
public Dictionary<string, string> currParams { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// DataOra ultima comunicazione IN (con PLC)
|
|
/// </summary>
|
|
public DateTime lastDataIn { get; set; } = DateTime.Now.AddYears(-1);
|
|
|
|
/// <summary>
|
|
/// DataOra ultima comunicazione OUT (con MP Server)
|
|
/// </summary>
|
|
public DateTime lastDataOut { get; set; } = DateTime.Now.AddYears(-1);
|
|
|
|
/// <summary>
|
|
/// Lunghezza coda EVENTI in uscita
|
|
/// </summary>
|
|
public int queueEvLen { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Lunghezza coda FluxLog in uscita
|
|
/// </summary>
|
|
public int queueFLogLen { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Semaforo IN (IOB-PLC)
|
|
/// </summary>
|
|
public Semaforo SemIn { get; set; } = Semaforo.ND;
|
|
|
|
/// <summary>
|
|
/// Semaforo OUT (IOB-MPserver)
|
|
/// </summary>
|
|
public Semaforo SemOut { get; set; } = Semaforo.ND;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Array elementi tipo KeyValuePair inviati come JSon che indicano lo stato LIVE dell'IOB
|
|
/// </summary>
|
|
public class liveIOB
|
|
{
|
|
#region Public Properties
|
|
|
|
public List<KeyValuePair<string, string>> dataList { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Descrittore oggetto DataItem generico
|
|
/// </summary>
|
|
public class machDataItem
|
|
{
|
|
#region Public Constructors
|
|
|
|
public machDataItem()
|
|
{ }
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Categoria oggetto
|
|
/// </summary>
|
|
public DataItemCategory Category { get; set; }
|
|
|
|
/// <summary>
|
|
/// Nome / descrizione
|
|
/// </summary>
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>
|
|
/// Tipologia specifica
|
|
/// </summary>
|
|
public string SubType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Tipologia principale
|
|
/// </summary>
|
|
public string Type { get; set; }
|
|
|
|
/// <summary>
|
|
/// Unità di misura
|
|
/// </summary>
|
|
public string Units { get; set; }
|
|
|
|
/// <summary>
|
|
/// ID generico
|
|
/// </summary>
|
|
public string uuid { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configurazione delle macchine MTC
|
|
/// </summary>
|
|
public class MtcSetup
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Setup della macchina
|
|
/// </summary>
|
|
public List<machDataItem> dataItems { get; set; }
|
|
|
|
/// <summary>
|
|
/// IdxMacchina cui ci riferiamo
|
|
/// </summary>
|
|
public string idxMacchina { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe gestione ITEM di un OBJ (machine) generico (read/write)
|
|
/// </summary>
|
|
public class objItem
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// DESCRIZIONE item
|
|
/// </summary>
|
|
public string description { get; set; } = "-";
|
|
|
|
/// <summary>
|
|
/// Ultimo messaggio associato (conferma scrittura, errore, ...)
|
|
/// </summary>
|
|
public string lastMessage { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// DataOra ultima lettura
|
|
/// </summary>
|
|
public DateTime lastRead { get; set; } = DateTime.Now.AddHours(-1);
|
|
|
|
/// <summary>
|
|
/// DataOra ultima richiesta scrittura
|
|
/// </summary>
|
|
public DateTime lastRequest { get; set; } = DateTime.Now.AddDays(-1);
|
|
|
|
/// <summary>
|
|
/// NOME item
|
|
/// </summary>
|
|
public string name { get; set; } = ".";
|
|
|
|
/// <summary>
|
|
/// Indica il NUOVO valore richiesto x l'item
|
|
/// </summary>
|
|
public string reqValue { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// UID univoco
|
|
/// </summary>
|
|
public string uid { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Unità Misura parametro
|
|
/// </summary>
|
|
public string UM { get; set; } = "#";
|
|
|
|
/// <summary>
|
|
/// Valore MASSIMO (SE impostato)
|
|
/// </summary>
|
|
public double valMax { get; set; }
|
|
|
|
/// <summary>
|
|
/// Valore minimo (SE impostato)
|
|
/// </summary>
|
|
public double valMin { get; set; }
|
|
|
|
/// <summary>
|
|
/// Valore parametro (come stringa, decimali con ",", default VUOTO), sul CNC/PLC
|
|
/// </summary>
|
|
public string value { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Indica se sia abilitato in scrittura (WRITE)
|
|
/// </summary>
|
|
public bool writable { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// Valore per determinare Display Ordinal (es pagina TAB / invio parametri)
|
|
/// </summary>
|
|
public int displOrdinal { get; set; } = 0;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Struttura conf memorie PLC (inizialmente SIEMENS)
|
|
/// </summary>
|
|
public class plcMemMap
|
|
{
|
|
#region Public Fields
|
|
|
|
/// <summary>
|
|
/// Parametri ammessi per IOB x lettura
|
|
/// </summary>
|
|
public Dictionary<string, dataConfTSVC> mMapRead = new Dictionary<string, dataConfTSVC>();
|
|
|
|
/// <summary>
|
|
/// Parametri ammessi per IOB x scrittura
|
|
/// </summary>
|
|
public Dictionary<string, dataConf> mMapWrite = new Dictionary<string, dataConf>();
|
|
|
|
#endregion Public Fields
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe gesitone conteggi produzione
|
|
/// </summary>
|
|
public class prodCounter
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// NUmero pezzi CONFERMATI
|
|
/// </summary>
|
|
public int numPzConf { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Numero pezzi ORDINATI
|
|
/// </summary>
|
|
public int numPzOrd { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Numero pezzi PRODOTTI
|
|
/// </summary>
|
|
public int numPzProd { get; set; } = 0;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Array valori tipo BaseRawTransf inviati come JSon
|
|
/// </summary>
|
|
public class rawTransfJsonPayload
|
|
{
|
|
#region Public Properties
|
|
|
|
public List<BaseRawTransf> rawTransfData { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tracciato RegGiacenze x insert da IOB
|
|
/// </summary>
|
|
public class RegGiacenze
|
|
{
|
|
#region Public Properties
|
|
|
|
public DateTime DateRif { get; set; } = DateTime.Today;
|
|
public string ExtDoc { get; set; } = "";
|
|
public string IdentRG { get; set; } = "";
|
|
public int IdxODL { get; set; } = 0;
|
|
public string Notes { get; set; } = "";
|
|
public int NumPack { get; set; } = 0;
|
|
public string Product { get; set; } = "";
|
|
public double QtyTot { get; set; } = 0;
|
|
public string Supplier { get; set; } = "";
|
|
public string Variety { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
public class StCheckOverride
|
|
{
|
|
#region Public Properties
|
|
|
|
public bool CanForce { get; set; } = false;
|
|
public string CodGruppo { get; set; } = "";
|
|
public string CodTipo { get; set; } = "";
|
|
public int IdxST { get; set; } = 0;
|
|
public int Num { get; set; } = 0;
|
|
public int Oggetto { get; set; } = 0;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |