Aggiunta preliminare progetto IobConf globale x IOB-WIN da singolo file
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.12.35527.113
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgwConf.Iob", "EgwConf.Iob\EgwConf.Iob.csproj", "{26CD6258-206B-4FB4-B9FB-1C573C930919}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{26CD6258-206B-4FB4-B9FB-1C573C930919}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{26CD6258-206B-4FB4-B9FB-1C573C930919}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{26CD6258-206B-4FB4-B9FB-1C573C930919}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{26CD6258-206B-4FB4-B9FB-1C573C930919}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {E2472E21-58D3-4EAD-BC4A-BC3915B18BEF}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
public class InputSignalProcess
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Maschera di filtro blink, INT corrispondente ai BIT da filtrare, ad es
|
||||||
|
/// 11111111 = 255
|
||||||
|
/// 00010110 = 22
|
||||||
|
/// 00000111 = 7
|
||||||
|
/// </summary>
|
||||||
|
public int BlinkFilterMask { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Numero di cicli per cui effettuare il mascheramento dei valori (sul fronte di discesa)
|
||||||
|
/// </summary>
|
||||||
|
public int BlinkMaxCounter { get; set; } = 10;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Set comandi URI x chiamate server
|
||||||
|
/// </summary>
|
||||||
|
public class CmdUri
|
||||||
|
{
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Init classe gestione comandi
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="baseURI"></param>
|
||||||
|
public CmdUri(string baseURI)
|
||||||
|
{
|
||||||
|
BaseUri = baseURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Constructors
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x USER LOG - salvataggio parametri extra sistema MAPO
|
||||||
|
/// </summary>
|
||||||
|
public string ULog { get; set; } = "IOB/ulog/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x USER LOG - salvataggio parametri extra sistema MAPO in modalità JSON
|
||||||
|
/// payload come lista
|
||||||
|
/// </summary>
|
||||||
|
public string ULogJson { get; set; } = "IOB/ulogJson/";
|
||||||
|
|
||||||
|
#endregion Public Properties
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recupera path/URI comando richiesto (SE disponibile)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetCommand(string key)
|
||||||
|
{
|
||||||
|
// default ad implicito...
|
||||||
|
string answ = $"{BaseUri}/{key}/";
|
||||||
|
if (CurrSetup.ContainsKey(key))
|
||||||
|
{
|
||||||
|
answ = CurrSetup[key];
|
||||||
|
}
|
||||||
|
return answ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string> StdCommands()
|
||||||
|
{
|
||||||
|
CurrSetup = new Dictionary<string, string>();
|
||||||
|
CurrSetup.Add("Alive", "IOB");
|
||||||
|
CurrSetup.Add("Base", "IOB/input/");
|
||||||
|
CurrSetup.Add("BaseJson", "IOB/evListJson/");
|
||||||
|
CurrSetup.Add("RawTransfJson", "IOB/rawTransfJson/");
|
||||||
|
CurrSetup.Add("Enabled", "IOB/enabled/");
|
||||||
|
CurrSetup.Add("Flog", "IOB/flog/");
|
||||||
|
CurrSetup.Add("FlogJson", "IOB/flogJson/");
|
||||||
|
CurrSetup.Add("ForcleSplitOdl", "IOB/forceSplitOdlFull/");
|
||||||
|
CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/");
|
||||||
|
CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/");
|
||||||
|
CurrSetup.Add("Reboot", "IOB/sendReboot.aspx?idxMacchina=/");
|
||||||
|
// riordino
|
||||||
|
CurrSetup = CurrSetup.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
return CurrSetup;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Protected Properties
|
||||||
|
|
||||||
|
protected string BaseUri { get; set; } = "IOB";
|
||||||
|
protected Dictionary<string, string> CurrSetup { get; set; } = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
#endregion Protected Properties
|
||||||
|
|
||||||
|
#if false
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x check ALIVE
|
||||||
|
/// </summary>
|
||||||
|
public string Alive { get; set; } = "IOB";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comando base x INPUT
|
||||||
|
/// </summary>
|
||||||
|
public string Base { get; set; } = "IOB/input/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x INPUT in modalità JSON payload come lista
|
||||||
|
/// </summary>
|
||||||
|
public string BaseJson { get; set; } = "IOB/evListJson/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x Raw Transf LOG - salvataggio valori generici in modalità JSON payload
|
||||||
|
/// come lista
|
||||||
|
/// </summary>
|
||||||
|
public string RawTransfJson { get; set; } = "IOB/rawTransfJson/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x check ENABLED
|
||||||
|
/// </summary>
|
||||||
|
public string Enabled { get; set; } = "IOB/enabled/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x LOG di FLUSSO generico - salvataggio parametri extra sistema MAPO
|
||||||
|
/// </summary>
|
||||||
|
public string Flog { get; set; } = "IOB/flog/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x LOG di FLUSSO generico - salvataggio parametri extra sistema MAPO in
|
||||||
|
/// modalità JSON payload come lista
|
||||||
|
/// </summary>
|
||||||
|
public string FlogJson { get; set; } = "IOB/flogJson/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comando base x ForceSplitODL (check avvio ODL)
|
||||||
|
/// </summary>
|
||||||
|
public string ForcleSplitOdl { get; set; } = "IOB/forceSplitOdlFull/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x check IDLE time IOB
|
||||||
|
/// </summary>
|
||||||
|
public string IdleTime { get; set; } = "IOB/getIdlePeriod/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x check avvio ODL
|
||||||
|
/// </summary>
|
||||||
|
public string OdlStarted { get; set; } = "IOB/getCurrOdlStart/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// comando base x comando reboot
|
||||||
|
/// </summary>
|
||||||
|
public string Reboot { get; set; } = "sendReboot.aspx?idxMacchina=";
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
public class CncConf
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Init classe default
|
||||||
|
/// </summary>
|
||||||
|
public CncConf()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indirizzo Ip del CNC Controllato
|
||||||
|
/// </summary>
|
||||||
|
public string IpAddr { get; set; } = "127.0.0.1";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Porta del CNC Controllato
|
||||||
|
/// </summary>
|
||||||
|
public string Port { get; set; } = "0";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Timeout test PING
|
||||||
|
/// </summary>
|
||||||
|
public int pingMsTimeout { get; set; } = 500;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TipoCPU (es: Siemens)
|
||||||
|
/// </summary>
|
||||||
|
public string CpuType { get; set; } = "ND";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rack (Siemens S7)
|
||||||
|
/// </summary>
|
||||||
|
public short Rack { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Slot (Siemens S7)
|
||||||
|
/// </summary>
|
||||||
|
public short Slot { get; set; } = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{26CD6258-206B-4FB4-B9FB-1C573C930919}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>EgwConf.Iob</RootNamespace>
|
||||||
|
<AssemblyName>EgwConf.Iob</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NLog.5.3.4\lib\net46\NLog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="YamlDotNet, Version=16.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\YamlDotNet.16.3.0\lib\netstandard2.0\YamlDotNet.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="BlinkSignal.cs" />
|
||||||
|
<Compile Include="CmdUri.cs" />
|
||||||
|
<Compile Include="CncConf.cs" />
|
||||||
|
<Compile Include="EnumConf.cs" />
|
||||||
|
<Compile Include="IniFile.cs" />
|
||||||
|
<Compile Include="IobConfTree.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="RedisPub.cs" />
|
||||||
|
<Compile Include="ServerMapo.cs" />
|
||||||
|
<Compile Include="TCData.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,324 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
public class EnumConf
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Macro tipologia sistema di comunicazione (macro-adapter)
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum ComLayer
|
||||||
|
{
|
||||||
|
ND = 0,
|
||||||
|
Beckhoff,
|
||||||
|
Fanuc,
|
||||||
|
File,
|
||||||
|
SqlServer,
|
||||||
|
IobPi,
|
||||||
|
Kawasaki,
|
||||||
|
ModBus,
|
||||||
|
MtConnect,
|
||||||
|
Omron,
|
||||||
|
OpcUa,
|
||||||
|
Osai,
|
||||||
|
Ping,
|
||||||
|
Siemens,
|
||||||
|
WPS
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tipologia di adapters ammessi
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum AdapterType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Adapter non specificato
|
||||||
|
/// </summary>
|
||||||
|
ND = 0,
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
/// 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 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 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 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 BLM / Mecart
|
||||||
|
/// </summary>
|
||||||
|
OpcUaEwonBLM,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adapter OPC-UA per Ewon x Monti / Tenditalia
|
||||||
|
/// </summary>
|
||||||
|
OpcUaEwonMonti,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adapter OPC-UA per Ewon x Mecolpress / Stil
|
||||||
|
/// </summary>
|
||||||
|
OpcUaEwonMecolpress,
|
||||||
|
|
||||||
|
/// <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 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 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)
|
||||||
|
/// </summary>
|
||||||
|
SIEMENS_FAPE,
|
||||||
|
|
||||||
|
/// <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>
|
||||||
|
/// Metodi di WPS WebPageScraping (es x compressori Atlas Copco)
|
||||||
|
/// </summary>
|
||||||
|
WPS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,316 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new INI file to store or load data
|
||||||
|
/// </summary>
|
||||||
|
public class IniFile
|
||||||
|
{
|
||||||
|
#region Public Fields
|
||||||
|
|
||||||
|
public string FileName;
|
||||||
|
|
||||||
|
#endregion Public Fields
|
||||||
|
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <PARAM name="INIPath"></PARAM>
|
||||||
|
public IniFile(string INIPath)
|
||||||
|
{
|
||||||
|
FileName = INIPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Constructors
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a key from section
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
public void IniDeleteKey(string Section, string Key)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(Section, Key, "", FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Completely remove one section
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
public void IniDeleteSection(string Section)
|
||||||
|
{
|
||||||
|
WritePrivateProfileSection(Section, "", FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return true if section exists
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IniSectionExists(string Section)
|
||||||
|
{
|
||||||
|
int bytesReturned = 0;
|
||||||
|
const int bufferSize = 2048; // max is 32767
|
||||||
|
IntPtr pReturnedString = Marshal.AllocCoTaskMem(bufferSize);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bytesReturned = GetPrivateProfileSection(Section, pReturnedString, bufferSize, FileName);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FreeCoTaskMem(pReturnedString);
|
||||||
|
}
|
||||||
|
return (bytesReturned > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a boolean
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ReadBoolean(string Section, string Key)
|
||||||
|
{
|
||||||
|
return (ReadInteger(Section, Key, 0) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a boolean with default value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <param name="DefaultVal"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ReadBoolean(string Section, string Key, bool DefaultVal)
|
||||||
|
{
|
||||||
|
int v = DefaultVal ? 1 : 0;
|
||||||
|
return (ReadInteger(Section, Key, v) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read an integer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int ReadInteger(string Section, string Key)
|
||||||
|
{
|
||||||
|
return GetPrivateProfileInt(Section, Key, 0, FileName);
|
||||||
|
//System.Convert.ToInt32(IniReadValue(Section, Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read an integer. If not found use default value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <param name="DefaultVal"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int ReadInteger(string Section, string Key, int DefaultVal)
|
||||||
|
{
|
||||||
|
//int temp = System.Convert.ToInt32(IniReadString(Section, Key, Convert.ToString(DefaultVal)));
|
||||||
|
//return temp;
|
||||||
|
return GetPrivateProfileInt(Section, Key, DefaultVal, FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a complete section (keys=values)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// Section name
|
||||||
|
/// <returns>
|
||||||
|
/// restituisce delle stringhe keys=values da suddividere appunto come key/val successivamente
|
||||||
|
/// </returns>
|
||||||
|
public string[] ReadSection(string Section)
|
||||||
|
{
|
||||||
|
const int bufferSize = 2048; // max is 32767
|
||||||
|
|
||||||
|
StringBuilder returnedString = new StringBuilder();
|
||||||
|
|
||||||
|
IntPtr pReturnedString = Marshal.AllocCoTaskMem(bufferSize);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int bytesReturned = GetPrivateProfileSection(Section, pReturnedString, bufferSize, FileName);
|
||||||
|
if (bytesReturned > 0)
|
||||||
|
{
|
||||||
|
//bytesReturned -1 to remove trailing \0
|
||||||
|
for (int i = 0; i < bytesReturned - 1; i++)
|
||||||
|
{
|
||||||
|
var currPointer = IntPtr.Add(pReturnedString, i);
|
||||||
|
var currChar = (char)Marshal.ReadByte(currPointer);
|
||||||
|
returnedString.Append(currChar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Marshal.FreeCoTaskMem(pReturnedString);
|
||||||
|
}
|
||||||
|
|
||||||
|
string sectionData = returnedString.ToString();
|
||||||
|
return sectionData.Split('\0');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read data from the Ini file
|
||||||
|
/// </summary>
|
||||||
|
/// <PARAM name="Section"></PARAM>
|
||||||
|
/// <PARAM name="Key"></PARAM>
|
||||||
|
/// <PARAM name="Path"></PARAM>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ReadString(string Section, string Key)
|
||||||
|
{
|
||||||
|
StringBuilder temp = new StringBuilder(255);
|
||||||
|
int i = GetPrivateProfileString(Section, Key, "", temp, 255, FileName);
|
||||||
|
return temp.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read a string. If not found use default value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <param name="DefaultVal"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ReadString(string Section, string Key, string DefaultVal)
|
||||||
|
{
|
||||||
|
string temp = ReadString(Section, Key);
|
||||||
|
if (temp == "") temp = DefaultVal;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return true if value exists
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ValueExists(string Section, string Key)
|
||||||
|
{
|
||||||
|
StringBuilder temp = new StringBuilder(255);
|
||||||
|
int i = GetPrivateProfileString(Section, Key, "", temp, 255, FileName);
|
||||||
|
return (i > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write a boolean value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <param name="Value"></param>
|
||||||
|
public void WriteBoolean(string Section, string Key, bool Value)
|
||||||
|
{
|
||||||
|
int flag = Value ? 1 : 0;
|
||||||
|
WriteString(Section, Key, Convert.ToString(flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write a double value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <param name="Value"></param>
|
||||||
|
public void WriteDouble(string Section, string Key, double Value)
|
||||||
|
{
|
||||||
|
WriteString(Section, Key, Convert.ToString(Value, NumberFormatInfo.InvariantInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write an integer value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section"></param>
|
||||||
|
/// <param name="Key"></param>
|
||||||
|
/// <param name="Value"></param>
|
||||||
|
public void WriteInteger(string Section, string Key, int Value)
|
||||||
|
{
|
||||||
|
WriteString(Section, Key, Convert.ToString(Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write data to the INI file
|
||||||
|
/// </summary>
|
||||||
|
/// <PARAM name="Section"></PARAM>
|
||||||
|
/// Section name
|
||||||
|
/// <PARAM name="Key"></PARAM>
|
||||||
|
/// Key Name
|
||||||
|
/// <PARAM name="Value"></PARAM>
|
||||||
|
/// Value Name
|
||||||
|
public void WriteString(string Section, string Key, string Value)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(Section, Key, Value, FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
|
||||||
|
#region Private Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetPrivateProfileInt: import windows dll functions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="def"></param>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("kernel32")]
|
||||||
|
private static extern int GetPrivateProfileInt(string section, string key, int def, string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetPrivateProfileSection: import windows dll functions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section"></param>
|
||||||
|
/// <param name="retVal"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("kernel32")]
|
||||||
|
private static extern int GetPrivateProfileSection(string section, IntPtr retVal, uint size, string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetPrivateProfileString: import windows dll functions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="def"></param>
|
||||||
|
/// <param name="retVal"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("kernel32")]
|
||||||
|
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WritePrivateProfileSection: import windows dll functions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("kernel32")]
|
||||||
|
private static extern bool WritePrivateProfileSection(string section, string value, string filePath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WritePrivateProfileString: import windows dll functions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="val"></param>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("kernel32", CharSet = CharSet.Auto, BestFitMapping = false)]
|
||||||
|
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||||
|
|
||||||
|
#endregion Private Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,311 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
using NLog;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
using static EgwConf.Iob.EnumConf;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
// <Auto-Generated>
|
||||||
|
// This is here so CodeMaid doesn't reorganize this document
|
||||||
|
// </Auto-Generated>
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Albero configurazione globale IOB in formato serializable
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class IobConfTree
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Init classe configurazione
|
||||||
|
/// </summary>
|
||||||
|
public IobConfTree()
|
||||||
|
{
|
||||||
|
Log = LogManager.GetCurrentClassLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restituisce un oggetto di conf leggendo INI ed effettuando conversione
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iniFilePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IobConfTree LoadFromINI(string iniFilePath)
|
||||||
|
{
|
||||||
|
IobConfTree newConfObj = new IobConfTree();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// leggo file INI
|
||||||
|
IniFile fIni = new IniFile(iniFilePath);
|
||||||
|
string codIob = Path.GetFileNameWithoutExtension(iniFilePath);
|
||||||
|
|
||||||
|
// effettuo conversione...
|
||||||
|
|
||||||
|
// Dati generali (vendor, modello...)
|
||||||
|
newConfObj.CodIOB = fIni.ReadString("IOB", "IOB_NAME", codIob);
|
||||||
|
newConfObj.Vendor = fIni.ReadString("MACHINE", "VENDOR", "STEAMWARE");
|
||||||
|
newConfObj.Model = fIni.ReadString("MACHINE", "MODEL", "NONE");
|
||||||
|
newConfObj.ConfFileName = Path.GetFileName(iniFilePath);
|
||||||
|
|
||||||
|
// tipo adapter// verifico tipo adapter
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newConfObj.IobType = (AdapterType)Enum.Parse(typeof(AdapterType), fIni.ReadString("IOB", "CNCTYPE", "ND"));
|
||||||
|
}
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
newConfObj.IobType = AdapterType.ND;
|
||||||
|
string rawVal = fIni.ReadString("IOB", "CNCTYPE", "DEMO");
|
||||||
|
newConfObj.lgError($"Eccezione in conversione tipo adapter: richiesto {rawVal} | tipo non codificato...{Environment.NewLine}{exc}");
|
||||||
|
}
|
||||||
|
newConfObj.GeneralCom = (ComLayer)Enum.Parse(typeof(ComLayer), fIni.ReadString("IOB", "CNCFAMILY", "ND"));
|
||||||
|
|
||||||
|
// CNC
|
||||||
|
newConfObj.CncData.pingMsTimeout = fIni.ReadInteger("IOB", "PING_MS_TIMEOUT", 500);
|
||||||
|
newConfObj.CncData.IpAddr = fIni.ReadString("CNC", "IP", "::1");
|
||||||
|
newConfObj.CncData.Port = fIni.ReadString("CNC", "PORT", "0");
|
||||||
|
newConfObj.CncData.CpuType = fIni.ReadString("CNC", "CPUTYPE", "");
|
||||||
|
newConfObj.CncData.Rack = (short)fIni.ReadInteger("CNC", "RACK", 0);
|
||||||
|
newConfObj.CncData.Slot = (short)fIni.ReadInteger("CNC", "SLOT", 0);
|
||||||
|
|
||||||
|
// BLINK
|
||||||
|
newConfObj.InputDataProc.BlinkMaxCounter = Convert.ToInt32(fIni.ReadString("BLINK", "MAX_COUNTER_BLINK", "1"));
|
||||||
|
newConfObj.InputDataProc.BlinkFilterMask = Convert.ToInt32(fIni.ReadString("BLINK", "BLINK_FILT", "0"));
|
||||||
|
newConfObj.TempoCiclo.MaxDelayFactor = Convert.ToDouble(fIni.ReadString("OPTPAR", "TC_MAX_TC_FACTOR", "1.2").Replace(".", ","));
|
||||||
|
newConfObj.TempoCiclo.Lambda = Convert.ToDouble(fIni.ReadString("OPTPAR", "TC_LAMBDA", "0.5").Replace(".", ","));
|
||||||
|
newConfObj.TempoCiclo.MaxIncrPz = Convert.ToDouble(fIni.ReadString("OPTPAR", "TC_MAX_INCR", "5").Replace(".", ","));
|
||||||
|
|
||||||
|
// Server
|
||||||
|
string MpIp = fIni.ReadString("SERVER", "MPIP", "::1");
|
||||||
|
if (!string.IsNullOrEmpty(MpIp))
|
||||||
|
{
|
||||||
|
newConfObj.ServerMES.Transport = MpIp.StartsWith("https://") ? "https" : "http";
|
||||||
|
newConfObj.ServerMES.IpAddr = MpIp.Replace($"{newConfObj.ServerMES.Transport}://", ""); // tolgo http/https...
|
||||||
|
}
|
||||||
|
|
||||||
|
// Altro (versione, ...)
|
||||||
|
newConfObj.ReleaseVers = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}";
|
||||||
|
newConfObj.IobManConf.MinDeltaSec = fIni.ReadInteger("IOB", "MinDeltaSec", 6);
|
||||||
|
|
||||||
|
// OptPar
|
||||||
|
Dictionary<string, string> optParRead = new Dictionary<string, string>();
|
||||||
|
string[] optParRows = fIni.ReadSection("OPTPAR");
|
||||||
|
if (optParRows.Length > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string[] kvp;
|
||||||
|
foreach (var item in optParRows)
|
||||||
|
{
|
||||||
|
kvp = item.Split('=');
|
||||||
|
optParRead.Add(kvp[0], kvp[1]);
|
||||||
|
}
|
||||||
|
//newConfObj.lgDebug($"Caricati {optParRead.Count} parametri opzionali da OPTPAR");
|
||||||
|
}
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
newConfObj.lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// riordino alfabeticamente
|
||||||
|
optParRead = optParRead.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
newConfObj.OptPar = optParRead;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
return newConfObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Logging
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// oggetto logging
|
||||||
|
/// </summary>
|
||||||
|
protected Logger Log;// = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="txt2log"></param>
|
||||||
|
protected void lgDebug(string txt2log)
|
||||||
|
{
|
||||||
|
Log.Factory.Configuration.Variables["codIOB"] = this.CodIOB;
|
||||||
|
Log.Debug(txt2log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="txt2log"></param>
|
||||||
|
protected void lgError(string txt2log)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(txt2log))
|
||||||
|
{
|
||||||
|
Log.Factory.Configuration.Variables["codIOB"] = this.CodIOB;
|
||||||
|
Log.Error(txt2log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="txt2log"></param>
|
||||||
|
protected void lgInfo(string txt2log)
|
||||||
|
{
|
||||||
|
Log.Factory.Configuration.Variables["codIOB"] = this.CodIOB;
|
||||||
|
Log.Info(txt2log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="txt2log"></param>
|
||||||
|
protected void lgTrace(string txt2log)
|
||||||
|
{
|
||||||
|
Log.Factory.Configuration.Variables["codIOB"] = this.CodIOB;
|
||||||
|
Log.Trace(txt2log);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("EgwConf.Iob")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("EgwConf.Iob")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("26cd6258-206b-4fb4-b9fb-1c573c930919")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Classe setup comunicazione server REDIS
|
||||||
|
/// </summary>
|
||||||
|
public class RedisPub
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Minimo delta in sec x considerare variazioni informazioni inviate ad IOB-MAN via redis
|
||||||
|
/// </summary>
|
||||||
|
public int MinDeltaSec { get; set; } = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
public class ServerMapo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indica il metodo di trasporto http/https
|
||||||
|
/// </summary>
|
||||||
|
public string Transport { get; set; } = "http";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indirizzo IP server
|
||||||
|
/// </summary>
|
||||||
|
public string IpAddr { get; set; } = "127.0.0.1";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// URL Base del server applicativo
|
||||||
|
/// </summary>
|
||||||
|
public string BaseAppUrl { get; set; } = "/MP/IO/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dizionario comandi configurati
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> Commands { get; set; } = new CmdUri("IOB").StdCommands();
|
||||||
|
//public CmdUri Commands { get; set; } = new CmdUri();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Installazione di riferimento
|
||||||
|
/// </summary>
|
||||||
|
public string ClientInstall { get; set; } = "SW";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EgwConf.Iob
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Classe gestione parametri legati a gestioen TempoCiclo
|
||||||
|
/// </summary>
|
||||||
|
public class TCData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fattore Lambda (innovazione) per calcolo EWMA valore TCiclo corrente
|
||||||
|
/// </summary>
|
||||||
|
public double Lambda { get; set; } = 0.4;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fattore massimo ammesso di delay x il TCiclo
|
||||||
|
/// </summary>
|
||||||
|
public double MaxDelayFactor { get; set; } = 1.2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Incremento massimo pezzi per cui fare calcolo del tempociclo attuale
|
||||||
|
/// </summary>
|
||||||
|
public double MaxIncrPz { get; set; } = 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
|
||||||
|
<package id="NLog" version="5.3.4" targetFramework="net462" />
|
||||||
|
<package id="YamlDotNet" version="16.3.0" targetFramework="net462" />
|
||||||
|
</packages>
|
||||||
Reference in New Issue
Block a user