From 8fdf8b74c4789853424199e21c4d2771257dfe38 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 1 Feb 2021 19:45:09 +0100 Subject: [PATCH 01/25] Bozza oggetti DI/O --- .../DTOModels/ThIO/DTODigInModel.cs | 47 ++++++++++++++++ .../DTOModels/ThIO/DTODigOutModel.cs | 56 +++++++++++++++++++ .../DTOModels/ThIO/DTOInOutConfigModel.cs | 12 ++++ 3 files changed, 115 insertions(+) create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs new file mode 100644 index 00000000..be5fcba8 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTODigInModel + { + public int Block { get; set; } = 0; + public int Num { get; set; } = 0; + public string Page { get; set; } = "0"; + public string Wire { get; set; } = "0"; + public string Profinet { get; set; } = ""; + public string Label { get; set; } = ""; + public bool Value { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DTODigInModel item)) + return false; + + if (Block != item.Block) + return false; + if (Num != item.Num) + return false; + if (Page != item.Page) + return false; + if (Wire!= Wire) + return false; + if (Profinet != item.Profinet) + return false; + if (Label != item.Label) + return false; + if (Value != item.Value) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs new file mode 100644 index 00000000..4f1e84cf --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTODigOutModel + { + public int Block { get; set; } = 0; + public int Num { get; set; } = 0; + public string Page { get; set; } = "0"; + public string Wire { get; set; } = "0"; + public string Profinet { get; set; } = ""; + public string Label { get; set; } = ""; + public bool Value { get; set; } = false; + public bool ForceZero { get; set; } = false; + public bool ForceOne { get; set; } = false; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DTODigOutModel item)) + return false; + + if (Block != item.Block) + return false; + if (Num != item.Num) + return false; + if (Page != item.Page) + return false; + if (Wire != Wire) + return false; + if (Profinet != item.Profinet) + return false; + if (Label != item.Label) + return false; + if (Value != item.Value) + return false; + if (ForceZero != item.ForceZero) + return false; + if (ForceOne != item.ForceOne) + return false; + if (IsForced != item.IsForced) + return false; + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs new file mode 100644 index 00000000..b2375c3a --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + class DTOInOutConfigModel + { + } +} From dd869ef96654e9c7f8c79dfeff6dc25f60630d85 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 1 Feb 2021 19:45:25 +0100 Subject: [PATCH 02/25] Sim CycleLog in UTH --- Thermo.Active.Config/Config/serverConfig.xml | 2 +- .../Thermo.Active.Model.csproj | 3 + Thermo.Active.NC/NcAdapter.cs | 128 ++++++++++++++++++ .../WebApi/ThermocameraController.cs | 2 +- .../WebApi/UnderTheHoodController.cs | 56 ++++++++ Thermo.Active/Thermo.Active.csproj | 1 + 6 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs diff --git a/Thermo.Active.Config/Config/serverConfig.xml b/Thermo.Active.Config/Config/serverConfig.xml index 6301f517..fac4f66d 100644 --- a/Thermo.Active.Config/Config/serverConfig.xml +++ b/Thermo.Active.Config/Config/serverConfig.xml @@ -4,7 +4,7 @@ S7NET false - 192.168.0.1 + 192.168.0.102 102 Thermo 2020 C:\CMS\Recipes\ diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 53f0a8d6..5ccaec20 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -112,6 +112,9 @@ + + + diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 4cdbb667..1b85a73c 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -1456,6 +1456,134 @@ namespace Thermo.Active.NC return libraryError; } + + /// + /// Legge dal PLC elenco di eventi LOG del ciclo e li presenta + /// + /// Oggetto elenco elementi LOG registrati da macchina + /// + public CmsError GetCycleLog(out Dictionary machineLog) + { + CmsError libraryError = NO_ERROR; + machineLog = new Dictionary(); + + if (false) + { + // recupero l'oggetto dall'NC + + // effettuo traduzione +#if false + // overview di base: ultima salvata... + var err2fix = new Dictionary(); + + // leggo la ricetta dal PLC! + var currRecipe = new Dictionary(); + libraryError = ReadFullRecipe(out currRecipe); + if (libraryError.IsError()) + return libraryError; + + // leggo l'intero array delle DB... QUI FAKE sulle DB configurate... + List recipeConfig = RecipeConfig.Select(x => new DTORecipeConfigModel() + { + Id = x.Id, + ScaleFactor = x.ScaleFactor, + NumDec = x.NumDec, + Category = x.Category.ToString(), + SubCategory_1 = x.SubCategory_1, + SubCategory_2 = x.SubCategory_2, + Name = x.Name, + Description = x.Description, + Format = x.Format, + Label = $"{x.Category}_{x.SubCategory_1}_{x.SubCategory_2}_{x.Name}".Replace("__", "_").Replace("__", "_").ToLower(), + EnumVal = x.EnumVal + }).ToList(); + + RecipeCatStatus currStatus = RecipeCatStatus.Unchanged; + + // da conf ricetta --> se ci sono li leggo da li... + if (NcFileAdapter.RecipeLiveData.RecipeOverview != null) + { + currOverview = NcFileAdapter.RecipeLiveData.RecipeOverview; + } + + // verifico eventualmente se mancasse qualcosa... + bool changed = false; + foreach (var item in recipeConfig) + { + if (!currOverview.ContainsKey(getRecipeSection(item.Category))) + { + currOverview.Add(getRecipeSection(item.Category), RecipeCatStatus.Unchanged); + changed = true; + } + } + + // ricerco SE co fossero errori --> reset come changedOK + foreach (var item in currOverview) + { + if (item.Value == RecipeCatStatus.HasError) + err2fix.Add(item.Key, RecipeCatStatus.ChangedOk); + } + foreach (var item in err2fix) + { + currOverview[item.Key] = item.Value; + changed = true; + } + + // se cambiato --> salvo in live data... + if (changed) + { + NcFileAdapter.RecipeLiveData.RecipeOverview = currOverview; + } + + // ORA percorro conf ricetta x cercare eventuali ERRORI...... + foreach (var item in recipeConfig) + { + currStatus = currOverview[getRecipeSection(item.Category)]; + + // se lo stato è errore --> esco... + if (currStatus == RecipeCatStatus.HasError) + { + continue; + } + // altrimenti controllo + else + { + // se in errore AND visibile --> registro... + bool checkCondition = false; + checkCondition = (currRecipe[item.Label].Status.HasError); + // 2020.07.29 - controllo condizione secondo status debug/release... + if (checkCondition) + { + currOverview[getRecipeSection(item.Category)] = RecipeCatStatus.HasError; + } + } + } +#endif + } + // altrimenti genero FAKE data + else + { + int eventVal = 0; + DateTime eventDate = DateTime.Now; + // genero random eventi da 1..maxEvent + Random rndGen = new Random(); + int maxEvent = 16; + int maxDelay = 30000; + for (int i = 0; i < 1024; i++) + { + // calcolo nuovo evento + eventVal = rndGen.Next(maxEvent); + // calcolo tempo anticipato + eventDate = eventDate.AddMilliseconds(-rndGen.Next(maxDelay)); + //salvo + machineLog.Add(eventDate, eventVal); + } + } + + // restituisco cod errore se trovato + return libraryError; + } + /// /// Legge tutti i parametri della ricetta e calcolo la overview dei vari steps /// diff --git a/Thermo.Active/Controllers/WebApi/ThermocameraController.cs b/Thermo.Active/Controllers/WebApi/ThermocameraController.cs index 87fa7be3..2738f8c9 100644 --- a/Thermo.Active/Controllers/WebApi/ThermocameraController.cs +++ b/Thermo.Active/Controllers/WebApi/ThermocameraController.cs @@ -24,7 +24,7 @@ namespace Thermo.Active.Controllers.WebApi public class ThermocameraController : ApiController { [Route("show"), HttpPost] - public IHttpActionResult GetDataPaginated() + public IHttpActionResult showCamera() { String ThermoCameraXpos = AdditionalParametersConfig["ThermoCameraXpos"]; String ThermoCameraYpos = AdditionalParametersConfig["ThermoCameraYpos"]; diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs new file mode 100644 index 00000000..adac2447 --- /dev/null +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -0,0 +1,56 @@ +using CMS_CORE_Library.Models; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Claims; +using System.Threading.Tasks; +using System.Web; +using System.Web.Http; +using System.Windows.Media.Animation; +using TeamDev.SDK.MVVM; +using Thermo.Active.Config; +using Thermo.Active.Database.Controllers; +using Thermo.Active.Model.DTOModels; +using Thermo.Active.Model.DTOModels.ThRecipe; +using Thermo.Active.Model.DTOModels.ThWarmers; +using Thermo.Active.NC; +using Thermo.Active.Utils; +using static CMS_CORE_Library.Models.DataStructures; +using static Thermo.Active.Config.ServerConfig; +using static Thermo.Active.Model.Constants; + +namespace Thermo.Active.Controllers.WebApi +{ + [RoutePrefix("api/underthehood")] + public class UnderTheHoodController : ApiController + { + /// + /// Oggetto adapter condiviso da WebAPI + /// + protected static NcAdapter ncAdapter = new NcAdapter(); + + [Route("cyclelog"), HttpGet] + public IHttpActionResult GetCycleLog() + { + // // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"ncAdapter Not connected! | GetCycleLog | {libraryError.exception}"); + } + + libraryError = ncAdapter.GetCycleLog(out Dictionary machineLog); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"GetCycleLog error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + return Ok(machineLog); + } + } +} \ No newline at end of file diff --git a/Thermo.Active/Thermo.Active.csproj b/Thermo.Active/Thermo.Active.csproj index 853d2397..0e2f0e06 100644 --- a/Thermo.Active/Thermo.Active.csproj +++ b/Thermo.Active/Thermo.Active.csproj @@ -223,6 +223,7 @@ + From fb16f616e58b09e0e5d38076972e9f10273f17d8 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 2 Feb 2021 19:39:35 +0100 Subject: [PATCH 03/25] partial commit: update config IO --- Thermo.Active.Config/Config/IOConfig.xml | 183 ++++++++++++++++++ .../Config/IOConfigValidator.xsd | 35 ++++ Thermo.Active.Config/ServerConfig.cs | 1 + .../ServerConfigController.cs | 31 +++ .../Thermo.Active.Config.csproj | 7 + .../ConfigModels/IOConfigModel.cs | 18 ++ Thermo.Active.Model/Constants.cs | 22 +++ .../DTOModels/ThIO/DTOIOConfigModel.cs | 17 ++ .../DTOModels/ThIO/DTOInOutConfigModel.cs | 12 -- .../Thermo.Active.Model.csproj | 3 +- 10 files changed, 316 insertions(+), 13 deletions(-) create mode 100644 Thermo.Active.Config/Config/IOConfig.xml create mode 100644 Thermo.Active.Config/Config/IOConfigValidator.xsd create mode 100644 Thermo.Active.Model/ConfigModels/IOConfigModel.cs create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs delete mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs diff --git a/Thermo.Active.Config/Config/IOConfig.xml b/Thermo.Active.Config/Config/IOConfig.xml new file mode 100644 index 00000000..57e7bed7 --- /dev/null +++ b/Thermo.Active.Config/Config/IOConfig.xml @@ -0,0 +1,183 @@ + + + + 1 + DI + 0 + 0 + 301 + 404 + A32.3 + + + 2 + DI + 0 + 1 + 301 + 405 + A32.5 + + + 3 + DI + 0 + 2 + 301 + 406 + A32.7 + + + 4 + DI + 0 + 3 + 301 + 407 + A32.8 + + + 5 + DI + 0 + 4 + 301 + 408 + A32.1 + + + 6 + AI + 0 + 5 + 301 + 409 + A32.2 + + + 7 + DI + 0 + 6 + 301 + 210 + A32.4 + + + 8 + DI + 0 + 7 + 301 + 211 + A32.6 + + + 11 + DO + 0 + 0 + 301 + 404 + B43.3 + + + 12 + DO + 0 + 1 + 301 + 405 + B43.5 + + + 13 + DO + 0 + 2 + 301 + 406 + B43.7 + + + 14 + DO + 0 + 3 + 301 + 407 + B43.8 + + + 15 + DO + 0 + 4 + 301 + 408 + B43.1 + + + 16 + AI + 0 + 5 + 301 + 409 + B43.2 + + + 17 + DO + 0 + 6 + 301 + 210 + B43.4 + + + 18 + DO + 0 + 7 + 301 + 211 + B43.6 + + + 21 + AI + 0 + 0 + 501 + 604 + C43.3 + + + 22 + AI + 0 + 1 + 501 + 605 + C43.5 + + + 31 + AO + 0 + 0 + 701 + 804 + D43.3 + + + 32 + AO + 0 + 1 + 701 + 805 + D43.5 + + \ No newline at end of file diff --git a/Thermo.Active.Config/Config/IOConfigValidator.xsd b/Thermo.Active.Config/Config/IOConfigValidator.xsd new file mode 100644 index 00000000..19e57569 --- /dev/null +++ b/Thermo.Active.Config/Config/IOConfigValidator.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Thermo.Active.Config/ServerConfig.cs b/Thermo.Active.Config/ServerConfig.cs index 21598824..e1b1b2e2 100644 --- a/Thermo.Active.Config/ServerConfig.cs +++ b/Thermo.Active.Config/ServerConfig.cs @@ -61,6 +61,7 @@ namespace Thermo.Active.Config public static List ThermoProdConfig; public static List RecipeConfig; public static List ModBlockConfig; + public static List IOConfig; public static List RiskResistConfig; public static List RiskChannelConfig; public static List RiskBoardConfig; diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 8ee9f64a..8679bc16 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -326,6 +326,7 @@ namespace Thermo.Active.Config ReadThermoProdConfig(); ReadRecipeConfig(); ReadModBlockConfig(); + ReadIOConfig(); ReadRiskConfig(); ReadAxesConfig(); ReadCMSConnectConfig(); @@ -499,6 +500,36 @@ namespace Thermo.Active.Config .ToList(); } + /// + /// IO config setup from file + /// + private static void ReadIOConfig() + { + XDocument xmlConfigFile = GetXmlHandlerWithValidator(IO_CONFIG_SCHEMA_PATH, IO_CONFIG_PATH); + + // Read head config from XML file + IOConfig = xmlConfigFile + .Root + .Elements() + .Select(x => new IOConfigModel() + { + Id = Convert.ToInt16(x.Element("id").Value), + Label = x.Element("label").Value, + Type = GetTActMB_Type(x.Element("type").Value), + Section = GetTActMB_Section(x.Element("section").Value), + IdParam = Convert.ToInt16(x.Element("idParam").Value), + ShowDelay = Convert.ToBoolean(x.Element("showDelay").Value), + Priority = Convert.ToInt16(x.Element("priority").Value), + // attributi presi da default se NON presenti... + ScaleFactor = x.Element("scaleFactor") != null ? Convert.ToInt16(x.Element("scaleFactor").Value) : 1000, + NumDec = x.Element("numDec") != null ? Convert.ToInt16(x.Element("numDec").Value) : 1, + Category = x.Element("category") != null ? x.Element("category").Value : "", + SubCategory_1 = x.Element("subCategory_1") != null ? x.Element("subCategory_1").Value : "", + SubCategory_2 = x.Element("subCategory_2") != null ? x.Element("subCategory_2").Value : "" + }) + .ToList(); + } + private static void ReadNcSoftKeys() { XDocument xmlConfigFile = GetXmlHandlerWithValidator(NC_SOFTKEYS_CONFIG_SCHEMA_PATH, NC_SOFTKEYS_CONFIG_PATH); diff --git a/Thermo.Active.Config/Thermo.Active.Config.csproj b/Thermo.Active.Config/Thermo.Active.Config.csproj index db77d72e..99d8c390 100644 --- a/Thermo.Active.Config/Thermo.Active.Config.csproj +++ b/Thermo.Active.Config/Thermo.Active.Config.csproj @@ -65,6 +65,9 @@ + + PreserveNewest + PreserveNewest @@ -215,6 +218,10 @@ Designer Always + + Designer + Always + Always diff --git a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs new file mode 100644 index 00000000..e5e574cc --- /dev/null +++ b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using static Thermo.Active.Model.Constants; + +namespace Thermo.Active.Model.ConfigModels +{ + public class IOConfigModel + { + public int Id { get; set; } =0; + public TACT_IO_TYPE Category { get; set; } + public string Bank { get; set; } = "0"; + public string Position { get; set; } = ""; + public string Page { get; set; } = ""; + public string Wire { get; set; } = ""; + public string Profinet { get; set; } = ""; + public string Label { get; set; } = ""; + } + +} diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index b69607df..e96f3f17 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -98,6 +98,25 @@ namespace Thermo.Active.Model Options } + public enum TACT_IO_TYPE + { + /// + /// Digital OUT + /// + DO = 0, + /// + /// Digital IN + /// + DI, + /// + /// Analog OUT + /// + AO, + /// + /// Analog IN + /// + AI + } public enum TACT_MBLOCK_TYPE { ND = 0, @@ -303,6 +322,9 @@ namespace Thermo.Active.Model public const string MODBLOCK_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "moduleBlockConfigValidator.xsd"; public const string MODBLOCK_CONFIG_PATH = CONFIG_DIRECTORY + "moduleBlockConfig.xml"; + public const string IO_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "IOConfigValidator.xsd"; + public const string IO_CONFIG_PATH = CONFIG_DIRECTORY + "IOConfig.xml"; + public const string RISK_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "risk2007Validator.xsd"; public const string RISK_CONFIG_PATH = CONFIG_DIRECTORY + "risk2007.xml"; diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs new file mode 100644 index 00000000..9690d6f4 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTOIOConfigModel + { + public int Bank { get; set; } = 0; + public int Bit { get; set; } = 0; + public string Page { get; set; } = ""; + public string Wire { get; set; } = ""; + public string Profinet { get; set; } = ""; + } +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs deleted file mode 100644 index b2375c3a..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOInOutConfigModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Thermo.Active.Model.DTOModels.ThIO -{ - class DTOInOutConfigModel - { - } -} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 5ccaec20..5ef98cd0 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -66,6 +66,7 @@ + @@ -113,7 +114,7 @@ - + From 64e8bd03316148c40acbeffe37ae2d8faf27e00e Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 08:47:33 +0100 Subject: [PATCH 04/25] ok gestione CONF x IO --- .../ServerConfigController.cs | 19 ++++++------------- .../ConfigModels/IOConfigModel.cs | 9 ++++++++- Thermo.Active.Model/Constants.cs | 15 ++++++++------- Thermo.Active.Utils/supportFunctions.cs | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 8679bc16..32e91330 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -506,7 +506,6 @@ namespace Thermo.Active.Config private static void ReadIOConfig() { XDocument xmlConfigFile = GetXmlHandlerWithValidator(IO_CONFIG_SCHEMA_PATH, IO_CONFIG_PATH); - // Read head config from XML file IOConfig = xmlConfigFile .Root @@ -514,18 +513,12 @@ namespace Thermo.Active.Config .Select(x => new IOConfigModel() { Id = Convert.ToInt16(x.Element("id").Value), - Label = x.Element("label").Value, - Type = GetTActMB_Type(x.Element("type").Value), - Section = GetTActMB_Section(x.Element("section").Value), - IdParam = Convert.ToInt16(x.Element("idParam").Value), - ShowDelay = Convert.ToBoolean(x.Element("showDelay").Value), - Priority = Convert.ToInt16(x.Element("priority").Value), - // attributi presi da default se NON presenti... - ScaleFactor = x.Element("scaleFactor") != null ? Convert.ToInt16(x.Element("scaleFactor").Value) : 1000, - NumDec = x.Element("numDec") != null ? Convert.ToInt16(x.Element("numDec").Value) : 1, - Category = x.Element("category") != null ? x.Element("category").Value : "", - SubCategory_1 = x.Element("subCategory_1") != null ? x.Element("subCategory_1").Value : "", - SubCategory_2 = x.Element("subCategory_2") != null ? x.Element("subCategory_2").Value : "" + Category = GetTActIO_Type(x.Element("category").Value), + Bank = x.Element("bank") != null ? x.Element("bank").Value : "0", + Position = x.Element("position") != null ? x.Element("position").Value : "0", + Page = x.Element("page") != null ? x.Element("page").Value : "", + Wire = x.Element("wire") != null ? x.Element("wire").Value : "", + Profinet = x.Element("profinet") != null ? x.Element("profinet").Value : "" }) .ToList(); } diff --git a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs index e5e574cc..e8c6a2b0 100644 --- a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs +++ b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs @@ -12,7 +12,14 @@ namespace Thermo.Active.Model.ConfigModels public string Page { get; set; } = ""; public string Wire { get; set; } = ""; public string Profinet { get; set; } = ""; - public string Label { get; set; } = ""; + public string Label + { + get + { + string answ = $"LBL_IO_{Id}_{Bank}_{Position}"; + return answ; + } + } } } diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index e96f3f17..213147a5 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -100,22 +100,23 @@ namespace Thermo.Active.Model public enum TACT_IO_TYPE { - /// - /// Digital OUT - /// - DO = 0, + ND = 0, /// /// Digital IN /// DI, /// - /// Analog OUT + /// Digital OUT /// - AO, + DO, /// /// Analog IN /// - AI + AI, + /// + /// Analog OUT + /// + AO } public enum TACT_MBLOCK_TYPE { diff --git a/Thermo.Active.Utils/supportFunctions.cs b/Thermo.Active.Utils/supportFunctions.cs index 3cd93d2f..faab6cce 100644 --- a/Thermo.Active.Utils/supportFunctions.cs +++ b/Thermo.Active.Utils/supportFunctions.cs @@ -100,6 +100,21 @@ namespace Thermo.Active.Utils return answ; } /// + /// Conversion string --> TACT_IO_TYPE + /// + /// + /// + public static TACT_IO_TYPE GetTActIO_Type(string strValue) + { + TACT_IO_TYPE answ = TACT_IO_TYPE.ND; + try + { + answ = (TACT_IO_TYPE)Enum.Parse(typeof(TACT_IO_TYPE), strValue); + } + catch { } + return answ; + } + /// /// Conversion string --> TACT_MBLOCK_SECTION /// /// From 7af6a9726ab63e5de45ea9bd403817e4253de660 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 13:21:00 +0100 Subject: [PATCH 05/25] Update lettura XML + conf DTO --- Thermo.Active.Config/Config/IOConfig.xml | 1 + .../Config/IOConfigValidator.xsd | 1 + .../ServerConfigController.cs | 3 +- .../ConfigModels/IOConfigModel.cs | 7 +- .../DTOModels/ThIO/DTOChannelsIOModel.cs | 173 ++++++++++++++++++ .../DTOModels/ThIO/DTOIOConfigModel.cs | 17 -- .../Thermo.Active.Model.csproj | 2 +- Thermo.Active.NC/NcAdapter.cs | 51 ++++++ 8 files changed, 233 insertions(+), 22 deletions(-) create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs delete mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs diff --git a/Thermo.Active.Config/Config/IOConfig.xml b/Thermo.Active.Config/Config/IOConfig.xml index 57e7bed7..6974bff5 100644 --- a/Thermo.Active.Config/Config/IOConfig.xml +++ b/Thermo.Active.Config/Config/IOConfig.xml @@ -17,6 +17,7 @@ 301 405 A32.5 + true 3 diff --git a/Thermo.Active.Config/Config/IOConfigValidator.xsd b/Thermo.Active.Config/Config/IOConfigValidator.xsd index 19e57569..a5649327 100644 --- a/Thermo.Active.Config/Config/IOConfigValidator.xsd +++ b/Thermo.Active.Config/Config/IOConfigValidator.xsd @@ -15,6 +15,7 @@ + diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 32e91330..de8b6946 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -518,7 +518,8 @@ namespace Thermo.Active.Config Position = x.Element("position") != null ? x.Element("position").Value : "0", Page = x.Element("page") != null ? x.Element("page").Value : "", Wire = x.Element("wire") != null ? x.Element("wire").Value : "", - Profinet = x.Element("profinet") != null ? x.Element("profinet").Value : "" + Profinet = x.Element("profinet") != null ? x.Element("profinet").Value : "", + DisableForce = x.Element("disableForce") != null ? Convert.ToBoolean(x.Element("disableForce").Value): false }) .ToList(); } diff --git a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs index e8c6a2b0..2cfc288c 100644 --- a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs +++ b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs @@ -5,18 +5,19 @@ namespace Thermo.Active.Model.ConfigModels { public class IOConfigModel { - public int Id { get; set; } =0; public TACT_IO_TYPE Category { get; set; } + public int Id { get; set; } =0; public string Bank { get; set; } = "0"; - public string Position { get; set; } = ""; + public string Position { get; set; } = "0"; public string Page { get; set; } = ""; public string Wire { get; set; } = ""; public string Profinet { get; set; } = ""; + public bool DisableForce { get; set; } = false; public string Label { get { - string answ = $"LBL_IO_{Id}_{Bank}_{Position}"; + string answ = $"LBL_IO_{Category}_{Id}"; return answ; } } diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs new file mode 100644 index 00000000..1dd7b908 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTOChannelsIOModel + { + public List DI { get; set; } + public List DO { get; set; } + public List AI { get; set; } + public List AO { get; set; } + } + public class DigitalIN : IoBaseConf + { + public bool Value { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DigitalIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoBaseConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class DigitalOUT : DigitalIN + { + public bool ForceEnabled { get; set; } = false; + public bool ForceZero { get; set; } = false; + public bool ForceOne { get; set; } = false; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DigitalOUT item)) + return false; + + if (ForceEnabled != item.ForceEnabled) + return false; + if (ForceZero != item.ForceZero) + return false; + if (ForceOne != item.ForceOne) + return false; + if (IsForced != item.IsForced) + return false; + + return base.Equals((DigitalIN)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class AnalogIN : IoBaseConf + { + public double Value { get; set; } = 0; + + public override bool Equals(object obj) + { + if (!(obj is AnalogIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoBaseConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class AnalogOUT : AnalogIN + { + public bool ForceEnabled { get; set; } = false; + public double ForcedValue { get; set; } = 0; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is AnalogOUT item)) + return false; + + if (ForceEnabled != item.ForceEnabled) + return false; + if (ForcedValue != item.ForcedValue) + return false; + if (IsForced != item.IsForced) + return false; + + return base.Equals((AnalogIN)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class IoBaseConf + { + public int Id { get; set; } = 0; + public int Bank { get; set; } = 0; + public string Position { get; set; } = ""; + public string Page { get; set; } = ""; + public string Wire { get; set; } = ""; + public string Profinet { get; set; } = ""; + public string Label { get; set; } = ""; + public bool Visible { get; set; } = false; + + + public override bool Equals(object obj) + { + if (!(obj is IoBaseConf item)) + return false; + + if (Id != item.Id) + return false; + if (Bank != item.Bank) + return false; + if (Position != item.Position) + return false; + if (Page != item.Page) + return false; + if (Wire != Wire) + return false; + if (Profinet != item.Profinet) + return false; + if (Label != item.Label) + return false; + if (Visible != item.Visible) + return false; + + return true; + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + + +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs deleted file mode 100644 index 9690d6f4..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Thermo.Active.Model.DTOModels.ThIO -{ - public class DTOIOConfigModel - { - public int Bank { get; set; } = 0; - public int Bit { get; set; } = 0; - public string Page { get; set; } = ""; - public string Wire { get; set; } = ""; - public string Profinet { get; set; } = ""; - } -} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 5ef98cd0..83f412a9 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -114,7 +114,7 @@ - + diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 1b85a73c..109647a9 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -2167,6 +2167,57 @@ namespace Thermo.Active.NC return libraryError; } + + public CmsError ReadIO(out Dictionary currModules) + { + CmsError libraryError = NO_ERROR; + currModules = new Dictionary(); + DTOModulesBlock currVal = new DTOModulesBlock(); + + // read and return warmers data + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + Dictionary currModBlock = new Dictionary(); + libraryError = numericalControl.PLC_RModulesBlockList(false, ref currModBlock); + + foreach (var item in ModBlockConfig) + { + try + { + ThermoModels.ModuleBlock currModule = currModBlock[item.Id]; + currVal = new DTOModulesBlock() + { + Id = item.Id, + Label = item.Label, + Type = item.Type, + Section = item.Section, + IdParam = item.IdParam, + ShowDelay = item.ShowDelay, + Priority = item.Priority, + ScaleFactor = item.ScaleFactor, + NumDec = item.NumDec, + ActualDelay = (double)currModule.ActualDelay / item.ScaleFactor, + ActualDuration = (double)currModule.ActualDuration / item.ScaleFactor, + EstimatedDelay = (double)currModule.EstimatedDelay / item.ScaleFactor, + EstimatedDuration = (double)currModule.EstimatedDuration / item.ScaleFactor, + PrecedingId = currModule.PrecedingId, + Visible = currModule.Visible, + Running = currModule.Running, + HasError = currModule.HasError, + Terminated = currModule.Terminated, + Category = item.Category, + SubCategory_1 = item.SubCategory_1, + SubCategory_2 = item.SubCategory_2 + }; + currModules.Add(item.Id, currVal); + } + catch + { } + } + } + return libraryError; + } + /// /// Legge tutti i parametri della ricetta /// From e77887153d6fc124231ce974340e9cd28b96657a Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 14:28:18 +0100 Subject: [PATCH 06/25] Aggiunto chiamata x status canali IO --- .../Config/IOConfigValidator.xsd | 2 +- .../DTOModels/ThIO/DTOChannelsIOModel.cs | 18 +++--- .../DTOModels/ThIO/DTODigInModel.cs | 47 -------------- .../DTOModels/ThIO/DTODigOutModel.cs | 56 ----------------- .../Thermo.Active.Model.csproj | 2 - .../WebApi/ConfigurationController.cs | 63 +++++++++++++++++++ .../WebApi/UnderTheHoodController.cs | 61 ++++++++++++++++++ 7 files changed, 134 insertions(+), 115 deletions(-) delete mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs delete mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs diff --git a/Thermo.Active.Config/Config/IOConfigValidator.xsd b/Thermo.Active.Config/Config/IOConfigValidator.xsd index a5649327..2f1a68ab 100644 --- a/Thermo.Active.Config/Config/IOConfigValidator.xsd +++ b/Thermo.Active.Config/Config/IOConfigValidator.xsd @@ -15,7 +15,7 @@ - + diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs index 1dd7b908..5e62404b 100644 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs @@ -38,7 +38,7 @@ namespace Thermo.Active.Model.DTOModels.ThIO } public class DigitalOUT : DigitalIN { - public bool ForceEnabled { get; set; } = false; + public bool ForceEnabled { get; set; } = true; public bool ForceZero { get; set; } = false; public bool ForceOne { get; set; } = false; public bool IsForced { get; set; } = false; @@ -94,7 +94,7 @@ namespace Thermo.Active.Model.DTOModels.ThIO public class AnalogOUT : AnalogIN { - public bool ForceEnabled { get; set; } = false; + public bool ForceEnabled { get; set; } = true; public double ForcedValue { get; set; } = 0; public bool IsForced { get; set; } = false; @@ -125,13 +125,13 @@ namespace Thermo.Active.Model.DTOModels.ThIO public class IoBaseConf { public int Id { get; set; } = 0; - public int Bank { get; set; } = 0; - public string Position { get; set; } = ""; - public string Page { get; set; } = ""; - public string Wire { get; set; } = ""; - public string Profinet { get; set; } = ""; - public string Label { get; set; } = ""; - public bool Visible { get; set; } = false; + public string Bank { get; set; } = "0"; + public string Position { get; set; } = "0"; + public string Page { get; set; } = "0"; + public string Wire { get; set; } = "0"; + public string Profinet { get; set; } = "0"; + public string Label { get; set; } = "LBL"; + public bool Visible { get; set; } = true; public override bool Equals(object obj) diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs deleted file mode 100644 index be5fcba8..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Thermo.Active.Model.DTOModels.ThIO -{ - public class DTODigInModel - { - public int Block { get; set; } = 0; - public int Num { get; set; } = 0; - public string Page { get; set; } = "0"; - public string Wire { get; set; } = "0"; - public string Profinet { get; set; } = ""; - public string Label { get; set; } = ""; - public bool Value { get; set; } = false; - - public override bool Equals(object obj) - { - if (!(obj is DTODigInModel item)) - return false; - - if (Block != item.Block) - return false; - if (Num != item.Num) - return false; - if (Page != item.Page) - return false; - if (Wire!= Wire) - return false; - if (Profinet != item.Profinet) - return false; - if (Label != item.Label) - return false; - if (Value != item.Value) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs deleted file mode 100644 index 4f1e84cf..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Thermo.Active.Model.DTOModels.ThIO -{ - public class DTODigOutModel - { - public int Block { get; set; } = 0; - public int Num { get; set; } = 0; - public string Page { get; set; } = "0"; - public string Wire { get; set; } = "0"; - public string Profinet { get; set; } = ""; - public string Label { get; set; } = ""; - public bool Value { get; set; } = false; - public bool ForceZero { get; set; } = false; - public bool ForceOne { get; set; } = false; - public bool IsForced { get; set; } = false; - - public override bool Equals(object obj) - { - if (!(obj is DTODigOutModel item)) - return false; - - if (Block != item.Block) - return false; - if (Num != item.Num) - return false; - if (Page != item.Page) - return false; - if (Wire != Wire) - return false; - if (Profinet != item.Profinet) - return false; - if (Label != item.Label) - return false; - if (Value != item.Value) - return false; - if (ForceZero != item.ForceZero) - return false; - if (ForceOne != item.ForceOne) - return false; - if (IsForced != item.IsForced) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 83f412a9..3e779827 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -113,9 +113,7 @@ - - diff --git a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs index 10ae29d5..32ce7a7f 100644 --- a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs +++ b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs @@ -5,6 +5,7 @@ using Thermo.Active.Database.Controllers; using Thermo.Active.Model.ConfigModels; using Thermo.Active.Model.DTOModels; using Thermo.Active.Model.DTOModels.AlarmModels; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThProd; using Thermo.Active.Model.DTOModels.ThRecipe; using static Thermo.Active.Config.ServerConfig; @@ -124,6 +125,68 @@ namespace Thermo.Active.Controllers.WebApi return Ok(recipeConfig); } +#if false + [Route("IO"), HttpGet] + public IHttpActionResult GetIOConfig() + { + DTOChannelsIOModel ChannelsIO = new DTOChannelsIOModel(); + // leggo i 4 tipi di oggetti e popolo + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + + // assegno! + ChannelsIO.DI = listDI; + ChannelsIO.DO = listDO; + ChannelsIO.AI = listAI; + ChannelsIO.AO = listAO; + + // restituisco + return Ok(ChannelsIO); + } +#endif + [Route("thermoProd"), HttpGet] public IHttpActionResult GetThermoProdConfig() { diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index adac2447..07c7451f 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -15,6 +15,7 @@ using TeamDev.SDK.MVVM; using Thermo.Active.Config; using Thermo.Active.Database.Controllers; using Thermo.Active.Model.DTOModels; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThRecipe; using Thermo.Active.Model.DTOModels.ThWarmers; using Thermo.Active.NC; @@ -52,5 +53,65 @@ namespace Thermo.Active.Controllers.WebApi return Ok(machineLog); } + + [Route("channels_io"), HttpGet] + public IHttpActionResult GetChannelsIO() + { + DTOChannelsIOModel ChannelsIO = new DTOChannelsIOModel(); + // leggo i 4 tipi di oggetti e popolo + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + + // assegno! + ChannelsIO.DI = listDI; + ChannelsIO.DO = listDO; + ChannelsIO.AI = listAI; + ChannelsIO.AO = listAO; + + // restituisco + return Ok(ChannelsIO); + } } } \ No newline at end of file From e16fc55c577406becb4962771a5092311bb7f321 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 14:36:40 +0100 Subject: [PATCH 07/25] refresh vers numb 1.1.150 --- Thermo.Active/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index be6f7282..d85e02c9 100644 --- a/Thermo.Active/Properties/AssemblyInfo.cs +++ b/Thermo.Active/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("CMS S.P.A.")] [assembly: AssemblyProduct("Thermo Active Server")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyCopyright("Copyright � 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -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.110.146")] +[assembly: AssemblyVersion("1.1.150")] From 5ad7b7990c58d1e859517b59ea0047ce4ae1f7be Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 19:04:40 +0100 Subject: [PATCH 08/25] inizio lettura da PLC (da testare!!!) --- ...DTOChannelsIOModel.cs => DTOChannelsIO.cs} | 2 +- .../Thermo.Active.Model.csproj | 2 +- Thermo.Active.NC/NcAdapter.cs | 73 +++++++++++++++++-- .../WebApi/UnderTheHoodController.cs | 27 ++++++- 4 files changed, 95 insertions(+), 9 deletions(-) rename Thermo.Active.Model/DTOModels/ThIO/{DTOChannelsIOModel.cs => DTOChannelsIO.cs} (99%) diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs similarity index 99% rename from Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs rename to Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs index 5e62404b..24571013 100644 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Thermo.Active.Model.DTOModels.ThIO { - public class DTOChannelsIOModel + public class DTOChannelsIO { public List DI { get; set; } public List DO { get; set; } diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 3e779827..24c9a727 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -113,7 +113,7 @@ - + diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 109647a9..e7368c6b 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -14,6 +14,7 @@ using Thermo.Active.Model.DTOModels.AlarmModels; using Thermo.Active.Model.DTOModels.MaintenanceModels; using Thermo.Active.Model.DTOModels.Scada; using Thermo.Active.Model.DTOModels.ThAxes; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThModules; using Thermo.Active.Model.DTOModels.ThProd; using Thermo.Active.Model.DTOModels.ThRecipe; @@ -2168,18 +2169,79 @@ namespace Thermo.Active.NC } - public CmsError ReadIO(out Dictionary currModules) + public CmsError ReadIO(out DTOChannelsIO currChannelsIO) { CmsError libraryError = NO_ERROR; - currModules = new Dictionary(); - DTOModulesBlock currVal = new DTOModulesBlock(); + currChannelsIO = new DTOChannelsIO(); // read and return warmers data if (NcConfig.NcVendor == NC_VENDOR.S7NET) { + // lettura da PLC Dictionary currModBlock = new Dictionary(); - libraryError = numericalControl.PLC_RModulesBlockList(false, ref currModBlock); + ThermoModels.ChanIOVis currThermoIOVis = new ThermoModels.ChanIOVis(); + ThermoModels.ChanIOVal currThermoIOVal = new ThermoModels.ChanIOVal(); + ThermoModels.ChanIOFor currThermoIOFor = new ThermoModels.ChanIOFor(); + ThermoModels.ChanIOValFor currThermoIOValFor = new ThermoModels.ChanIOValFor(); + libraryError = numericalControl.PLC_RIOChannels(false, ref currThermoIOVis, ref currThermoIOVal, ref currThermoIOFor, ref currThermoIOValFor); + // setup da config + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), + Visible = currThermoIOVis.DI[x.Id] + }).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), + Visible = currThermoIOVis.DO[x.Id] + }).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), + Visible = currThermoIOVis.AI[x.Id] + }).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), + Visible = currThermoIOVis.AO[x.Id] + }).ToList(); + + // assegno! + currChannelsIO.DI = listDI; + currChannelsIO.DO = listDO; + currChannelsIO.AI = listAI; + currChannelsIO.AO = listAO; + +#if false foreach (var item in ModBlockConfig) { try @@ -2213,7 +2275,8 @@ namespace Thermo.Active.NC } catch { } - } + } +#endif } return libraryError; } diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index 07c7451f..bd664ba9 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -57,7 +57,29 @@ namespace Thermo.Active.Controllers.WebApi [Route("channels_io"), HttpGet] public IHttpActionResult GetChannelsIO() { - DTOChannelsIOModel ChannelsIO = new DTOChannelsIOModel(); + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | GetChannelsIO | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + // leggo dati gauges + libraryError = ncAdapter.ReadIO(out DTOChannelsIO ChannelsIO); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"GetChannelsIO error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + // ritorno solo fatto! + return Ok(ChannelsIO); +#if false + + + + DTOChannelsIO ChannelsIO = new DTOChannelsIO(); // leggo i 4 tipi di oggetti e popolo List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() { @@ -111,7 +133,8 @@ namespace Thermo.Active.Controllers.WebApi ChannelsIO.AO = listAO; // restituisco - return Ok(ChannelsIO); + return Ok(ChannelsIO); +#endif } } } \ No newline at end of file From 272f0823af2bf55865b8b914e339460f632565fb Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 19:20:48 +0100 Subject: [PATCH 09/25] =?UTF-8?q?OK=20primo=20test=20lettura=20dal=20PLC?= =?UTF-8?q?=20x=20bit=20vbisibilit=C3=A0=20canali=20IO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Thermo.Active.Config/Config/IOConfig.xml | 2 +- Thermo.Active/Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Thermo.Active.Config/Config/IOConfig.xml b/Thermo.Active.Config/Config/IOConfig.xml index 6974bff5..5dacaa96 100644 --- a/Thermo.Active.Config/Config/IOConfig.xml +++ b/Thermo.Active.Config/Config/IOConfig.xml @@ -173,7 +173,7 @@ D43.3 - 32 + 31 AO 0 1 diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index d85e02c9..ef1f06a0 100644 --- a/Thermo.Active/Properties/AssemblyInfo.cs +++ b/Thermo.Active/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -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("1.1.150")] +[assembly: AssemblyVersion("1.1.151")] From d2d20d16a20f8206eb4a38945968e1dd8fea8dd3 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 3 Feb 2021 19:33:26 +0100 Subject: [PATCH 10/25] Aggiunta altri parametri realtime letti da PLC x IO --- Thermo.Active.NC/NcAdapter.cs | 56 ++++++++++------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index e7368c6b..c654a714 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -2196,7 +2196,8 @@ namespace Thermo.Active.NC Wire = x.Wire, Profinet = x.Profinet, Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), - Visible = currThermoIOVis.DI[x.Id] + Visible = currThermoIOVis.DI.ContainsKey(x.Id)? currThermoIOVis.DI[x.Id]:false, + Value = currThermoIOVal.DI.ContainsKey(x.Id) ? currThermoIOVal.DI[x.Id] : false }).ToList(); List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() { @@ -2208,7 +2209,12 @@ namespace Thermo.Active.NC Wire = x.Wire, Profinet = x.Profinet, Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), - Visible = currThermoIOVis.DO[x.Id] + ForceEnabled=!x.DisableForce, + Visible = currThermoIOVis.DO.ContainsKey(x.Id) ? currThermoIOVis.DO[x.Id] : false, + Value = currThermoIOVal.DO.ContainsKey(x.Id) ? currThermoIOVal.DO[x.Id] : false, + IsForced = currThermoIOFor.DO.ContainsKey(x.Id) ? currThermoIOFor.DO[x.Id] : false, + ForceOne = currThermoIOValFor.DO.ContainsKey(x.Id) ? currThermoIOValFor.DO[x.Id] : false, + ForceZero = currThermoIOValFor.DO.ContainsKey(x.Id) ? !currThermoIOValFor.DO[x.Id] : false }).ToList(); List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() { @@ -2220,7 +2226,8 @@ namespace Thermo.Active.NC Wire = x.Wire, Profinet = x.Profinet, Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), - Visible = currThermoIOVis.AI[x.Id] + Visible = currThermoIOVis.AI.ContainsKey(x.Id) ? currThermoIOVis.AI[x.Id] : false, + Value = currThermoIOVal.AI.ContainsKey(x.Id) ? currThermoIOVal.AI[x.Id] : 0 }).ToList(); List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() { @@ -2232,7 +2239,11 @@ namespace Thermo.Active.NC Wire = x.Wire, Profinet = x.Profinet, Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower(), - Visible = currThermoIOVis.AO[x.Id] + ForceEnabled = !x.DisableForce, + Visible = currThermoIOVis.AO.ContainsKey(x.Id) ? currThermoIOVis.AO[x.Id] : false, + Value = currThermoIOVal.AO.ContainsKey(x.Id) ? currThermoIOVal.AO[x.Id] : 0, + IsForced = currThermoIOFor.AO.ContainsKey(x.Id) ? currThermoIOFor.AO[x.Id] : false, + ForcedValue = currThermoIOValFor.AO.ContainsKey(x.Id) ? currThermoIOValFor.AO[x.Id] : 0 }).ToList(); // assegno! @@ -2240,43 +2251,6 @@ namespace Thermo.Active.NC currChannelsIO.DO = listDO; currChannelsIO.AI = listAI; currChannelsIO.AO = listAO; - -#if false - foreach (var item in ModBlockConfig) - { - try - { - ThermoModels.ModuleBlock currModule = currModBlock[item.Id]; - currVal = new DTOModulesBlock() - { - Id = item.Id, - Label = item.Label, - Type = item.Type, - Section = item.Section, - IdParam = item.IdParam, - ShowDelay = item.ShowDelay, - Priority = item.Priority, - ScaleFactor = item.ScaleFactor, - NumDec = item.NumDec, - ActualDelay = (double)currModule.ActualDelay / item.ScaleFactor, - ActualDuration = (double)currModule.ActualDuration / item.ScaleFactor, - EstimatedDelay = (double)currModule.EstimatedDelay / item.ScaleFactor, - EstimatedDuration = (double)currModule.EstimatedDuration / item.ScaleFactor, - PrecedingId = currModule.PrecedingId, - Visible = currModule.Visible, - Running = currModule.Running, - HasError = currModule.HasError, - Terminated = currModule.Terminated, - Category = item.Category, - SubCategory_1 = item.SubCategory_1, - SubCategory_2 = item.SubCategory_2 - }; - currModules.Add(item.Id, currVal); - } - catch - { } - } -#endif } return libraryError; } From 89ee2034614a663c3ed14424070112c57154d434 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 10:55:36 +0100 Subject: [PATCH 11/25] test x output conf IO --- .../DTOModels/ThIO/DTOChannelsSetup.cs | 16 ++++ .../Thermo.Active.Model.csproj | 1 + .../WebApi/ConfigurationController.cs | 86 +++++++----------- UpgradeLog.htm | Bin 0 -> 29046 bytes 4 files changed, 50 insertions(+), 53 deletions(-) create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOChannelsSetup.cs create mode 100644 UpgradeLog.htm diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsSetup.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsSetup.cs new file mode 100644 index 00000000..8c26c8b9 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsSetup.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTOChannelsSetup + { + public List DI { get; set; } = new List(); + public List DO { get; set; } = new List(); + public List AI { get; set; } = new List(); + public List AO { get; set; } = new List(); + } +} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 24c9a727..37483ff3 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -113,6 +113,7 @@ + diff --git a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs index 32ce7a7f..5a0efe06 100644 --- a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs +++ b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs @@ -125,67 +125,47 @@ namespace Thermo.Active.Controllers.WebApi return Ok(recipeConfig); } -#if false - [Route("IO"), HttpGet] + + [Route("recipeTest"), HttpGet] + public IHttpActionResult GetRecipeTest() + { + List recipeConfig = RecipeConfig.Select(x => new DTORecipeConfigModel() + { + Id = x.Id, + ScaleFactor = x.ScaleFactor, + NumDec = x.NumDec, + Category = x.Category.ToString(), + SubCategory_1 = x.SubCategory_1, + SubCategory_2 = x.SubCategory_2, + Name = x.Name, + Description = x.Description, + Format = x.Format, + Label = $"{x.Category}_{x.SubCategory_1}_{x.SubCategory_2}_{x.Name}".Replace("__", "_").Replace("__", "_").ToLower(), + EnumVal = x.EnumVal + }).ToList(); + + return Ok(recipeConfig); + } + + [Route("configIO"), HttpGet] public IHttpActionResult GetIOConfig() { - DTOChannelsIOModel ChannelsIO = new DTOChannelsIOModel(); + DTOChannelsSetup configIO = new DTOChannelsSetup(); // leggo i 4 tipi di oggetti e popolo - List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).GroupBy(x => x.Bank).Select(x => x.Key).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).GroupBy(x => x.Bank).Select(x => x.Key).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).GroupBy(x => x.Bank).Select(x => x.Key).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).GroupBy(x => x.Bank).Select(x => x.Key).ToList(); // assegno! - ChannelsIO.DI = listDI; - ChannelsIO.DO = listDO; - ChannelsIO.AI = listAI; - ChannelsIO.AO = listAO; + configIO.DI = listDI; + configIO.DO = listDO; + configIO.AI = listAI; + configIO.AO = listAO; // restituisco - return Ok(ChannelsIO); + return Ok(configIO); } -#endif [Route("thermoProd"), HttpGet] public IHttpActionResult GetThermoProdConfig() diff --git a/UpgradeLog.htm b/UpgradeLog.htm new file mode 100644 index 0000000000000000000000000000000000000000..864f64988bd4677ec422b533e16e4b85df14aabd GIT binary patch literal 29046 zcmeI5`BNLolE?ekw-Nh4Xw1HWS%yPkb9kOTA%wt~!(0ZNVPXOh_i4mE^WLAnyPt0* zn>TD>{visa1&1IXj5nL>*BtpJMbf`iXk$+&u@*>u5JR z;0CeA5A-ZzC9?{Qh&T3rO9OM_Sk0VNJ(FXN5xx2=B7sp*ngh`F> z7SOx67GAG!Tc1TQ=u5q9(x&Rp4;>zBV4}K)oqpd?ca!Tb`m1qnoH&b4DA|m@P`V5K zs#Q+3>x!m;eH3j|V~yWU*S4o&U*gIY{q}t2!7mP{9iW_ofw=Vsm}gMd1!o6x;j|cC zgLxd6Gw?ryqnq^d2ghURpFsM7B1u<0?>hSCxjNzOlvcg;?PXS=eeyF+i*4$yQPbKM zqIhfRQL=?3-{WcuZPKTWZ&9lZN51d!qlQ#R#}ofgnxwkbdTB%h6DvOj=Oj zD{1e7udb@x-GIx|3Y8at)sw4t>AL#OgYloaYI{1@;qXSZ?|7~8bwt0f!MH6Ni~4WB zFQZ>tf~~P2ojARPSi~0CcdSK-;=4H7g#^~zSUrGC!uLhA0JpcfFA01^3tvQ%)FSnE zDAoAZ^|+JCCZo=-m$*KKW{oy0kxi1t=;Et;yY$r>{U<=G@{zsTc3Aed2uawV0z;5Q zZC*J4bn?riO{V|v;DBflAByyw90jsz-gZmMVLS+5;i{5gA@Yub9s10Jb892uu9S-K z_XImCKHD*r__NkDBIvIy;tkxBH2a|Q1WvUEv)%|cpA{c_6?*aCR{N2RO&7YHH$DSr z^Na;YfjHKNCoA55`?!`DJ%H9K)aA3l-a@6VNFP!uVwrSojgp6sCXZQ=<|UGpzf$BO zi5@}qsk1o;IdOc9k!pO8`>VSn^#u`{`Q{5S-;6F@Bp}PDSnL=&W)HO4o%HZNSG zB>y<>dxmiwq!Axm#c1dOV=KUXJPCX4sb_ayeYHD=Yu!_PUcjG7^G?vn<7n?zBQ?$x1<2#)*UA28)yc=#pP-vbeV5*}>PsHWGCs9# zH{CU*KbEx*PhWW^o+^@Ghj-#uh(oB8E7H25dDcmbl55OeA8Fb#A9uZ0-;Eq3!Pa2Kt(r7fvtwyP zm`ln7J$xkAiz3XsjWNRQn|GAw*EY+vOd(;Dy)1#n2L+DuZ^|nNj~B9!^&<+++>|wq z!;$`|-LA7TugOO0lg?Hv;`Z}Cd0C5^1V{5hVIm16V->5fti46(?O3xg_id-#TPEf8 zEla9s$l9sQvTOz7c;z2;rTM4N8|ROPx*fj8%c)yVKE21d8y`J1*LlBoR?vO>jJ7z! zyiB@WKIiegMSktCC#~0Lu-AZZA-Pr~TW<^Rm)sauMW10lt=YzZAIX{BDl=X+sx4RK zv6CeUIVYb9wzU#3*#cwSGEcHB8$i%JN$0_WNizlAXOlJ8uko=pF^idGDP&Pp*DQ=+ zC?Ak-PSEYB(CS&7Cgr!EUI#tj(tclD@!ZX)FZoBJ$#aphCkveBbX-0r&vcCtHJPW- z7(Pcb$|vgHzJq&?FAsBKt^QgR9G~0S3`tnz&FXZg@RlT{RZlO$OLVykojWd;*D678 z^!J=&yj7Xa!o#r6WPaPP@Xq{ekDBo^2Pmxv7B3V#f zNuwlDjmR|@1&2C{leV}sOtkuUj`?j~8xWGK0C6mzd(^C9FBGZfvvgi(j6Yp59x9d} zB#*9fm`@`gD*L2uH2Hc9rz;;>%l2Jzb?tP(%P}tDycV!6WdW0YKet4UqI~jfmG>oQ z=?kp?D5VW+U5~H7n$8 zw8n9os`d1e)6OUDR0`Vn8gHQ0vsUNv9-@3pSRD;8^NmSA&g(_jUGPggi?mxoE3le_ zCd=~aV0K^H!K5`8zb5+H>B;lPX-WN5rogn`_96vceX23=^!jM==nTA8bSzsw%DJtr zE5guNRL)d)lTps0vw;?eth-vrXmvNWCaCSRDq((N*%9-D+U=wLUh=zwD^6-e+8Vg> zr<#9w&+BU`ri$}?*LiF0+bg)X%A06cqwGn6RSaP+oa|iI!*-5&c(%@2bv7tqtU97t znHJl3lh?j^y*A$d#u(A(6Yvh8cnQeLJ!v0``~m1{5fQHMehf|yadi?+I#@+01$UL-=@Y6 z_ol$&J@w19+~MjJXu@I$-VIXgf|3%)&S-}3h2zi#XIDTH)T)eQ3SAhdVoz zEYhY(uNnng;J8j5?Qx!l`XjDi(Q*`+JIHL0<0O5)cThgkYl&-(!$l|e0qU0F?hMqu zqg0UAXmtn=Dsc4zn93Jwzko(%h5om}cmn(eDO;r8HJsW)PTSzH!M$VpQv7&;6pz7r z8Yp|vdIXnmxR#bI(!&-d6?ilYZD;VL7x?}od$Z*1(IoU})JfalI7^zx_qQ6&`>5J> z(fLU0Y2qB;SJI>9q0%xK-n%w?{2t-_e~)my<|MWBd!(ZX?!E}^X(OExEND7nsbL!} zVmZbx&td83v8jVtzDw-m4Ho(so4Dt^<0RI%ilsZkdRO_Lb7vm=t0$R;Xg!UmC{nH{ zq!U;d)T&Xo2EB9iJ%W|q;JOU_Wh`phc^z5%Ibd#JlgEI0#+l;lIV`oXSflO?R$18~ zMF9KGhYS-hOao_tGR4K4K+{}APclt`!3Xf(;HX^Z7-v^dFoxaUbX1k`?2~-I;1?7b z4$-f?rXn?Y*CnoJX|q9}2lxW@IRmAAv=SXxl#RJQ7ig_GrRHi1)-u$70+V5&4s)jm zoGv)q28#ATEBYDbY{RwOhR5@?R-Cg%UwgC~q0Kws7u_9k^$Yx*fr4pZXt%=}_vP~s z;OHcM%sG!Zflt(R4VpAJ9EYpJP&4d&buWFc0DGU>%CPo;=@7N%xxS>$oa1yKCH-Kg z2)hqIx&)qz9B*9NXYS1a?EsmTfwlr|o!nD|GUPZT@4pS6hm;hdvjQ&HNaF@9G^?59 zT;=lmlDu|gDRP^j&6U%t3(B@QyXLN>yae}Nf%~A-vPsGZp=-`zRHmOD?n{>al)6ryN~zhides`M^EO!p2m|W`}pq9&(Nap84I5sNa{nq zj73s^zWecS=f_Lf-c~Xe@>H_j@r=a@wsHa6JBL**b5xx%?C(pCC2Z{oWmDX_;&_Vf z9&$E%jdDH3sd;l5OTK{Jo#&`5#2{BCZ0;QXM_xi!eVKd8Zq4Bhma*2Kob{L0|Ag0= z0HG?wR_hkc2EtU$pR ztp60pb3D`~USt%!uKC=+D0eUBGN|bj3MbDmTX1@d`ibiViY#$Gz+`ue2 zT>xhQ+BDlfp_VXJj%9#4nmzY`(LPs#H$Wc?P^0X}5pd2O#jogJ>*0zZhG^ZxahcYW zKvdZ~TIi1Ag+*X=(yJmL;dut-d%(Gdo-^kOd%0G2U-R`6)GPwKlO8nt-Q&84V?Xtk z!Bp1f2#j=R3_5#&JO-y;@_EnwCGJVL#7plTN4PUji&t><6r3bUecn9dj5nDyHEUfK2h1|^xXCfR&^1Z`Vng=pEr+fQ;zTw z+dYdH`G}1h!YY@r(wF>dPSJ<0Jg1&A)Ftez=4zTDRj}Ne=Zs(@D_B$6S{*W&FtToa-5`s^Is9^A$?I;14xl zoTN^T;|+bkr&M|K0c`OREtPj(0M~JB_BcIOxZ1@^-|#sAqax)~(4kqQeBlx^#8Y6b z)3!)2m(By0vFGw*)A)cDYJP^EO^44KB~x%^3*5CTcmW;CdTP#f4%`}jFYqbS<|R1x z14Vot;C??a`W?)3T8LMp)R=~ggY@>9>tXO30?QK6SAeP22JH#bD)NN$G}R>*0Gst(t2$4%ha;ZHaz2DB0%DAUv>3lsjtla8m+bJGz*_Z z>nJq6gfhiV+EqFX9~bCfI=D}{|2*#8xp972Z!!rx{_RaBdMk~zM(e>EF^Y%uo)xXo z+B;wNpg{X6wF=V z)xvvWf7B|uy?;WxNR_>ke-;O9%{;V7zjLJrIqy9j;-?hXDia{{OR_#@^91fp>YKeYJrLS}7DhlFBABm+Z27&(D|a{=}g?+|e#ly(!12 zd@No)jNwGo3Wwpc3A-^9~JA`DT z)Ka5FwlCN}^B>YXwk8fmqSeeW+i;Nlyi z8tn+)<@*o5NzC*_lE$~9#hu%Foy0`hoUmRRk9Tj0JXe%qvi)W9GM>5uIHvLX4SauR z7n^aYL~YS8?NSD36WgU{?@TkA<%(frUf>7b%6A_&KSn=-PyM^y;2=M%DCC3lCmst~ zM`cj-e0ww8%ge(wFE!ehz{bX$q?pCW5MOnJy;_|hdF{paShvH`ygSE*Q$0L>r97!; zUY^-_6r5D;EfIQ}Qv2dsg(GURteNMhj@f?GYG&8TzMF-|UCU(=t=_4jRk>p~KhTaF z?OBY=+pJ66dS%a+}&?Sv&Ws<|FbtHHTF8N0E@$ zDD>Wn=HX=9o@T6<)yc9_^>7WbcDAL>#xJW^i#Rn8(T+eL6~?2^dJ&_~5u|6enjeVU z=K1Vt7uB)n(!x&gFgr~~so_n#e)g*SS@_?z?Y^aGxptak`HXCRZpLy;LVipJ4*V7U zMR_k@#U>i({$4Wj%kJN#uis`d@h#HYZPYfe-KINPJoY^m$Rg<}Xl2tBp@p{(OYV}L z-b5^knY=YuR7q0W{$5f~{0v2Jeh9Oc@J5OxjOMWQcHH*;dmT4l(t~DrjQ{$2RzsGC z^H0$#vC%5@>iZiMb&>Nc@vFVmU1auF`CTP`{+(F9gSz$V{LXU$KSjSf7{5}hUL6nT z4{E9A&#v|=zpFt0k*5t;qyOS5gH?3vUs$bGG-Q={>USXPsROMMXIqCLzvlQ>U!%HH zBfG;{)B|#(f=ax#^%eFrB0=6;j>FU?a>-QRCCXI+&rDnWawtNIJOGdh%C%^Rqos7%P zW{zdXh}KW+UHzTFtk1D#a!z@$X|Ico_P^Td$0@5)dM@P>OI*Oq{QKagwMylF8sn8M zzijDeN&fEWTp)tgcx#j`NNT|MQTjZiG{mHq!Lb=${F&SKuiBn|4^7SKnPhv}&>DE_ zm^XLycw;f!zRO}YXGuNB^cE!faC@VUo`u$$fJOF-;x4#~=RS>3VXZWquZjmX*Onv{ z^Xpfum-+{i1Fp2<5d559wa6aTqEVm6kwLJ|54ASJDcj;?-L=*Eu*R)hU{llR|I9`fHP`ac}|Hx%_P9F*U_piH(}F}`-Vg|%(}e>Qq=d>YRWZUy+% z>6S7(i@>n|S5d3Tzg-ukRo8EkB<3$Lo9zZJd(4b_M$y8bEY>dWD+)}37gq)j~r@djM=6Iog z)qmPXPaZwhmSK4OW$7A)Lw1eNu>bM+L^zV8@)aizA j@*o})(=p?J&@r9GN0pwgQM@LuC(q+?W%!T3x6%Ir|K|?r literal 0 HcmV?d00001 From d6d5c105170eff376f0c2c0d3b0d27c8ca24ab32 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 11:24:03 +0100 Subject: [PATCH 12/25] completato preview conf x IO --- Thermo.Active.Config/Config/IOConfig.xml | 64 +++++++++---------- .../WebApi/ConfigurationController.cs | 22 ------- 2 files changed, 32 insertions(+), 54 deletions(-) diff --git a/Thermo.Active.Config/Config/IOConfig.xml b/Thermo.Active.Config/Config/IOConfig.xml index 5dacaa96..7602b9d1 100644 --- a/Thermo.Active.Config/Config/IOConfig.xml +++ b/Thermo.Active.Config/Config/IOConfig.xml @@ -1,7 +1,7 @@ - 1 + 0 DI 0 0 @@ -10,7 +10,7 @@ A32.3 - 2 + 1 DI 0 1 @@ -20,7 +20,7 @@ true - 3 + 2 DI 0 2 @@ -29,7 +29,7 @@ A32.7 - 4 + 3 DI 0 3 @@ -38,7 +38,7 @@ A32.8 - 5 + 4 DI 0 4 @@ -47,7 +47,7 @@ A32.1 - 6 + 5 AI 0 5 @@ -56,7 +56,7 @@ A32.2 - 7 + 6 DI 0 6 @@ -65,7 +65,7 @@ A32.4 - 8 + 7 DI 0 7 @@ -74,99 +74,99 @@ A32.6 - 11 + 16 DO - 0 + 1 0 301 404 B43.3 - 12 + 17 DO - 0 + 1 1 301 405 B43.5 - 13 + 18 DO - 0 + 1 2 301 406 B43.7 - 14 + 19 DO - 0 + 1 3 301 407 B43.8 - 15 + 20 DO - 0 + 1 4 301 408 B43.1 - 16 + 21 AI - 0 + 1 5 301 409 B43.2 - 17 + 22 DO - 0 + 1 6 301 210 B43.4 - 18 + 23 DO - 0 + 1 7 301 211 B43.6 - 21 + 16 AI - 0 + 2 0 501 604 C43.3 - 22 + 17 AI - 0 + 2 1 501 605 C43.5 - 31 + 16 AO - 0 + 3 0 701 804 @@ -175,8 +175,8 @@ 31 AO - 0 - 1 + 4 + 15 701 805 D43.5 diff --git a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs index 5a0efe06..0c79ddda 100644 --- a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs +++ b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs @@ -125,28 +125,6 @@ namespace Thermo.Active.Controllers.WebApi return Ok(recipeConfig); } - - [Route("recipeTest"), HttpGet] - public IHttpActionResult GetRecipeTest() - { - List recipeConfig = RecipeConfig.Select(x => new DTORecipeConfigModel() - { - Id = x.Id, - ScaleFactor = x.ScaleFactor, - NumDec = x.NumDec, - Category = x.Category.ToString(), - SubCategory_1 = x.SubCategory_1, - SubCategory_2 = x.SubCategory_2, - Name = x.Name, - Description = x.Description, - Format = x.Format, - Label = $"{x.Category}_{x.SubCategory_1}_{x.SubCategory_2}_{x.Name}".Replace("__", "_").Replace("__", "_").ToLower(), - EnumVal = x.EnumVal - }).ToList(); - - return Ok(recipeConfig); - } - [Route("configIO"), HttpGet] public IHttpActionResult GetIOConfig() { From b8462438c1e3b55ac245e300e9cda6681b3ac480 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 15:54:27 +0100 Subject: [PATCH 13/25] completata verifica lettura IO: OK x AI/AO! --- Thermo.Active.Config/Config/IOConfig.xml | 67 ++++++++++++++++--- .../WebApi/UnderTheHoodController.cs | 62 +---------------- 2 files changed, 57 insertions(+), 72 deletions(-) diff --git a/Thermo.Active.Config/Config/IOConfig.xml b/Thermo.Active.Config/Config/IOConfig.xml index 7602b9d1..6d641346 100644 --- a/Thermo.Active.Config/Config/IOConfig.xml +++ b/Thermo.Active.Config/Config/IOConfig.xml @@ -74,45 +74,45 @@ A32.6 - 16 + 0 DO - 1 + 0 0 301 404 B43.3 - 17 + 1 DO - 1 + 0 1 301 405 B43.5 - 18 + 2 DO - 1 + 0 2 301 406 B43.7 - 19 + 3 DO - 1 + 0 3 301 407 B43.8 - 20 + 4 DO - 1 + 0 4 301 408 @@ -120,7 +120,7 @@ 21 - AI + DO 1 5 301 @@ -145,6 +145,24 @@ 211 B43.6 + + 0 + AI + 0 + 0 + 511 + 614 + C43.23 + + + 1 + AI + 0 + 1 + 511 + 615 + C43.25 + 16 AI @@ -163,6 +181,33 @@ 605 C43.5 + + 0 + AO + 0 + 0 + 700 + 800 + D43.13 + + + 1 + AO + 0 + 1 + 701 + 801 + D43.14 + + + 2 + AO + 0 + 2 + 702 + 802 + D43.15 + 16 AO diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index bd664ba9..ebd97265 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -73,68 +73,8 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(libraryError.localizationKey); } - // ritorno solo fatto! + // ritorno! return Ok(ChannelsIO); -#if false - - - - DTOChannelsIO ChannelsIO = new DTOChannelsIO(); - // leggo i 4 tipi di oggetti e popolo - List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() - { - Id = x.Id, - Bank = x.Bank, - Position = x.Position, - //Page = x.Category.ToString(), - Page = x.Page, - Wire = x.Wire, - Profinet = x.Profinet, - Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() - }).ToList(); - - // assegno! - ChannelsIO.DI = listDI; - ChannelsIO.DO = listDO; - ChannelsIO.AI = listAI; - ChannelsIO.AO = listAO; - - // restituisco - return Ok(ChannelsIO); -#endif } } } \ No newline at end of file From a6a078faacbfbffc1e06fddf72318621c2eef1c8 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 16:19:11 +0100 Subject: [PATCH 14/25] refactor + new DTO x valori signal-r --- .../DTOModels/ThIO/DTOChannelsIO.cs | 109 +++++---------- .../DTOModels/ThIO/DTOChannelsIOVal.cs | 124 ++++++++++++++++++ .../DTOModels/ThIO/IoBaseConf.cs | 57 ++++++++ .../Thermo.Active.Model.csproj | 2 + 4 files changed, 213 insertions(+), 79 deletions(-) create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs create mode 100644 Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs index 24571013..5f7efb57 100644 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIO.cs @@ -8,12 +8,12 @@ namespace Thermo.Active.Model.DTOModels.ThIO { public class DTOChannelsIO { - public List DI { get; set; } - public List DO { get; set; } - public List AI { get; set; } - public List AO { get; set; } + public List DI { get; set; } = new List(); + public List DO { get; set; } = new List(); + public List AI { get; set; } = new List(); + public List AO { get; set; } = new List(); } - public class DigitalIN : IoBaseConf + public class DigitalIN : IoItemConf { public bool Value { get; set; } = false; @@ -25,7 +25,30 @@ namespace Thermo.Active.Model.DTOModels.ThIO if (Value != item.Value) return false; - return base.Equals((IoBaseConf)obj); + return base.Equals((IoItemConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class AnalogIN : IoItemConf + { + public int Value { get; set; } = 0; + + public override bool Equals(object obj) + { + if (!(obj is AnalogIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoItemConf)obj); } /// /// Hash gen @@ -68,34 +91,10 @@ namespace Thermo.Active.Model.DTOModels.ThIO return base.GetHashCode(); } } - public class AnalogIN : IoBaseConf - { - public double Value { get; set; } = 0; - - public override bool Equals(object obj) - { - if (!(obj is AnalogIN item)) - return false; - - if (Value != item.Value) - return false; - - return base.Equals((IoBaseConf)obj); - } - /// - /// Hash gen - /// - /// - public override int GetHashCode() - { - return base.GetHashCode(); - } - } - public class AnalogOUT : AnalogIN { public bool ForceEnabled { get; set; } = true; - public double ForcedValue { get; set; } = 0; + public int ForcedValue { get; set; } = 0; public bool IsForced { get; set; } = false; public override bool Equals(object obj) @@ -122,52 +121,4 @@ namespace Thermo.Active.Model.DTOModels.ThIO } } - public class IoBaseConf - { - public int Id { get; set; } = 0; - public string Bank { get; set; } = "0"; - public string Position { get; set; } = "0"; - public string Page { get; set; } = "0"; - public string Wire { get; set; } = "0"; - public string Profinet { get; set; } = "0"; - public string Label { get; set; } = "LBL"; - public bool Visible { get; set; } = true; - - - public override bool Equals(object obj) - { - if (!(obj is IoBaseConf item)) - return false; - - if (Id != item.Id) - return false; - if (Bank != item.Bank) - return false; - if (Position != item.Position) - return false; - if (Page != item.Page) - return false; - if (Wire != Wire) - return false; - if (Profinet != item.Profinet) - return false; - if (Label != item.Label) - return false; - if (Visible != item.Visible) - return false; - - return true; - } - /// - /// Hash gen - /// - /// - public override int GetHashCode() - { - return base.GetHashCode(); - } - } - - - } diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs new file mode 100644 index 00000000..e36ee53f --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTOChannelsIOVal + { + public List DI { get; set; } = new List(); + public List DO { get; set; } = new List(); + public List AI { get; set; } = new List(); + public List AO { get; set; } = new List(); + } + public class DigInVal: IoItem + { + public bool Value { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DigitalIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoItemConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class AnalInVal: IoItem + { + public int Value { get; set; } = 0; + + public override bool Equals(object obj) + { + if (!(obj is AnalogIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoItemConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class DigOutVal : DigitalIN + { + public bool ForceEnabled { get; set; } = true; + public bool ForceZero { get; set; } = false; + public bool ForceOne { get; set; } = false; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DigitalOUT item)) + return false; + + if (ForceEnabled != item.ForceEnabled) + return false; + if (ForceZero != item.ForceZero) + return false; + if (ForceOne != item.ForceOne) + return false; + if (IsForced != item.IsForced) + return false; + + return base.Equals((DigitalIN)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class AnalOutVal : AnalogIN + { + public bool ForceEnabled { get; set; } = true; + public int ForcedValue { get; set; } = 0; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is AnalogOUT item)) + return false; + + if (ForceEnabled != item.ForceEnabled) + return false; + if (ForcedValue != item.ForcedValue) + return false; + if (IsForced != item.IsForced) + return false; + + return base.Equals((AnalogIN)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs b/Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs new file mode 100644 index 00000000..a11334a3 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class IoItem + { + public int Id { get; set; } = 0; + } + public class IoItemConf:IoItem + { + public string Bank { get; set; } = "0"; + public string Position { get; set; } = "0"; + public string Page { get; set; } = "0"; + public string Wire { get; set; } = "0"; + public string Profinet { get; set; } = "0"; + public string Label { get; set; } = "LBL"; + public bool Visible { get; set; } = true; + + + public override bool Equals(object obj) + { + if (!(obj is IoItemConf item)) + return false; + + if (Id != item.Id) + return false; + if (Bank != item.Bank) + return false; + if (Position != item.Position) + return false; + if (Page != item.Page) + return false; + if (Wire != Wire) + return false; + if (Profinet != item.Profinet) + return false; + if (Label != item.Label) + return false; + if (Visible != item.Visible) + return false; + + return true; + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 37483ff3..365268b4 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -113,8 +113,10 @@ + + From f7fdfd7f55c27d18dbfb3903c8d8268378ec66f3 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 16:44:42 +0100 Subject: [PATCH 15/25] new rel x API solo valori --- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index ef1f06a0..ad421426 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("1.1.151")] +[assembly: AssemblyVersion("1.1.152")] From 4aec0ca0d9163824371c6f4649f551f968ed59ce Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 16:45:22 +0100 Subject: [PATCH 16/25] OK x nuova API invio solo valori (DTO signal-r) --- .../DTOModels/ThIO/DTOChannelsIOVal.cs | 4 +- Thermo.Active.NC/NcAdapter.cs | 73 +++++++++++++++++-- .../WebApi/ConfigurationController.cs | 1 + .../WebApi/UnderTheHoodController.cs | 24 +++++- 4 files changed, 94 insertions(+), 8 deletions(-) diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs index e36ee53f..d327aefe 100644 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOVal.cs @@ -59,7 +59,7 @@ namespace Thermo.Active.Model.DTOModels.ThIO return base.GetHashCode(); } } - public class DigOutVal : DigitalIN + public class DigOutVal : DigInVal { public bool ForceEnabled { get; set; } = true; public bool ForceZero { get; set; } = false; @@ -91,7 +91,7 @@ namespace Thermo.Active.Model.DTOModels.ThIO return base.GetHashCode(); } } - public class AnalOutVal : AnalogIN + public class AnalOutVal : AnalInVal { public bool ForceEnabled { get; set; } = true; public int ForcedValue { get; set; } = 0; diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index c654a714..76d7a76a 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -2167,14 +2167,17 @@ namespace Thermo.Active.NC } return libraryError; } - - - public CmsError ReadIO(out DTOChannelsIO currChannelsIO) + /// + /// Restitusice intero set dati IO Channels (conf + valori) + /// + /// + /// + public CmsError ReadFullIO(out DTOChannelsIO currChannelsIO) { CmsError libraryError = NO_ERROR; currChannelsIO = new DTOChannelsIO(); - // read and return warmers data + // read and return channel IO data if (NcConfig.NcVendor == NC_VENDOR.S7NET) { // lettura da PLC @@ -2183,7 +2186,8 @@ namespace Thermo.Active.NC ThermoModels.ChanIOVal currThermoIOVal = new ThermoModels.ChanIOVal(); ThermoModels.ChanIOFor currThermoIOFor = new ThermoModels.ChanIOFor(); ThermoModels.ChanIOValFor currThermoIOValFor = new ThermoModels.ChanIOValFor(); - libraryError = numericalControl.PLC_RIOChannels(false, ref currThermoIOVis, ref currThermoIOVal, ref currThermoIOFor, ref currThermoIOValFor); + libraryError = numericalControl.PLC_RIOChannelsConf(ref currThermoIOVis); + libraryError = numericalControl.PLC_RIOChannelsVal(ref currThermoIOVal, ref currThermoIOFor, ref currThermoIOValFor); // setup da config List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() @@ -2254,6 +2258,65 @@ namespace Thermo.Active.NC } return libraryError; } + /// + /// Restitusice SOLO VALORI IO Channels + /// + /// + /// + public CmsError ReadValIO(out DTOChannelsIOVal currChannelsIoVal) + { + CmsError libraryError = NO_ERROR; + currChannelsIoVal = new DTOChannelsIOVal(); + // read and return channel IO data + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + // lettura da PLC + Dictionary currModBlock = new Dictionary(); + ThermoModels.ChanIOVis currThermoIOVis = new ThermoModels.ChanIOVis(); + ThermoModels.ChanIOVal currThermoIOVal = new ThermoModels.ChanIOVal(); + ThermoModels.ChanIOFor currThermoIOFor = new ThermoModels.ChanIOFor(); + ThermoModels.ChanIOValFor currThermoIOValFor = new ThermoModels.ChanIOValFor(); + libraryError = numericalControl.PLC_RIOChannelsConf(ref currThermoIOVis); + libraryError = numericalControl.PLC_RIOChannelsVal(ref currThermoIOVal, ref currThermoIOFor, ref currThermoIOValFor); + + // setup da config + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigInVal() + { + Id = x.Id, + Value = currThermoIOVal.DI.ContainsKey(x.Id) ? currThermoIOVal.DI[x.Id] : false + }).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigOutVal() + { + Id = x.Id, + ForceEnabled = !x.DisableForce, + Value = currThermoIOVal.DO.ContainsKey(x.Id) ? currThermoIOVal.DO[x.Id] : false, + IsForced = currThermoIOFor.DO.ContainsKey(x.Id) ? currThermoIOFor.DO[x.Id] : false, + ForceOne = currThermoIOValFor.DO.ContainsKey(x.Id) ? currThermoIOValFor.DO[x.Id] : false, + ForceZero = currThermoIOValFor.DO.ContainsKey(x.Id) ? !currThermoIOValFor.DO[x.Id] : false + }).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalInVal() + { + Id = x.Id, + Value = currThermoIOVal.AI.ContainsKey(x.Id) ? currThermoIOVal.AI[x.Id] : 0 + }).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalOutVal() + { + Id = x.Id, + ForceEnabled = !x.DisableForce, + Value = currThermoIOVal.AO.ContainsKey(x.Id) ? currThermoIOVal.AO[x.Id] : 0, + IsForced = currThermoIOFor.AO.ContainsKey(x.Id) ? currThermoIOFor.AO[x.Id] : false, + ForcedValue = currThermoIOValFor.AO.ContainsKey(x.Id) ? currThermoIOValFor.AO[x.Id] : 0 + }).ToList(); + + // assegno! + currChannelsIoVal.DI = listDI; + currChannelsIoVal.DO = listDO; + currChannelsIoVal.AI = listAI; + currChannelsIoVal.AO = listAO; + } + return libraryError; + + } /// /// Legge tutti i parametri della ricetta diff --git a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs index 0c79ddda..35f08dbe 100644 --- a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs +++ b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs @@ -128,6 +128,7 @@ namespace Thermo.Active.Controllers.WebApi [Route("configIO"), HttpGet] public IHttpActionResult GetIOConfig() { + // restituisce la configurazione come item dei banchi DI/DO/AI/AO DTOChannelsSetup configIO = new DTOChannelsSetup(); // leggo i 4 tipi di oggetti e popolo List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).GroupBy(x => x.Bank).Select(x => x.Key).ToList(); diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index ebd97265..e27ca247 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -66,7 +66,7 @@ namespace Thermo.Active.Controllers.WebApi } // leggo dati gauges - libraryError = ncAdapter.ReadIO(out DTOChannelsIO ChannelsIO); + libraryError = ncAdapter.ReadFullIO(out DTOChannelsIO ChannelsIO); if (libraryError.IsError()) { ThermoActiveLogger.LogError($"GetChannelsIO error | {libraryError.exception}"); @@ -76,5 +76,27 @@ namespace Thermo.Active.Controllers.WebApi // ritorno! return Ok(ChannelsIO); } + [Route("channels_io_val"), HttpGet] + public IHttpActionResult GetChannelsIoVal() + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | GetChannelsIoVal | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + // leggo dati gauges + libraryError = ncAdapter.ReadValIO(out DTOChannelsIOVal ChannelsIOVal); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"GetChannelsIoVal error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); + } + + // ritorno! + return Ok(ChannelsIOVal); + } } } \ No newline at end of file From b6dc59ea939327ba09b35eb81551e652a1db9ab6 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 19:12:19 +0100 Subject: [PATCH 17/25] Prima vers signal-r x dati ChannelsIO --- Thermo.Active.Config/Config/serverConfig.xml | 2 + Thermo.Active.Core/ThreadsFunctions.cs | 50 +++++++++++++ Thermo.Active.Core/ThreadsHandler.cs | 1 + .../Controllers/RedisController.cs | 26 +++++++ Thermo.Active.Model/Constants.cs | 1 + Thermo.Active/Listeners/ListenersHandler.cs | 4 ++ .../Listeners/SignalR/SignalRListener.cs | 70 +++++++++++++++++-- .../Listeners/SignalRStaticObjects.cs | 4 ++ 8 files changed, 153 insertions(+), 5 deletions(-) diff --git a/Thermo.Active.Config/Config/serverConfig.xml b/Thermo.Active.Config/Config/serverConfig.xml index fac4f66d..43d120f2 100644 --- a/Thermo.Active.Config/Config/serverConfig.xml +++ b/Thermo.Active.Config/Config/serverConfig.xml @@ -119,6 +119,8 @@ + + diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 211a283c..57fa3178 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -30,6 +30,7 @@ using static Thermo.Active.Utils.ExceptionManager; using System.Windows; using System.Drawing; using System.Configuration; +using Thermo.Active.Model.DTOModels.ThIO; public static class ThreadsFunctions { @@ -412,6 +413,55 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } + /// + /// Lettura valorichannelsIO + /// + public static void ReadChannelsIoData() + { + NcAdapter ncAdapter = new NcAdapter(); + Stopwatch sw = new Stopwatch(); + + try + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.errorCode != 0) + ManageLibraryError(libraryError); + + while (true) + { + + sw.Restart(); + + if (ncAdapter.numericalControl.NC_IsConnected()) + { + // Get Data from config and PLC + libraryError = ncAdapter.ReadValIO(out DTOChannelsIOVal currChannelsIoVal); + if (libraryError.errorCode != 0) + ManageLibraryError(libraryError); + else + // Send through signalR + MessageServices.Current.Publish(SEND_CHANNELS_IO_DATA, null, currChannelsIoVal); + } + else + RestoreConnection(); + + sw.Stop(); + + //Update thread timer + UpdateStat(MethodBase.GetCurrentMethod().Name, sw.ElapsedMilliseconds); + + // verifico se periodo rapido o veloce... + int timerAct = RedisController.FastIoSample ? samplMsec("channelsIoFast") : samplMsec("channelsIoSlow"); + // Wait + Thread.Sleep(CalcSleepTime(timerAct, (int)sw.ElapsedMilliseconds)); + } + } + catch (ThreadAbortException) + { + ncAdapter.Dispose(); + } + } public static void ReadEnabledFunctionality() { diff --git a/Thermo.Active.Core/ThreadsHandler.cs b/Thermo.Active.Core/ThreadsHandler.cs index 1727e073..0c608eb8 100644 --- a/Thermo.Active.Core/ThreadsHandler.cs +++ b/Thermo.Active.Core/ThreadsHandler.cs @@ -36,6 +36,7 @@ namespace Thermo.Active.Core ThreadsFunctions.ReadScadaData, ThreadsFunctions.ReadMComandsData, ThreadsFunctions.ReadAxisInfoData, + ThreadsFunctions.ReadChannelsIoData, ThreadsFunctions.ReadM154Data // levare? }; diff --git a/Thermo.Active.Database/Controllers/RedisController.cs b/Thermo.Active.Database/Controllers/RedisController.cs index 1143bef6..ce50bbff 100644 --- a/Thermo.Active.Database/Controllers/RedisController.cs +++ b/Thermo.Active.Database/Controllers/RedisController.cs @@ -183,6 +183,32 @@ namespace Thermo.Active.Database.Controllers redUtil.man.ListPush(redisHash, msg); return true; } + public static string ReadValue(string msgKey) + { + string redisHash = redUtil.man.redHash(msgKey); + return redUtil.man.getRSV(redisHash); + } + public static bool WriteValue(string msgKey, string msg, int ttlSec) + { + string redisHash = redUtil.man.redHash(msgKey); + redUtil.man.setRSV(redisHash, msg, ttlSec); + return true; + } + + public static bool FastIoSample + { + get + { + var currVal = ReadValue("FastIoSample"); + bool answ = !string.IsNullOrEmpty(currVal); + return answ; + } + set + { + // imposta con TTL a 5 min + WriteValue("FastIoSample", "Active", 60 * 5); + } + } public static bool WriteCurrentAxisStatus(Dictionary axis) { diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index 213147a5..fc041bc4 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -377,6 +377,7 @@ namespace Thermo.Active.Model public const string SEND_NC_SOFTKEYS_DATA = "SEND_NC_SOFTKEYS_DATA"; public const string SEND_HEADS_DATA = "SEND_HEADS_DATA"; public const string SEND_AXIS_INFO = "SEND_AXIS_INFO"; + public const string SEND_CHANNELS_IO_DATA = "SEND_CHANNELS_IO_DATA"; public const string SEND_ACTIVE_PROGRAM_DATA = "SEND_ACTIVE_PROGRAM_DATA"; public const string SEND_QUEUE_DATA = "SEND_QUEUE_DATA"; public const string SEND_M155_DATA = "SEND_M155_DATA"; diff --git a/Thermo.Active/Listeners/ListenersHandler.cs b/Thermo.Active/Listeners/ListenersHandler.cs index ec75eaa5..f9b7a02e 100644 --- a/Thermo.Active/Listeners/ListenersHandler.cs +++ b/Thermo.Active/Listeners/ListenersHandler.cs @@ -64,6 +64,10 @@ namespace Thermo.Active.Listeners { SignalRListener.SendThermoAxisInfoData(a); })); + infos.Add(MessageServices.Current.Subscribe(SEND_CHANNELS_IO_DATA, (a, b) => + { + SignalRListener.SendThermoChannelsIoData(a); + })); infos.Add(MessageServices.Current.Subscribe(SEND_ACTIVE_PROGRAM_DATA, (a, b) => { SignalRListener.SendActiveProgramData(a); diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index e0029ecb..ee78b783 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -13,6 +13,7 @@ using Thermo.Active.Model.DTOModels; using Thermo.Active.Model.DTOModels.AlarmModels; using Thermo.Active.Model.DTOModels.Scada; using Thermo.Active.Model.DTOModels.ThAxes; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThModules; using Thermo.Active.Model.DTOModels.ThProd; using Thermo.Active.Model.DTOModels.ThRecipe; @@ -59,7 +60,7 @@ namespace Thermo.Active.Listeners.SignalR { RedisController.WriteCurrentMachineEmergencyPath(LastPowerOnData.PrePowerOn.EmergencyButtons.Active); } - + } } @@ -456,8 +457,8 @@ namespace Thermo.Active.Listeners.SignalR LastProdPanelData = currProdPanel; var context = GlobalHost.ConnectionManager.GetHubContext(); - context.Clients.Group("ncData").prodPanelData(currProdPanel); - + context.Clients.Group("ncData").prodPanelData(currProdPanel); + if (Config.ServerConfig.ServerStartupConfig.CmsConnectReady) { if (newPiece) @@ -508,8 +509,8 @@ namespace Thermo.Active.Listeners.SignalR RedisController.WriteCurrentMachineStatus(CMSConnectConstants.ConvertThermoToConnectStatus(currProdCycle.Status)); RedisController.WriteCurrentMachinePowerPath(CMSConnectConstants.ConvertThermoToConnectPower(currProdCycle.Status)); - RedisController.WriteCurrentProcessStatus(1,CMSConnectConstants.ConvertThermoToConnectProcessStatus(currProdCycle.Status)); - RedisController.WriteCurrentProcessMode(1,CMSConnectConstants.ConvertThermoToConnectProcessMode(currProdCycle.Mode)); + RedisController.WriteCurrentProcessStatus(1, CMSConnectConstants.ConvertThermoToConnectProcessStatus(currProdCycle.Status)); + RedisController.WriteCurrentProcessMode(1, CMSConnectConstants.ConvertThermoToConnectProcessMode(currProdCycle.Mode)); } @@ -551,6 +552,65 @@ namespace Thermo.Active.Listeners.SignalR } } + public static void SendThermoChannelsIoData(object channelsIoData) + { + DTOChannelsIOVal currChannelsIoData = channelsIoData as DTOChannelsIOVal; + DTOChannelsIOVal diffChannelsData = new DTOChannelsIOVal(); + + // processing differenze DI + foreach (var item in currChannelsIoData.DI) + { + // recupero + var element = LastChannelsIoData.DI.Find(x => x.Id == item.Id); + if ((element == null) || (!item.Value.Equals(element))) + { + diffChannelsData.DI.Add(item); + } + } + // processing differenze DO + foreach (var item in currChannelsIoData.DO) + { + // recupero + var element = LastChannelsIoData.DO.Find(x => x.Id == item.Id); + if ((element == null) || (!item.Value.Equals(element))) + { + diffChannelsData.DO.Add(item); + } + } + // processing differenze AI + foreach (var item in currChannelsIoData.AI) + { + // recupero + var element = LastChannelsIoData.AI.Find(x => x.Id == item.Id); + if ((element == null) || (!item.Value.Equals(element))) + { + diffChannelsData.AI.Add(item); + } + } + // processing differenze AO + foreach (var item in currChannelsIoData.AO) + { + // recupero + var element = LastChannelsIoData.AO.Find(x => x.Id == item.Id); + if ((element == null) || (!item.Value.Equals(element))) + { + diffChannelsData.AO.Add(item); + } + } + + // se ho differenze invio! + if (diffChannelsData.DI.Count + diffChannelsData.DO.Count + diffChannelsData.AI.Count + diffChannelsData.AO.Count > 0) + { + // salvo update CLONANDO + LastChannelsIoData.DI = currChannelsIoData.DI.Clone(); + LastChannelsIoData.DO = currChannelsIoData.DO.Clone(); + LastChannelsIoData.AI = currChannelsIoData.AI.Clone(); + LastChannelsIoData.AO = currChannelsIoData.AO.Clone(); + var context = GlobalHost.ConnectionManager.GetHubContext(); + context.Clients.Group("ncData").channelsIoVal(diffChannelsData); + } + } + public static void SetGatewayRebootStatus(object status) { string msg = status.ToString(); diff --git a/Thermo.Active/Listeners/SignalRStaticObjects.cs b/Thermo.Active/Listeners/SignalRStaticObjects.cs index df07bf23..82d3e34f 100644 --- a/Thermo.Active/Listeners/SignalRStaticObjects.cs +++ b/Thermo.Active/Listeners/SignalRStaticObjects.cs @@ -1,9 +1,11 @@ using CMS_CORE_Library.Models; +using System; using System.Collections.Generic; using Thermo.Active.Model.DTOModels; using Thermo.Active.Model.DTOModels.AlarmModels; using Thermo.Active.Model.DTOModels.Scada; using Thermo.Active.Model.DTOModels.ThAxes; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThModules; using Thermo.Active.Model.DTOModels.ThProd; using Thermo.Active.Model.DTOModels.ThRecipe; @@ -46,6 +48,8 @@ namespace Thermo.Active.Listeners public static DTOThermoPanelProd LastProdPanelData = new DTOThermoPanelProd(); // Oggetti per assi THERMO public static Dictionary LastAxisInfoData = new Dictionary(); + // Oggetti x Valori Channels IO + public static DTOChannelsIOVal LastChannelsIoData = new DTOChannelsIOVal(); public static bool LastIsNcConnected = false; } From 7578bc4b5bb508ac7123be0b8235b2ed7c4358b7 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 19:13:43 +0100 Subject: [PATCH 18/25] new rel vers --- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index ad421426..b1d4bd88 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("1.1.152")] +[assembly: AssemblyVersion("1.1.153")] From 302c74c64e0736e91eba194c47b0b47a5116ab77 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 4 Feb 2021 19:14:08 +0100 Subject: [PATCH 19/25] start new rel sprint --- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index b1d4bd88..e371e850 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("1.1.153")] +[assembly: AssemblyVersion("1.1.154")] From dd7ca930aec59827b323b915cf6c12c278d71b43 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 5 Feb 2021 12:24:56 +0100 Subject: [PATCH 20/25] Add PLC R/W per channlesIO (val e forzature) --- Thermo.Active.NC/NcAdapter.cs | 135 ++++++++++++++++- .../WebApi/UnderTheHoodController.cs | 140 ++++++++++++++++++ 2 files changed, 270 insertions(+), 5 deletions(-) diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 76d7a76a..df4e195a 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -2168,7 +2168,7 @@ namespace Thermo.Active.NC return libraryError; } /// - /// Restitusice intero set dati IO Channels (conf + valori) + /// Restituisce intero set dati IO Channels (conf + valori) /// /// /// @@ -2272,11 +2272,9 @@ namespace Thermo.Active.NC { // lettura da PLC Dictionary currModBlock = new Dictionary(); - ThermoModels.ChanIOVis currThermoIOVis = new ThermoModels.ChanIOVis(); ThermoModels.ChanIOVal currThermoIOVal = new ThermoModels.ChanIOVal(); ThermoModels.ChanIOFor currThermoIOFor = new ThermoModels.ChanIOFor(); ThermoModels.ChanIOValFor currThermoIOValFor = new ThermoModels.ChanIOValFor(); - libraryError = numericalControl.PLC_RIOChannelsConf(ref currThermoIOVis); libraryError = numericalControl.PLC_RIOChannelsVal(ref currThermoIOVal, ref currThermoIOFor, ref currThermoIOValFor); // setup da config @@ -3340,7 +3338,7 @@ namespace Thermo.Active.NC /// /// Oggetto parametri da aggiornare (from HMI) /// num max parametri da scrivere singolarmente - /// delay in scriottura multi parametri singoli + /// delay in scrittura multi parametri singoli /// public CmsError WriteRecipeParametersToPLC(Dictionary updtRecipe, int nMaxParamWrite, int delayParamWrite) { @@ -3370,7 +3368,7 @@ namespace Thermo.Active.NC /// /// Oggetto parametri da aggiornare (from HMI) /// num max parametri da scrivere singolarmente - /// delay in scriottura multi parametri singoli + /// delay in scrittura multi parametri singoli /// public CmsError WriteRecipeParams(Dictionary updtRecipe, int nMaxParamWrite, int delayParamWrite) { @@ -3379,6 +3377,133 @@ namespace Thermo.Active.NC return libraryError; } + + /// + /// ChannelsID: write DO to PLC (values + setForce) + /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scrittura multi parametri singoli + /// + public CmsError Write_IO_DO_ToPLC(Dictionary newValues, int nMaxParamWrite, int delayParamWrite) + { + // solo x S7... + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + // scrivo! + CmsError libraryError = numericalControl.PLC_W_IO_DO_Val(newValues, nMaxParamWrite, delayParamWrite); + if (libraryError.IsError()) + return libraryError; + } + else + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + return NO_ERROR; + } + /// + /// ChannelsID: write AO to PLC (values + setForce) + /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scrittura multi parametri singoli + /// + public CmsError Write_IO_AO_ToPLC(Dictionary newValues, int nMaxParamWrite, int delayParamWrite) + { + // solo x S7... + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + // scrivo! + CmsError libraryError = numericalControl.PLC_W_IO_AO_Val(newValues, nMaxParamWrite, delayParamWrite); + if (libraryError.IsError()) + return libraryError; + } + else + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + return NO_ERROR; + } + /// + /// ChannelsID: Write RESET (not forced) for DO to PLC (setForce = false) + /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scrittura multi parametri singoli + /// + public CmsError WriteReset_IO_DO_ToPLC(List channels, int nMaxParamWrite, int delayParamWrite) + { + // solo x S7... + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + Dictionary newForced = new Dictionary(); + foreach (var item in channels) + { + newForced.Add(item, false); + } + // scrivo! + CmsError libraryError = numericalControl.PLC_W_IO_DO_Reset(newForced, nMaxParamWrite, delayParamWrite); + if (libraryError.IsError()) + return libraryError; + } + else + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + return NO_ERROR; + } + /// + /// ChannelsID: Write RESET (not forced) for AO to PLC (setForce = false) + /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scrittura multi parametri singoli + /// + public CmsError WriteReset_IO_AO_ToPLC(List channels, int nMaxParamWrite, int delayParamWrite) + { + // solo x S7... + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + Dictionary newForced = new Dictionary(); + foreach (var item in channels) + { + newForced.Add(item, false); + } + // scrivo! + CmsError libraryError = numericalControl.PLC_W_IO_AO_Reset(newForced, nMaxParamWrite, delayParamWrite); + if (libraryError.IsError()) + return libraryError; + } + else + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + return NO_ERROR; + } + /// + /// ChannelsID: Write RESET (not forced) for DO + AO to PLC (setForce = false) + /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scrittura multi parametri singoli + /// + public CmsError WriteReset_IO_ALL_ToPLC() + { + // solo x S7... + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + // scrivo! + CmsError libraryError = numericalControl.PLC_W_IO_ResetAll(); + if (libraryError.IsError()) + return libraryError; + } + else + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + return NO_ERROR; + } + /// /// Scrive le softkey star /// diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index e27ca247..a7c78529 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -98,5 +98,145 @@ namespace Thermo.Active.Controllers.WebApi // ritorno! return Ok(ChannelsIOVal); } + + + [Route("io_force_ch_do"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] + public IHttpActionResult ForceChDO(Dictionary parametersList) + { + if (parametersList != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | ForceChDO | {libraryError.exception}"); + return InternalServerError(); + } + + if (parametersList.Count > 0) + { + // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + ncAdapter.Write_IO_DO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + } + + // ritorno solo fatto! + return Ok(); + } + else + { + ThermoActiveLogger.LogError($"ForceChDO parametersList null | Empty Parameters"); + return BadRequest(); + } + } + + [Route("io_force_ch_ao"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] + public IHttpActionResult ForceChAO(Dictionary parametersList) + { + if (parametersList != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | ForceChAO | {libraryError.exception}"); + return InternalServerError(); + } + + if (parametersList.Count > 0) + { + // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + ncAdapter.Write_IO_AO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + } + + // ritorno solo fatto! + return Ok(); + } + else + { + ThermoActiveLogger.LogError($"ForceChAO parametersList null | Empty Parameters"); + return BadRequest(); + } + } + + [Route("io_reset_ch_do"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] + public IHttpActionResult ResetChDO(List parametersList) + { + if (parametersList != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | ResetChDO | {libraryError.exception}"); + return InternalServerError(); + } + + if (parametersList.Count > 0) + { + // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + ncAdapter.WriteReset_IO_DO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + } + + // ritorno solo fatto! + return Ok(); + } + else + { + ThermoActiveLogger.LogError($"ResetChDO parametersList null | Empty Parameters"); + return BadRequest(); + } + } + + [Route("io_reset_ch_ao"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] + public IHttpActionResult ResetChAO(List parametersList) + { + if (parametersList != null) + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | ResetChAO | {libraryError.exception}"); + return InternalServerError(); + } + + if (parametersList.Count > 0) + { + // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + ncAdapter.WriteReset_IO_AO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + } + + // ritorno solo fatto! + return Ok(); + } + else + { + ThermoActiveLogger.LogError($"ResetChAO parametersList null | Empty Parameters"); + return BadRequest(); + } + } + + [Route("io_reset_all_ch"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] + public IHttpActionResult ResetAllCh() + { + // Try connection + CmsError libraryError = ncAdapter.Connect(); + if (libraryError.IsError()) + { + ThermoActiveLogger.LogError($"NC Not connected! | ResetAllCh | {libraryError.exception}"); + return InternalServerError(); + } + + // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + ncAdapter.WriteReset_IO_ALL_ToPLC();//parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + + // ritorno solo fatto! + return Ok(); + } } } \ No newline at end of file From 28444f60c0fc8b62276e33a0d16708641cbd6918 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 5 Feb 2021 13:59:49 +0100 Subject: [PATCH 21/25] Completata implementazione WRITE IO (testare!) --- Thermo.Active.NC/NcAdapter.cs | 24 +++++++------------ .../WebApi/UnderTheHoodController.cs | 10 ++++---- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index df4e195a..e484a923 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -3382,16 +3382,14 @@ namespace Thermo.Active.NC /// ChannelsID: write DO to PLC (values + setForce) /// /// Oggetto parametri da aggiornare (from HMI) - /// num max parametri da scrivere singolarmente - /// delay in scrittura multi parametri singoli /// - public CmsError Write_IO_DO_ToPLC(Dictionary newValues, int nMaxParamWrite, int delayParamWrite) + public CmsError Write_IO_DO_ToPLC(Dictionary newValues) { // solo x S7... if (NcConfig.NcVendor == NC_VENDOR.S7NET) { // scrivo! - CmsError libraryError = numericalControl.PLC_W_IO_DO_Val(newValues, nMaxParamWrite, delayParamWrite); + CmsError libraryError = numericalControl.PLC_W_IO_DO_Val(newValues); if (libraryError.IsError()) return libraryError; } @@ -3405,16 +3403,14 @@ namespace Thermo.Active.NC /// ChannelsID: write AO to PLC (values + setForce) /// /// Oggetto parametri da aggiornare (from HMI) - /// num max parametri da scrivere singolarmente - /// delay in scrittura multi parametri singoli /// - public CmsError Write_IO_AO_ToPLC(Dictionary newValues, int nMaxParamWrite, int delayParamWrite) + public CmsError Write_IO_AO_ToPLC(Dictionary newValues) { // solo x S7... if (NcConfig.NcVendor == NC_VENDOR.S7NET) { // scrivo! - CmsError libraryError = numericalControl.PLC_W_IO_AO_Val(newValues, nMaxParamWrite, delayParamWrite); + CmsError libraryError = numericalControl.PLC_W_IO_AO_Val(newValues); if (libraryError.IsError()) return libraryError; } @@ -3428,10 +3424,8 @@ namespace Thermo.Active.NC /// ChannelsID: Write RESET (not forced) for DO to PLC (setForce = false) /// /// Oggetto parametri da aggiornare (from HMI) - /// num max parametri da scrivere singolarmente - /// delay in scrittura multi parametri singoli /// - public CmsError WriteReset_IO_DO_ToPLC(List channels, int nMaxParamWrite, int delayParamWrite) + public CmsError WriteReset_IO_DO_ToPLC(List channels) { // solo x S7... if (NcConfig.NcVendor == NC_VENDOR.S7NET) @@ -3442,7 +3436,7 @@ namespace Thermo.Active.NC newForced.Add(item, false); } // scrivo! - CmsError libraryError = numericalControl.PLC_W_IO_DO_Reset(newForced, nMaxParamWrite, delayParamWrite); + CmsError libraryError = numericalControl.PLC_W_IO_DO_Reset(newForced); if (libraryError.IsError()) return libraryError; } @@ -3456,10 +3450,8 @@ namespace Thermo.Active.NC /// ChannelsID: Write RESET (not forced) for AO to PLC (setForce = false) /// /// Oggetto parametri da aggiornare (from HMI) - /// num max parametri da scrivere singolarmente - /// delay in scrittura multi parametri singoli /// - public CmsError WriteReset_IO_AO_ToPLC(List channels, int nMaxParamWrite, int delayParamWrite) + public CmsError WriteReset_IO_AO_ToPLC(List channels) { // solo x S7... if (NcConfig.NcVendor == NC_VENDOR.S7NET) @@ -3470,7 +3462,7 @@ namespace Thermo.Active.NC newForced.Add(item, false); } // scrivo! - CmsError libraryError = numericalControl.PLC_W_IO_AO_Reset(newForced, nMaxParamWrite, delayParamWrite); + CmsError libraryError = numericalControl.PLC_W_IO_AO_Reset(newForced); if (libraryError.IsError()) return libraryError; } diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index a7c78529..6e37fd79 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -117,7 +117,7 @@ namespace Thermo.Active.Controllers.WebApi if (parametersList.Count > 0) { // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento - ncAdapter.Write_IO_DO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + ncAdapter.Write_IO_DO_ToPLC(parametersList); } // ritorno solo fatto! @@ -147,7 +147,7 @@ namespace Thermo.Active.Controllers.WebApi if (parametersList.Count > 0) { // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento - ncAdapter.Write_IO_AO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + ncAdapter.Write_IO_AO_ToPLC(parametersList); } // ritorno solo fatto! @@ -177,7 +177,7 @@ namespace Thermo.Active.Controllers.WebApi if (parametersList.Count > 0) { // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento - ncAdapter.WriteReset_IO_DO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + ncAdapter.WriteReset_IO_DO_ToPLC(parametersList); } // ritorno solo fatto! @@ -207,7 +207,7 @@ namespace Thermo.Active.Controllers.WebApi if (parametersList.Count > 0) { // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento - ncAdapter.WriteReset_IO_AO_ToPLC(parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + ncAdapter.WriteReset_IO_AO_ToPLC(parametersList); } // ritorno solo fatto! @@ -233,7 +233,7 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento - ncAdapter.WriteReset_IO_ALL_ToPLC();//parametersList, ncAdapter.nMaxParamWrite, ncAdapter.delayParamWrite); + ncAdapter.WriteReset_IO_ALL_ToPLC();//parametersList); // ritorno solo fatto! return Ok(); From 0ccab81063639ee46e7ae66662feb43cb2aedae7 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 5 Feb 2021 14:28:39 +0100 Subject: [PATCH 22/25] Aggiunta conf x sample variabile --- .../Controllers/RedisController.cs | 31 ++++++++++--------- .../WebApi/UnderTheHoodController.cs | 10 ++++++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Thermo.Active.Database/Controllers/RedisController.cs b/Thermo.Active.Database/Controllers/RedisController.cs index ce50bbff..9bd42ef6 100644 --- a/Thermo.Active.Database/Controllers/RedisController.cs +++ b/Thermo.Active.Database/Controllers/RedisController.cs @@ -19,7 +19,7 @@ namespace Thermo.Active.Database.Controllers private const string machinePowerPath = "Machine:Power"; private const string machineAlarmPath = "Machine:Alarm"; private const string machineEmergencyPath = "Machine:Emergency"; - private const string alarmsPath = "Machine:Plc:Condition"; + private const string alarmsPath = "Machine:Plc:Condition"; private const string processStatusPath = "Machine:Cnc:CncProcesses:%NN%:Status"; private const string processModePath = "Machine:Cnc:CncProcesses:%NN%:Mode"; private const string processFeedOverridePath = "Machine:Cnc:CncProcesses:%NN%:FeedOverride"; @@ -27,7 +27,7 @@ namespace Thermo.Active.Database.Controllers private const string processSpeedOverridePath = "Machine:Cnc:CncProcesses:%NN%:SpeedOverride"; private const string datamodelPath = "AdpConf:DataModel"; - private const string currentActiveVersionPath = "Machine:Hmi:Version"; + private const string currentActiveVersionPath = "Machine:Hmi:Version"; private const string machineAxisPosition = "Machine:Axes:%NN%:CurrentPos"; private const string machineAxisSpeed = "Machine:Axes:%NN%:FeedRate"; private const string machineAxisLoad = "Machine:Axes:%NN%:Load"; @@ -70,7 +70,7 @@ namespace Thermo.Active.Database.Controllers string redisHash = redUtil.man.redHash(redisAlmEn); return redUtil.man.redSaveHashDict(redisHash, alarms); } - + public static bool WriteDatamodel(string datamodel) { @@ -79,7 +79,7 @@ namespace Thermo.Active.Database.Controllers } public static bool WriteDefaultEntry(Dictionary entries) { - foreach (KeyValuePair entry in entries) + foreach (KeyValuePair entry in entries) { if (!redUtil.man.setRSV(redUtil.man.redHash(entry.Key), entry.Value)) return false; @@ -109,7 +109,7 @@ namespace Thermo.Active.Database.Controllers string redisHash = redUtil.man.redHash(machineStatusPath); return redUtil.man.setRSV(redisHash, status.ToString()); } - + public static bool WriteCurrentProcessStatus(uint ProductionProcess, string status) { string redisHash = redUtil.man.redHash(processStatusPath).Replace("%NN%", ProductionProcess.ToString("00")); @@ -131,21 +131,21 @@ namespace Thermo.Active.Database.Controllers if (!redUtil.man.setRSV(redisHash, "100")) return false; redisHash = redUtil.man.redHash(processSpeedOverridePath).Replace("%NN%", ProductionProcess.ToString("00")); - if(!redUtil.man.setRSV(redisHash, "100")) + if (!redUtil.man.setRSV(redisHash, "100")) return false; return true; } - + public static bool WriteCurrentMachinePowerPath(bool status) { string redisHash = redUtil.man.redHash(machinePowerPath); - if(status) + if (status) return redUtil.man.setRSV(redisHash, "true"); else return redUtil.man.setRSV(redisHash, "false"); } - + public static bool WriteCurrentMachineAlarmPath(bool status) { string redisHash = redUtil.man.redHash(machineAlarmPath); @@ -154,7 +154,7 @@ namespace Thermo.Active.Database.Controllers else return redUtil.man.setRSV(redisHash, "false"); } - + public static bool WriteCurrentMachineEmergencyPath(bool status) { string redisHash = redUtil.man.redHash(machineEmergencyPath); @@ -205,18 +205,19 @@ namespace Thermo.Active.Database.Controllers } set { - // imposta con TTL a 5 min - WriteValue("FastIoSample", "Active", 60 * 5); + // TTL: se true 5 min, altrimenti 1 sec + int ttlSec = value ? 60 * 5 : 1; + WriteValue("FastIoSample", "Active", ttlSec); } } public static bool WriteCurrentAxisStatus(Dictionary axis) { - foreach(KeyValuePair asse in axis) + foreach (KeyValuePair asse in axis) { string redisHash = redUtil.man.redHash(machineAxisName).Replace("%NN%", asse.Value.ID.ToString("00")); - if(redUtil.man.getRSV(redisHash) != null) + if (redUtil.man.getRSV(redisHash) != null) { redisHash = redUtil.man.redHash(machineAxisPosition).Replace("%NN%", asse.Value.ID.ToString("00")); if (!redUtil.man.setRSV(redisHash, asse.Value.position.ToString())) @@ -229,7 +230,7 @@ namespace Thermo.Active.Database.Controllers redisHash = redUtil.man.redHash(machineAxisLoad).Replace("%NN%", asse.Value.ID.ToString("00")); if (!redUtil.man.setRSV(redisHash, asse.Value.load.ToString())) return false; - } + } } return true; } diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index 6e37fd79..73f2663f 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -235,6 +235,16 @@ namespace Thermo.Active.Controllers.WebApi // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento ncAdapter.WriteReset_IO_ALL_ToPLC();//parametersList); + // ritorno solo fatto! + return Ok(); + } + [Route("io_sample_fast"), HttpPut] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] + public IHttpActionResult SetFastSample(bool value) + { + // imposta (su redis) campionamento RAPIDO/lento x IO... + RedisController.FastIoSample = value; + // ritorno solo fatto! return Ok(); } From de3c615801adda0a127519f42bd8abdd56e0bdaf Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 5 Feb 2021 14:28:47 +0100 Subject: [PATCH 23/25] new rel --- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index e371e850..b8343141 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("1.1.154")] +[assembly: AssemblyVersion("1.1.155")] From 8fc103563d0e2b674b214108c22f6f65b0544a86 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 5 Feb 2021 16:04:03 +0100 Subject: [PATCH 24/25] fix swagger class reference --- .../DTOModels/ThIO/DTOCycleLog.cs | 20 ++ .../ThIO/{IoBaseConf.cs => IoItemConf.cs} | 10 +- .../Thermo.Active.Model.csproj | 3 +- Thermo.Active/App_Start/SwaggerConfig.cs | 226 +++++++++--------- .../WebApi/UnderTheHoodController.cs | 58 +++-- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 6 files changed, 190 insertions(+), 129 deletions(-) create mode 100644 Thermo.Active.Model/DTOModels/ThIO/DTOCycleLog.cs rename Thermo.Active.Model/DTOModels/ThIO/{IoBaseConf.cs => IoItemConf.cs} (86%) diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOCycleLog.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOCycleLog.cs new file mode 100644 index 00000000..9cbc2db6 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOCycleLog.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTOCycleLog + { + public List events { get; set; } = new List(); + } + + public class CycleEvent + { + public DateTime dtEvent { get; set; } + + public int code { get; set; } = 0; + } +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs b/Thermo.Active.Model/DTOModels/ThIO/IoItemConf.cs similarity index 86% rename from Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs rename to Thermo.Active.Model/DTOModels/ThIO/IoItemConf.cs index a11334a3..6e4e2b6c 100644 --- a/Thermo.Active.Model/DTOModels/ThIO/IoBaseConf.cs +++ b/Thermo.Active.Model/DTOModels/ThIO/IoItemConf.cs @@ -10,7 +10,15 @@ namespace Thermo.Active.Model.DTOModels.ThIO { public int Id { get; set; } = 0; } - public class IoItemConf:IoItem + public class IoItemDigi : IoItem + { + public bool value { get; set; } = false; + } + public class IoItemAnal : IoItem + { + public int value { get; set; } = 0; + } + public class IoItemConf : IoItem { public string Bank { get; set; } = "0"; public string Position { get; set; } = "0"; diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 365268b4..9c1f8e90 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -114,9 +114,10 @@ + - + diff --git a/Thermo.Active/App_Start/SwaggerConfig.cs b/Thermo.Active/App_Start/SwaggerConfig.cs index fb0fe40a..704b5f02 100644 --- a/Thermo.Active/App_Start/SwaggerConfig.cs +++ b/Thermo.Active/App_Start/SwaggerConfig.cs @@ -1,6 +1,9 @@ using Swashbuckle.Application; using Swashbuckle.Swagger; +using System; using System.Collections.Generic; +using System.IO; +using System.Reflection; using System.Web.Http; using System.Web.Http.Description; @@ -33,129 +36,132 @@ namespace Thermo.Active // c.SingleApiVersion("v1", "ThermoActive"); - // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option. - // - //c.PrettyPrint(); + // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option. + // + //c.PrettyPrint(); - // If your API has multiple versions, use "MultipleApiVersions" instead of "SingleApiVersion". - // In this case, you must provide a lambda that tells Swashbuckle which actions should be - // included in the docs for a given API version. Like "SingleApiVersion", each call to "Version" - // returns an "Info" builder so you can provide additional metadata per API version. - // - //c.MultipleApiVersions( - // (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion), - // (vc) => - // { - // vc.Version("v2", "Swashbuckle Dummy API V2"); - // vc.Version("v1", "Swashbuckle Dummy API V1"); - // }); + // If your API has multiple versions, use "MultipleApiVersions" instead of "SingleApiVersion". + // In this case, you must provide a lambda that tells Swashbuckle which actions should be + // included in the docs for a given API version. Like "SingleApiVersion", each call to "Version" + // returns an "Info" builder so you can provide additional metadata per API version. + // + //c.MultipleApiVersions( + // (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion), + // (vc) => + // { + // vc.Version("v2", "Swashbuckle Dummy API V2"); + // vc.Version("v1", "Swashbuckle Dummy API V1"); + // }); - // You can use "BasicAuth", "ApiKey" or "OAuth2" options to describe security schemes for the API. - // See https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md for more details. - // NOTE: These only define the schemes and need to be coupled with a corresponding "security" property - // at the document or operation level to indicate which schemes are required for an operation. To do this, - // you'll need to implement a custom IDocumentFilter and/or IOperationFilter to set these properties - // according to your specific authorization implementation - // - //c.BasicAuth("basic") - // .Description("Basic HTTP Authentication"); - // - // NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section - //c.ApiKey("apiKey") - // .Description("API Key Authentication") - // .Name("apiKey") - // .In("header"); - // - //c.OAuth2("oauth2") - // .Description("OAuth2 Implicit Grant") - // .Flow("implicit") - // .AuthorizationUrl("http://localhost:9000/token") - // .TokenUrl("http://localhost:9000/token") - // .Scopes(scopes => - // { - // scopes.Add("read", "Read access to protected resources"); - // scopes.Add("write", "Write access to protected resources"); - // }); + // You can use "BasicAuth", "ApiKey" or "OAuth2" options to describe security schemes for the API. + // See https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md for more details. + // NOTE: These only define the schemes and need to be coupled with a corresponding "security" property + // at the document or operation level to indicate which schemes are required for an operation. To do this, + // you'll need to implement a custom IDocumentFilter and/or IOperationFilter to set these properties + // according to your specific authorization implementation + // + //c.BasicAuth("basic") + // .Description("Basic HTTP Authentication"); + // + // NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section + //c.ApiKey("apiKey") + // .Description("API Key Authentication") + // .Name("apiKey") + // .In("header"); + // + //c.OAuth2("oauth2") + // .Description("OAuth2 Implicit Grant") + // .Flow("implicit") + // .AuthorizationUrl("http://localhost:9000/token") + // .TokenUrl("http://localhost:9000/token") + // .Scopes(scopes => + // { + // scopes.Add("read", "Read access to protected resources"); + // scopes.Add("write", "Write access to protected resources"); + // }); - // Set this flag to omit descriptions for any actions decorated with the Obsolete attribute - //c.IgnoreObsoleteActions(); + // Set this flag to omit descriptions for any actions decorated with the Obsolete attribute + //c.IgnoreObsoleteActions(); - // Each operation be assigned one or more tags which are then used by consumers for various reasons. - // For example, the swagger-ui groups operations according to the first tag of each operation. - // By default, this will be controller name but you can use the "GroupActionsBy" option to - // override with any value. - // - //c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString()); + // Each operation be assigned one or more tags which are then used by consumers for various reasons. + // For example, the swagger-ui groups operations according to the first tag of each operation. + // By default, this will be controller name but you can use the "GroupActionsBy" option to + // override with any value. + // + //c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString()); - // You can also specify a custom sort order for groups (as defined by "GroupActionsBy") to dictate - // the order in which operations are listed. For example, if the default grouping is in place - // (controller name) and you specify a descending alphabetic sort order, then actions from a - // ProductsController will be listed before those from a CustomersController. This is typically - // used to customize the order of groupings in the swagger-ui. - // - //c.OrderActionGroupsBy(new DescendingAlphabeticComparer()); + // You can also specify a custom sort order for groups (as defined by "GroupActionsBy") to dictate + // the order in which operations are listed. For example, if the default grouping is in place + // (controller name) and you specify a descending alphabetic sort order, then actions from a + // ProductsController will be listed before those from a CustomersController. This is typically + // used to customize the order of groupings in the swagger-ui. + // + //c.OrderActionGroupsBy(new DescendingAlphabeticComparer()); - // If you annotate Controllers and API Types with - // Xml comments (http://msdn.microsoft.com/en-us/library/b2s063f7(v=vs.110).aspx), you can incorporate - // those comments into the generated docs and UI. You can enable this by providing the path to one or - // more Xml comment files. - // - //c.IncludeXmlComments(GetXmlCommentsPath()); + // If you annotate Controllers and API Types with + // Xml comments (http://msdn.microsoft.com/en-us/library/b2s063f7(v=vs.110).aspx), you can incorporate + // those comments into the generated docs and UI. You can enable this by providing the path to one or + // more Xml comment files. + // + //c.IncludeXmlComments(GetXmlCommentsPath()); + //var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + //var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + //c.IncludeXmlComments(xmlPath); - // Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types - // exposed in your API. However, there may be occasions when more control of the output is needed. - // This is supported through the "MapType" and "SchemaFilter" options: - // - // Use the "MapType" option to override the Schema generation for a specific type. - // It should be noted that the resulting Schema will be placed "inline" for any applicable Operations. - // While Swagger 2.0 supports inline definitions for "all" Schema types, the swagger-ui tool does not. - // It expects "complex" Schemas to be defined separately and referenced. For this reason, you should only - // use the "MapType" option when the resulting Schema is a primitive or array type. If you need to alter a - // complex Schema, use a Schema filter. - // - //c.MapType(() => new Schema { type = "integer", format = "int32" }); + // Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types + // exposed in your API. However, there may be occasions when more control of the output is needed. + // This is supported through the "MapType" and "SchemaFilter" options: + // + // Use the "MapType" option to override the Schema generation for a specific type. + // It should be noted that the resulting Schema will be placed "inline" for any applicable Operations. + // While Swagger 2.0 supports inline definitions for "all" Schema types, the swagger-ui tool does not. + // It expects "complex" Schemas to be defined separately and referenced. For this reason, you should only + // use the "MapType" option when the resulting Schema is a primitive or array type. If you need to alter a + // complex Schema, use a Schema filter. + // + //c.MapType(() => new Schema { type = "integer", format = "int32" }); - // If you want to post-modify "complex" Schemas once they've been generated, across the board or for a - // specific type, you can wire up one or more Schema filters. - // - //c.SchemaFilter(); + // If you want to post-modify "complex" Schemas once they've been generated, across the board or for a + // specific type, you can wire up one or more Schema filters. + // + //c.SchemaFilter(); - // In a Swagger 2.0 document, complex types are typically declared globally and referenced by unique - // Schema Id. By default, Swashbuckle does NOT use the full type name in Schema Ids. In most cases, this - // works well because it prevents the "implementation detail" of type namespaces from leaking into your - // Swagger docs and UI. However, if you have multiple types in your API with the same class name, you'll - // need to opt out of this behavior to avoid Schema Id conflicts. - // - //c.UseFullTypeNameInSchemaIds(); + // In a Swagger 2.0 document, complex types are typically declared globally and referenced by unique + // Schema Id. By default, Swashbuckle does NOT use the full type name in Schema Ids. In most cases, this + // works well because it prevents the "implementation detail" of type namespaces from leaking into your + // Swagger docs and UI. However, if you have multiple types in your API with the same class name, you'll + // need to opt out of this behavior to avoid Schema Id conflicts. + // + //c.UseFullTypeNameInSchemaIds(); - // Alternatively, you can provide your own custom strategy for inferring SchemaId's for - // describing "complex" types in your API. - // - //c.SchemaId(t => t.FullName.Contains('`') ? t.FullName.Substring(0, t.FullName.IndexOf('`')) : t.FullName); + // Alternatively, you can provide your own custom strategy for inferring SchemaId's for + // describing "complex" types in your API. + // + //c.SchemaId(t => t.FullName.Contains('`') ? t.FullName.Substring(0, t.FullName.IndexOf('`')) : t.FullName); - // Set this flag to omit schema property descriptions for any type properties decorated with the - // Obsolete attribute - //c.IgnoreObsoleteProperties(); + // Set this flag to omit schema property descriptions for any type properties decorated with the + // Obsolete attribute + //c.IgnoreObsoleteProperties(); - // In accordance with the built in JsonSerializer, Swashbuckle will, by default, describe enums as integers. - // You can change the serializer behavior by configuring the StringToEnumConverter globally or for a given - // enum type. Swashbuckle will honor this change out-of-the-box. However, if you use a different - // approach to serialize enums as strings, you can also force Swashbuckle to describe them as strings. - // - //c.DescribeAllEnumsAsStrings(); + // In accordance with the built in JsonSerializer, Swashbuckle will, by default, describe enums as integers. + // You can change the serializer behavior by configuring the StringToEnumConverter globally or for a given + // enum type. Swashbuckle will honor this change out-of-the-box. However, if you use a different + // approach to serialize enums as strings, you can also force Swashbuckle to describe them as strings. + // + //c.DescribeAllEnumsAsStrings(); - // Similar to Schema filters, Swashbuckle also supports Operation and Document filters: - // - // Post-modify Operation descriptions once they've been generated by wiring up one or more - // Operation filters. - // - //c.OperationFilter(); - // - // If you've defined an OAuth2 flow as described above, you could use a custom filter - // to inspect some attribute on each action and infer which (if any) OAuth2 scopes are required - // to execute the operation - // - c.OperationFilter(() => new AddRequiredHeaderParameter()); + // Similar to Schema filters, Swashbuckle also supports Operation and Document filters: + // + // Post-modify Operation descriptions once they've been generated by wiring up one or more + // Operation filters. + // + //c.OperationFilter(); + // + // If you've defined an OAuth2 flow as described above, you could use a custom filter + // to inspect some attribute on each action and infer which (if any) OAuth2 scopes are required + // to execute the operation + // + c.OperationFilter(() => new AddRequiredHeaderParameter()); // Post-modify the entire Swagger document by wiring up one or more Document filters. // This gives full control to modify the final SwaggerDocument. You should have a good understanding of diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index 73f2663f..04f40792 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -10,6 +10,7 @@ using System.Security.Claims; using System.Threading.Tasks; using System.Web; using System.Web.Http; +using System.Web.Http.Description; using System.Windows.Media.Animation; using TeamDev.SDK.MVVM; using Thermo.Active.Config; @@ -34,26 +35,35 @@ namespace Thermo.Active.Controllers.WebApi /// protected static NcAdapter ncAdapter = new NcAdapter(); + [ResponseType(typeof(DTOCycleLog))] [Route("cyclelog"), HttpGet] public IHttpActionResult GetCycleLog() { // // Try connection CmsError libraryError = ncAdapter.Connect(); + DTOCycleLog currCycleLog = new DTOCycleLog(); + if (libraryError.IsError()) { ThermoActiveLogger.LogError($"ncAdapter Not connected! | GetCycleLog | {libraryError.exception}"); } - libraryError = ncAdapter.GetCycleLog(out Dictionary machineLog); + libraryError = ncAdapter.GetCycleLog(out Dictionary cycleLog); + foreach (var item in cycleLog) + { + currCycleLog.events.Add(new CycleEvent() { dtEvent=item.Key, code=item.Value }); + } + if (libraryError.IsError()) { ThermoActiveLogger.LogError($"GetCycleLog error | {libraryError.exception}"); return BadRequest(libraryError.localizationKey); } - return Ok(machineLog); + return Ok(currCycleLog); } + [ResponseType(typeof(DTOChannelsIO))] [Route("channels_io"), HttpGet] public IHttpActionResult GetChannelsIO() { @@ -76,6 +86,8 @@ namespace Thermo.Active.Controllers.WebApi // ritorno! return Ok(ChannelsIO); } + + [ResponseType(typeof(DTOChannelsIOVal))] [Route("channels_io_val"), HttpGet] public IHttpActionResult GetChannelsIoVal() { @@ -99,12 +111,11 @@ namespace Thermo.Active.Controllers.WebApi return Ok(ChannelsIOVal); } - [Route("io_force_ch_do"), HttpPut] [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] - public IHttpActionResult ForceChDO(Dictionary parametersList) + public IHttpActionResult ForceChDO(List updVal) { - if (parametersList != null) + if (updVal != null) { // Try connection CmsError libraryError = ncAdapter.Connect(); @@ -114,9 +125,16 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - if (parametersList.Count > 0) + if (updVal.Count > 0) { - // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + // converto + Dictionary parametersList = new Dictionary(); + foreach (var item in updVal) + { + parametersList.Add(item.Id, item.value); + } + + // scrivo sul PLC con i parametri specificati ncAdapter.Write_IO_DO_ToPLC(parametersList); } @@ -125,16 +143,15 @@ namespace Thermo.Active.Controllers.WebApi } else { - ThermoActiveLogger.LogError($"ForceChDO parametersList null | Empty Parameters"); + ThermoActiveLogger.LogError($"ForceChDO updatedVal null | Empty Parameters"); return BadRequest(); } } - [Route("io_force_ch_ao"), HttpPut] [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] - public IHttpActionResult ForceChAO(Dictionary parametersList) + public IHttpActionResult ForceChAO(List updVal) { - if (parametersList != null) + if (updVal != null) { // Try connection CmsError libraryError = ncAdapter.Connect(); @@ -144,9 +161,15 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - if (parametersList.Count > 0) + if (updVal.Count > 0) { - // scrivo sul PLC con i parametri specificati x ritardo/raggruppamento + Dictionary parametersList = new Dictionary(); + foreach (var item in updVal) + { + parametersList.Add(item.Id, item.value); + } + + // scrivo sul PLC con i parametri specificati ncAdapter.Write_IO_AO_ToPLC(parametersList); } @@ -159,7 +182,6 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(); } } - [Route("io_reset_ch_do"), HttpPut] [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] public IHttpActionResult ResetChDO(List parametersList) @@ -189,7 +211,11 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(); } } - + /// + /// Reset "force bit" on selected channels + /// + /// List of channels index, zero based + /// [Route("io_reset_ch_ao"), HttpPut] [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] public IHttpActionResult ResetChAO(List parametersList) @@ -219,7 +245,6 @@ namespace Thermo.Active.Controllers.WebApi return BadRequest(); } } - [Route("io_reset_all_ch"), HttpPut] [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] public IHttpActionResult ResetAllCh() @@ -238,6 +263,7 @@ namespace Thermo.Active.Controllers.WebApi // ritorno solo fatto! return Ok(); } + [Route("io_sample_fast"), HttpPut] [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.MAINTENANCE, Action = ACTIONS.WRITE)] public IHttpActionResult SetFastSample(bool value) diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index b8343141..052aea09 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("1.1.155")] +[assembly: AssemblyVersion("1.1.156")] From df9e5fc477609e4d8da98cc7568ae3c887629ec3 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 5 Feb 2021 17:37:01 +0100 Subject: [PATCH 25/25] fix equality test x signal-r degli IO --- .../Listeners/SignalR/SignalRListener.cs | 16 ++++++++-------- Thermo.Active/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Thermo.Active/Listeners/SignalR/SignalRListener.cs b/Thermo.Active/Listeners/SignalR/SignalRListener.cs index ee78b783..bb86d9d1 100644 --- a/Thermo.Active/Listeners/SignalR/SignalRListener.cs +++ b/Thermo.Active/Listeners/SignalR/SignalRListener.cs @@ -562,7 +562,7 @@ namespace Thermo.Active.Listeners.SignalR { // recupero var element = LastChannelsIoData.DI.Find(x => x.Id == item.Id); - if ((element == null) || (!item.Value.Equals(element))) + if ((element == null) || (!item.Value.Equals(element.Value))) { diffChannelsData.DI.Add(item); } @@ -572,7 +572,7 @@ namespace Thermo.Active.Listeners.SignalR { // recupero var element = LastChannelsIoData.DO.Find(x => x.Id == item.Id); - if ((element == null) || (!item.Value.Equals(element))) + if ((element == null) || (!item.Value.Equals(element.Value))) { diffChannelsData.DO.Add(item); } @@ -582,7 +582,7 @@ namespace Thermo.Active.Listeners.SignalR { // recupero var element = LastChannelsIoData.AI.Find(x => x.Id == item.Id); - if ((element == null) || (!item.Value.Equals(element))) + if ((element == null) || (!item.Value.Equals(element.Value))) { diffChannelsData.AI.Add(item); } @@ -592,7 +592,7 @@ namespace Thermo.Active.Listeners.SignalR { // recupero var element = LastChannelsIoData.AO.Find(x => x.Id == item.Id); - if ((element == null) || (!item.Value.Equals(element))) + if ((element == null) || (!item.Value.Equals(element.Value))) { diffChannelsData.AO.Add(item); } @@ -602,10 +602,10 @@ namespace Thermo.Active.Listeners.SignalR if (diffChannelsData.DI.Count + diffChannelsData.DO.Count + diffChannelsData.AI.Count + diffChannelsData.AO.Count > 0) { // salvo update CLONANDO - LastChannelsIoData.DI = currChannelsIoData.DI.Clone(); - LastChannelsIoData.DO = currChannelsIoData.DO.Clone(); - LastChannelsIoData.AI = currChannelsIoData.AI.Clone(); - LastChannelsIoData.AO = currChannelsIoData.AO.Clone(); + LastChannelsIoData.DI = currChannelsIoData.DI; + LastChannelsIoData.DO = currChannelsIoData.DO; + LastChannelsIoData.AI = currChannelsIoData.AI; + LastChannelsIoData.AO = currChannelsIoData.AO; var context = GlobalHost.ConnectionManager.GetHubContext(); context.Clients.Group("ncData").channelsIoVal(diffChannelsData); } diff --git a/Thermo.Active/Properties/AssemblyInfo.cs b/Thermo.Active/Properties/AssemblyInfo.cs index 052aea09..5f2eb65b 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("1.1.156")] +[assembly: AssemblyVersion("1.1.157")]