From 69ae63f60f57f2dec1897e1a5869a8f3f3378ab3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 3 Sep 2020 12:01:48 +0200 Subject: [PATCH] More fix for avoiding PLC write error for recipe --- CMS_CORE_Library/NcThermo.cs | 6 ++++-- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CMS_CORE_Library/NcThermo.cs b/CMS_CORE_Library/NcThermo.cs index 1d486f0..2354e4a 100644 --- a/CMS_CORE_Library/NcThermo.cs +++ b/CMS_CORE_Library/NcThermo.cs @@ -636,9 +636,11 @@ namespace CMS_CORE_Library /// /// Write recipe updated MULTIPLE parameter /// - /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scriottura multi parametri singoli /// - public abstract CmsError PLC_WRecipeParameters(Dictionary newParameters); + public abstract CmsError PLC_WRecipeParameters(Dictionary newParameters, int nMaxParamWrite, int delayParamWrite); /// /// Confirm/Cancel recipe modifications /// diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index cfec263..bd4aee4 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -2098,9 +2098,11 @@ namespace CMS_CORE_Library.S7Net /// /// Write recipe updated MULTIPLE parameter /// - /// + /// Oggetto parametri da aggiornare (from HMI) + /// num max parametri da scrivere singolarmente + /// delay in scriottura multi parametri singoli /// - public override CmsError PLC_WRecipeParameters(Dictionary newParameters) + public override CmsError PLC_WRecipeParameters(Dictionary newParameters, int nMaxParamWrite, int delayParamWrite) { // init variabili accessorie CmsError libraryError = NO_ERROR; @@ -2108,9 +2110,9 @@ namespace CMS_CORE_Library.S7Net int memIndex = 0; int packSize = 20; - // 2020.08.07 - // limite a 5 parametri x scrivere tutto (era 30) - bool writeSingle = newParameters.Count < 5; + + // 2020.09.03: ricevuto da chiamata, dovrebbe essere 5 parametri x scrivere tutto (era 30 prima di 2008.08.07) + bool writeSingle = newParameters.Count < nMaxParamWrite; // leggo da PLC a array di byte di appoggio... libraryError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, 0, PARAMETER_DATA.Size, ref currMem); @@ -2143,6 +2145,8 @@ namespace CMS_CORE_Library.S7Net libraryError = MEM_RWByteList(W, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress + packSize * (currParam.Id - 1) + 2, 0, 4, ref newMem); if (libraryError.IsError()) return libraryError; + // attendo x sicurezza... + Thread.Sleep(delayParamWrite); } else {