311 lines
9.7 KiB
C#
311 lines
9.7 KiB
C#
using MapoSDK;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace IOB_UT_NEXT
|
|
{
|
|
/// <summary>
|
|
/// Classe gestione configurazione parametri di base x allarmi
|
|
/// </summary>
|
|
public class BaseAlarmConf
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Elenco dei contatori blink (x gestione caso frponte salita/discesa segnale hce blinka)
|
|
/// </summary>
|
|
public int[] alarmBlinkCounter { get; set; }
|
|
|
|
/// <summary>
|
|
/// Elenco boolean degli allarmi silenziati/disabilitati (se iniziano per ##)
|
|
/// </summary>
|
|
public bool[] alarmDisabled { get; set; }
|
|
|
|
/// <summary>
|
|
/// Array dei valori allarme correnti
|
|
/// </summary>
|
|
public int[] alarmsState { get; set; }
|
|
|
|
/// <summary>
|
|
/// Descrizione area allarmi
|
|
/// </summary>
|
|
public string description { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Indice nell'area di memoria (da valore iniziale = 0)
|
|
/// </summary>
|
|
public int index { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Nome "assoluto" della posizione nell'area di memoria (anche diverso da indice)
|
|
/// </summary>
|
|
public string memAddr { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Elenco allarmi configurati x la bitmap
|
|
/// </summary>
|
|
public List<string> messages { get; set; } = new List<string>();
|
|
|
|
/// <summary>
|
|
/// Size in byte
|
|
/// </summary>
|
|
public int size { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// Tipo di dato
|
|
/// </summary>
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public plcDataType tipoMem { get; set; } = plcDataType.Boolean;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Effettua il decremento dei contatori blink (se >0) per gestire i segnali alternati sul fronte di discesa
|
|
/// </summary>
|
|
public void decreaseBlinkCounter()
|
|
{
|
|
int idx = 0;
|
|
foreach (var item in alarmBlinkCounter)
|
|
{
|
|
alarmBlinkCounter[idx] = item > 0 ? item - 1 : item;
|
|
idx++;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confronta un valore di stato allarme con lo stato precedentemente salvato considerando blink/veto
|
|
/// </summary>
|
|
/// <param name="num">Numero/indice del banco di allarme (int16)</param>
|
|
/// <param name="newValue">Nuovo valore bitmap allarmi come int16</param>
|
|
/// <returns></returns>
|
|
public bool isChanged(int num, int newValue)
|
|
{
|
|
// FIXME TODO fare davvero veto/blink....
|
|
|
|
bool answ = !alarmsState[num].Equals(newValue);
|
|
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Inizializzazione classe con valori calcolati
|
|
/// </summary>
|
|
public void SetupData()
|
|
{
|
|
// inizializzo vettore valore allarmi x banco int16
|
|
alarmsState = new int[size / 2];
|
|
|
|
// una volta inizializzata la classe di base sistemo vettori allarmi disabilitati ed il contatore blink dei fronti di discesa
|
|
alarmDisabled = new bool[messages.Count];
|
|
alarmBlinkCounter = new int[messages.Count];
|
|
int i = 0;
|
|
foreach (var item in messages)
|
|
{
|
|
if (item.StartsWith("##"))
|
|
{
|
|
alarmDisabled[i] = true;
|
|
alarmBlinkCounter[i] = 9999;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe gestione configurazione parametri di base x configuraizone estesa (es MTConnect, OPC-UA, ...)
|
|
/// </summary>
|
|
public class BaseParamConf
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione LAVORA / Green
|
|
/// </summary>
|
|
public List<diCheckCondition> condWork { get; set; } = new List<diCheckCondition>();
|
|
|
|
/// <summary>
|
|
/// Elenco items FILTRATI da invio come dynData --> FluxLog (events o samples)
|
|
/// </summary>
|
|
public List<string> fluxLogVeto { get; set; } = new List<string>();
|
|
|
|
/// <summary>
|
|
/// Array degli elementi di traduzione item
|
|
/// </summary>
|
|
public Dictionary<string, string> itemTranslation { get; set; } = new Dictionary<string, string>();
|
|
|
|
/// <summary>
|
|
/// Nome variabile x EmergencyStop
|
|
/// </summary>
|
|
public string keyEStop { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Nome variabile x pezzi FATTI
|
|
/// </summary>
|
|
public string keyPartCount { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Nome variabile x Codice Articolo
|
|
/// </summary>
|
|
public string keyPartId { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Nome variabile x pezzi RICHIESTI
|
|
/// </summary>
|
|
public string keyPartReq { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Nome variabile x NOME PROGRAMMA
|
|
/// </summary>
|
|
public string keyProgName { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Nome variabile x RunMode
|
|
/// </summary>
|
|
public string keyRunMode { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Dictionary dei nomi da cercare come "endsWith" a cui applicare la soglia indicata
|
|
/// </summary>
|
|
public Dictionary<string, int> paramsEndThresh { get; set; } = new Dictionary<string, int>();
|
|
|
|
/// <summary>
|
|
/// Indica se il ping sia un criterio valido x determinare powerON impianto
|
|
/// </summary>
|
|
public bool pingAsPowerOn { get; set; } = true;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per rappresentare oggetti chaive/valore target x controlo condizioni multiple
|
|
/// </summary>
|
|
public class diCheckCondition
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// nome variabile
|
|
/// </summary>
|
|
public string keyName { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// valore target per esito richeisto
|
|
/// </summary>
|
|
public string targetValue { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per rappresentare una lista di oggetti chaive/valore target x controlo condizioni multiple + indicazione modalità di controllo (AND/OR/...)
|
|
/// </summary>
|
|
public class diCheckCondSetup
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Elenco condizioni
|
|
/// </summary>
|
|
public List<diCheckCondition> checkList { get; set; } = new List<diCheckCondition>();
|
|
|
|
/// <summary>
|
|
/// Modalità verifica condizioni
|
|
/// </summary>
|
|
public boolCheckMode checkMode { get; set; } = boolCheckMode.AND;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe gestione configurazione parametri specifici MTC da BaseParamConf
|
|
/// </summary>
|
|
public class MtcParamConf : BaseParamConf
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione PowerOn
|
|
/// </summary>
|
|
public diCheckCondition condPowerOn { get; set; } = new diCheckCondition();
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe gestione configurazione parametri specifici OPC-UA da BaseParamConf
|
|
/// </summary>
|
|
public class OpcUaParamConf : BaseParamConf
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Identificativo nodo iniziale
|
|
/// </summary>
|
|
public string BrowseFullVal { get; set; } = "ns=2;s=Scalar_Static";
|
|
|
|
/// <summary>
|
|
/// Indice NS da cui fare il browse dei file
|
|
/// </summary>
|
|
public ushort BrowseNSIndex { get; set; } = 4;
|
|
|
|
/// <summary>
|
|
/// ID del nodo da cui partire x il browse di identificazione nodi iniziale
|
|
/// </summary>
|
|
public uint BrowseValue { get; set; } = 5001;
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione Contapezzi Abilitato (se vuoto = sempre abilitato)
|
|
/// </summary>
|
|
public diCheckCondSetup condCountEnabled { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione Errore
|
|
/// </summary>
|
|
public diCheckCondSetup condError { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione Emergenza
|
|
/// </summary>
|
|
public diCheckCondSetup condEStop { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione Manual
|
|
/// </summary>
|
|
public diCheckCondSetup condManual { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione PowerOn
|
|
/// </summary>
|
|
public diCheckCondSetup condPowerOn { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione READY
|
|
/// </summary>
|
|
public diCheckCondSetup condReady { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Struttura dati x check condizione WarmUp - CoolDown
|
|
/// </summary>
|
|
public diCheckCondSetup condWarmUpCoolDown { get; set; } = new diCheckCondSetup();
|
|
|
|
/// <summary>
|
|
/// Aree di memoria lettura
|
|
/// </summary>
|
|
public Dictionary<string, dataConfTSVC> mMapRead { get; set; } = new Dictionary<string, dataConfTSVC>();
|
|
|
|
/// <summary>
|
|
/// Aree di memoria scrittura
|
|
/// </summary>
|
|
public Dictionary<string, dataConf> mMapWrite { get; set; } = new Dictionary<string, dataConf>();
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |