From 49ba5b0ce31932d612d2ae24cb75143d46071b9f Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Thu, 4 Apr 2019 08:38:40 +0000 Subject: [PATCH] Fix reset counters --- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 6 ++++-- CMS_CORE_Library/Osai/Nc_Osai.cs | 6 ++++-- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 743552c..22298a9 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -892,9 +892,11 @@ namespace CMS_CORE_Library.Fanuc bool bitValue = true; int nTry = 0; - for (int i = 0; i < 4; i++) + for (int i = 0; i <= 4; i++) { //Scrivo il bit + bitValue = true; + nTry = 0; cmsError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, 0, ref bitValue); if (cmsError.IsError()) return cmsError; @@ -908,7 +910,7 @@ namespace CMS_CORE_Library.Fanuc if (cmsError.IsError()) return cmsError; - } while (!bitValue || nTry > 10); + } while (bitValue && nTry <= 10); //se il valore ่ rimasto a 1 il plc non l'ha preso in carico, e abortisco if (bitValue) diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 83748e3..ef1a83f 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -861,9 +861,11 @@ namespace CMS_CORE_Library.Osai bool bitValue = true; int nTry = 0; - for (int i = 0; i<4; i++) + for (int i = 0; i<=4; i++) { //Scrivo il bit + bitValue = true; + nTry = 0; cmsError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address,0, ref bitValue); if (cmsError.IsError()) return cmsError; @@ -877,7 +879,7 @@ namespace CMS_CORE_Library.Osai if (cmsError.IsError()) return cmsError; - } while (!bitValue || nTry > 10); + } while (bitValue && nTry <= 10); //se il valore รจ rimasto a 1 il plc non l'ha preso in carico, e abortisco if (bitValue) diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index d49ee1d..7f5b7bb 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1094,9 +1094,11 @@ namespace CMS_CORE_Library.Siemens bool bitValue = true; int nTry = 0; - for (int i = 0; i < 4; i++) + for (int i = 0; i <= 4; i++) { //Scrivo il bit + bitValue = true; + nTry = 0; cmsError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, MACHINE_RESET_WORKED_TIME.SubAddress, 0, ref bitValue); if (cmsError.IsError()) return cmsError; @@ -1110,7 +1112,7 @@ namespace CMS_CORE_Library.Siemens if (cmsError.IsError()) return cmsError; - } while (!bitValue || nTry > 10); + } while (bitValue && nTry <= 10); //se il valore รจ rimasto a 1 il plc non l'ha preso in carico, e abortisco if (bitValue)