From 0b01dbdba9705e0d4317f3720221a95fc3b60a15 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2020 11:05:32 +0200 Subject: [PATCH] fix error for thermo params collision --- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 41 +++++++++++++++++++----------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index a762c5b..396be1b 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -2038,7 +2038,13 @@ namespace CMS_CORE_Library.S7Net } else { - ThermoParamList.Add(currParam.Id, new ThermoModels.RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + try + { + ThermoParamList.Add(currParam.Id, new ThermoModels.RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + } + catch + { + } } } } @@ -2213,15 +2219,20 @@ namespace CMS_CORE_Library.S7Net } else { - ThermoModuleList.Add(currModBlock.Id, new ThermoModels.ModuleBlock() + try { - Id = currModBlock.Id, - ActualDuration = currModBlock.ActualDuration, - ActualDelay = currModBlock.ActualDelay, - Visible = currModBlock.Visible, - Running = currModBlock.Running, - HasError = currModBlock.HasError - }); + ThermoModuleList.Add(currModBlock.Id, new ThermoModels.ModuleBlock() + { + Id = currModBlock.Id, + ActualDuration = currModBlock.ActualDuration, + ActualDelay = currModBlock.ActualDelay, + Visible = currModBlock.Visible, + Running = currModBlock.Running, + HasError = currModBlock.HasError + }); + } + catch + { } } } } @@ -2689,7 +2700,7 @@ namespace CMS_CORE_Library.S7Net // update only given data... foreach (var item in newData) { - newMem[item.Key - 1] = item.Value; + newMem[item.Key] = item.Value; } // return as list... ListValue = newMem.ToList(); @@ -2721,7 +2732,7 @@ namespace CMS_CORE_Library.S7Net // update only given data... foreach (var item in newData) { - newMem[item.Key - 1] = (byte)item.Value; + newMem[item.Key] = (byte)item.Value; } // return as list... currMem = newMem.ToList(); @@ -3166,11 +3177,11 @@ namespace CMS_CORE_Library.S7Net List ListValue = new List() { Value }; //uses the List method with one-element list - CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue); + CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemTable, MemIndex, 2, ref ListValue); if (cmsError.IsError()) return cmsError; - - Value = ListValue.First(); + if(ListValue.Count>0) + Value = ListValue.First(); return NO_ERROR; } @@ -4734,7 +4745,7 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL MODULE_RT_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 603, 12, 1536); // riscaldi - internal static MEMORY_CELL RISC_VU_MIN = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 513, 0, 1); + internal static MEMORY_CELL RISC_VU_MIN = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 513, 0, 2); internal static MEMORY_CELL RISC_OCC_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 64, 64); internal static MEMORY_CELL RISC_CHP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 614, 0, 1024); internal static MEMORY_CELL RISC_CFI_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 514, 2176, 1024);