diff --git a/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs b/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs
index 4cd98d3..ffe7abb 100644
--- a/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs
+++ b/MTC_Adapter/MTC_Adapter/AdapterFanuc.cs
@@ -327,7 +327,10 @@ namespace MTC_Adapter
}
// Invio comunque strobe non riconosciuti
- mUnkStrobe.Value = UnkStrobe.Trim();
+ if (mUnkStrobe.Value.ToString() != UnkStrobe.Trim())
+ {
+ mUnkStrobe.Value = UnkStrobe.Trim();
+ }
// INVIO COMUNQUE stato test...
mTestingData.Value = TestingData.Trim();
diff --git a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs
index e73ffef..b0ad307 100644
--- a/MTC_Adapter/MTC_Adapter/AdapterOsai.cs
+++ b/MTC_Adapter/MTC_Adapter/AdapterOsai.cs
@@ -319,78 +319,97 @@ namespace MTC_Adapter
{
base.processStrobe();
- // gestione multipath: ciclo
- for (int i = 1; i <= currAdpConf.nPath; i++)
+ // oggetti "accessori" x processing (1 byte di strobe x ogni path)
+ StFlag8 currStrobe;
+ StFlag8 currAck;
+ string UserAction = "";
+
+ // processo ora i dai dei path... di sicuro il primo
+ currStrobe = (StFlag8)(Strobes[4]); // 5° byte
+ currAck = (StFlag8)(Acknowl[4]); // 5° byte
+ procPathStrobes(0, currStrobe, currAck, 19098, 19020, ref UserAction);
+
+ //...e se c'è pure il secondo...
+ if (currAdpConf.nPath > 1)
{
- processPath(i);
+ currStrobe = (StFlag8)(Strobes[6]); // 7° byte
+ currAck = (StFlag8)(Acknowl[6]); // 7° byte
+ procPathStrobes(1, currStrobe, currAck, 19121, 19021, ref UserAction);
}
+ // 2017.01.16 INVIO vettore azioni (1 o +)... SE CE NE SONO!
+ if (UserAction.Trim() != "")
+ {
+ mUserAction.ForceChanged();
+ mUserAction.Value = UserAction.Trim();
+ }
+
+ // verifico strobe dell'auto-test
+ processTestStrobe();
+
// gestione bit di watchdog... sulal DWord successiva
sendWatchDog();
}
+
///
/// Processa strobe x un dato path
///
- ///
- private void processPath(int idxPath)
+ /// path corrente
+ /// Byte di strobe del path corrente
+ /// Byte di strobe del path corrente
+ /// indice x lettura memoria MST del path
+ /// indice x scrittura ACK x path
+ /// stringa COMPLESSIVA azioni utente
+ private void procPathStrobes(int idxPath, StFlag8 currStrobe, StFlag8 currAck, int memIndexMST, int memIndexAck, ref string UserAction)
{
// byte di strobe e di acknowledge... inizializzo!!!
- byte[] currACK_DW = new byte[4];
- StFlag32 currStrobe;
- // verifico in base al path quali DW usare x i vari strobe/ack... userò DW1 per path1 e DW2 x path2... HARD CODED...
- switch (idxPath)
- {
- case 1:
- currStrobe = STRB_DW1;
- break;
- case 2:
- currStrobe = STRB_DW2;
- break;
- default:
- currStrobe = STRB_DW1;
- break;
- }
+ byte[] currACK_DW = new byte[1];
// inizializzo vettori ulteriori (userAction, testing data, unkStrobes...)
- string UserAction = "";
- string TestingData = "";
- string UnkStrobe = "";
+#if false
+ string UnkStrobe = "";
+#endif
// altre variabili
- int memIndex = 0;
int bitNum = 0;
inizio = DateTime.Now;
// incomincio vera e propria gestione...
try
{
// controllo TUTTI i flag: se ce ne sono di alzati DEVO processare...
- if (currStrobe != StFlag32.NONE)
+ if (currStrobe != StFlag8.NONE)
{
- // blocco memoria x lettura TUTTI i dati di buffer M/S/T: 46 byte: 2byte (16bit) x (11+6+6) aree
- byte[] MemBlock = new byte[46];
+ // se ho un M/S/T leggo area...
+ if (currStrobe.HasFlag(StFlag8.B0) || currStrobe.HasFlag(StFlag8.B1) || currStrobe.HasFlag(StFlag8.B2))
+ {
- // leggo tutto!!!
- memIndex = 10660;
- inizio = DateTime.Now;
-#if false
- OsaiMemRW(R, FANUC.MemType.R, memIndex, ref MemBlock);
-#endif
- if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-STRB_DW1", MemBlock.Length), DateTime.Now.Subtract(inizio).Ticks);
+ // blocco memoria x lettura TUTTI i dati di buffer M/S/T: 23 short(16bit) x (11+6+6) aree
+ ushort[] MemBlock_W = new ushort[23];
- // check COD_M
- bitNum = 0;
- gestStrobeCodMST(bitNum, ref currACK_DW, 0, MemBlock, "M");
+ // leggo tutto!!!
+ inizio = DateTime.Now;
+ OsaiMemRW_Word(R, OSAI.MemTypeWord.MW_CODE, memIndexMST, ref MemBlock_W);
+ if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-STRB_DW1-P{1:00}", MemBlock_W.Length, idxPath), DateTime.Now.Subtract(inizio).Ticks);
- // check COD_S
- bitNum = 1;
- gestStrobeCodMST(bitNum, ref currACK_DW, 11, MemBlock, "S");
+ // converto a byte x compatibilità...
+ byte[] MemBlock = new byte[MemBlock_W.Length * 2];
+ Buffer.BlockCopy(MemBlock_W, 0, MemBlock, 0, MemBlock.Length);
- // check COD_T
- bitNum = 2;
- gestStrobeCodMST(bitNum, ref currACK_DW, 17, MemBlock, "T");
+ // check COD_M
+ bitNum = 0;
+ gestStrobeCodMST(bitNum, ref currACK_DW, 0, MemBlock, "M");
+ // check COD_S
+ bitNum = 1;
+ gestStrobeCodMST(bitNum, ref currACK_DW, 11, MemBlock, "S");
+
+ // check COD_T
+ bitNum = 2;
+ gestStrobeCodMST(bitNum, ref currACK_DW, 17, MemBlock, "T");
+
+ }
// check FILE DATI MODIFICATO: ricaricare...
bitNum = 3;
- if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
+ if (STRB_DW1.HasFlag((StFlag8)Math.Pow(2, bitNum)))
{
lg.Info("Notifica file modificato");
try
@@ -410,50 +429,35 @@ namespace MTC_Adapter
// AREA strobe USER ACTION
// chiamato Start...
bitNum = 4;
- gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, " (START) ");
+ gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} START) ", idxPath));
// chiamato Stop...
bitNum = 5;
- gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, " (STOP) ");
+ gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} STOP) ", idxPath));
// chiamato Reset...
bitNum = 6;
- gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, " (RESET) ");
+ gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} RESET) ", idxPath));
- // processo tutti gli strobe x i BIT 7-29 NON gestiti in modo da dare comunque ACK e event...
- for (int i = 7; i < 30; i++)
+ //2017.03.27 tolto controllo ALTRI stobes
+#if false
+ // processo tutti gli strobe x i BIT 7 NON gestiti in modo da dare comunque ACK e event...
+ for (int i = 7; i < 8; i++)
{
gestStrobeUserAction(i, ref currACK_DW, ref UnkStrobe, string.Format(" [STROBE_{0:00}] ", i));
- }
-
- // AREA strobe x TEST
- // INIZIO TEST...
- bitNum = 30;
- if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
- {
- // formatto stringa risultato
- TestingData = string.Format("START TEST{0}", getTestData(utils.CRS("testCharSep")));
-
- // memorizzo allarme nel vettore ack....
- currACK_DW = utils.setBitOnStFlag(currACK_DW, true, bitNum);
- }
- // FINE TEST...
- bitNum = 31;
- if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
- {
- // formatto stringa risultato
- TestingData = string.Format("STOP TEST{0}", getTestData(utils.CRS("testCharSep")));
-
- // memorizzo allarme nel vettore ack....
- currACK_DW = utils.setBitOnStFlag(currACK_DW, true, bitNum);
- }
+ }
+#endif
}
else
{
+#if false
// se mi sono rimasti degli strobe di lettura allarmi alzati li abbasso
if (ACK_DW1 != StFlag32.NONE)
- {
- // inizializzo 4 byte a zero!!!
- currACK_DW = new byte[4];
- }
+ {
+#endif
+ // inizializzo 4 byte a zero!!!
+ currACK_DW = new byte[1];
+#if false
+ }
+#endif
}
}
catch
@@ -461,31 +465,58 @@ namespace MTC_Adapter
lg.Info("Errore in strobe");
}
- // 2017.01.16 INVIO vettore azioni (1 o +)... SE CE NE SONO!
- if (UserAction.Trim() != "")
- {
- mUserAction.ForceChanged();
- mUserAction.Value = UserAction.Trim();
- }
+ // 2017.03.27 tolti UNK strobes
+#if false
// Invio comunque strobe non riconosciuti
- mUnkStrobe.Value = UnkStrobe.Trim();
+ if (mUnkStrobe.Value.ToString() != UnkStrobe.Trim())
+ {
+ mUnkStrobe.Value = UnkStrobe.Trim();
+ }
+#endif
- // INVIO COMUNQUE stato test...
- mTestingData.Value = TestingData.Trim();
-
- memIndex = 10504;
// scrivo update ad ack SE VARIATO!!!
- if (ACK_DW1 != (StFlag32)BitConverter.ToUInt32(currACK_DW, 0))
+ if (currAck != (StFlag8)currACK_DW[0])
{
inizio = DateTime.Now;
-#if false
- OsaiMemRW(W, FANUC.MemType.R, memIndex, ref retACK_DW);
-#endif
- if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-DW1", currACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
+ OsaiMemRW_Byte(W, OSAI.MemTypeWord.MW_CODE, memIndexAck, 0, ref currACK_DW);
+ if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-B", currACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
}
}
+ ///
+ /// Verifica strobe autotest
+ ///
+ private void processTestStrobe()
+ {
+ string TestingData = "";
+#if false
+ // AREA strobe x TEST
+ // INIZIO TEST...
+ bitNum = 30;
+ if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
+ {
+ // formatto stringa risultato
+ TestingData = string.Format("START TEST{0}", getTestData(utils.CRS("testCharSep")));
+ // memorizzo allarme nel vettore ack....
+ currACK_DW = utils.setBitOnStFlag(currACK_DW, true, bitNum);
+ }
+ // FINE TEST...
+ bitNum = 31;
+ if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
+ {
+ // formatto stringa risultato
+ TestingData = string.Format("STOP TEST{0}", getTestData(utils.CRS("testCharSep")));
+
+ // memorizzo allarme nel vettore ack....
+ currACK_DW = utils.setBitOnStFlag(currACK_DW, true, bitNum);
+ }
+
+
+ // INVIO COMUNQUE stato test...
+ mTestingData.Value = TestingData.Trim();
+#endif
+ }
///
/// Invia (se necessario) il watchdog di stato in vita... blink 0/1 ogni secondo
///