- completo modifica comportamento INIT
- riorganizzazione aree memoria Fanuc/Mitsubishi
This commit is contained in:
Samuele Locatelli
2025-02-28 08:38:18 +01:00
parent 64a89c82f5
commit fff0036e5e
13 changed files with 133 additions and 119 deletions
-4
View File
@@ -73,10 +73,6 @@ namespace IOB_UT_NEXT.Config.Base
/// </summary>
public Dictionary<string, string> SigLUT { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Configurazione specifica FANUC (se applicabile)
/// </summary>
public MemoryDto Memory { get; set; }
}
}
+90 -82
View File
@@ -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<string, string> memDict = new Dictionary<string, string>();
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<plcMemMapExt>(jsonData);
newConfObj.Memory = JsonConvert.DeserializeObject<plcMemMapExt>(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<string, string> memDict = new Dictionary<string, string>();
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
/// <summary>
/// Struttura memoria PLC x lettura/scrittura
/// </summary>
public plcMemMapExt MemMap { get; set; }
public plcMemMapExt Memory { get; set; }
/// <summary>
/// Setup processing dati in ingresso (es: blink segnali)
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace IOB_UT_NEXT.Config.Special
{
public class FanucDto
public class FanucDto_old
{
#region Public Properties
@@ -8,9 +8,9 @@ using System.Threading.Tasks;
namespace IOB_UT_NEXT.Config.Special
{
/// <summary>
/// Configurazione memoria a banchi (es: Fanuc, Mitsubishi, ...)
/// Configurazione memoria a banchi (es: Fanuc, Mitsubishi)
/// </summary>
public class MemoryDto
public class MemBankDto
{
/// <summary>
/// Conf aree di memoria da gestire
@@ -12,6 +12,11 @@ namespace IOB_UT_NEXT.Config.Special
/// </summary>
public class SpecializedDto
{
/// <summary>
/// Configurazione specifica FANUC/Mitsubishi (ove applicabile)
/// </summary>
public MemBankDto BankConf { get; set; }
/// <summary>
/// Parametri speciali per Modbus
/// </summary>
+1 -2
View File
@@ -169,8 +169,7 @@
<Compile Include="Config\IobConfTree.cs" />
<Compile Include="Config\Mem\MemAreaDto.cs" />
<Compile Include="Config\Special\ActionDto.cs" />
<Compile Include="Config\Special\MemoryDto.cs" />
<Compile Include="Config\Special\FanucDto.cs" />
<Compile Include="Config\Special\MemBankDto.cs" />
<Compile Include="Config\Special\SpecializedDto.cs" />
<Compile Include="Config\Special\SiemensDto.cs" />
<Compile Include="DataModel\Fimat.cs" />
+2 -1
View File
@@ -1,4 +1,5 @@
using MapoSDK;
using IOB_UT_NEXT.Config.Special;
using MapoSDK;
using System;
using System.Collections.Generic;
using System.Linq;
+4 -2
View File
@@ -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
+1
View File
@@ -23,6 +23,7 @@ CLI_INST=SteamWareSim
;STARTLIST=VL27
;STARTLIST=3027
;STARTLIST=EV112
;STARTLIST=3021
STARTLIST=3004
+3 -1
View File
@@ -163,7 +163,9 @@
<None Include="DATA\CONF\3007.ini" />
<None Include="DATA\CONF\3012.ini" />
<None Include="DATA\CONF\3015.ini" />
<None Include="DATA\CONF\3021.ini" />
<None Include="DATA\CONF\3021.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\3025.ini" />
<None Include="DATA\CONF\3027.ini" />
<None Include="DATA\CONF\3028.ini" />
+13 -13
View File
@@ -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...
+8 -8
View File
@@ -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
/// </summary>
protected string urlSetOptVal
{
get => $@"{urlCommandIob("addOptPar")}";
get => $@"{urlCommandIob("addOptPar")}?";
}
/// <summary>
@@ -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
+3 -3
View File
@@ -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..