Files
mapo-core/IobConf.Core/IobConfTree.cs
T

161 lines
4.5 KiB
C#

using Newtonsoft.Json;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization;
using static IobConf.Core.Enum;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace IobConf.Core
{
/// <summary>
/// Albero configurazione globale IOB
/// </summary>
[Serializable]
public class IobConfTree
{
/// <summary>
/// Init classe configurazione
/// </summary>
public IobConfTree()
{ }
/// <summary>
/// Codice Cliente/Installazione
/// </summary>
public string Customer { get; set; } = "SteamWare";
/// <summary>
/// Codice univoco IOB
/// </summary>
public string CodIOB { get; set; } = "ND";
/// <summary>
/// Costruttore
/// </summary>
public string Vendor { get; set; } = "ACME";
/// <summary>
/// Codice modello
/// </summary>
public string Model { get; set; } = "NONE";
/// <summary>
/// Nome file di configurazione
/// </summary>
public string ConfFileName { get; set; } = "";
/// <summary>
/// TIpologia generale dell'adapter
/// </summary>
public ComLayer GeneralCom { get; set; } = ComLayer.ND;
/// <summary>
/// Tipo Adapter specifico (implementazione)
/// </summary>
public AdapterType IobType { get; set; } = AdapterType.ND;
/// <summary>
/// Setup server MP da chiamare
/// </summary>
public ServerMapo ServerMES { get; set; } = new ServerMapo();
/// <summary>
/// Setup info verso IOB-MAN
/// </summary>
public RedisPub IobManConf { get; set; } = new RedisPub();
/// <summary>
/// Dati configurazione CNC
/// </summary>
public CncConf CncData { get; set; } = new CncConf();
/// <summary>
/// Setup processing dati in ingresso (es: blink segnali)
/// </summary>
public InputSignalProcess InputDataProc { get; set; } = new InputSignalProcess();
/// <summary>
/// Dati relativi ai parametri gestione tempo ciclo
/// </summary>
public TCData TempoCiclo { get; set; } = new TCData();
/// <summary>
/// Dizionario dei parametri opzionali
/// </summary>
public Dictionary<string, string> OptPar { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Versione software IOB
/// </summary>
public string ReleaseVers { get; set; } = "0.0.0.0";
#region Metodi Serializzazione
/// <summary>
/// Restituisce conf serializzata in formato JSON
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public string getJson()
{
string rawdata = JsonConvert.SerializeObject(this, Formatting.Indented);
return rawdata;
}
/// <summary>
/// Restituisce conf serializzata in formato YAML
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public string getYaml()
{
var serializer = new SerializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var rawdata = serializer.Serialize(this);
return rawdata;
}
#endregion
#region Metodi Load/Save
/// <summary>
/// Scrive conf serializzata in formato JSON
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public bool SaveJson(string filePath)
{
bool answ = false;
try
{
string rawdata = getJson();
File.WriteAllText(filePath, rawdata);
answ = true;
}
catch
{ }
return answ;
}
/// <summary>
/// Scrive conf serializzata in formato YAML
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public bool SaveYaml(string filePath)
{
bool answ = false;
try
{
var rawdata = getYaml();
File.WriteAllText(filePath, rawdata);
answ = true;
}
catch
{ }
return answ;
}
#endregion
}
}