From 6a9560eca19945ea6120a3a94adca8a9f4716fad Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Mon, 23 Oct 2017 11:19:58 +0200 Subject: [PATCH] pulizia codice --- IOB-WIN/IOB-WIN/IOB-WIN.csproj | 1 - IOB-WIN/IOB-WIN/IobDemo.cs | 23 --- IOB-WIN/IOB-WIN/IobGeneric.cs | 339 +------------------------------- IOB-WIN/IOB-WIN/IobSiemens.cs | 44 ----- IOB-WIN/IOB-WIN/MainForm.cs | 27 --- IOB-WIN/IOB-WIN/Readme/ToDo.txt | 2 +- 6 files changed, 5 insertions(+), 431 deletions(-) delete mode 100644 IOB-WIN/IOB-WIN/IobSiemens.cs diff --git a/IOB-WIN/IOB-WIN/IOB-WIN.csproj b/IOB-WIN/IOB-WIN/IOB-WIN.csproj index 4238690..a491f14 100644 --- a/IOB-WIN/IOB-WIN/IOB-WIN.csproj +++ b/IOB-WIN/IOB-WIN/IOB-WIN.csproj @@ -54,7 +54,6 @@ VersGen.cs - diff --git a/IOB-WIN/IOB-WIN/IobDemo.cs b/IOB-WIN/IOB-WIN/IobDemo.cs index 47fecc9..9efe492 100644 --- a/IOB-WIN/IOB-WIN/IobDemo.cs +++ b/IOB-WIN/IOB-WIN/IobDemo.cs @@ -16,29 +16,6 @@ namespace IOB_WIN /// public IobDemo(MainForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) { -#if false - // è little endian (NON serve conversione) - hasBigEndian = false; - - lg.Info("Start init Adapter FANUC all'IP {0}", utils.CRS("ipPLC")); - - parentForm.commPlcActive = true; - Runtime.CreateNC(CNC.NcType.FANUC, utils.CRS("ipPLC")); - parentForm.commPlcActive = false; - // inizializzo posizioni assi... - prevPosAxis = new double[adpConf.nAxis]; - prevDirAxis = new int[adpConf.nAxis]; - - FANUC_ref = (FANUC)Runtime.NC; - if (utils.CRB("verbose")) lg.Info("FANUC_ref da CMSCncLib"); - - // disconnetto e connetto... - if (utils.CRB("verbose")) lg.Info("FANUC: tryDisconnect"); - tryDisconnect(); - lg.Info("FANUC: tryConnect"); - tryConnect(); - lg.Info("End init Adapter FANUC"); -#endif } } } diff --git a/IOB-WIN/IOB-WIN/IobGeneric.cs b/IOB-WIN/IOB-WIN/IobGeneric.cs index ae69db9..d039499 100644 --- a/IOB-WIN/IOB-WIN/IobGeneric.cs +++ b/IOB-WIN/IOB-WIN/IobGeneric.cs @@ -114,40 +114,11 @@ namespace IOB_WIN /// Contatore x invio dati /// public int counter { get; set; } - + /// + /// Ultimo URL + /// public string lastUrl { get; set; } - - // Tolgo gestione strobes --> bitarray! -#if false - /// - /// 16 byte di strobe (4 word da 32 bit di flags...) - /// - public byte[] Strobes = new byte[16]; - /// - /// 16 byte di strobe - valori PREVIOUS (lettura precedente) - /// - public byte[] StrobesPrev = new byte[16]; - /// - /// Prima word di strobe da array flag completo - /// - public StFlag32 STRB_DW0 - { - get - { - return (StFlag32)BitConverter.ToUInt32(Strobes, 0); - } - } - /// - /// Prima word di strobe (valori PRECEDENTI) da array flag completo - /// - public StFlag32 STRB_00_PREV - { - get - { - return (StFlag32)BitConverter.ToUInt32(StrobesPrev, 0); - } - } -#endif + /// /// Array dei contatori x segnali blinking /// @@ -265,63 +236,6 @@ namespace IOB_WIN /// public void loadPersData() { -#if false - try - { - // nuova lettura valori da file persistenza... - contOreMaccOn = getStoredValDouble("ACC_TIME"); - contOreMaccLav = getStoredValDouble("ACC_TIME_WORK"); - contSlittaTast = getStoredValDouble("SlittaTastatore_Count"); - - for (int i = 0; i < currAdpConf.nUnOp; i++) - { - contGiriElettrom[i] = getStoredValUInt(string.Format("UnOp_{0:00}_AccTime", i + 1)); - currNumCambiUt[i] = getStoredValUInt(string.Format("UnOp_{0:00}_NumCU", i + 1)); - } - - for (int i = 0; i < currAdpConf.nAxis; i++) - { - contDistMovAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_DistDone", i + 1)); - contNumInvAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_InvDDone", i + 1)); - contAccTimeAssi[i] = getStoredValDouble(string.Format("Axis_{0:00}_AccTime", i + 1)); - } - - for (int i = 0; i < currAdpConf.nVacuumPump; i++) - { - currVacPumpWrkTime[i] = getStoredValUInt(string.Format("VacPump_{0:00}_WrkTime", i + 1)); - } - - for (int i = 0; i < currAdpConf.nVacuumAct; i++) - { - currVacActCount[i] = getStoredValUInt(string.Format("VacAct_{0:00}_Count", i + 1)); - } - - for (int i = 0; i < currAdpConf.nLubro; i++) - { - currLubroCount[i] = getStoredValUInt(string.Format("Lubro_{0:00}_Count", i + 1)); - } - - for (int i = 0; i < currAdpConf.nSlittaMag; i++) - { - currSlittaMag[i] = getStoredValUInt(string.Format("SlittaMagazzino_{0:00}_Count", i + 1)); - } - - for (int i = 0; i < mCounters.Length; i++) - { - currCounters[i] = getStoredValUInt(string.Format("Counter_{0:000}", i + 1)); - } - - for (int i = 0; i < currAdpConf.nProtMag; i++) - { - currProtMag[i] = getStoredValUInt(string.Format("ProtMagazzino_{0:00}_Count", i + 1)); - } - - } - catch (Exception exc) - { - lg.Error(string.Format("Eccezione in decodifica valori PersLayer: {0}{1}", Environment.NewLine, exc)); - } -#endif } /// @@ -337,169 +251,6 @@ namespace IOB_WIN TimingData.resetData(); // aggiungo altri defaults setDefaults(); -#if false - // inizializzo vettori di utility.. - loadAllarmi(); - loadSubMode(); - loadOtherFile(); - - // salvo porta! - mAdapter.Port = port; - adpPortNum = port; - // avvio! - mAdapter.Start(); - - // setto status a ON - mStatus.Value = "ON"; - - // resetto running flag... - adpCommAct = false; - - // avvio i sample vectors... - istOreMaccOn = new sampleVect(); - istOreMaccLav = new sampleVect(); - istSlittaTast = new sampleVect(); - - // carico valori da adapter x i conteggi - contOreMaccOn = currAdpConf.ContOreMaccOn; - contOreMaccLav = currAdpConf.ContOreMaccLav; - contSlittaTast = currAdpConf.ContSlittaTast; - contGiriElettrom = new uint[currAdpConf.nUnOp]; - istGiriElettrom = new sampleVect[currAdpConf.nUnOp]; - currNumCambiUt = new uint[currAdpConf.nUnOp]; - istNumCambiUt = new sampleVect[currAdpConf.nUnOp]; - for (int i = 0; i < currAdpConf.nUnOp; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.UnOp[i].dataRefList; - // punto all'item - DataRefItem riContRpm = listaDR.Find(x => x.Key == string.Format("UnOp_{0:00}_AccTime", i + 1)); - DataRefItem riContNumCU = listaDR.Find(x => x.Key == string.Format("UnOp_{0:00}_NumCU", i + 1)); - // recupero valore giri... - UInt32 contTotGiri = Convert.ToUInt32(riContRpm.Value); - // recupero valore num cambi ut... - UInt32 contNumCU = Convert.ToUInt32(riContNumCU.Value); - // salvo valore letto - contGiriElettrom[i] = contTotGiri; - currNumCambiUt[i] = contNumCU; - istGiriElettrom[i] = new sampleVect(); - istNumCambiUt[i] = new sampleVect(); - } - // imposto num assi e leggo valori salvati... - contDistMovAssi = new double[currAdpConf.nAxis]; - istDistMovAssi = new sampleVect[currAdpConf.nAxis]; - istLoadAssi = new sampleVect[currAdpConf.nAxis]; - contNumInvAssi = new uint[currAdpConf.nAxis]; - istAccTimeAssi = new sampleVect[currAdpConf.nAxis]; - contAccTimeAssi = new double[currAdpConf.nAxis]; - istNumInvAssi = new sampleVect[currAdpConf.nAxis]; - lastChekAccumTimeAxis = DateTime.Now; - for (int i = 0; i < currAdpConf.nAxis; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.Axis[i].dataRefList; - // punto all'item - DataRefItem riContDist = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_DistDone", i + 1)); - DataRefItem riNumInv = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_Invers", i + 1)); - DataRefItem riAccTime = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_AccTime", i + 1)); - // recupero valori... - contDistMovAssi[i] = Convert.ToUInt32(riContDist.Value); - contNumInvAssi[i] = Convert.ToUInt32(riNumInv.Value); - contAccTimeAssi[i] = Convert.ToDouble(riAccTime.Value); - vettAxis[i].mAxAlarmCNC.Normal(); - vettAxis[i].mAxAlarmPLC.Normal(); - istDistMovAssi[i] = new sampleVect(); - istLoadAssi[i] = new sampleVect(); - istAccTimeAssi[i] = new sampleVect(); - istNumInvAssi[i] = new sampleVect(); - } - currPathPartId = new string[currAdpConf.nPath]; - istPathPartId = new string[currAdpConf.nPath]; - currPathProgrName = new string[currAdpConf.nPath]; - istPathProgrName = new string[currAdpConf.nPath]; - currPathPartCount = new uint[currAdpConf.nPath]; - istPathPartCount = new sampleVect[currAdpConf.nPath]; - for (int i = 0; i < currAdpConf.nPath; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.Path[i].dataRefList; - // punto all'item - DataRefItem riPathProgr = listaDR.Find(x => x.Key == string.Format("Path_{0:00}_PartId", i + 1)); - DataRefItem riPathPzTot = listaDR.Find(x => x.Key == string.Format("Path_{0:00}_PZ_TOT", i + 1)); - // recupero valori... - currPathPartId[i] = riPathProgr.Value; - currPathPartCount[i] = Convert.ToUInt32(riPathPzTot.Value); - currPathProgrName[i] = ""; - vettPath[i].mPathAlarmCNC.Normal(); - vettPath[i].mPathAlarmPLC.Normal(); - istPathPartCount[i] = new sampleVect(); - } - currVacPumpWrkTime = new uint[currAdpConf.nVacuumPump]; - istVacPumpWrkTime = new sampleVect[currAdpConf.nVacuumPump]; - for (int i = 0; i < currAdpConf.nVacuumPump; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.VacuumPump[i].dataRefList; - // punto all'item - DataRefItem riVacPumpWrk = listaDR.Find(x => x.Key == string.Format("VacPump_{0:00}_WrkTime", i + 1)); - // recupero valori... - currVacPumpWrkTime[i] = Convert.ToUInt32(riVacPumpWrk.Value); - istVacPumpWrkTime[i] = new sampleVect(); - } - currVacActCount = new uint[currAdpConf.nVacuumAct]; - istVacActCount = new sampleVect[currAdpConf.nVacuumAct]; - for (int i = 0; i < currAdpConf.nVacuumAct; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.VacuumAct[i].dataRefList; - // punto all'item - DataRefItem riVacActCount = listaDR.Find(x => x.Key == string.Format("VacAct_{0:00}_Count", i + 1)); - // recupero valori... - currVacActCount[i] = Convert.ToUInt32(riVacActCount.Value); - istVacActCount[i] = new sampleVect(); - } - currLubroCount = new uint[currAdpConf.nLubro]; - istLubroCount = new sampleVect[currAdpConf.nLubro]; - for (int i = 0; i < currAdpConf.nLubro; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.Lubro[i].dataRefList; - // punto all'item - DataRefItem riLubro = listaDR.Find(x => x.Key == string.Format("Lubro_{0:00}_Count", i + 1)); - // recupero valori... - currLubroCount[i] = Convert.ToUInt32(riLubro.Value); - istLubroCount[i] = new sampleVect(); - } - currSlittaMag = new uint[currAdpConf.nSlittaMag]; - istSlittaMag = new sampleVect[currAdpConf.nSlittaMag]; - for (int i = 0; i < currAdpConf.nSlittaMag; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.SlittaMag[i].dataRefList; - // punto all'item - DataRefItem riSlittaMag = listaDR.Find(x => x.Key == string.Format("SlittaMagazzino_{0:00}_Count", i + 1)); - // recupero valori... - currSlittaMag[i] = Convert.ToUInt32(riSlittaMag.Value); - istSlittaMag[i] = new sampleVect(); - } - currProtMag = new uint[currAdpConf.nProtMag]; - istProtMag = new sampleVect[currAdpConf.nProtMag]; - for (int i = 0; i < currAdpConf.nProtMag; i++) - { - // leggo tutti i dati... - List> listaDR = currAdpConf.ProtMag[i].dataRefList; - // punto all'item - DataRefItem riProtMag = listaDR.Find(x => x.Key == string.Format("ProtMagazzino_{0:00}_Count", i + 1)); - // recupero valori... - currProtMag[i] = Convert.ToUInt32(riProtMag.Value); - istProtMag[i] = new sampleVect(); - } - - //mAlarmSystem.Normal(); - mAlarmCNC.Normal(); - mAlarmPLC.Normal(); -#endif - //mAlarmGeneral.Normal(); adpTryRestart = true; parentForm.displayTaskAndWait("Adapter Started!"); } @@ -525,30 +276,11 @@ namespace IOB_WIN // chiudo la connessione all'adapter... tryDisconnect(); -#if false - // Stop everything... - try - { - mAdapter.Stop(); - } - catch (Exception exc) - { - lg.Error(exc, "Eccezione in chiusura Adapter"); - } -#endif dtStopAdp = DateTime.Now; -#if false - adpPortNum = mAdapter.Port; -#endif adpTryRestart = tryRestart; adpRunning = false; // chiudo! parentForm.resetProgBar(); -#if false - parentForm.dataMonitor_1 = "... not connected, waiting for data ..."; - parentForm.dataMonitor_2 = ""; - parentForm.dataMonitor_3 = ""; -#endif parentForm.displayTaskAndWait("Adapter Stopped."); parentForm.commPlcActive = false; } @@ -681,59 +413,9 @@ namespace IOB_WIN /// public void checkSavePersDataLayer() { -#if false - // aggiungo dettaglio valori ultimi codici MST - StringBuilder sb = new StringBuilder(); - string codM = ""; - string codS = ""; - string codT = ""; - for (int i = 0; i < currAdpConf.nPath; i++) - { - codM = vettPath[i].mPathCodM.Value.ToString().Replace("UNAVAILABLE", "n.d."); - codS = vettPath[i].mPathCodS.Value.ToString().Replace("UNAVAILABLE", "n.d."); - codT = vettPath[i].mPathCodT.Value.ToString().Replace("UNAVAILABLE", "n.d."); - // accodo ultimi codici in visualizzazione... - sb.AppendLine(string.Format("P{0} last MST: {1} | {2} | {3}", i + 1, codM, codS, codT)); - } - parentForm.dataMonitor_1 += sb.ToString(); - - if (persistenceLayer != null) - { - bool needSave = false; - // verifica se si debba aggiornare XML (e salva in adapter dati vari) - needSave = procOreMaccOn(needSave); - needSave = procOreMaccLav(needSave); - needSave = procProgrName(needSave); - needSave = procPartId(needSave); - needSave = procPzProd(needSave); - needSave = procGiriTotUnOp(needSave); - needSave = procNumCU(needSave); - needSave = procCounters(needSave); - needSave = procMovTotAssi(needSave); - needSave = procAccTimeAssi(needSave); - needSave = procNumInvAssi(needSave); - needSave = procVacPump(needSave); - needSave = procVacAct(needSave); - needSave = procLubro(needSave); - needSave = procSlittaMag(needSave); - needSave = procProtMag(needSave); - - // salvo se necessario! - if (needSave) parentForm.persistData(); - // ------------------------------------------- - } -#endif } public void resetDebugConsole() { -#if false - // resetto console debug... - parentForm.dataMonitor_1 = ""; - parentForm.dataMonitor_2 = ""; - parentForm.dataMonitor_3 = ""; - // indico msg allarme NON inviati - alarmMsgDispl = false; -#endif } /// @@ -955,19 +637,6 @@ namespace IOB_WIN /// public virtual void forceAlarmCheck() { -#if false - // carico status allarmi (completo) - StFlag32 forceAlarm = (StFlag32)unchecked((int)UInt32.MaxValue); - try - { - refreshAlarmState(forceAlarm, false); - } - catch - { - lg.Error("Errore in fase di esecuzione di forceAlarmCheck"); - } - if (utils.CRB("recTime")) logTimeResults(); -#endif } diff --git a/IOB-WIN/IOB-WIN/IobSiemens.cs b/IOB-WIN/IOB-WIN/IobSiemens.cs deleted file mode 100644 index 47547b8..0000000 --- a/IOB-WIN/IOB-WIN/IobSiemens.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using IOB_UT; - -namespace IOB_WIN -{ - public class IobSiemens : IobGeneric - { - /// - /// estende l'init della classe base... - /// - /// - /// - public IobSiemens(MainForm caller, IobConfiguration IOBConf) : base(caller, IOBConf) - { -#if false - // è little endian (NON serve conversione) - hasBigEndian = false; - - lg.Info("Start init Adapter FANUC all'IP {0}", utils.CRS("ipPLC")); - - parentForm.commPlcActive = true; - Runtime.CreateNC(CNC.NcType.FANUC, utils.CRS("ipPLC")); - parentForm.commPlcActive = false; - // inizializzo posizioni assi... - prevPosAxis = new double[adpConf.nAxis]; - prevDirAxis = new int[adpConf.nAxis]; - - FANUC_ref = (FANUC)Runtime.NC; - if (utils.CRB("verbose")) lg.Info("FANUC_ref da CMSCncLib"); - - // disconnetto e connetto... - if (utils.CRB("verbose")) lg.Info("FANUC: tryDisconnect"); - tryDisconnect(); - lg.Info("FANUC: tryConnect"); - tryConnect(); - lg.Info("End init Adapter FANUC"); -#endif - } - } -} diff --git a/IOB-WIN/IOB-WIN/MainForm.cs b/IOB-WIN/IOB-WIN/MainForm.cs index 0dfd4e5..bbede4c 100644 --- a/IOB-WIN/IOB-WIN/MainForm.cs +++ b/IOB-WIN/IOB-WIN/MainForm.cs @@ -380,21 +380,6 @@ namespace IOB_WIN iobObj.gaterAndSend(gatherCycle.MF); } } - private void checkFastTask() - { - // decremento... - fastCount--; - // se il counter è a zero eseguo... - if (fastCount <= 0) - { - fastCount = utils.CRI("fastCount"); - - // avvio fase raccolta dati e invio con adapter - iobObj.gaterAndSend(gatherCycle.HF); - - refreshFormData(); - } - } private void refreshFormData() { // aggiorno visualizzazioni varie in form... @@ -409,20 +394,8 @@ namespace IOB_WIN advProgBar(); if (iobObj.connectionOk) { -#if false - // check esecuzione FastTask - checkFastTask(); -#endif // check esecuzione NormTask checkNormTask(); -#if false - // check esecuzione SlowTask - checkSlowTask(); - // check esecuzione AlarmSync - checkAlarmSync(); - // check esecuzione SendTask (VHF) - checkSendTask(); -#endif if (utils.CRI("waitEndCycle") > 0) { Thread.Sleep(utils.CRI("waitEndCycle")); diff --git a/IOB-WIN/IOB-WIN/Readme/ToDo.txt b/IOB-WIN/IOB-WIN/Readme/ToDo.txt index 8712559..efe3d82 100644 --- a/IOB-WIN/IOB-WIN/Readme/ToDo.txt +++ b/IOB-WIN/IOB-WIN/Readme/ToDo.txt @@ -10,7 +10,7 @@ OK - ENABLED .. - fare gestione come rPI-IOB, ovvero OK - gestione QUEUE eventi OK - salvataggio su file dello storico eventi rilevati - - gestione dei segnali ballerini (BITMASK!) +OK - gestione dei segnali ballerini (BITMASK!) - fare integrazione ALTRI varori FANUC, tra cui - allarmi - load/speed