From fff0036e5e7ec36d8e229dd7612708e255cdf9fb Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 28 Feb 2025 08:38:18 +0100 Subject: [PATCH] FANUC: - completo modifica comportamento INIT - riorganizzazione aree memoria Fanuc/Mitsubishi --- IOB-UT-NEXT/Config/Base/DeviceDto.cs | 4 - IOB-UT-NEXT/Config/IobConfTree.cs | 172 +++++++++--------- .../Special/{FanucDto.cs => FanucDto_old.cs} | 2 +- .../Special/{MemoryDto.cs => MemBankDto.cs} | 4 +- IOB-UT-NEXT/Config/Special/SpecializedDto.cs | 5 + IOB-UT-NEXT/IOB-UT-NEXT.csproj | 3 +- IOB-UT-NEXT/plcMemMapExt.cs | 3 +- IOB-WIN-FANUC/DATA/CONF/3021.ini | 6 +- IOB-WIN-FANUC/DATA/CONF/MAIN.ini | 1 + IOB-WIN-FANUC/IOB-WIN-FANUC.csproj | 4 +- IOB-WIN-FANUC/Iob/Fanuc.cs | 26 +-- IOB-WIN-FORM/Iob/Generic.cs | 16 +- IOB-WIN-FORM/Iob/Simula.cs | 6 +- 13 files changed, 133 insertions(+), 119 deletions(-) rename IOB-UT-NEXT/Config/Special/{FanucDto.cs => FanucDto_old.cs} (96%) rename IOB-UT-NEXT/Config/Special/{MemoryDto.cs => MemBankDto.cs} (86%) diff --git a/IOB-UT-NEXT/Config/Base/DeviceDto.cs b/IOB-UT-NEXT/Config/Base/DeviceDto.cs index b5446155..2cd9736c 100644 --- a/IOB-UT-NEXT/Config/Base/DeviceDto.cs +++ b/IOB-UT-NEXT/Config/Base/DeviceDto.cs @@ -73,10 +73,6 @@ namespace IOB_UT_NEXT.Config.Base /// public Dictionary SigLUT { get; set; } = new Dictionary(); - /// - /// Configurazione specifica FANUC (se applicabile) - /// - public MemoryDto Memory { get; set; } } } diff --git a/IOB-UT-NEXT/Config/IobConfTree.cs b/IOB-UT-NEXT/Config/IobConfTree.cs index 517c4723..56195a96 100644 --- a/IOB-UT-NEXT/Config/IobConfTree.cs +++ b/IOB-UT-NEXT/Config/IobConfTree.cs @@ -108,7 +108,7 @@ namespace IOB_UT_NEXT.Config CodIOB = fIni.ReadString("IOB", "IOB_NAME", codIob), FileName = Path.GetFileName(iniFilePath), Customer = fIni.ReadString("TAGS", "Customer", "EgalWare"), - EnabRedisQue = bool.Parse(fIni.ReadString("IOB", "EnabRedisQue", "false")), + EnabRedisQue = bool.Parse(fIni.ReadString("IOB", "EnableRedisQueue", "true")), MinDeltaSec = fIni.ReadInteger("IOB", "MinDeltaSec", 6), RelVers = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}", WaitRecMsec = Convert.ToInt32(fIni.ReadString("OPTPAR", "WAIT_REC_MSEC", "90000")) @@ -144,7 +144,7 @@ namespace IOB_UT_NEXT.Config PzCountMode = fIni.ReadString("OPTPAR", "PZCOUNT_MODE", ""), Vendor = fIni.ReadString("MACHINE", "VENDOR", "STEAMWARE"), Model = fIni.ReadString("MACHINE", "MODEL", "ND"), - EnabProgName = fIni.ReadBoolean("CNC", "GETPRGNAME", true), + EnabProgName = bool.Parse(fIni.ReadString("CNC", "GETPRGNAME", "true")), Connect = new ConnectionDto() { IpAddr = fIni.ReadString("CNC", "IP", "::1"), @@ -154,83 +154,7 @@ namespace IOB_UT_NEXT.Config } }; exclOptPar.Add("PZCOUNT_MODE"); - // parametri opzionali Memory - string[] memSection = fIni.ReadSection("MEMORY"); - // in primis SE ho qualcosa... - if (memSection != null && memSection.Count() > 0) - { - // trasformo in array... - Dictionary memDict = new Dictionary(); - foreach (var item in memSection) - { - // verifica preliminare NON sia commento (inizia per ";") - if (!item.StartsWith(";") && item.Contains("=")) - { - var KVP = item.Split('='); - memDict.Add(KVP[0], KVP[1]); - } - } - // ora se ho qualcosa proseguo... - if (memDict.Count() > 0) - { - // cerco dati x popolare SigLUT - foreach (var item in memDict.Where(x => x.Key.StartsWith("BIT"))) - { - if (newConfObj.Device.SigLUT.ContainsKey(item.Key)) - { - newConfObj.Device.SigLUT[item.Key] = item.Value; - } - else - { - newConfObj.Device.SigLUT.Add(item.Key, item.Value); - } - } - // cerco dati specifici x popolare l'area Memoria (Fanuc/Mitsubischi/...) - if (memDict.Where(x => x.Key.StartsWith("AREA") || x.Key.StartsWith("PAR") || x.Key.StartsWith("SIGN")).Count() > 0) - { - // init fanuc... - newConfObj.Device.Memory = new MemoryDto(); - // inizio setup prendendo quelli con valori addrSize - foreach (var item in memDict.Where(x => x.Key.EndsWith("SIZE"))) - { - int addrSize = 0; - int.TryParse(item.Value, out addrSize); - // salvo solo quelli con valori addrSize > 0 - if (addrSize > 0) - { - string mId = item.Key.Replace("_SIZE", ""); - // cerco record inizio - var valStart = memDict.Where(x => x.Key == item.Key.Replace("_SIZE", "_START")).Select(x => x.Value).FirstOrDefault(); - if (!string.IsNullOrEmpty(valStart)) - { - int addrStart = 0; - int.TryParse(valStart, out addrStart); - var memArea = new Mem.MemAreaDto() - { - Start = addrStart, - Size = addrSize - }; - if (newConfObj.Device.Memory.AreaConf.ContainsKey(mId)) - { - newConfObj.Device.Memory.AreaConf[mId] = memArea; - } - else - { - newConfObj.Device.Memory.AreaConf.Add(mId, memArea); - } - } - } - } - } - } - } - // salvo eventuale memTrace... - if (!string.IsNullOrEmpty(fIni.ReadString("OPTPAR", "MEM_2_TRACE", ""))) - { - newConfObj.Device.Memory.Mem2Trace = fIni.ReadString("OPTPAR", "MEM_2_TRACE", ""); - exclOptPar.Add("MEM_2_TRACE"); - } - + // multi... newConfObj.Device.IsMulti = Convert.ToBoolean(fIni.ReadString("OPTPAR", "IS_MULTI", "false")) || fIni.ReadString("OPTPAR", "IS_MULTI", "0") == "1"; exclOptPar.Add("IS_MULTI"); @@ -308,10 +232,13 @@ namespace IOB_UT_NEXT.Config string jsonData = reader.ReadToEnd(); if (!string.IsNullOrEmpty(jsonData)) { - newConfObj.MemMap = new plcMemMapExt(); + if (newConfObj.Memory == null) + { + newConfObj.Memory = new plcMemMapExt(); + } try { - newConfObj.MemMap = JsonConvert.DeserializeObject(jsonData); + newConfObj.Memory = JsonConvert.DeserializeObject(jsonData); } catch (Exception exc) { @@ -331,6 +258,13 @@ namespace IOB_UT_NEXT.Config } } + // salvo eventuale memTrace... + if (!string.IsNullOrEmpty(fIni.ReadString("OPTPAR", "MEM_2_TRACE", ""))) + { + newConfObj.Special.BankConf.Mem2Trace = fIni.ReadString("OPTPAR", "MEM_2_TRACE", ""); + exclOptPar.Add("MEM_2_TRACE"); + } + // parametri opzionali Siemens if (!string.IsNullOrEmpty(fIni.ReadString("CNC", "CPUTYPE", ""))) { @@ -346,6 +280,80 @@ namespace IOB_UT_NEXT.Config newConfObj.Special.SiemensConf.MemSizeWrite = fIni.ReadInteger("MEMORY", "SIZE_WRITE", 0); } + // parametri opzionali BankConf + string[] memSection = fIni.ReadSection("MEMORY"); + // in primis SE ho qualcosa... + if (memSection != null && memSection.Count() > 0) + { + // trasformo in array... + Dictionary memDict = new Dictionary(); + foreach (var item in memSection) + { + // verifica preliminare NON sia commento (inizia per ";") + if (!item.StartsWith(";") && item.Contains("=")) + { + var KVP = item.Split('='); + memDict.Add(KVP[0], KVP[1]); + } + } + // ora se ho qualcosa proseguo... + if (memDict.Count() > 0) + { + // cerco dati x popolare SigLUT + foreach (var item in memDict.Where(x => x.Key.StartsWith("BIT"))) + { + if (newConfObj.Device.SigLUT.ContainsKey(item.Key)) + { + newConfObj.Device.SigLUT[item.Key] = item.Value; + } + else + { + newConfObj.Device.SigLUT.Add(item.Key, item.Value); + } + } + // cerco dati specifici x popolare l'area Memoria (Fanuc/Mitsubischi/...) + if (memDict.Where(x => x.Key.StartsWith("AREA") || x.Key.StartsWith("PAR") || x.Key.StartsWith("SIGN")).Count() > 0) + { + // init info bank memoria... + if (newConfObj.Special.BankConf == null) + { + newConfObj.Special.BankConf = new MemBankDto(); + } + // inizio setup prendendo quelli con valori addrSize + foreach (var item in memDict.Where(x => x.Key.EndsWith("SIZE"))) + { + int addrSize = 0; + int.TryParse(item.Value, out addrSize); + // salvo solo quelli con valori addrSize > 0 + if (addrSize > 0) + { + string mId = item.Key.Replace("_SIZE", ""); + // cerco record inizio + var valStart = memDict.Where(x => x.Key == item.Key.Replace("_SIZE", "_START")).Select(x => x.Value).FirstOrDefault(); + if (!string.IsNullOrEmpty(valStart)) + { + int addrStart = 0; + int.TryParse(valStart, out addrStart); + var memArea = new Mem.MemAreaDto() + { + Start = addrStart, + Size = addrSize + }; + if (newConfObj.Special.BankConf.AreaConf.ContainsKey(mId)) + { + newConfObj.Special.BankConf.AreaConf[mId] = memArea; + } + else + { + newConfObj.Special.BankConf.AreaConf.Add(mId, memArea); + } + } + } + } + } + } + } + // gestione speciale x type MBus if ($"{newConfObj.General.IobType}".StartsWith("MODBUS_TCP")) { @@ -416,7 +424,7 @@ namespace IOB_UT_NEXT.Config /// /// Struttura memoria PLC x lettura/scrittura /// - public plcMemMapExt MemMap { get; set; } + public plcMemMapExt Memory { get; set; } /// /// Setup processing dati in ingresso (es: blink segnali) diff --git a/IOB-UT-NEXT/Config/Special/FanucDto.cs b/IOB-UT-NEXT/Config/Special/FanucDto_old.cs similarity index 96% rename from IOB-UT-NEXT/Config/Special/FanucDto.cs rename to IOB-UT-NEXT/Config/Special/FanucDto_old.cs index 55db1008..3d26403c 100644 --- a/IOB-UT-NEXT/Config/Special/FanucDto.cs +++ b/IOB-UT-NEXT/Config/Special/FanucDto_old.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace IOB_UT_NEXT.Config.Special { - public class FanucDto + public class FanucDto_old { #region Public Properties diff --git a/IOB-UT-NEXT/Config/Special/MemoryDto.cs b/IOB-UT-NEXT/Config/Special/MemBankDto.cs similarity index 86% rename from IOB-UT-NEXT/Config/Special/MemoryDto.cs rename to IOB-UT-NEXT/Config/Special/MemBankDto.cs index 14a41b14..1fab6c80 100644 --- a/IOB-UT-NEXT/Config/Special/MemoryDto.cs +++ b/IOB-UT-NEXT/Config/Special/MemBankDto.cs @@ -8,9 +8,9 @@ using System.Threading.Tasks; namespace IOB_UT_NEXT.Config.Special { /// - /// Configurazione memoria a banchi (es: Fanuc, Mitsubishi, ...) + /// Configurazione memoria a banchi (es: Fanuc, Mitsubishi) /// - public class MemoryDto + public class MemBankDto { /// /// Conf aree di memoria da gestire diff --git a/IOB-UT-NEXT/Config/Special/SpecializedDto.cs b/IOB-UT-NEXT/Config/Special/SpecializedDto.cs index 3584b011..3ad1d52a 100644 --- a/IOB-UT-NEXT/Config/Special/SpecializedDto.cs +++ b/IOB-UT-NEXT/Config/Special/SpecializedDto.cs @@ -12,6 +12,11 @@ namespace IOB_UT_NEXT.Config.Special /// public class SpecializedDto { + /// + /// Configurazione specifica FANUC/Mitsubishi (ove applicabile) + /// + public MemBankDto BankConf { get; set; } + /// /// Parametri speciali per Modbus /// diff --git a/IOB-UT-NEXT/IOB-UT-NEXT.csproj b/IOB-UT-NEXT/IOB-UT-NEXT.csproj index 30f7216e..c25aab50 100644 --- a/IOB-UT-NEXT/IOB-UT-NEXT.csproj +++ b/IOB-UT-NEXT/IOB-UT-NEXT.csproj @@ -169,8 +169,7 @@ - - + diff --git a/IOB-UT-NEXT/plcMemMapExt.cs b/IOB-UT-NEXT/plcMemMapExt.cs index 184e2f9b..e93bab12 100644 --- a/IOB-UT-NEXT/plcMemMapExt.cs +++ b/IOB-UT-NEXT/plcMemMapExt.cs @@ -1,4 +1,5 @@ -using MapoSDK; +using IOB_UT_NEXT.Config.Special; +using MapoSDK; using System; using System.Collections.Generic; using System.Linq; diff --git a/IOB-WIN-FANUC/DATA/CONF/3021.ini b/IOB-WIN-FANUC/DATA/CONF/3021.ini index 5b34555a..a40f525b 100644 --- a/IOB-WIN-FANUC/DATA/CONF/3021.ini +++ b/IOB-WIN-FANUC/DATA/CONF/3021.ini @@ -1,6 +1,7 @@ ;Configurazione IOB-WIN [IOB] CNCTYPE=FANUC +EnableRedisQueue=true [MACHINE] VENDOR=CITIZEN @@ -33,11 +34,12 @@ BIT4=Y1.7 BIT5=currPrgName|O5000 AREAD_START=0 AREAD_SIZE=0 +AREAG_START=0 AREAG_SIZE=48 AREAR_START=0 -AREAR_SIZE=0 +AREAR_SIZE=32 AREAX_START=0 -AREAX_SIZE=0 +AREAX_SIZE=8 AREAY_START=0 AREAY_SIZE=8 PAR_START=6711 diff --git a/IOB-WIN-FANUC/DATA/CONF/MAIN.ini b/IOB-WIN-FANUC/DATA/CONF/MAIN.ini index 4d3a9a76..2e3567f0 100644 --- a/IOB-WIN-FANUC/DATA/CONF/MAIN.ini +++ b/IOB-WIN-FANUC/DATA/CONF/MAIN.ini @@ -23,6 +23,7 @@ CLI_INST=SteamWareSim ;STARTLIST=VL27 ;STARTLIST=3027 ;STARTLIST=EV112 +;STARTLIST=3021 STARTLIST=3004 diff --git a/IOB-WIN-FANUC/IOB-WIN-FANUC.csproj b/IOB-WIN-FANUC/IOB-WIN-FANUC.csproj index 15c361cf..5dce1496 100644 --- a/IOB-WIN-FANUC/IOB-WIN-FANUC.csproj +++ b/IOB-WIN-FANUC/IOB-WIN-FANUC.csproj @@ -163,7 +163,9 @@ - + + Always + diff --git a/IOB-WIN-FANUC/Iob/Fanuc.cs b/IOB-WIN-FANUC/Iob/Fanuc.cs index 96b11c31..3bc16145 100644 --- a/IOB-WIN-FANUC/Iob/Fanuc.cs +++ b/IOB-WIN-FANUC/Iob/Fanuc.cs @@ -33,21 +33,21 @@ namespace IOB_WIN_FANUC.Iob int rSize = 8; int xSize = 8; int ySize = 8; - if (IOBConfFull.Device.Memory.AreaConf.ContainsKey("AREAG")) + if (IOBConfFull.Special.BankConf.AreaConf.ContainsKey("AREAG")) { - gSize = IOBConfFull.Device.Memory.AreaConf["AREAG"].Size; + gSize = IOBConfFull.Special.BankConf.AreaConf["AREAG"].Size; } - if (IOBConfFull.Device.Memory.AreaConf.ContainsKey("AREAR")) + if (IOBConfFull.Special.BankConf.AreaConf.ContainsKey("AREAR")) { - rSize = IOBConfFull.Device.Memory.AreaConf["AREAR"].Size; + rSize = IOBConfFull.Special.BankConf.AreaConf["AREAR"].Size; } - if (IOBConfFull.Device.Memory.AreaConf.ContainsKey("AREAX")) + if (IOBConfFull.Special.BankConf.AreaConf.ContainsKey("AREAX")) { - xSize = IOBConfFull.Device.Memory.AreaConf["AREAX"].Size; + xSize = IOBConfFull.Special.BankConf.AreaConf["AREAX"].Size; } - if (IOBConfFull.Device.Memory.AreaConf.ContainsKey("AREAY")) + if (IOBConfFull.Special.BankConf.AreaConf.ContainsKey("AREAY")) { - ySize = IOBConfFull.Device.Memory.AreaConf["AREAY"].Size; + ySize = IOBConfFull.Special.BankConf.AreaConf["AREAY"].Size; } MemBlockG = new byte[gSize]; MemBlockR = new byte[rSize]; @@ -139,9 +139,9 @@ namespace IOB_WIN_FANUC.Iob private memAreaFanuc FormatAreaFanuc(string aName, string mKey) { var newArea = new memAreaFanuc() { areaName = aName }; - if (IOBConfFull.Device.Memory.AreaConf.ContainsKey(mKey)) + if (IOBConfFull.Special.BankConf.AreaConf.ContainsKey(mKey)) { - var thisConf = IOBConfFull.Device.Memory.AreaConf[mKey]; + var thisConf = IOBConfFull.Special.BankConf.AreaConf[mKey]; newArea.startIdx = thisConf.Start; newArea.arraySize = thisConf.Size; @@ -200,7 +200,7 @@ namespace IOB_WIN_FANUC.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } upsertKey(item.Key, item.Value); break; @@ -251,7 +251,7 @@ namespace IOB_WIN_FANUC.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } // invio a controller... @@ -307,7 +307,7 @@ namespace IOB_WIN_FANUC.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } // invio a controller... diff --git a/IOB-WIN-FORM/Iob/Generic.cs b/IOB-WIN-FORM/Iob/Generic.cs index 852aa955..e26ecee6 100644 --- a/IOB-WIN-FORM/Iob/Generic.cs +++ b/IOB-WIN-FORM/Iob/Generic.cs @@ -775,7 +775,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {item.Value}"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {item.Value}"; } // salvo in currProd.. upsertKey(item.Key, item.Value); @@ -809,7 +809,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {item.Value}"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {item.Value}"; } break; @@ -842,7 +842,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } // salvo in currProd.. @@ -871,7 +871,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } // salvo in currProd.. @@ -950,7 +950,7 @@ namespace IOB_WIN_FORM.Iob // converto richiesta in enum... taskType tName = taskType.nihil; Enum.TryParse(item.Key, out tName); - string taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED (no MemMap) | NO EXEC"; + string taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED (no BankConf) | NO EXEC"; // aggiungo task! taskDone.Add(item.Key, taskVal); } @@ -2651,7 +2651,7 @@ namespace IOB_WIN_FORM.Iob sb.Append($"B_input --> {(short)B_input}{Environment.NewLine}"); sb.Append($"{baseUtils.binaryForm(B_input)}{Environment.NewLine}"); sb.Append($"{Environment.NewLine}"); - sb.Append($"----------- RAW Data Memory -----------{Environment.NewLine}"); + sb.Append($"----------- RAW Data BankConf -----------{Environment.NewLine}"); // Do x scontato siano VALIDI i valori di RawDataInputStart / size --> filtro... var filtRawData = new byte[RawDataInputSize]; Array.Copy(RawInput, RawDataInputStart, filtRawData, 0, RawDataInputSize); @@ -4542,7 +4542,7 @@ namespace IOB_WIN_FORM.Iob /// protected string urlSetOptVal { - get => $@"{urlCommandIob("addOptPar")}"; + get => $@"{urlCommandIob("addOptPar")}?"; } /// @@ -8291,7 +8291,7 @@ namespace IOB_WIN_FORM.Iob pzCountDelay =IOBConfFull.Device.PzCountDelay; enablePrgName = IOBConfFull.Device.EnabProgName; enablePzCountByApp = IOBConfFull.Device.EnabPzCount; - mem2trace = IOBConfFull.Device.Memory.Mem2Trace; + mem2trace = IOBConfFull.Special.BankConf.Mem2Trace; numArtCharTrim = IOBConfFull.Device.NumArtCharTrim; // valore standard divieto accodamento segnali IN diff --git a/IOB-WIN-FORM/Iob/Simula.cs b/IOB-WIN-FORM/Iob/Simula.cs index f54c2727..dcd60f11 100644 --- a/IOB-WIN-FORM/Iob/Simula.cs +++ b/IOB-WIN-FORM/Iob/Simula.cs @@ -258,7 +258,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {item.Value}"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {item.Value}"; } // salvo in currProd.. upsertKey(item.Key, item.Value); @@ -320,7 +320,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } // salvo in currProd.. @@ -349,7 +349,7 @@ namespace IOB_WIN_FORM.Iob } else { - taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})"; + taskVal = $"NO BankConf found, SET task: {item.Key} --> {newVal} ({item.Value})"; } // salvo in currProd..