diff --git a/MTC_Adapter/MTC_Adapter/AdapterDemo.cs b/MTC_Adapter/MTC_Adapter/AdapterDemo.cs index bca0939..fb512c8 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterDemo.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterDemo.cs @@ -1,9 +1,5 @@ using MTConnect; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MTC_Adapter { diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index d5e126e..95217ab 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -523,6 +523,10 @@ namespace MTC_Adapter /// public bool adpRunning = false; /// + /// valore booleano di check se l'adapter STIA SALVANDO + /// + public bool adpSaving = false; + /// /// valore booleano (richiesta di riavvio automatico) /// public bool adpTryRestart; diff --git a/MTC_Adapter/MTC_Adapter/App.config b/MTC_Adapter/MTC_Adapter/App.config index 0eb9557..afd0386 100644 --- a/MTC_Adapter/MTC_Adapter/App.config +++ b/MTC_Adapter/MTC_Adapter/App.config @@ -58,6 +58,7 @@ + diff --git a/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml b/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml index 27c7257..2fc088a 100644 --- a/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml +++ b/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml @@ -1,8 +1,8 @@ 1 - ADAPTER_OSAI - OSAI + ADAPTER_FANUC + FANUC 0 0 diff --git a/MTC_Adapter/MTC_Adapter/DATA/CONF/AlarmList.map b/MTC_Adapter/MTC_Adapter/DATA/CONF/AlarmList.map index 6698345..c799ba6 100644 --- a/MTC_Adapter/MTC_Adapter/DATA/CONF/AlarmList.map +++ b/MTC_Adapter/MTC_Adapter/DATA/CONF/AlarmList.map @@ -377,7 +377,7 @@ 000376|PLC|FAULT|[COD 002107] - 530 PULSANTIERA ESTERNA ABILITATA 000377|PLC|FAULT|[COD 002108] - 504 CAMBIO UTENSILE INTERROTTO 000378|PLC|FAULT|[COD 002109] - 363 MONTANTE CENTRALE ALTO -000379|PLC|FAULT|[COD 002110] - =--- PREALLARME TERMICO TORQUE A +000379|PLC|FAULT|[COD 002110] - --- PREALLARME TERMICO TORQUE A 000380|PLC|FAULT|[COD 002111] - 498 CARICO MASSIMO SUL MANDRINO SUPERATO SOGLIA S1 000381|PLC|FAULT|[COD 002112] - --- PREALLARME TERMICO TORQUE C 000382|PLC|FAULT|[COD 002113] - 432 UTENSILE NON SGANCIATO @@ -431,7 +431,7 @@ 000430|PLC|FAULT|[COD 002161] - 289 ATTREZZAGGIO CAMBIO UTENSILE 2 IN CORSO 000431|PLC|FAULT|[COD 002162] - 584 PORTA DI SICUREZZA MAGAZZINO DISCO 2 NON CHIUSA 000432|PLC|FAULT|[COD 002163] - 514 PROTEZIONE MAGAZZINO DISCO 2 NON IN POSIZIONE -000433|PLC|FAULT|[COD 002164] - +000433|PLC|FAULT|[COD 002164] - ... 000434|PLC|FAULT|[COD 002165] - 550 GRUPPO DI FORATURA NON IN POSIZIONE 000435|PLC|FAULT|[COD 002166] - ... 000436|PLC|FAULT|[COD 002167] - ... diff --git a/MTC_Adapter/MTC_Adapter/DATA/DAT/PersistData.dat b/MTC_Adapter/MTC_Adapter/DATA/DAT/PersistData.dat index e69de29..ea7fd62 100644 Binary files a/MTC_Adapter/MTC_Adapter/DATA/DAT/PersistData.dat and b/MTC_Adapter/MTC_Adapter/DATA/DAT/PersistData.dat differ diff --git a/MTC_Adapter/MTC_Adapter/ExtLib/DotNetAdapterSDK.dll b/MTC_Adapter/MTC_Adapter/ExtLib/DotNetAdapterSDK.dll index 9d85914..6dd7bde 100644 Binary files a/MTC_Adapter/MTC_Adapter/ExtLib/DotNetAdapterSDK.dll and b/MTC_Adapter/MTC_Adapter/ExtLib/DotNetAdapterSDK.dll differ diff --git a/MTC_Adapter/MTC_Adapter/MTC-Adapter.csproj b/MTC_Adapter/MTC_Adapter/MTC-Adapter.csproj index 95335d0..a759628 100644 --- a/MTC_Adapter/MTC_Adapter/MTC-Adapter.csproj +++ b/MTC_Adapter/MTC_Adapter/MTC-Adapter.csproj @@ -97,7 +97,7 @@ true - + False ExtLib\DotNetAdapterSDK.dll diff --git a/MTC_Adapter/MTC_Adapter/MainForm.cs b/MTC_Adapter/MTC_Adapter/MainForm.cs index 068b7e5..1c29cf2 100644 --- a/MTC_Adapter/MTC_Adapter/MainForm.cs +++ b/MTC_Adapter/MTC_Adapter/MainForm.cs @@ -149,7 +149,7 @@ namespace MTC_Adapter var sentinalRule = new LoggingRule("*", LogLevel.Trace, sentinalTarget); LogManager.Configuration.AddTarget("sentinal", sentinalTarget); LogManager.Configuration.LoggingRules.Add(sentinalRule); - + #endif LogManager.ReconfigExistingLoggers(); @@ -633,6 +633,15 @@ namespace MTC_Adapter } } /// + /// file persistenza generale data attuale ANTICIPATA di xx giorni + /// + /// num DD di anticipo + /// + public string prevPersLayerFile(int numDD) + { + return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD)); + } + /// /// salva i valori attuali del file di conf sia in file corrente che in cartella valori storici /// public void persistData() @@ -653,7 +662,7 @@ namespace MTC_Adapter private void checkNormTask() { - + // decremento... normCount--; // se il counter è a zero eseguo... @@ -1169,21 +1178,29 @@ namespace MTC_Adapter /// public void savePersistLayer(string filePath) { - // se HO dei dati... - if (agObj.persistenceLayer != null) + // in primis check semaforo salvataggio... + if (!agObj.adpSaving) { - try + // alzo semaforo salvataggio + agObj.adpSaving = true; + // se HO dei dati... + if (agObj.persistenceLayer != null) { - utils.WritePlain(agObj.persistenceLayer, filePath); + try + { + utils.WritePlain(agObj.persistenceLayer, filePath); + } + catch (Exception exc) + { + lg.Error(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc)); + } } - catch (Exception exc) + else { - lg.Error(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc)); + lg.Info("persistenceLayer null, non salvato..."); } - } - else - { - lg.Info("persistenceLayer null, non salvato..."); + // abbasso semaforo salvataggio + agObj.adpSaving = false; } } /// @@ -1195,6 +1212,24 @@ namespace MTC_Adapter // inizializzo prima di leggere... agObj.persistenceLayer = new Dictionary(); agObj.persistenceLayer = utils.ReadPlain(filePath); + + // 2017.03.23 check problema files corrotti... + if (agObj.persistenceLayer.Count == 0) + { + // se avesse letto un valore NON coerente (senza righe) PROVA a leggere a ritroso vecchi files... da histPersLayerFile e precedenti... + int numDD = 0; + int maxNumDD = utils.CRI("maxNumDD"); + Dictionary lastRead = new Dictionary(); + // continuo fino a che non leggo almeno 1 riga valida e non ho raggiunto maxDD + while (numDD < maxNumDD && lastRead.Count == 0) + { + // leggo il file storico alla data anticipata... + lastRead = utils.ReadPlain(prevPersLayerFile(numDD)); + numDD++; + } + // se sono uscito PROVO a passare il file storico letto buono (oppure vuoto...) + agObj.persistenceLayer = lastRead; + } } #endregion @@ -1615,6 +1650,6 @@ namespace MTC_Adapter agObj.tryDisconnect(); } } - + } } diff --git a/MaterialeSetup/FANUC/2017/2017-03-02.mtc b/MaterialeSetup/FANUC/2017/2017-03-02.mtc new file mode 100644 index 0000000..b0b3de9 --- /dev/null +++ b/MaterialeSetup/FANUC/2017/2017-03-02.mtc @@ -0,0 +1,29 @@ +ACC_TIME:18 +ACC_TIME_WORK:0 +Axis_01_AccTime:0 +Axis_01_DistDone:11 +Axis_01_InvDDone:15 +Axis_02_AccTime:0 +Axis_02_DistDone:10 +Axis_02_InvDDone:17 +Axis_03_AccTime:0 +Axis_03_DistDone:3 +Axis_03_InvDDone:11 +Axis_04_AccTime:0 +Axis_04_DistDone:2 +Axis_04_InvDDone:7 +Axis_05_AccTime:1 +Axis_05_DistDone:0 +Axis_05_InvDDone:0 +Axis_06_AccTime:0 +Axis_06_DistDone:11 +Axis_06_InvDDone:15 +Lubro_01_Count:0 +Lubro_02_Count:0 +Path_01_PartId:P000123 +UnOp_01_AccTime:155 +UnOp_01_NumCU:6 +VacAct_01_Count:10 +VacAct_02_Count:10 +VacPump_01_WrkTime:4 +VacPump_02_WrkTime:5 diff --git a/MaterialeSetup/FANUC/2017/2017-03-19.dat b/MaterialeSetup/FANUC/2017/2017-03-19.dat new file mode 100644 index 0000000..b0b3de9 --- /dev/null +++ b/MaterialeSetup/FANUC/2017/2017-03-19.dat @@ -0,0 +1,29 @@ +ACC_TIME:18 +ACC_TIME_WORK:0 +Axis_01_AccTime:0 +Axis_01_DistDone:11 +Axis_01_InvDDone:15 +Axis_02_AccTime:0 +Axis_02_DistDone:10 +Axis_02_InvDDone:17 +Axis_03_AccTime:0 +Axis_03_DistDone:3 +Axis_03_InvDDone:11 +Axis_04_AccTime:0 +Axis_04_DistDone:2 +Axis_04_InvDDone:7 +Axis_05_AccTime:1 +Axis_05_DistDone:0 +Axis_05_InvDDone:0 +Axis_06_AccTime:0 +Axis_06_DistDone:11 +Axis_06_InvDDone:15 +Lubro_01_Count:0 +Lubro_02_Count:0 +Path_01_PartId:P000123 +UnOp_01_AccTime:155 +UnOp_01_NumCU:6 +VacAct_01_Count:10 +VacAct_02_Count:10 +VacPump_01_WrkTime:4 +VacPump_02_WrkTime:5 diff --git a/MaterialeSetup/FANUC/2017/2017-03-20.dat b/MaterialeSetup/FANUC/2017/2017-03-20.dat new file mode 100644 index 0000000..e69de29 diff --git a/MaterialeSetup/FANUC/2017/2017-03-21.dat b/MaterialeSetup/FANUC/2017/2017-03-21.dat new file mode 100644 index 0000000..ea7fd62 Binary files /dev/null and b/MaterialeSetup/FANUC/2017/2017-03-21.dat differ diff --git a/MaterialeSetup/FANUC/2017/2017-03-22.dat b/MaterialeSetup/FANUC/2017/2017-03-22.dat new file mode 100644 index 0000000..ea7fd62 Binary files /dev/null and b/MaterialeSetup/FANUC/2017/2017-03-22.dat differ diff --git a/MaterialeSetup/FANUC/2017/2017-03-23.dat b/MaterialeSetup/FANUC/2017/2017-03-23.dat new file mode 100644 index 0000000..ea7fd62 Binary files /dev/null and b/MaterialeSetup/FANUC/2017/2017-03-23.dat differ diff --git a/MaterialeSetup/FANUC/PersistData.dat b/MaterialeSetup/FANUC/PersistData.dat new file mode 100644 index 0000000..b0b3de9 --- /dev/null +++ b/MaterialeSetup/FANUC/PersistData.dat @@ -0,0 +1,29 @@ +ACC_TIME:18 +ACC_TIME_WORK:0 +Axis_01_AccTime:0 +Axis_01_DistDone:11 +Axis_01_InvDDone:15 +Axis_02_AccTime:0 +Axis_02_DistDone:10 +Axis_02_InvDDone:17 +Axis_03_AccTime:0 +Axis_03_DistDone:3 +Axis_03_InvDDone:11 +Axis_04_AccTime:0 +Axis_04_DistDone:2 +Axis_04_InvDDone:7 +Axis_05_AccTime:1 +Axis_05_DistDone:0 +Axis_05_InvDDone:0 +Axis_06_AccTime:0 +Axis_06_DistDone:11 +Axis_06_InvDDone:15 +Lubro_01_Count:0 +Lubro_02_Count:0 +Path_01_PartId:P000123 +UnOp_01_AccTime:155 +UnOp_01_NumCU:6 +VacAct_01_Count:10 +VacAct_02_Count:10 +VacPump_01_WrkTime:4 +VacPump_02_WrkTime:5 diff --git a/MaterialeSetup/FANUC/PersistData_KO.dat b/MaterialeSetup/FANUC/PersistData_KO.dat new file mode 100644 index 0000000..ea7fd62 Binary files /dev/null and b/MaterialeSetup/FANUC/PersistData_KO.dat differ diff --git a/MaterialeSetup/FANUC/PersistData_OK.dat b/MaterialeSetup/FANUC/PersistData_OK.dat new file mode 100644 index 0000000..e69de29