diff --git a/IOB-WIN-NEXT/DATA/CONF/VL27.ini b/IOB-WIN-NEXT/DATA/CONF/VL27.ini
index a8c67c6b..e4a0da57 100644
--- a/IOB-WIN-NEXT/DATA/CONF/VL27.ini
+++ b/IOB-WIN-NEXT/DATA/CONF/VL27.ini
@@ -59,15 +59,23 @@ BLINK_FILT=0
[OPTPAR]
;PZCOUNT_MODE=STD|BIT
-PZCOUNT_MODE=STD.PAR.6711
-PZGTOT_MODE=STD.PAR.6712
-;PZREQ_MODE=STD.PAR.6713
+;PZCOUNT_MODE=STD.PAR.6711
+;PZGTOT_MODE=STD.PAR.6712
+;;PZREQ_MODE=STD.PAR.6713
+PZCOUNT_MODE=STD.MACRO.930
+PZGTOT_MODE=STD.MACRO.929
+PZREQ_MODE=STD.MACRO.964
ENABLE_PZ_RESET=TRUE
ENABLE_PZ_RESET_stopSetup=TRUE
;gestione invio pezzi in blocco
ENABLE_SEND_PZC_BLOCK=TRUE
MIN_SEND_PZC_BLOCK=0
MAX_SEND_PZC_BLOCK=100
+; conf cablata set Art/Commessa
+SET_NUM_ART=MACRO.966
+SET_NUM_COM=MACRO.965
+; conf parametri memoria READ/WRITE
+PARAM_CONF=VL27.json
[BRANCH]
diff --git a/IOB-WIN-NEXT/DATA/CONF/VL27.json b/IOB-WIN-NEXT/DATA/CONF/VL27.json
new file mode 100644
index 00000000..8db03ba7
--- /dev/null
+++ b/IOB-WIN-NEXT/DATA/CONF/VL27.json
@@ -0,0 +1,77 @@
+{
+ "mMapWrite": {
+ "setArt": {
+ "name": "setArt",
+ "description": "Articolo",
+ "memAddr": "",
+ "tipoMem": "String",
+ "index": 0,
+ "size": 20,
+ "displOrdinal": 1
+ },
+ "setArtNum": {
+ "name": "setArtNum",
+ "description": "# Num Articolo",
+ "memAddr": "MACRO.966",
+ "tipoMem": "Int",
+ "index": 966,
+ "size": 4,
+ "displOrdinal": 1
+ },
+ "setComm": {
+ "name": "setComm",
+ "description": "Commessa",
+ "memAddr": "",
+ "tipoMem": "String",
+ "index": 0,
+ "size": 20,
+ "displOrdinal": 2
+ },
+ "setCommNum": {
+ "name": "setCommNum",
+ "description": "# NumCommessa",
+ "memAddr": "MACRO.965",
+ "tipoMem": "Int",
+ "index": 965,
+ "size": 4,
+ "displOrdinal": 2
+ },
+ "setPzComm": {
+ "name": "setPzComm",
+ "description": "Qta Richiesta",
+ "memAddr": "MACRO.964",
+ "tipoMem": "Int",
+ "index": 964,
+ "size": 4,
+ "displOrdinal": 3
+ }
+ },
+ "mMapRead": {
+ "ContatoreAssoluto": {
+ "name": "ContatoreAssoluto",
+ "description": "Contapezzi ASSOLUTO",
+ "memAddr": "MACRO.929",
+ "tipoMem": "Int",
+ "index": 929,
+ "size": 4,
+ "func": "MAX",
+ "period": 60,
+ "factor": 1
+ },
+ "ContatoreParziale": {
+ "name": "ContatoreParziale",
+ "description": "Contapezzi Parziale",
+ "memAddr": "MACRO.930",
+ "tipoMem": "DInt",
+ "index": 930,
+ "size": 4,
+ "func": "MAX",
+ "period": 60,
+ "factor": 1
+ }
+ },
+ "mMapWriteLink": {
+ "setArt": "setArtNum",
+ "setComm": "setCommNum"
+ }
+}
\ No newline at end of file
diff --git a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj
index dbacb5b4..296c4125 100644
--- a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj
+++ b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj
@@ -514,6 +514,7 @@
+
Always
diff --git a/IOB-WIN-NEXT/Iob/Fanuc.cs b/IOB-WIN-NEXT/Iob/Fanuc.cs
index 78d5e0f5..ea3870eb 100644
--- a/IOB-WIN-NEXT/Iob/Fanuc.cs
+++ b/IOB-WIN-NEXT/Iob/Fanuc.cs
@@ -1,6 +1,8 @@
using EgwProxy.MultiCncLib.CNC;
using IOB_UT_NEXT;
using MapoSDK;
+using Opc.Ua;
+using Org.BouncyCastle.Ocsp;
using System;
using System.Collections.Generic;
using System.Net;
@@ -183,6 +185,8 @@ namespace IOB_WIN_NEXT.Iob
{
bool taskOk = false;
string taskVal = "";
+ string newVal = "";
+ int newValInt = 0;
// cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4
foreach (var item in task2exe)
{
@@ -193,11 +197,11 @@ namespace IOB_WIN_NEXT.Iob
Enum.TryParse(item.Key, out tName);
switch (tName)
{
+ case taskType.setArt:
+ case taskType.setComm:
case taskType.nihil:
case taskType.fixStopSetup:
case taskType.forceResetPzCount:
- case taskType.setArt:
- case taskType.setComm:
case taskType.setProg:
case taskType.forceSetPzCount:
case taskType.sendWatchDogMes2Plc:
@@ -205,10 +209,82 @@ namespace IOB_WIN_NEXT.Iob
lgInfo($"Chiamata senza processing: taskOk: {taskOk} | taskVal: {taskVal}");
break;
+ case taskType.setArtNum:
+ lgInfo($"Richiesta scrittura cod ART numerico");
+ // in primis faccio una chiamata per tutta la tab SE fosse vuoto il dict
+ // di traduzione
+ if (DictNumArt == null || DictNumArt.Count == 0)
+ {
+ getNumArt("");
+ }
+ // chiamo server x avere decodifica valore INT
+ newVal = getNumArt(item.Value);
+ // converto int...
+ int.TryParse(newVal, out newValInt);
+ // procedo come il resto cercando mappatura in memMap: recupero dati da memMap...
+ if (memMap != null && memMap.mMapWrite != null)
+ {
+ if (memMap.mMapWrite.ContainsKey(item.Key))
+ {
+ dataConf currMem = memMap.mMapWrite[item.Key];
+ string addr = currMem.memAddr;
+ taskVal = $"SET task: {item.Key} --> {newVal} | mem: {currMem.memAddr} - {currMem.size} byte";
+ // salvo il nuovo valore nella memoria... così prox invio lo trasmetterà
+ memMap.mMapWrite[item.Key].value = newVal;
+ }
+ else
+ {
+ taskVal = $"NO DATA MEM, SET task: {item.Key} --> {newVal} ({item.Value})";
+ }
+ }
+ else
+ {
+ taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})";
+ }
+
+ // invio a controller...
+ taskOk = setNumArt(newValInt);
+
+ // salvo in currProd..
+ saveProdData(new KeyValuePair(item.Key, newVal));
+ break;
+
+ case taskType.setCommNum:
+ lgInfo($"Richiesta scrittura cod COMMESSA numerica");
+ // chiamo server x avere decodifica valore INT
+ newVal = getNumComm(item.Value);
+ // procedo come il resto cercando mappatura in memMap: recupero dati da memMap...
+ if (memMap != null && memMap.mMapWrite != null)
+ {
+ if (memMap.mMapWrite.ContainsKey(item.Key))
+ {
+ dataConf currMem = memMap.mMapWrite[item.Key];
+ string addr = currMem.memAddr;
+ taskVal = $"SET task: {item.Key} --> {newVal} | mem: {currMem.memAddr} - {currMem.size} byte";
+ // salvo il nuovo valore nella memoria... così prox invio lo trasmetterà
+ memMap.mMapWrite[item.Key].value = newVal;
+ }
+ else
+ {
+ taskVal = $"NO DATA MEM, SET task: {item.Key} --> {newVal} ({item.Value})";
+ }
+ }
+ else
+ {
+ taskVal = $"NO MemMap found, SET task: {item.Key} --> {newVal} ({item.Value})";
+ }
+
+ // invio a controller...
+ taskOk = setNumCom(newValInt);
+
+ // salvo in currProd..
+ saveProdData(new KeyValuePair(item.Key, newVal));
+ break;
+
case taskType.setPzComm:
int pzReq = 0;
int.TryParse(item.Value, out pzReq);
- // set contatore pezzi richiestiinizio setup
+ // set pezzi richiesti inizio setup
taskOk = setPzComm(pzReq);
taskVal = taskOk ? "RESET: SETUP START" : "PZ RESET DISABLED | NO EXEC";
lgInfo($"Chiamata startSetup: taskOk: {taskOk} | taskVal: {taskVal}");
@@ -243,6 +319,60 @@ namespace IOB_WIN_NEXT.Iob
return taskDone;
}
+ ///
+ /// Wrapper chiamata lettura/scrittura INTERO in area macro...
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool FanucMemMacroRW(bool bWrite, Int32 memIndex, ref short Value)
+ {
+ bool answ = false;
+ if (connectionOk)
+ {
+ if (FANUC_ref.Connected)
+ {
+ try
+ {
+ parentForm.commPlcActive = true;
+ answ = FANUC_ref.F_RW_Macro_Short(bWrite, memIndex, ref Value);
+ }
+ catch
+ { }
+ }
+ }
+ parentForm.commPlcActive = false;
+ return answ;
+ }
+
+ ///
+ /// Wrapper chiamata lettura/scrittura DOUBLE in area macro...
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool FanucMemMacroRW(bool bWrite, Int32 memIndex, ref double Value)
+ {
+ bool answ = false;
+ if (connectionOk)
+ {
+ if (FANUC_ref.Connected)
+ {
+ try
+ {
+ parentForm.commPlcActive = true;
+ answ = FANUC_ref.F_RW_Macro_Double(bWrite, memIndex, ref Value);
+ }
+ catch
+ { }
+ }
+ }
+ parentForm.commPlcActive = false;
+ return answ;
+ }
+
///
/// wrapper chiamata lettura/scrittura SINGOLO BYTE...
///
@@ -277,7 +407,7 @@ namespace IOB_WIN_NEXT.Iob
///
///
///
- ///
+ ///
///
public bool FanucMemRW(bool bWrite, FANUC.MemType MemType, Int32 memIndex, ref byte[] Value)
{
@@ -820,6 +950,24 @@ namespace IOB_WIN_NEXT.Iob
TimingData.addResult(cIobConf.codIOB, string.Format("W{0}-PAR", 4), stopwatch.ElapsedTicks);
}
}
+ else if (memAddr.StartsWith("MACRO."))
+ {
+ // recupero parametro...
+ int.TryParse(memAddr.Replace("MACRO.", ""), out cntAddr);
+ if (cntAddr == 0)
+ {
+ cntAddr = 9999;
+ }
+
+ // processo SET contapezzi (lavorati)
+ stopwatch.Restart();
+ Int16 reqVal = (Int16)0;
+ FANUC_ref.F_RW_Macro_Short(true, cntAddr, ref reqVal);
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, "MACRO-SHORT", stopwatch.ElapsedTicks);
+ }
+ }
// altrimenti se legge da area memoria specifica leggo da li... formto
// tipo STD.D.1604.DW
else
@@ -907,6 +1055,224 @@ namespace IOB_WIN_NEXT.Iob
}
}
+ ///
+ /// Effettua impostazione del valore numerico ARTICOLO (specifico FANUC)
+ ///
+ ///
+ public bool setNumArt(int valReq)
+ {
+ bool answ = false;
+ // verifico quale modalità sia richiesta
+ string memAddr = getOptPar("SET_NUM_ART");
+ if (cIobConf.optPar.Count > 0 && !string.IsNullOrEmpty(memAddr))
+ {
+ // scrivo valore richiesto in area configurata
+ try
+ {
+ // var di appoggio
+ int cntAddr = 0;
+#if false
+ // var contapezzi a zero....
+ object newVal = new object();
+ newVal = valReq;
+#endif
+ // verifico se si tratta di lettura MACRO... formato tipo MACRO.6711
+ if (memAddr.StartsWith("MACRO."))
+ {
+ // recupero parametro...
+ int.TryParse(memAddr.Replace("MACRO.", ""), out cntAddr);
+ if (cntAddr == 0)
+ {
+ cntAddr = 9999;
+ }
+
+ // processo SET contapezzi (lavorati)
+ stopwatch.Restart();
+ Int16 reqVal = (Int16)valReq;
+ FANUC_ref.F_RW_Macro_Short(true, cntAddr, ref reqVal);
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, "MACRO-SHORT", stopwatch.ElapsedTicks);
+ }
+ }
+#if false
+ else if (memAddr.StartsWith("PAR."))
+ {
+ // recupero parametro...
+ int.TryParse(memAddr.Replace("PAR.", ""), out cntAddr);
+ if (cntAddr == 0)
+ {
+ cntAddr = 6711;
+ }
+
+ // processo SET contapezzi (lavorati)
+ stopwatch.Restart();
+ FANUC_ref.F_RW_Param_Integer(true, cntAddr, 3, ref newVal);
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, string.Format("W{0}-PAR", 4), stopwatch.ElapsedTicks);
+ }
+ }
+ else
+ {
+ memAddressFanuc areaCounter = new memAddressFanuc(memAddr);
+
+ if (isVerboseLog)
+ {
+ lgInfo("setPzComm [0] area memoria: {0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType);
+ }
+ // leggo!
+ stopwatch.Restart();
+ // switch x tipo dati --> tipo lettura... e salvo ultimo conteggio rilevato
+ switch (areaCounter.vType)
+ {
+ case "B":
+ byte valB = (byte)pzReq;
+ FANUC_ref.F_RW_Byte(true, areaCounter.mType, areaCounter.mPos, ref valB);
+ newVal = valB;
+ break;
+
+ case "D":
+ ushort valW = (ushort)pzReq;
+ FANUC_ref.F_RW_Word(true, areaCounter.mType, areaCounter.mPos, ref valW);
+ newVal = valW;
+ break;
+
+ case "DW":
+ uint valDW = (uint)pzReq;
+ FANUC_ref.F_RW_DWord(true, areaCounter.mType, areaCounter.mPos, ref valDW);
+ break;
+
+ default:
+ break;
+ }
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, string.Format("W-{0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType), stopwatch.ElapsedTicks);
+ }
+ }
+#endif
+ stopwatch.Stop();
+ }
+ catch (Exception exc)
+ {
+ lgError(exc, "Errore in setNumArt FANUC");
+ connectionOk = false;
+ }
+ answ = true;
+ }
+ return answ;
+ }
+
+ ///
+ /// Effettua impostazione del valore numerico COMMESSA (specifico FANUC)
+ ///
+ ///
+ public bool setNumCom(int valReq)
+ {
+ bool answ = false;
+ // verifico quale modalità sia richiesta
+ string memAddr = getOptPar("SET_NUM_COM");
+ if (cIobConf.optPar.Count > 0 && !string.IsNullOrEmpty(memAddr))
+ {
+ // scrivo valore richiesto in area configurata
+ try
+ {
+ // var di appoggio
+ int cntAddr = 0;
+#if false
+ // var contapezzi a zero....
+ object newVal = new object();
+ newVal = valReq;
+#endif
+ // verifico se si tratta di lettura MACRO... formato tipo MACRO.6711
+ if (memAddr.StartsWith("MACRO."))
+ {
+ // recupero parametro...
+ int.TryParse(memAddr.Replace("MACRO.", ""), out cntAddr);
+ if (cntAddr == 0)
+ {
+ cntAddr = 9999;
+ }
+
+ // processo SET contapezzi (lavorati)
+ stopwatch.Restart();
+ Int16 reqVal = (Int16)valReq;
+ FANUC_ref.F_RW_Macro_Short(true, cntAddr, ref reqVal);
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, "MACRO-SHORT", stopwatch.ElapsedTicks);
+ }
+ }
+#if false
+ else if (memAddr.StartsWith("PAR."))
+ {
+ // recupero parametro...
+ int.TryParse(memAddr.Replace("PAR.", ""), out cntAddr);
+ if (cntAddr == 0)
+ {
+ cntAddr = 6711;
+ }
+
+ // processo SET contapezzi (lavorati)
+ stopwatch.Restart();
+ FANUC_ref.F_RW_Param_Integer(true, cntAddr, 3, ref newVal);
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, string.Format("W{0}-PAR", 4), stopwatch.ElapsedTicks);
+ }
+ }
+ else
+ {
+ memAddressFanuc areaCounter = new memAddressFanuc(memAddr);
+
+ if (isVerboseLog)
+ {
+ lgInfo("setPzComm [0] area memoria: {0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType);
+ }
+ // leggo!
+ stopwatch.Restart();
+ // switch x tipo dati --> tipo lettura... e salvo ultimo conteggio rilevato
+ switch (areaCounter.vType)
+ {
+ case "B":
+ byte valB = (byte)pzReq;
+ FANUC_ref.F_RW_Byte(true, areaCounter.mType, areaCounter.mPos, ref valB);
+ newVal = valB;
+ break;
+
+ case "D":
+ ushort valW = (ushort)pzReq;
+ FANUC_ref.F_RW_Word(true, areaCounter.mType, areaCounter.mPos, ref valW);
+ newVal = valW;
+ break;
+
+ case "DW":
+ uint valDW = (uint)pzReq;
+ FANUC_ref.F_RW_DWord(true, areaCounter.mType, areaCounter.mPos, ref valDW);
+ break;
+
+ default:
+ break;
+ }
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, string.Format("W-{0}.{1}.{2}", areaCounter.mType, areaCounter.mPos, areaCounter.vType), stopwatch.ElapsedTicks);
+ }
+ }
+#endif
+ stopwatch.Stop();
+ }
+ catch (Exception exc)
+ {
+ lgError(exc, "Errore in setNumCom FANUC");
+ connectionOk = false;
+ }
+ answ = true;
+ }
+ return answ;
+ }
+
///
/// Effettua impostazione del conteggio pezzi richiesti
///
@@ -934,7 +1300,7 @@ namespace IOB_WIN_NEXT.Iob
int cntAddr = 0;
// var contapezzi a zero....
object newVal = new object();
- newVal = 0;
+ newVal = pzReq;
// verifico se si tratta di lettura parametro... formato tipo STD.PAR.6711
if (memAddr.StartsWith("PAR."))
{
@@ -945,7 +1311,7 @@ namespace IOB_WIN_NEXT.Iob
cntAddr = 6711;
}
- // processo RESET contapezzi (lavorati)
+ // processo SET contapezzi (lavorati)
stopwatch.Restart();
FANUC_ref.F_RW_Param_Integer(true, cntAddr, 3, ref newVal);
if (utils.CRB("recTime"))
@@ -953,6 +1319,24 @@ namespace IOB_WIN_NEXT.Iob
TimingData.addResult(cIobConf.codIOB, string.Format("W{0}-PAR", 4), stopwatch.ElapsedTicks);
}
}
+ else if (memAddr.StartsWith("MACRO."))
+ {
+ // recupero parametro...
+ int.TryParse(memAddr.Replace("MACRO.", ""), out cntAddr);
+ if (cntAddr == 0)
+ {
+ cntAddr = 9999;
+ }
+
+ // processo SET contapezzi (lavorati)
+ stopwatch.Restart();
+ Int16 reqVal = (Int16)pzReq;
+ FANUC_ref.F_RW_Macro_Short(true, cntAddr, ref reqVal);
+ if (utils.CRB("recTime"))
+ {
+ TimingData.addResult(cIobConf.codIOB, "MACRO-SHORT", stopwatch.ElapsedTicks);
+ }
+ }
// altrimenti se legge da area memoria specifica leggo da li... formto
// tipo STD.D.1604.DW
else
@@ -1349,8 +1733,8 @@ namespace IOB_WIN_NEXT.Iob
// verifico se variato contapezzi...
if (contapezziPLC > contapezziIOB)
{
- // salvo nuovo contapezzi (incremento di 1...) + richiesta
- // refresh conteggio
+ // salvo nuovo contapezzi (incremento di 1...) +
+ // richiesta refresh conteggio
contapezziIOB++;
needRefreshPzCount = true;
// salvo in semaforo!
diff --git a/IOB-WIN-NEXT/Iob/Generic.cs b/IOB-WIN-NEXT/Iob/Generic.cs
index 493c892a..8e696fc3 100644
--- a/IOB-WIN-NEXT/Iob/Generic.cs
+++ b/IOB-WIN-NEXT/Iob/Generic.cs
@@ -3080,6 +3080,7 @@ namespace IOB_WIN_NEXT.Iob
{
// aggiungo a task2add...
task2Add.Add(linkVal, item.Value);
+ lgInfo($"Aggiunta task linked: {linkVal} -> {item.Value}");
}
}
// se ho task Link da aggiungere li aggiungo!