From 6d52ccdc9ccdd2db29934de06d97d36222211ab5 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 9 Jun 2020 19:13:57 +0200 Subject: [PATCH] Continuing warmers & recipe fix & config --- Thermo.Active.Core/ThreadsFunctions.cs | 10 ++--- .../ConfigModels/RiskConfigModel.cs | 1 + Thermo.Active.NC/NcAdapter.cs | 44 +++++++++++++++++++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 47b10f28..2731f119 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -713,13 +713,12 @@ public static class ThreadsFunctions // Check if client is connected if (ncAdapter.numericalControl.NC_IsConnected()) { - // Get new data from PLC libraryError = ncAdapter.ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoData); if (libraryError.IsError()) ManageLibraryError(libraryError); - MessageServices.Current.Publish(SEND_THERMO_PROD_INFO_DATA, null, prodInfoData); + MessageServices.Current.Publish(SEND_THERMO_PROD_INFO_DATA, null, prodInfoData); } else RestoreConnection(); @@ -756,15 +755,12 @@ public static class ThreadsFunctions // Check if client is connected if (ncAdapter.numericalControl.NC_IsConnected()) { - -#if false // Get new data from PLC - libraryError = ncAdapter.ReadProdCycle(out ThermoModels.GaugeModel gaugeData); + libraryError = ncAdapter.ReadProdCycleData(out ThermoModels.ProdCycleModel prodCycleData); if (libraryError.IsError()) ManageLibraryError(libraryError); - MessageServices.Current.Publish(SEND_THERMO_GAUGE_DATA, null, gaugeData); -#endif + MessageServices.Current.Publish(SEND_THERMO_PROD_CYCLE_DATA, null, prodCycleData); } else RestoreConnection(); diff --git a/Thermo.Active.Model/ConfigModels/RiskConfigModel.cs b/Thermo.Active.Model/ConfigModels/RiskConfigModel.cs index 7c1f6d30..7a8b9144 100644 --- a/Thermo.Active.Model/ConfigModels/RiskConfigModel.cs +++ b/Thermo.Active.Model/ConfigModels/RiskConfigModel.cs @@ -35,5 +35,6 @@ namespace Thermo.Active.Model.ConfigModels public int SetpointRecipe; public int SetpointThermo; public int MaxPower; + //public int MinCurrent; } } diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index ef664d97..fca8b583 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -1240,6 +1240,48 @@ namespace Thermo.Active.NC return NO_ERROR; } /// + /// Vero metodo lettura Warmers data da memoria PLC + /// + /// + /// + public CmsError ReadWarmersData(out Dictionary currentWarmers) + { + // init obj + currentWarmers = new Dictionary(); + // solo x S7... + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + CmsError cmsError = NO_ERROR; + + // leggo stato ricetta da PLC + Dictionary currPlcWarmers = new Dictionary(); + cmsError = numericalControl.PLC_RWarmerChannelList(ref currPlcWarmers); + + if (cmsError.IsError()) + return cmsError; + + // compongo con il resto delle info da config... do x scontato di avere TUTIT i 1024 channels + List warmersConfig = RiskChannelConfig.Select(x => new DTOWarmers() + { + IdChannel = x.IdChannel, + IdReflector= x.IdReflector, + SetpointRecipe = x.SetpointRecipe, + SetpointTermocam = 0, // FIXME TODO x.SetpointTer, + SetpointPLC = currPlcWarmers[x.IdChannel].SetpointPLC, + ChannelStatus = currPlcWarmers[x.IdChannel].ChStatus, + ActualCurrent = currPlcWarmers[x.IdChannel].CurrAct, + ActualPerc = currPlcWarmers[x.IdChannel].PercAct, + MaxPower = x.MaxPower + }).ToList(); + } + else + { + currentWarmers = new Dictionary(); + } + + return NO_ERROR; + } + /// /// Recipe Parameters write to PLC (only SetpointHMI) /// /// @@ -1278,6 +1320,8 @@ namespace Thermo.Active.NC } + + public CmsError ReadNcScada(ScadaSchemaModel scadaSchema, out DTOScadaModel scadaValue) { //ReadScadaDataSiemens(scadaSchema, out scadaValue);