From 1c0f161640564cdecd780f1e25dbb4a1facf13bd Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 18 Sep 2020 09:36:02 +0200 Subject: [PATCH] =?UTF-8?q?update=20config=20controller=20x=20gestione=20u?= =?UTF-8?q?nit=C3=A0=20di=20misura?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Thermo.Active.Config/ServerConfig.cs | 3 ++- Thermo.Active.Config/ServerConfigController.cs | 9 ++++++++- Thermo.Active.NC/NcAdapter.cs | 15 ++++++++++++++- .../Controllers/WebApi/ConfigurationController.cs | 2 +- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Thermo.Active.Config/ServerConfig.cs b/Thermo.Active.Config/ServerConfig.cs index 2f504829..6ead2f2e 100644 --- a/Thermo.Active.Config/ServerConfig.cs +++ b/Thermo.Active.Config/ServerConfig.cs @@ -11,7 +11,8 @@ namespace Thermo.Active.Config public static ServerConfigModel ServerStartupConfig; public static NcConfigModel NcConfig; public static List ExtSoftwaresConfig; - public static Dictionary additionalParametersConfig; + public static Dictionary AdditionalParametersConfig; + public static Dictionary UnitMeasuresConfig; public static SoftwareProdConfigModel SoftwareProdConfig; public static MachineModel MachineConfig; public static List MaintenancesConfig; diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 679252b3..d16e497b 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -372,11 +372,18 @@ namespace Thermo.Active.Config }).ToList(); // carico additionals parameters - additionalParametersConfig = xmlConfigFile + AdditionalParametersConfig = xmlConfigFile .Descendants("additionalParameters") .Elements("entry") .Select(x => new KeyValuePair(x.Element("key").Value,x.Element("value").Value)) .ToDictionary(x => x.Key, x => x.Value); + + // carico unità di misura... + UnitMeasuresConfig = xmlConfigFile + .Descendants("unitOfMeasures") + .Elements("unitOfMeasure") + .Select(x => new KeyValuePair(Convert.ToInt32(x.Attribute("id").Value), x.Attribute("value").Value)) + .ToDictionary(x => x.Key, x => x.Value); } private static void ReadAreaConfig() diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index c4484c8f..c7082267 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -1836,7 +1836,7 @@ namespace Thermo.Active.NC Id = item.Id, Range = currRange, Status = currStatus, - UnitMeasure = $"{paramPLC.UnitMeasure}", + UnitMeasure = getUM(paramPLC.UnitMeasure), ValueAct = paramPLC.ValueAct / item.ScaleFactor, SetpointHMI = paramPLC.SetpointHMI / item.ScaleFactor, SetpointPLC = paramPLC.SetpointPLC / item.ScaleFactor, @@ -1884,6 +1884,19 @@ namespace Thermo.Active.NC return NO_ERROR; } + + protected string getUM(int um) + { + // default: no translation... + string answ = $"{um}"; + // cerco in dictionary... + if (UnitMeasuresConfig.ContainsKey(um)) + { + answ = UnitMeasuresConfig[um]; + } + return answ; + } + /// /// Recipe Parameters write to PLC (only SetpointHMI) /// diff --git a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs index ec23e712..10ae29d5 100644 --- a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs +++ b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs @@ -45,7 +45,7 @@ namespace Thermo.Active.Controllers.WebApi ProdEnabled = SoftwareProdConfig.Enabled, ProdPath = SoftwareProdConfig.Path, ExtSoftwares = ExtSoftwaresConfig, - AdditionalParameters = additionalParametersConfig, + AdditionalParameters = AdditionalParametersConfig, Autorun = ServerStartupConfig.AutoOpenCmsClient, EditorPath = ServerStartupConfig.TextEditorPath, MgiOption = NcConfig.MgiOption, diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index be63593c..d1f112ba 100644 --- a/Thermo.Active/Properties/AssemblyInfo.cs +++ b/Thermo.Active/Properties/AssemblyInfo.cs @@ -30,4 +30,4 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.15.83")] \ No newline at end of file +[assembly: AssemblyVersion("0.15.85")] \ No newline at end of file