using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
namespace MapoSDK
{
///
/// Raccolta dati di storici sintetici per Macchina e Variabile
///
public class histData
{
#region Public Properties
///
/// Data riferimento campione in formato YMD = yyyyMMdd
///
public int dateYMD { get; set; } = 0;
///
/// Macchina
///
public string macName { get; set; } = "";
///
/// Periodo di aggregazione di riferimento
///
//[JsonConverter(typeof(StringEnumConverter))]
public timeWindow period { get; set; } = timeWindow.day;
///
/// Statistiche raccolte nel periodo
///
public List stats { get; set; } = null;
///
/// Tipo di valore registrato (internamente è string)
///
//[JsonConverter(typeof(StringEnumConverter))]
public plcDataType varType { get; set; } = plcDataType.Int;
#endregion Public Properties
}
///
/// Classe oggetto base TimeSeries
///
public class tsData
{
#region Public Properties
///
/// In base al tipo di oggetto restituisce il valore cona deguata conversione......
///
public object actValue
{
get
{
object answ = null;
bool currBool = false;
int currInt = 0;
double currDouble = 0;
switch (vcType)
{
case plcDataType.Boolean:
_ = bool.TryParse(strValue, out currBool);
answ = currBool;
break;
case plcDataType.Int:
case plcDataType.DInt:
_ = int.TryParse(strValue, out currInt);
answ = currInt;
break;
case plcDataType.Real:
_ = double.TryParse(strValue, out currDouble);
answ = currDouble;
break;
case plcDataType.String:
default:
answ = strValue;
break;
}
return answ;
}
}
///
/// Valore float
///
public float floatVal { get; set; } = 0;
///
/// Valore intero
///
public int intVal { get; set; } = 0;
///
/// Valore in formato stringa (che può venire customizzato)
///
public string strValue { get; set; } = "";
///
/// Data-Ora riferimento campione
///
public DateTime timeStamp { get; set; } = DateTime.Now;
///
/// Nome Macchina
///
public string vcMachine { get; set; } = "";
///
/// Nome della Var Casuale
///
public string vcName { get; set; } = "";
///
/// Tipo di valore gestito
///
[JsonConverter(typeof(StringEnumConverter))]
public plcDataType vcType { get; set; } = plcDataType.Int;
#endregion Public Properties
}
///
/// Aggregazione dati VC
///
public class tsGrouped
{
#region Public Properties
///
/// Valore medio (NON definito)
///
public object avgValue { get; set; }
///
/// Periodo di aggregazione di riferimento
///
public timeWindow period { get; set; } = timeWindow.hour;
///
/// Campioni effettivi nel periodo
///
public List samples { get; set; }
///
/// Data-Ora riferimento campione
///
public DateTime timeStamp { get; set; } = DateTime.Now;
///
/// Unità di Misura
///
public string UM { get; set; } = "#";
///
/// Nome Macchina
///
public string vcMachine { get; set; } = "";
///
/// Nome della Var Casuale
///
public string vcName { get; set; } = "";
#endregion Public Properties
}
///
/// Classe oggetto statistiche sui dati
///
public class varStats
{
#region Public Properties
///
/// Valore medio/mediano
///
public float avg { get; set; } = 0;
///
/// Valore max
///
public float max { get; set; } = 0;
///
/// Valore min
///
public float min { get; set; } = 0;
///
/// Num record
///
public int numRec { get; set; } = 0;
///
/// Nome della Variabile tracciata
///
public string varName { get; set; } = "";
#endregion Public Properties
}
}