diff --git a/MTC_Adapter/MTC_Adapter/AdapterESA.cs b/MTC_Adapter/MTC_Adapter/AdapterESA.cs
index f9f38ea..148dd6d 100644
--- a/MTC_Adapter/MTC_Adapter/AdapterESA.cs
+++ b/MTC_Adapter/MTC_Adapter/AdapterESA.cs
@@ -9,1115 +9,1121 @@ using System.Threading;
namespace MTC_Adapter
{
- public class AdapterESA : AdapterGeneric
+ public class AdapterESA : AdapterGeneric
+ {
+ ///
+ /// Configurazione valori da leggere IOT_Byte
+ ///
+ public otherData[] mapIOT_Byte;
+ ///
+ /// Configurazione valori da leggere IOT_Word
+ ///
+ public otherData[] mapIOT_Word;
+ ///
+ /// Configurazione valori da leggere IOT_DWord
+ ///
+ public otherData[] mapIOT_DWord;
+ ///
+ /// Configurazione valori da leggere IOT_String
+ ///
+ public otherData[] mapIOT_String;
+
+ ///
+ /// Oggetto elenco allarmi SOLO CNC (OCCHIO codice numerico = INDICE!!!)
+ ///
+ public allarme[] elencoAllarmiCNC;
+
+ ///
+ /// dimensione buffer BYTE (da file map)
+ ///
+ public int numByte = 0;
+ ///
+ /// dimensione buffer WORD (da file map)
+ ///
+ public int numWord = 0;
+ ///
+ /// dimensione buffer DWORD (da file map)
+ ///
+ public int numDWord = 0;
+ ///
+ /// Dimensione buffer string (FISSO!!!)
+ ///
+ public int numString = 255;
+
+ ///
+ /// Carico file conf dati IOT
+ ///
+ protected override void loadOtherFile()
{
- ///
- /// Configurazione valori da leggere IOT_Byte
- ///
- public otherData[] mapIOT_Byte;
- ///
- /// Configurazione valori da leggere IOT_Word
- ///
- public otherData[] mapIOT_Word;
- ///
- /// Configurazione valori da leggere IOT_DWord
- ///
- public otherData[] mapIOT_DWord;
- ///
- /// Configurazione valori da leggere IOT_String
- ///
- public otherData[] mapIOT_String;
-
- ///
- /// Oggetto elenco allarmi SOLO CNC (OCCHIO codice numerico = INDICE!!!)
- ///
- public allarme[] elencoAllarmiCNC;
-
- ///
- /// dimensione buffer BYTE (da file map)
- ///
- public int numByte = 0;
- ///
- /// dimensione buffer WORD (da file map)
- ///
- public int numWord = 0;
- ///
- /// dimensione buffer DWORD (da file map)
- ///
- public int numDWord = 0;
- ///
- /// Dimensione buffer string (FISSO!!!)
- ///
- public int numString = 255;
-
- ///
- /// Carico file conf dati IOT
- ///
- protected override void loadOtherFile()
- {
- base.loadOtherFile();
- loadByteListMap();
- loadWordListMap();
- loadDWordListMap();
- loadStringListMap();
- loadAllarmiCNC();
- }
- ///
- /// Carico conf vettore dati STRING
- ///
- private void loadStringListMap()
- {
- loadConfFile(ref mapIOT_String, filePath("IOTStringFilePath"), 1, ref numString);
- // riporto numString a 255!
- numString = 255;
- }
- ///
- /// Carico conf vettore dati DWORD
- ///
- private void loadDWordListMap()
- {
- loadConfFile(ref mapIOT_DWord, filePath("IOTDWordFilePath"), 1, ref numDWord);
- }
- ///
- /// Carico conf vettore dati WORD
- ///
- private void loadWordListMap()
- {
- loadConfFile(ref mapIOT_Word, filePath("IOTWordFilePath"), 1, ref numWord);
- }
- ///
- /// Carico conf vettore dati BYTE
- ///
- private void loadByteListMap()
- {
- loadConfFile(ref mapIOT_Byte, filePath("IOTByteFilePath"), 1, ref numByte);
- }
- ///
- /// caricamento allarmi da file (CON RIEMPIMENTO MANCANTI!!!!)
- ///
- protected void loadAllarmiCNC()
- {
- if (utils.CRB("verbose")) lg.Info("Inizio caricamento vettore allarmi");
- int totRighe = 0;
- string fileName = string.Format(@"{0}\{1}", utils.confDir, utils.CRS("AlarmListCNC"));
- string linea;
- try
- {
- string lastLine = File.ReadLines(fileName).Last();
- totRighe = startNumb(lastLine, utils.CRC("testCharSep"));
- }
- catch
- {
- totRighe = File.ReadLines(fileName).Count();
- }
- // creo un vettore della dimensione corretta... PRENDO IL MASSIMO dei valori...
- elencoAllarmiCNC = new allarme[totRighe];
- // ora creo un vettore di allarmi VUOTI...
- for (int i = 1; i <= totRighe; i++)
- {
- elencoAllarmiCNC[i - 1] = new allarme(i.ToString(), "CNC", "WARNING", string.Format("[{0}] MISSING", i));
- }
- // carica da file...
- System.IO.StreamReader file = new System.IO.StreamReader(fileName);
- // leggo 1 linea alla volta...
- int numRiga = 0;
- while ((linea = file.ReadLine()) != null)
- {
- // SE non è un commento...
- if (linea.Substring(0, 1) != "#")
- {
- // recupero numRiga da prima parte linea...
- numRiga = startNumb(linea, utils.CRC("testCharSep"));
- elencoAllarmiCNC[numRiga - 1] = decodeAlarmLine(linea, utils.CRC("testCharSep"));
- }
- }
- // chiudo file
- file.Close();
- if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore allarmi CNC: {0} allarmi caricati!", numRiga));
- }
- ///
- /// Restituisce path completo file da chaive configurazione
- ///
- /// chaive conf x file richiesto
- ///
- protected string filePath(string keyFile)
- {
- return string.Format(@"{0}\{1}", utils.confDir, utils.CRS(keyFile));
- }
- ///
- /// Legge il file di conf di una MAP di informazioni da gestire con lettura set memoria
- ///
- /// nome vettore memoria
- /// file origine
- /// dimensione (in byte) della memoria
- /// dimensione (in byte) della memoria
- protected void loadConfFile(ref otherData[] vettoreConf, string nomeFile, int memSize, ref int numVett)
- {
- otherData lastData = new otherData();
- int totRighe = 0;
- string linea;
- totRighe = File.ReadLines(nomeFile).Count();
- // creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
- vettoreConf = new otherData[File.ReadLines(nomeFile).Count()];
- // carica da file...
- StreamReader file = new StreamReader(nomeFile);
- // leggo 1 linea alla volta...
- int numRiga = 0;
- int bitNum = 0;
- int byteNum = 0;
- while ((linea = file.ReadLine()) != null)
- {
- // SE non è un commento...
- if (linea.Substring(0, 1) != "#")
- {
- // se finisce per BIT allora processo bit-a-bit...
- if (linea.EndsWith("BOOL"))
- {
- try
- {
- string[] memIdx = linea.Split(utils.CRC("testCharSep"))[0].Split('.');
- // calcolo bit e byte number...
- int.TryParse(memIdx[0], out byteNum);
- if (memIdx.Length > 1)
- {
- int.TryParse(memIdx[1], out bitNum);
- }
- else
- {
- bitNum = 0;
- }
- }
- catch
- {
- byteNum = 0;
- bitNum = 0;
- }
- lastData = decodeBitData(linea, utils.CRC("testCharSep"), byteNum, 1, bitNum);
- vettoreConf[numRiga] = lastData;
- }
- else
- {
- lastData = decodeOtherData(linea, utils.CRC("testCharSep"), "", 1, memSize);
- vettoreConf[numRiga] = lastData;
- }
- numRiga++;
- }
- }
- // salvo lunghezza file...
- try
- {
- numVett = Convert.ToInt32(lastData.memAddr) + 1;
- }
- catch
- {
- numVett = numRiga + 1;
- }
- // chiudo file
- file.Close();
- // ora trimmo vettore al solo numero VERO dei valori caricati...
- Array.Resize(ref vettoreConf, numRiga);
-
- if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili per file {1}", numRiga, nomeFile));
- }
-
- ///
- /// oggetto onnessione ESA
- ///
- protected thdNcEsaGvKvara ncDevice;
- ///
- /// thread del processo comunicazione esa
- ///
- protected Thread thdDevice;
-
- ///
- /// estende l'init della classe base...
- ///
- ///
- ///
- public AdapterESA(MainForm caller, AdapterConf adpConf) : base(caller, adpConf)
- {
- string iniPath = string.Format(@"{0}\{1}", utils.confDir, utils.CRS("defaultEsaFile"));
-
- lg.Info("Start init Adapter ESA dal file {0}", iniPath);
-
- IniFiles.IniFile EsaIni = new IniFiles.IniFile(iniPath);
-
- if (utils.CRB("verbose")) lg.Info("step 01: impostato INI File {0}", iniPath);
-
- loadOtherFile();
-
- parentForm.commPlcActive = true;
- //ncDevice = new thdNcEsaGvKvara(EsaIni, mapIOT_Byte.Length, mapIOT_Word.Length, mapIOT_DWord.Length, 255); // impostato a 255 byte (char) FISSO x la parte stringa... mapIOT_String.Length);
- ncDevice = new thdNcEsaGvKvara(EsaIni, numByte, numWord, numDWord, numString); // impostato a 255 byte (char) FISSO x la parte stringa... mapIOT_String.Length);
- parentForm.commPlcActive = false;
-
- if (utils.CRB("verbose")) lg.Info("step 02: avviato thdNcEsaGvKvara da INI File {0}", iniPath);
-
- // inizializzo posizioni assi...
- prevPosAxis = new double[adpConf.nAxis];
- prevDirAxis = new int[adpConf.nAxis];
-
- // verifica avvio...
- lg.Info("ESA: tryConnect");
- tryConnect();
- lg.Info("End init Adapter ESA");
- }
-
- public override void tryDisconnect()
- {
- base.tryDisconnect();
- // disconnetto
- ncDevice.Disconnect();
- connectionOk = false;
- }
-
- public override void tryConnect()
- {
- base.tryConnect();
-
- // se non già connesso provo a connettermi...
- if (!ncDevice.Connected)
- {
- // provo a collegarmi
- if (!ncDevice.Connect())
- {
- //altrimenti disconnette...
- ncDevice.Disconnect();
- connectionOk = false;
- }
- else
- {
- connectionOk = true;
- }
- }
- }
-
- ///
- /// Verifico connessione ESA...
- ///
- ///
- public override bool connectionOk
- {
- get
- {
- return ncDevice.Connected;
- }
- }
-
- ///
- /// Carica ed acquisisce dati del buffer Byte (8 bit) di memoria
- ///
- protected void getIotMem_Byte()
- {
- // HARD CODE: forzo path 1 (indice 0...)
- int idxPath = 0;
- // accodo dati path in DataMonitor......
- StringBuilder sb = new StringBuilder();
-
- if (connectionOk)
- {
- // leggo TUTTO il blocco di memoria
- parentForm.commPlcActive = true;
- inizio = DateTime.Now;
- ncDevice.ReadBufferByte();
- if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-Byte", ncDevice.PLC_MemoryAreaIOT_Byte.Length), DateTime.Now.Subtract(inizio).Ticks);
- parentForm.commPlcActive = false;
- }
- else
- {
- lg.Error("Errore connessione mancante in getIotMem_Byte");
- }
- // Processing area BYTE
- int numero = 0;
- string status = "";
- string pathExeMode = "";
- string pathRunMode = "";
- string ProgAreaRun = "";
- int ProgAreaRunCode = 0;
- bool isFeedHold = false;
- bool isActive = false;
- bool isReady = false;
- int bitNum = 0;
- int byteNum = 0;
- byte currByte;
- for (int i = 0; i < mapIOT_Byte.Length; i++)
- {
- // vado a gestire le variabili BYTE
- if (mapIOT_Byte[i].dataType == "BYTE")
- {
- int.TryParse(mapIOT_Byte[i].memAddr, out byteNum);
- if (mapIOT_Byte[i].varName == "IOT_OVRF")
- {
- FeedRateOver = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
- }
- else if (mapIOT_Byte[i].varName == "IOT_OVRS")
- {
- SpeedRateOver = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
- }
- else if (mapIOT_Byte[i].varName == "IOT_MODECN")
- {
- // Modo CN:0=Nessuno,1=Manuale,2=Automatico, 3=Pom,4=Mdi,5=SemiAutomatico,6=Rap,7=Test
- int modoCn = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
- switch (modoCn)
- {
- case 1:
- pathRunMode = "MANUAL";
- break;
- case 2:
- pathRunMode = "AUTOMATIC";
- break;
- case 3:
- pathRunMode = "POM";
- break;
- case 4:
- pathRunMode = "MANUAL_DATA_INPUT";
- break;
- case 5:
- pathRunMode = "SEMI_AUTOMATIC"; //"SEMIAUTO";
- break;
- case 6:
- pathRunMode = "RAP"; //"MANUAL";
- break;
- case 7:
- pathRunMode = "TES"; //"MANUAL";
- break;
- case 0:
- default:
- pathRunMode = "NA";
- break;
- }
- // salvo run mode
- vettPath[idxPath].mPathRunMode.Value = pathRunMode;
- }
- else if (mapIOT_Byte[i].varName.StartsWith("IOT_LUB_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_LUB_", "").Replace("_STA", "").Replace("_CNT", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettLubro.Length)
- {
- if (mapIOT_Byte[i].varName.EndsWith("_STA"))
- {
- if (ncDevice.PLC_MemoryAreaIOT_Byte[byteNum] != 0)
- {
- status = "EMPTY";
- }
- else
- {
- status = "OK";
- }
- vettLubro[numero - 1].mLubroStatus.Value = status;
- }
- else if (mapIOT_Byte[i].varName.EndsWith("_CNT"))
- {
- vettLubro[numero - 1].mLubroNum.Value = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
- }
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Byte[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
- }
- }
- else if (mapIOT_Byte[i].varName.StartsWith("IOT_I_MD_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_I_MD_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettUnOp.Length)
- {
- vettUnOp[numero - 1].mUnOpLoad.Value = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Byte[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
- }
- }
- }
- // gestisco le variabili BIT/BOOL
- else if (mapIOT_Byte[i].dataType == "BOOL")
- {
- string[] memIdx = mapIOT_Byte[i].memAddr.Split('.');
- // calcolo bit e byte number...
- int.TryParse(memIdx[0], out byteNum);
- if (memIdx.Length > 1)
- {
- int.TryParse(memIdx[1], out bitNum);
- }
- // leggo byte...
- currByte = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
- if (mapIOT_Byte[i].varName == "IOT_MACHON")
- {
- if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
- {
- mPower.Value = "ON";
- }
- else
- {
- mPower.Value = "OFF";
- }
- }
- else if (mapIOT_Byte[i].varName == "IOT_READY")
- {
- isReady = ((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum));
- }
- else if (mapIOT_Byte[i].varName == "IOT_EXEC")
- {
- isActive = ((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum));
- }
- else if (mapIOT_Byte[i].varName == "IOT_HOLD")
- {
- isFeedHold = ((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum));
- }
- else if (mapIOT_Byte[i].varName == "IOT_EMG")
- {
- if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
- {
- mEStop.Value = "TRIGGERED";
- }
- else
- {
- mEStop.Value = "ARMED";
- }
- }
- else if (mapIOT_Byte[i].varName == "IOT_ALRM")
- {
- if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
- {
- // inutile, leggo sempre TUTTI gli allarmi...
- }
- }
- else if (mapIOT_Byte[i].varName.StartsWith("IOT_EXEC_A_"))
- {
- ProgAreaRun = "OFF";
- ProgAreaRunCode = 0;
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_EXEC_A_", ""));
- // salvo SOLO SE ha bit = 1..
- if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
- {
- ProgAreaRun = "ON";
- ProgAreaRunCode = 1;
- }
- vettMemArea[numero - 1].mMemAreaRunning.Code = ProgAreaRunCode.ToString();
- vettMemArea[numero - 1].mMemAreaRunning.Value = ProgAreaRun;
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
- }
- }
- else if (mapIOT_Byte[i].varName.StartsWith("IOT_VAC_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_VAC_", ""));
- // controllo SE ha bit = 1 è ON..
- string VacStat = "";
- if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
- {
- VacStat = "ON";
- }
- else
- {
- VacStat = "OFF";
- }
- // salvo in vettore SE possibile...
- if (numero <= vettVacPump.Length)
- {
- vettVacPump[numero - 1].mVacPumpStatus.Value = VacStat;
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Byte[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
- }
- }
- }
- }
-
- // imposto exe mode alla fine secondo gerarchia stati...
- if (isFeedHold)
- {
- pathExeMode = "FEED_HOLD"; //"FEEDHOLD";
- }
- else if (isActive)
- {
- pathExeMode = "ACTIVE";
- }
- else if (isReady)
- {
- pathExeMode = "READY";
- }
- vettPath[idxPath].mPathExeMode.Value = pathExeMode;
-
- // sistemo le stringhe x display
- sb.AppendLine(string.Format("RunMode: {0}", pathRunMode));
- sb.AppendLine(string.Format("ExeMode: {0}", pathExeMode));
- sb.AppendLine(string.Format("FeedRateOver: {0} %", FeedRateOver));
- sb.AppendLine(string.Format("SpeedRateOver: {0} %", SpeedRateOver));
-
- // update form!
- parentForm.dataMonitor_1 += sb.ToString();
- }
- ///
- /// Carica ed acquisisce dati del buffer WORD (16 bit) di memoria
- ///
- protected void getIotMem_Word()
- {
- if (connectionOk)
- {
- // leggo TUTTO il blocco di memoria
- parentForm.commPlcActive = true;
- inizio = DateTime.Now;
- ncDevice.ReadBufferWord();
- if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-Word", ncDevice.PLC_MemoryAreaIOT_Word.Length), DateTime.Now.Subtract(inizio).Ticks);
- parentForm.commPlcActive = false;
- }
- else
- {
- lg.Error("Errore connessione mancante in getIotMem_Word");
- }
-
- StringBuilder sb = new StringBuilder();
- int numAlarmCNC = 0;
- int numero = 0;
- int byteNum = 0;
- // Processing area WORD
- for (int i = 0; i < mapIOT_Word.Length; i++)
- {
- int.TryParse(mapIOT_Word[i].memAddr, out byteNum);
-
- if (mapIOT_Word[i].varName == "IOT_CN_MSG")
- {
- // leggo codice allarme...
- numAlarmCNC = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- // controllo, SE è 0 --> normal/niente, altrimenti è l'allarme indicato!!!
- if (numAlarmCNC == 0)
- {
- mAlarmCNC.Normal();
- }
- else
- {
- allarme currAllarm = elencoAllarmiCNC[numAlarmCNC - 1];
- Condition.Level livello = Condition.Level.NORMAL;
- switch (currAllarm.livello)
- {
- case "WARNING":
- livello = Condition.Level.WARNING;
- break;
- case "FAULT":
- default:
- livello = Condition.Level.FAULT;
- break;
- }
- mAlarmCNC.Add(livello, currAllarm.descrizione, currAllarm.codNum, "", "");
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_S_MD_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_S_MD_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettUnOp.Length)
- {
- vettUnOp[numero - 1].mUnOpSpeed.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_T_MD_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_T_MD_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettUnOp.Length)
- {
- vettUnOp[numero - 1].mUnOpToolId.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_C_TC_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_TC_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettUnOp.Length)
- {
- vettUnOp[numero - 1].mUnOpNumCU.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_C_H_MD_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_H_MD_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettUnOp.Length)
- {
- vettUnOp[numero - 1].mUnOpAccTime.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_C_H_VAC_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_H_VAC_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettVacPump.Length)
- {
- vettVacPump[numero - 1].mVacPumpWrkTime.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_PGMR_A_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_PGMR_A_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettMemArea.Length)
- {
- vettMemArea[numero - 1].mMemAreaProgNumRep.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- else if (mapIOT_Word[i].varName.StartsWith("IOT_C_EXEC_A_"))
- {
- try
- {
- numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_EXEC_A_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettMemArea.Length)
- {
- vettMemArea[numero - 1].mMemAreaProgNumExe.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
- }
- }
- }
- // verifico se nei mandini ho un tool e quanti cambi...
- for (int i = 0; i < vettUnOp.Length; i++)
- {
- if (vettUnOp[i].mUnOpToolId.Value.ToString() != "") sb.AppendLine(string.Format("UnOp_{0}: ToolId: {1} | NumCU: {2}", i+1, vettUnOp[i].mUnOpToolId.Value, vettUnOp[i].mUnOpNumCU.Value));
- }
- // update form!
- parentForm.dataMonitor_2 += sb.ToString();
- }
- ///
- /// Carica ed acquisisce dati del buffer DWORD (32 bit) di memoria
- ///
- protected void getIotMem_DWord()
- {
- // accodo dati path in DataMonitor......
- StringBuilder sb = new StringBuilder();
- if (connectionOk)
- {
- // leggo TUTTO il blocco di memoria
- parentForm.commPlcActive = true;
- inizio = DateTime.Now;
- ncDevice.ReadBufferDWord();
- if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-DWord", ncDevice.PLC_MemoryAreaIOT_DWord.Length), DateTime.Now.Subtract(inizio).Ticks);
- parentForm.commPlcActive = false;
- }
- else
- {
- lg.Error("Errore connessione mancante in getIotMem_DWord");
- }
-
- int numero = 0;
- int byteNum = 0;
- double valDouble = 0;
- // Processing area WORD
- for (int i = 0; i < mapIOT_DWord.Length; i++)
- {
- int.TryParse(mapIOT_DWord[i].memAddr, out byteNum);
- if (mapIOT_DWord[i].varName == "IOT_FEED")
- {
- FeedRate = BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0);
- }
- else if (mapIOT_DWord[i].varName.StartsWith("IOT_FEED_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_FEED_", ""));
- // salvo in vettore SE possibile...
- if (numero <= FeedRateGrp.Length)
- {
- FeedRateGrp[numero - 1] = BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0);
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
- }
- }
- else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KU_AX_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_C_KU_AX_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettAxis.Length)
- {
- vettAxis[numero - 1].mAxDistDone.Value = ncDevice.PLC_MemoryAreaIOT_DWord[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
- }
- }
- else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KINV_AX_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_C_KINV_AX_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettAxis.Length)
- {
- vettAxis[numero - 1].mAxInvDDone.Value = ncDevice.PLC_MemoryAreaIOT_DWord[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
- }
- }
- else if (mapIOT_DWord[i].varName.StartsWith("IOT_POS_AX_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_POS_AX_", ""));
- // recupero valore pos assi (in micron)
- valDouble = (double)BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0);
- // salvo in vettore SE possibile...
- if (numero <= vettAxis.Length)
- {
- // riporto il dato in mm (divido x 1000)
- vettAxis[numero - 1].mAxPosAct.Value = valDouble / utils.CRI("fattdecimale");
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
- }
- }
- else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KREV_MD_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_C_KREV_MD_", ""));
- // salvo in vettore SE possibile...
- if (numero <= vettUnOp.Length)
- {
- vettUnOp[numero - 1].mUnOpKRev.Value = ncDevice.PLC_MemoryAreaIOT_DWord[byteNum];
- }
- else
- {
- lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
- }
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
- }
- }
- else if (mapIOT_DWord[i].varName.StartsWith("IOT_PLC_MSG_"))
- {
- // recupero NUMERO
- try
- {
- numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_PLC_MSG_", ""));
- // copio allarmi in vettore generale AlarmFlags (dove lo gestisce) 4 byte alla volta
- Buffer.BlockCopy(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0, AlarmFlags, numero * 4, 4);
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
- }
- }
- }
- // aggiungo feedrate
- sb.AppendLine(string.Format("FeedRate: {0} mm/min", FeedRate));
- // verifico se nei gruppi di feed ho qualcosa di diverso da zero...
- for (int i = 0; i < 20; i++)
- {
- if (FeedRateGrp[i] != 0) sb.AppendLine(string.Format("FeedRate_{1}: {0:00} mm/min", FeedRateGrp[i], i));
- }
- // update form!
- parentForm.dataMonitor_1 += sb.ToString();
- }
- ///
- /// Carica ed acquisisce dati del buffer STRING di memoria
- ///
- protected void getIotMem_String()
- {
- // accodo dati path in DataMonitor......
- StringBuilder sb = new StringBuilder();
- if (connectionOk)
- {
- // leggo TUTTO il blocco di memoria
- parentForm.commPlcActive = true;
- inizio = DateTime.Now;
- ncDevice.ReadBufferString();
- if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-DWord", ncDevice.PLC_MemoryAreaIOT_DWord.Length), DateTime.Now.Subtract(inizio).Ticks);
- parentForm.commPlcActive = false;
- }
- else
- {
- lg.Error("Errore connessione mancante in getIotMem_DWord");
- }
-
- // Processing area STRING: OGNI area di memoria...
- for (int j = 0; j < mapIOT_String.Length; j++)
- {
- string valString = "";
-
- for (int i = 0; i < numString; i++)
- {
- try
- {
- valString += Convert.ToChar(ncDevice.PLC_MemoryAreaIOT_String[j, i]).ToString().Replace("\0", " ");
- }
- catch (Exception exc)
- {
- lg.Error(exc, "Errore in decodifica " + mapIOT_String[i].varName);
- }
- }
- // trimmo!
- valString = valString.Trim();
- // salvo
- vettMemArea[j].mMemAreaProgName.Code = j.ToString();
- vettMemArea[j].mMemAreaProgName.Value = valString;
- // aggiungo nomi programmi...
- sb.AppendLine(string.Format("{0}: {1}", mapIOT_String[j].varName, valString));
- }
- // update form!
- parentForm.dataMonitor_2 += sb.ToString();
- }
- public override void getGlobalData()
- {
- base.getGlobalData();
- }
-
- ///
- /// Processing di TUTTA l'area di memoria configurata e delle variabili derivate...
- ///
- public override void processAllMemory()
- {
- // inizializzo data monitor su FORM
- parentForm.dataMonitor_1 = "";
- parentForm.dataMonitor_2 = "";
- parentForm.dataMonitor_3 = "";
-
- // recupero le varie memorie (prima string che mi serve x area selezionata --> programma selezionato)
- getIotMem_String();
- getIotMem_Byte();
- getIotMem_Word();
- getIotMem_DWord();
-
- // processo componenti specifici x info...
- getUnOp();
- getPath();
- getAxis();
- }
-
- ///
- /// Recupera la speed override x i mandrini (UnOp)
- ///
- public override void getUnOp()
- {
- // cicl su UnOp
- for (int i = 0; i < currAdpConf.nUnOp; i++)
- {
- vettUnOp[i].mUnOpSpeedOverr.Value = SpeedRateOver;
- }
- }
-
- ///
- /// Carica info accessorie assi (direzione, feed, ...)
- ///
- public override void getAxis()
- {
- // mostro assi in DataMonitor......
- StringBuilder sb = new StringBuilder();
-
- // nuova posizione (per calcoli)
- double newPos = 0;
- double distPerc = 0;
- int newDir = 0;
- string tipoAsse = "";
- string direzione = "";
-
- // leggo in modo "cablato" i dati dei vari assi...
- for (int i = 0; i < currAdpConf.nAxis; i++)
- {
- // verifico: se l'asse appartiene ad un gruppo uso la sua feedrate...
- int axGroup = 0;
- try
- {
- axGroup = Convert.ToInt32(vettAxis[i].mAxGrp.Value);
- }
- catch
- { }
- if (axGroup > 0)
- {
- vettAxis[i].mAxFeedAct.Value = FeedRateGrp[axGroup - 1];
- }
- else
- {
- vettAxis[i].mAxFeedAct.Value = FeedRate;
- }
- vettAxis[i].mAxFeedOver.Value = FeedRateOver;
-
- // calcolo distanza e salvo valore...
- newPos = Convert.ToDouble(vettAxis[i].mAxPosAct.Value);
- distPerc = newPos - prevPosAxis[i];
-
- // sistemo direzione +/- (POS/NEG se lineari, CCW/CW se rotativi)
- if (distPerc != 0)
- {
- newDir = Convert.ToInt32(distPerc / Math.Abs(distPerc));
- }
- else
- {
- newDir = prevDirAxis[i];
- }
-
-
- // verifico tipo direzione da tipo asse...
- tipoAsse = vettAxis[i].mAxType.Value.ToString();
- if (tipoAsse == "LINEAR")
- {
- // ?: conditional operator.
- direzione = (newDir > 0) ? "POSITIVE" : "NEGATIVE";
- }
- else if (tipoAsse == "ROTARY")
- {
- direzione = (newDir > 0) ? "CLOCKWISE" : "COUNTER_CLOCKWISE";
- }
-
- vettAxis[i].mAxDir.Value = direzione;
-
- // se la direzione è variata salvo il cambio direzione...
- if (newDir != prevDirAxis[i])
- {
- // salvo "+1" come cambi direzione
- istNumInvAssi[i]++;
- }
-
- if (utils.CRB("verbose"))
- {
- sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3} | {2}", i, (double)(newPos), direzione));
- }
-
- // salvo valori vettore prec...
- prevPosAxis[i] = newPos;
- prevDirAxis[i] = newDir;
- }
-
- parentForm.dataMonitor_3 += sb.ToString();
- }
+ base.loadOtherFile();
+ loadByteListMap();
+ loadWordListMap();
+ loadDWordListMap();
+ loadStringListMap();
+ loadAllarmiCNC();
}
+ ///
+ /// Carico conf vettore dati STRING
+ ///
+ private void loadStringListMap()
+ {
+ loadConfFile(ref mapIOT_String, filePath("IOTStringFilePath"), 1, ref numString);
+ // riporto numString a 255!
+ numString = 255;
+ }
+ ///
+ /// Carico conf vettore dati DWORD
+ ///
+ private void loadDWordListMap()
+ {
+ loadConfFile(ref mapIOT_DWord, filePath("IOTDWordFilePath"), 1, ref numDWord);
+ }
+ ///
+ /// Carico conf vettore dati WORD
+ ///
+ private void loadWordListMap()
+ {
+ loadConfFile(ref mapIOT_Word, filePath("IOTWordFilePath"), 1, ref numWord);
+ }
+ ///
+ /// Carico conf vettore dati BYTE
+ ///
+ private void loadByteListMap()
+ {
+ loadConfFile(ref mapIOT_Byte, filePath("IOTByteFilePath"), 1, ref numByte);
+ }
+ ///
+ /// caricamento allarmi da file (CON RIEMPIMENTO MANCANTI!!!!)
+ ///
+ protected void loadAllarmiCNC()
+ {
+ if (utils.CRB("verbose")) lg.Info("Inizio caricamento vettore allarmi");
+ int totRighe = 0;
+ string fileName = string.Format(@"{0}\{1}", utils.confDir, utils.CRS("AlarmListCNC"));
+ string linea;
+ try
+ {
+ string lastLine = File.ReadLines(fileName).Last();
+ totRighe = startNumb(lastLine, utils.CRC("testCharSep"));
+ }
+ catch
+ {
+ totRighe = File.ReadLines(fileName).Count();
+ }
+ // creo un vettore della dimensione corretta... PRENDO IL MASSIMO dei valori...
+ elencoAllarmiCNC = new allarme[totRighe];
+ // ora creo un vettore di allarmi VUOTI...
+ for (int i = 1; i <= totRighe; i++)
+ {
+ elencoAllarmiCNC[i - 1] = new allarme(i.ToString(), "CNC", "WARNING", string.Format("[{0}] MISSING", i));
+ }
+ // carica da file...
+ System.IO.StreamReader file = new System.IO.StreamReader(fileName);
+ // leggo 1 linea alla volta...
+ int numRiga = 0;
+ while ((linea = file.ReadLine()) != null)
+ {
+ // SE non è un commento...
+ if (linea.Substring(0, 1) != "#")
+ {
+ // recupero numRiga da prima parte linea...
+ numRiga = startNumb(linea, utils.CRC("testCharSep"));
+ elencoAllarmiCNC[numRiga - 1] = decodeAlarmLine(linea, utils.CRC("testCharSep"));
+ }
+ }
+ // chiudo file
+ file.Close();
+ if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore allarmi CNC: {0} allarmi caricati!", numRiga));
+ }
+ ///
+ /// Restituisce path completo file da chaive configurazione
+ ///
+ /// chaive conf x file richiesto
+ ///
+ protected string filePath(string keyFile)
+ {
+ return string.Format(@"{0}\{1}", utils.confDir, utils.CRS(keyFile));
+ }
+ ///
+ /// Legge il file di conf di una MAP di informazioni da gestire con lettura set memoria
+ ///
+ /// nome vettore memoria
+ /// file origine
+ /// dimensione (in byte) della memoria
+ /// dimensione (in byte) della memoria
+ protected void loadConfFile(ref otherData[] vettoreConf, string nomeFile, int memSize, ref int numVett)
+ {
+ otherData lastData = new otherData();
+ int totRighe = 0;
+ string linea;
+ totRighe = File.ReadLines(nomeFile).Count();
+ // creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
+ vettoreConf = new otherData[File.ReadLines(nomeFile).Count()];
+ // carica da file...
+ StreamReader file = new StreamReader(nomeFile);
+ // leggo 1 linea alla volta...
+ int numRiga = 0;
+ int bitNum = 0;
+ int byteNum = 0;
+ while ((linea = file.ReadLine()) != null)
+ {
+ // SE non è un commento...
+ if (linea.Substring(0, 1) != "#")
+ {
+ // se finisce per BIT allora processo bit-a-bit...
+ if (linea.EndsWith("BOOL"))
+ {
+ try
+ {
+ string[] memIdx = linea.Split(utils.CRC("testCharSep"))[0].Split('.');
+ // calcolo bit e byte number...
+ int.TryParse(memIdx[0], out byteNum);
+ if (memIdx.Length > 1)
+ {
+ int.TryParse(memIdx[1], out bitNum);
+ }
+ else
+ {
+ bitNum = 0;
+ }
+ }
+ catch
+ {
+ byteNum = 0;
+ bitNum = 0;
+ }
+ lastData = decodeBitData(linea, utils.CRC("testCharSep"), byteNum, 1, bitNum);
+ vettoreConf[numRiga] = lastData;
+ }
+ else
+ {
+ lastData = decodeOtherData(linea, utils.CRC("testCharSep"), "", 1, memSize);
+ vettoreConf[numRiga] = lastData;
+ }
+ numRiga++;
+ }
+ }
+ // salvo lunghezza file...
+ try
+ {
+ numVett = Convert.ToInt32(lastData.memAddr) + 1;
+ }
+ catch
+ {
+ numVett = numRiga + 1;
+ }
+ // chiudo file
+ file.Close();
+ // ora trimmo vettore al solo numero VERO dei valori caricati...
+ Array.Resize(ref vettoreConf, numRiga);
+
+ if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili per file {1}", numRiga, nomeFile));
+ }
+
+ ///
+ /// oggetto onnessione ESA
+ ///
+ protected thdNcEsaGvKvara ncDevice;
+ ///
+ /// thread del processo comunicazione esa
+ ///
+ protected Thread thdDevice;
+
+ ///
+ /// estende l'init della classe base...
+ ///
+ ///
+ ///
+ public AdapterESA(MainForm caller, AdapterConf adpConf) : base(caller, adpConf)
+ {
+ string iniPath = string.Format(@"{0}\{1}", utils.confDir, utils.CRS("defaultEsaFile"));
+
+ lg.Info("Start init Adapter ESA dal file {0}", iniPath);
+
+ IniFiles.IniFile EsaIni = new IniFiles.IniFile(iniPath);
+
+ if (utils.CRB("verbose")) lg.Info("step 01: impostato INI File {0}", iniPath);
+
+ loadOtherFile();
+
+ parentForm.commPlcActive = true;
+ //ncDevice = new thdNcEsaGvKvara(EsaIni, mapIOT_Byte.Length, mapIOT_Word.Length, mapIOT_DWord.Length, 255); // impostato a 255 byte (char) FISSO x la parte stringa... mapIOT_String.Length);
+ ncDevice = new thdNcEsaGvKvara(EsaIni, numByte, numWord, numDWord, numString); // impostato a 255 byte (char) FISSO x la parte stringa... mapIOT_String.Length);
+ parentForm.commPlcActive = false;
+
+ if (utils.CRB("verbose")) lg.Info("step 02: avviato thdNcEsaGvKvara da INI File {0}", iniPath);
+
+ // inizializzo posizioni assi...
+ prevPosAxis = new double[adpConf.nAxis];
+ prevDirAxis = new int[adpConf.nAxis];
+
+ // verifica avvio...
+ lg.Info("ESA: tryConnect");
+ tryConnect();
+ lg.Info("End init Adapter ESA");
+ }
+
+ public override void tryDisconnect()
+ {
+ base.tryDisconnect();
+ // disconnetto
+ ncDevice.Disconnect();
+ connectionOk = false;
+ }
+
+ public override void tryConnect()
+ {
+ base.tryConnect();
+
+ // se non già connesso provo a connettermi...
+ if (!ncDevice.Connected)
+ {
+ // provo a collegarmi
+ if (!ncDevice.Connect())
+ {
+ //altrimenti disconnette...
+ ncDevice.Disconnect();
+ connectionOk = false;
+ }
+ else
+ {
+ connectionOk = true;
+ }
+ }
+ }
+
+ ///
+ /// Verifico connessione ESA...
+ ///
+ ///
+ public override bool connectionOk
+ {
+ get
+ {
+ return ncDevice.Connected;
+ }
+ }
+
+ ///
+ /// Carica ed acquisisce dati del buffer Byte (8 bit) di memoria
+ ///
+ protected void getIotMem_Byte()
+ {
+ // HARD CODE: forzo path 1 (indice 0...)
+ int idxPath = 0;
+ // accodo dati path in DataMonitor......
+ StringBuilder sb = new StringBuilder();
+
+ if (connectionOk)
+ {
+ // leggo TUTTO il blocco di memoria
+ parentForm.commPlcActive = true;
+ inizio = DateTime.Now;
+ ncDevice.ReadBufferByte();
+ if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-Byte", ncDevice.PLC_MemoryAreaIOT_Byte.Length), DateTime.Now.Subtract(inizio).Ticks);
+ parentForm.commPlcActive = false;
+ }
+ else
+ {
+ lg.Error("Errore connessione mancante in getIotMem_Byte");
+ }
+ // Processing area BYTE
+ int numero = 0;
+ string status = "";
+ string pathExeMode = "";
+ string pathRunMode = "";
+ string ProgAreaRun = "";
+ int ProgAreaRunCode = 0;
+ bool isFeedHold = false;
+ bool isActive = false;
+ bool isReady = false;
+ int bitNum = 0;
+ int byteNum = 0;
+ byte currByte;
+ for (int i = 0; i < mapIOT_Byte.Length; i++)
+ {
+ // vado a gestire le variabili BYTE
+ if (mapIOT_Byte[i].dataType == "BYTE")
+ {
+ int.TryParse(mapIOT_Byte[i].memAddr, out byteNum);
+ if (mapIOT_Byte[i].varName == "IOT_OVRF")
+ {
+ FeedRateOver = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_OVRS")
+ {
+ SpeedRateOver = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_MODECN")
+ {
+ // Modo CN:0=Nessuno,1=Manuale,2=Automatico, 3=Pom,4=Mdi,5=SemiAutomatico,6=Rap,7=Test
+ int modoCn = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
+ switch (modoCn)
+ {
+ case 1:
+ pathRunMode = "MANUAL";
+ break;
+ case 2:
+ pathRunMode = "AUTOMATIC";
+ break;
+ case 3:
+ pathRunMode = "POM";
+ break;
+ case 4:
+ pathRunMode = "MANUAL_DATA_INPUT";
+ break;
+ case 5:
+ pathRunMode = "SEMI_AUTOMATIC"; //"SEMIAUTO";
+ break;
+ case 6:
+ pathRunMode = "RAP"; //"MANUAL";
+ break;
+ case 7:
+ pathRunMode = "TES"; //"MANUAL";
+ break;
+ case 0:
+ default:
+ pathRunMode = "NA";
+ break;
+ }
+ // salvo run mode
+ vettPath[idxPath].mPathRunMode.Value = pathRunMode;
+ }
+ else if (mapIOT_Byte[i].varName.StartsWith("IOT_LUB_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_LUB_", "").Replace("_STA", "").Replace("_CNT", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettLubro.Length)
+ {
+ if (mapIOT_Byte[i].varName.EndsWith("_STA"))
+ {
+ if (ncDevice.PLC_MemoryAreaIOT_Byte[byteNum] != 0)
+ {
+ status = "EMPTY";
+ }
+ else
+ {
+ status = "OK";
+ }
+ vettLubro[numero - 1].mLubroStatus.Value = status;
+ }
+ else if (mapIOT_Byte[i].varName.EndsWith("_CNT"))
+ {
+ vettLubro[numero - 1].mLubroNum.Value = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
+ }
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Byte[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
+ }
+ }
+ else if (mapIOT_Byte[i].varName.StartsWith("IOT_I_MD_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_I_MD_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettUnOp.Length)
+ {
+ vettUnOp[numero - 1].mUnOpLoad.Value = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Byte[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
+ }
+ }
+ }
+ // gestisco le variabili BIT/BOOL
+ else if (mapIOT_Byte[i].dataType == "BOOL")
+ {
+ string[] memIdx = mapIOT_Byte[i].memAddr.Split('.');
+ // calcolo bit e byte number...
+ int.TryParse(memIdx[0], out byteNum);
+ if (memIdx.Length > 1)
+ {
+ int.TryParse(memIdx[1], out bitNum);
+ }
+ // leggo byte...
+ currByte = ncDevice.PLC_MemoryAreaIOT_Byte[byteNum];
+ if (mapIOT_Byte[i].varName == "IOT_MACHON")
+ {
+ if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
+ {
+ mPower.Value = "ON";
+ }
+ else
+ {
+ mPower.Value = "OFF";
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_READY")
+ {
+ isReady = ((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum));
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_EXEC")
+ {
+ isActive = ((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum));
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_HOLD")
+ {
+ isFeedHold = ((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum));
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_EMG")
+ {
+ if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
+ {
+ mEStop.Value = "TRIGGERED";
+ }
+ else
+ {
+ mEStop.Value = "ARMED";
+ }
+ }
+ else if (mapIOT_Byte[i].varName == "IOT_ALRM")
+ {
+ if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
+ {
+ // inutile, leggo sempre TUTTI gli allarmi...
+ }
+ }
+ else if (mapIOT_Byte[i].varName.StartsWith("IOT_EXEC_A_"))
+ {
+ ProgAreaRun = "OFF";
+ ProgAreaRunCode = 0;
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_EXEC_A_", ""));
+ // salvo SOLO SE ha bit = 1..
+ if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
+ {
+ ProgAreaRun = "ON";
+ ProgAreaRunCode = 1;
+ }
+ vettMemArea[numero - 1].mMemAreaRunning.Code = ProgAreaRunCode.ToString();
+ vettMemArea[numero - 1].mMemAreaRunning.Value = ProgAreaRun;
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
+ }
+ }
+ else if (mapIOT_Byte[i].varName.StartsWith("IOT_VAC_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Byte[i].varName.Replace("IOT_VAC_", ""));
+ // controllo SE ha bit = 1 è ON..
+ string VacStat = "";
+ if (((StFlag8)currByte).HasFlag((StFlag8)Math.Pow(2, bitNum)))
+ {
+ VacStat = "ON";
+ }
+ else
+ {
+ VacStat = "OFF";
+ }
+ // salvo in vettore SE possibile...
+ if (numero <= vettVacPump.Length)
+ {
+ vettVacPump[numero - 1].mVacPumpStatus.Value = VacStat;
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Byte[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Byte[i].varName);
+ }
+ }
+ }
+ }
+
+ // imposto exe mode alla fine secondo gerarchia stati...
+ if (isFeedHold)
+ {
+ pathExeMode = "FEED_HOLD"; //"FEEDHOLD";
+ }
+ else if (isActive)
+ {
+ pathExeMode = "ACTIVE";
+ }
+ else if (isReady)
+ {
+ pathExeMode = "READY";
+ }
+ vettPath[idxPath].mPathExeMode.Value = pathExeMode;
+
+ // sistemo le stringhe x display
+ sb.AppendLine(string.Format("RunMode: {0}", pathRunMode));
+ sb.AppendLine(string.Format("ExeMode: {0}", pathExeMode));
+ sb.AppendLine(string.Format("FeedRateOver: {0} %", FeedRateOver));
+ sb.AppendLine(string.Format("SpeedRateOver: {0} %", SpeedRateOver));
+
+ // update form!
+ parentForm.dataMonitor_1 += sb.ToString();
+ }
+ ///
+ /// Carica ed acquisisce dati del buffer WORD (16 bit) di memoria
+ ///
+ protected void getIotMem_Word()
+ {
+ if (connectionOk)
+ {
+ // leggo TUTTO il blocco di memoria
+ parentForm.commPlcActive = true;
+ inizio = DateTime.Now;
+ ncDevice.ReadBufferWord();
+ if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-Word", ncDevice.PLC_MemoryAreaIOT_Word.Length), DateTime.Now.Subtract(inizio).Ticks);
+ parentForm.commPlcActive = false;
+ }
+ else
+ {
+ lg.Error("Errore connessione mancante in getIotMem_Word");
+ }
+
+ StringBuilder sb = new StringBuilder();
+ int numAlarmCNC = 0;
+ int numero = 0;
+ int byteNum = 0;
+ // Processing area WORD
+ for (int i = 0; i < mapIOT_Word.Length; i++)
+ {
+ int.TryParse(mapIOT_Word[i].memAddr, out byteNum);
+
+ if (mapIOT_Word[i].varName == "IOT_CN_MSG")
+ {
+ // leggo codice allarme...
+ numAlarmCNC = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ // controllo, SE è 0 --> normal/niente, altrimenti è l'allarme indicato!!!
+ if (numAlarmCNC == 0)
+ {
+ mAlarmCNC.Normal();
+ }
+ else
+ {
+ allarme currAllarm = elencoAllarmiCNC[numAlarmCNC - 1];
+ Condition.Level livello = Condition.Level.NORMAL;
+ switch (currAllarm.livello)
+ {
+ case "WARNING":
+ livello = Condition.Level.WARNING;
+ break;
+ case "FAULT":
+ default:
+ livello = Condition.Level.FAULT;
+ break;
+ }
+ mAlarmCNC.Add(livello, currAllarm.descrizione, currAllarm.codNum, "", "");
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_S_MD_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_S_MD_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettUnOp.Length)
+ {
+ vettUnOp[numero - 1].mUnOpSpeed.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_T_MD_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_T_MD_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettUnOp.Length)
+ {
+ vettUnOp[numero - 1].mUnOpToolId.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_C_TC_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_TC_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettUnOp.Length)
+ {
+ vettUnOp[numero - 1].mUnOpNumCU.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_C_H_MD_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_H_MD_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettUnOp.Length)
+ {
+ vettUnOp[numero - 1].mUnOpAccTime.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_C_H_VAC_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_H_VAC_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettVacPump.Length)
+ {
+ vettVacPump[numero - 1].mVacPumpWrkTime.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_PGMR_A_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_PGMR_A_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettMemArea.Length)
+ {
+ vettMemArea[numero - 1].mMemAreaProgNumRep.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ else if (mapIOT_Word[i].varName.StartsWith("IOT_C_EXEC_A_"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_Word[i].varName.Replace("IOT_C_EXEC_A_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettMemArea.Length)
+ {
+ vettMemArea[numero - 1].mMemAreaProgNumExe.Value = ncDevice.PLC_MemoryAreaIOT_Word[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_Word[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_Word[i].varName);
+ }
+ }
+ }
+ // verifico se nei mandini ho un tool e quanti cambi...
+ for (int i = 0; i < vettUnOp.Length; i++)
+ {
+ if (vettUnOp[i].mUnOpToolId.Value.ToString() != "") sb.AppendLine(string.Format("UnOp_{0}: ToolId: {1} | NumCU: {2}", i + 1, vettUnOp[i].mUnOpToolId.Value, vettUnOp[i].mUnOpNumCU.Value));
+ }
+ // update form!
+ parentForm.dataMonitor_2 += sb.ToString();
+ }
+ ///
+ /// Carica ed acquisisce dati del buffer DWORD (32 bit) di memoria
+ ///
+ protected void getIotMem_DWord()
+ {
+ // accodo dati path in DataMonitor......
+ StringBuilder sb = new StringBuilder();
+ if (connectionOk)
+ {
+ // leggo TUTTO il blocco di memoria
+ parentForm.commPlcActive = true;
+ inizio = DateTime.Now;
+ ncDevice.ReadBufferDWord();
+ if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-DWord", ncDevice.PLC_MemoryAreaIOT_DWord.Length), DateTime.Now.Subtract(inizio).Ticks);
+ parentForm.commPlcActive = false;
+ }
+ else
+ {
+ lg.Error("Errore connessione mancante in getIotMem_DWord");
+ }
+
+ int numero = 0;
+ int byteNum = 0;
+ double valDouble = 0;
+ // Processing area WORD
+ for (int i = 0; i < mapIOT_DWord.Length; i++)
+ {
+ int.TryParse(mapIOT_DWord[i].memAddr, out byteNum);
+ if (mapIOT_DWord[i].varName == "IOT_FEED")
+ {
+ FeedRate = BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0);
+ }
+ else if (mapIOT_DWord[i].varName.StartsWith("IOT_FEED_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_FEED_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= FeedRateGrp.Length)
+ {
+ FeedRateGrp[numero - 1] = BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0);
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
+ }
+ }
+ else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KU_AX_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_C_KU_AX_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettAxis.Length)
+ {
+ vettAxis[numero - 1].mAxDistDone.Value = ncDevice.PLC_MemoryAreaIOT_DWord[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
+ }
+ }
+ else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KINV_AX_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_C_KINV_AX_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettAxis.Length)
+ {
+ vettAxis[numero - 1].mAxInvDDone.Value = ncDevice.PLC_MemoryAreaIOT_DWord[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
+ }
+ }
+ else if (mapIOT_DWord[i].varName.StartsWith("IOT_POS_AX_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_POS_AX_", ""));
+ // recupero valore pos assi (in micron)
+ valDouble = (double)BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0);
+ // salvo in vettore SE possibile...
+ if (numero <= vettAxis.Length)
+ {
+ // riporto il dato in mm (divido x 1000)
+ vettAxis[numero - 1].mAxPosAct.Value = valDouble / utils.CRI("fattdecimale");
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
+ }
+ }
+ else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KREV_MD_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_C_KREV_MD_", ""));
+ // salvo in vettore SE possibile...
+ if (numero <= vettUnOp.Length)
+ {
+ vettUnOp[numero - 1].mUnOpKRev.Value = ncDevice.PLC_MemoryAreaIOT_DWord[byteNum];
+ }
+ else
+ {
+ lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName);
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
+ }
+ }
+ else if (mapIOT_DWord[i].varName.StartsWith("IOT_PLC_MSG_"))
+ {
+ // recupero NUMERO
+ try
+ {
+ numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_PLC_MSG_", ""));
+ // copio allarmi in vettore generale AlarmFlags (dove lo gestisce) 4 byte alla volta
+ Buffer.BlockCopy(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0, AlarmFlags, numero * 4, 4);
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName);
+ }
+ }
+ }
+ // aggiungo feedrate
+ sb.AppendLine(string.Format("FeedRate: {0} mm/min", FeedRate));
+ // verifico se nei gruppi di feed ho qualcosa di diverso da zero...
+ for (int i = 0; i < 20; i++)
+ {
+ if (FeedRateGrp[i] != 0) sb.AppendLine(string.Format("FeedRate_{1}: {0:00} mm/min", FeedRateGrp[i], i));
+ }
+ // update form!
+ parentForm.dataMonitor_1 += sb.ToString();
+ }
+ ///
+ /// Carica ed acquisisce dati del buffer STRING di memoria
+ ///
+ protected void getIotMem_String()
+ {
+ // accodo dati path in DataMonitor......
+ StringBuilder sb = new StringBuilder();
+ if (connectionOk)
+ {
+ // leggo TUTTO il blocco di memoria
+ parentForm.commPlcActive = true;
+ inizio = DateTime.Now;
+ ncDevice.ReadBufferString();
+ if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-DWord", ncDevice.PLC_MemoryAreaIOT_DWord.Length), DateTime.Now.Subtract(inizio).Ticks);
+ parentForm.commPlcActive = false;
+ }
+ else
+ {
+ lg.Error("Errore connessione mancante in getIotMem_DWord");
+ }
+
+ // Processing area STRING: OGNI area di memoria...
+ for (int j = 0; j < mapIOT_String.Length; j++)
+ {
+ string valString = "";
+
+ for (int i = 0; i < numString; i++)
+ {
+ try
+ {
+ valString += Convert.ToChar(ncDevice.PLC_MemoryAreaIOT_String[j, i]).ToString().Replace("\0", " ");
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Errore in decodifica " + mapIOT_String[i].varName);
+ }
+ }
+ // trimmo!
+ valString = valString.Trim();
+ // salvo
+ vettMemArea[j].mMemAreaProgName.Code = j.ToString();
+ vettMemArea[j].mMemAreaProgName.Value = valString;
+ // aggiungo nomi programmi...
+ sb.AppendLine(string.Format("{0}: {1}", mapIOT_String[j].varName, valString));
+ }
+ // update form!
+ parentForm.dataMonitor_2 += sb.ToString();
+ }
+ public override void getGlobalData()
+ {
+ base.getGlobalData();
+ }
+
+ ///
+ /// Processing di TUTTA l'area di memoria configurata e delle variabili derivate...
+ ///
+ public override void processAllMemory()
+ {
+ // inizializzo data monitor su FORM
+ parentForm.dataMonitor_1 = "";
+ parentForm.dataMonitor_2 = "";
+ parentForm.dataMonitor_3 = "";
+
+ // recupero le varie memorie (prima string che mi serve x area selezionata --> programma selezionato)
+ getIotMem_String();
+ getIotMem_Byte();
+ getIotMem_Word();
+ getIotMem_DWord();
+
+ // processo componenti specifici x info...
+ getUnOp();
+ getPath();
+ getAxis();
+ }
+
+ ///
+ /// Recupera la speed override x i mandrini (UnOp)
+ ///
+ public override void getUnOp()
+ {
+ // cicl su UnOp
+ for (int i = 0; i < currAdpConf.nUnOp; i++)
+ {
+ vettUnOp[i].mUnOpSpeedOverr.Value = SpeedRateOver;
+ }
+ }
+
+ ///
+ /// Carica info accessorie assi (direzione, feed, ...)
+ ///
+ public override void getAxis()
+ {
+ // mostro assi in DataMonitor......
+ StringBuilder sb = new StringBuilder();
+
+ // nuova posizione (per calcoli)
+ double newPos = 0;
+ double distPerc = 0;
+ int newDir = 0;
+ string tipoAsse = "";
+ string direzione = "";
+ int numInvAx = 0;
+
+ // leggo in modo "cablato" i dati dei vari assi...
+ for (int i = 0; i < currAdpConf.nAxis; i++)
+ {
+ // verifico: se l'asse appartiene ad un gruppo uso la sua feedrate...
+ int axGroup = 0;
+ try
+ {
+ axGroup = Convert.ToInt32(vettAxis[i].mAxGrp.Value);
+ }
+ catch
+ { }
+ if (axGroup > 0)
+ {
+ vettAxis[i].mAxFeedAct.Value = FeedRateGrp[axGroup - 1];
+ }
+ else
+ {
+ vettAxis[i].mAxFeedAct.Value = FeedRate;
+ }
+ vettAxis[i].mAxFeedOver.Value = FeedRateOver;
+
+ // calcolo distanza e salvo valore...
+ newPos = Convert.ToDouble(vettAxis[i].mAxPosAct.Value);
+ distPerc = newPos - prevPosAxis[i];
+
+ // sistemo direzione +/- (POS/NEG se lineari, CCW/CW se rotativi)
+ if (distPerc != 0)
+ {
+ newDir = Convert.ToInt32(distPerc / Math.Abs(distPerc));
+ }
+ else
+ {
+ newDir = prevDirAxis[i];
+ }
+
+
+ // verifico tipo direzione da tipo asse...
+ tipoAsse = vettAxis[i].mAxType.Value.ToString();
+ if (tipoAsse == "LINEAR")
+ {
+ // ?: conditional operator.
+ direzione = (newDir > 0) ? "POSITIVE" : "NEGATIVE";
+ }
+ else if (tipoAsse == "ROTARY")
+ {
+ direzione = (newDir > 0) ? "CLOCKWISE" : "COUNTER_CLOCKWISE";
+ }
+
+ vettAxis[i].mAxDir.Value = direzione;
+
+ // se la direzione è variata salvo il cambio direzione...
+ if (newDir != prevDirAxis[i])
+ {
+ // recupero num prec...
+ numInvAx = Convert.ToInt32(istNumInvAssi[i].vcMedian);
+ numInvAx++;
+ // salvo "+1" come cambi direzione.... ATTENZIONE servirà che la finestra sia "corta" (tipo 1 sec...) mentre io ne inserisco 3 distanziati di 1/5 sec
+ istNumInvAssi[i].addValue(DateTime.Now.AddMilliseconds(-400), numInvAx);
+ istNumInvAssi[i].addValue(DateTime.Now.AddMilliseconds(-200), numInvAx);
+ istNumInvAssi[i].addValue(DateTime.Now, numInvAx);
+ }
+
+ if (utils.CRB("verbose"))
+ {
+ sb.AppendLine(string.Format("Asse {0}: PosAct:{1:N3} | {2}", i, (double)(newPos), direzione));
+ }
+
+ // salvo valori vettore prec...
+ prevPosAxis[i] = newPos;
+ prevDirAxis[i] = newDir;
+ }
+
+ parentForm.dataMonitor_3 += sb.ToString();
+ }
+ }
}
diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs
index ce97456..4a96c73 100644
--- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs
+++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs
@@ -728,35 +728,35 @@ namespace MTC_Adapter
///
/// Conteggio ISTANTANEO ore macchina ON
///
- public double istOreMaccOn;
+ public sampleVect istOreMaccOn;
///
/// isteggio ISTANTANEO ore macchina IN LAVORO
///
- public double istOreMaccLav;
+ public sampleVect istOreMaccLav;
///
/// Conteggio ISTANTANEO contatore del numero movimenti Slitta Tastatore
///
- public double istSlittaTast;
+ public sampleVect istSlittaTast;
///
/// Vettore ISTANTANEO dei contatori giri cumulati elettromandrino (migliaia)
///
- public uint[] istGiriElettrom;
+ public sampleVect[] istGiriElettrom;
///
/// Vettore ISTANTANEO dei contatori del movimento degli assi
///
- public double[] istDistMovAssi;
+ public sampleVect[] istDistMovAssi;
///
/// Vettore ISTANTANEO dei contatori del LOAD degli assi
///
- public double[] istLoadAssi;
+ public sampleVect[] istLoadAssi;
///
/// Vettore ISTANTANEO dei contatori del tempo cumulato degli assi
///
- public double[] istAccTimeAssi;
+ public sampleVect[] istAccTimeAssi;
///
/// Vettore ISTANTANEO dei contatori del num inv degli assi
///
- public uint[] istNumInvAssi;
+ public sampleVect[] istNumInvAssi;
///
/// vettore dei Program Name dei path ISTANTANEI (nuovi/letti)
///
@@ -768,23 +768,23 @@ namespace MTC_Adapter
///
/// Vettore ISTANTANEO dei contatori del num pezzi fatti x PartId
///
- public uint[] istPathPartCount;
+ public sampleVect[] istPathPartCount;
///
/// Vettore ISTANTANEO dei contatori del work time x VacPump
///
- public uint[] istVacPumpWrkTime;
+ public sampleVect[] istVacPumpWrkTime;
///
/// Vettore ISTANTANEO dei contatori del numero impieghi VacAct
///
- public uint[] istVacActCount;
+ public sampleVect[] istVacActCount;
///
/// Vettore ISTANTANEO dei contatori del Lubro
///
- public uint[] istLubroCount;
+ public sampleVect[] istLubroCount;
///
/// Vettore ISTANTANEO dei contatori del numero cambi utensili x UnOp
///
- public uint[] istNumCambiUt;
+ public sampleVect[] istNumCambiUt;
///
/// Vettore ISTANTANEO dei contatori generici
///
@@ -792,11 +792,11 @@ namespace MTC_Adapter
///
/// Vettore ISTANTANEO dei contatori del numero movimenti Slitta Magazzino
///
- public uint[] istSlittaMag;
+ public sampleVect[] istSlittaMag;
///
/// Vettore ISTANTANEO dei contatori del numero movimenti Protezione Magazzino
///
- public uint[] istProtMag;
+ public sampleVect[] istProtMag;
///
/// vettore valori in file interscambio
@@ -1792,9 +1792,9 @@ namespace MTC_Adapter
contOreMaccLav = currAdpConf.ContOreMaccLav;
contSlittaTast = currAdpConf.ContSlittaTast;
contGiriElettrom = new uint[currAdpConf.nUnOp];
- istGiriElettrom = new uint[currAdpConf.nUnOp];
+ istGiriElettrom = new sampleVect[currAdpConf.nUnOp];
currNumCambiUt = new uint[currAdpConf.nUnOp];
- istNumCambiUt = new uint[currAdpConf.nUnOp];
+ istNumCambiUt = new sampleVect[currAdpConf.nUnOp];
for (int i = 0; i < currAdpConf.nUnOp; i++)
{
// leggo tutti i dati...
@@ -1812,12 +1812,12 @@ namespace MTC_Adapter
}
// imposto num assi e leggo valori salvati...
contDistMovAssi = new double[currAdpConf.nAxis];
- istDistMovAssi = new double[currAdpConf.nAxis];
- istLoadAssi = new double[currAdpConf.nAxis];
+ istDistMovAssi = new sampleVect[currAdpConf.nAxis];
+ istLoadAssi = new sampleVect[currAdpConf.nAxis];
contNumInvAssi = new uint[currAdpConf.nAxis];
- istAccTimeAssi = new double[currAdpConf.nAxis];
+ istAccTimeAssi = new sampleVect[currAdpConf.nAxis];
contAccTimeAssi = new double[currAdpConf.nAxis];
- istNumInvAssi = new uint[currAdpConf.nAxis];
+ istNumInvAssi = new sampleVect[currAdpConf.nAxis];
lastChekAccumTimeAxis = DateTime.Now;
for (int i = 0; i < currAdpConf.nAxis; i++)
{
@@ -1840,7 +1840,7 @@ namespace MTC_Adapter
currPathProgrName = new string[currAdpConf.nPath];
istPathProgrName = new string[currAdpConf.nPath];
currPathPartCount = new uint[currAdpConf.nPath];
- istPathPartCount = new uint[currAdpConf.nPath];
+ istPathPartCount = new sampleVect[currAdpConf.nPath];
for (int i = 0; i < currAdpConf.nPath; i++)
{
// leggo tutti i dati...
@@ -1856,7 +1856,7 @@ namespace MTC_Adapter
vettPath[i].mPathAlarmPLC.Normal();
}
currVacPumpWrkTime = new uint[currAdpConf.nVacuumPump];
- istVacPumpWrkTime = new uint[currAdpConf.nVacuumPump];
+ istVacPumpWrkTime = new sampleVect[currAdpConf.nVacuumPump];
for (int i = 0; i < currAdpConf.nVacuumPump; i++)
{
// leggo tutti i dati...
@@ -1867,7 +1867,7 @@ namespace MTC_Adapter
currVacPumpWrkTime[i] = Convert.ToUInt32(riVacPumpWrk.Value);
}
currVacActCount = new uint[currAdpConf.nVacuumAct];
- istVacActCount = new uint[currAdpConf.nVacuumAct];
+ istVacActCount = new sampleVect[currAdpConf.nVacuumAct];
for (int i = 0; i < currAdpConf.nVacuumAct; i++)
{
// leggo tutti i dati...
@@ -1878,7 +1878,7 @@ namespace MTC_Adapter
currVacActCount[i] = Convert.ToUInt32(riVacActCount.Value);
}
currLubroCount = new uint[currAdpConf.nLubro];
- istLubroCount = new uint[currAdpConf.nLubro];
+ istLubroCount = new sampleVect[currAdpConf.nLubro];
for (int i = 0; i < currAdpConf.nLubro; i++)
{
// leggo tutti i dati...
@@ -1889,7 +1889,7 @@ namespace MTC_Adapter
currLubroCount[i] = Convert.ToUInt32(riLubro.Value);
}
currSlittaMag = new uint[currAdpConf.nSlittaMag];
- istSlittaMag = new uint[currAdpConf.nSlittaMag];
+ istSlittaMag = new sampleVect[currAdpConf.nSlittaMag];
for (int i = 0; i < currAdpConf.nSlittaMag; i++)
{
// leggo tutti i dati...
@@ -1900,7 +1900,7 @@ namespace MTC_Adapter
currSlittaMag[i] = Convert.ToUInt32(riSlittaMag.Value);
}
currProtMag = new uint[currAdpConf.nProtMag];
- istProtMag = new uint[currAdpConf.nProtMag];
+ istProtMag = new sampleVect[currAdpConf.nProtMag];
for (int i = 0; i < currAdpConf.nProtMag; i++)
{
// leggo tutti i dati...
@@ -3333,15 +3333,15 @@ namespace MTC_Adapter
// decodifico...
if (maintData[i].varName == "ACC_TIME")
{
- istOreMaccOn = tabDatiMtz[i];
+ istOreMaccOn.addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
else if (maintData[i].varName == "ACC_TIME_WORK")
{
- istOreMaccLav = tabDatiMtz[i];
+ istOreMaccLav.addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
else if (maintData[i].varName == "SlittaTastatore_Count")
{
- istSlittaTast = tabDatiMtz[i];
+ istSlittaTast.addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
else if (maintData[i].varName.StartsWith("Counter_"))
{
@@ -3354,7 +3354,6 @@ namespace MTC_Adapter
}
if (numero > 0 && istCounters.Length >= numero)
{
- //istCounters[numero - 1] = tabDatiMtz[i];
istCounters[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
@@ -3386,7 +3385,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istDistMovAssi.Length >= numero)
{
- istDistMovAssi[numero - 1] = tabDatiMtz[i];
+ istDistMovAssi[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
else if (maintData[i].varName.EndsWith("_Invers"))
@@ -3409,7 +3408,7 @@ namespace MTC_Adapter
valRead = 0;
lg.Error(string.Format("Errore in recupero num inversioni:{0}parametro: {1}{0}i: {2}{0}Exc: {3}", Environment.NewLine, maintData[i].varName, i, exc));
}
- istNumInvAssi[numero - 1] = valRead;
+ istNumInvAssi[numero - 1].addValue(DateTime.Now, Convert.ToInt32(valRead));
}
}
else if (maintData[i].varName.EndsWith("_AccTime"))
@@ -3432,7 +3431,7 @@ namespace MTC_Adapter
valRead = 0;
lg.Error(string.Format("Errore in recupero num inversioni:{0}parametro: {1}{0}i: {2}{0}Exc: {3}", Environment.NewLine, maintData[i].varName, i, exc));
}
- istAccTimeAssi[numero - 1] = valRead;
+ istAccTimeAssi[numero - 1].addValue(DateTime.Now, Convert.ToInt32(valRead));
}
}
}
@@ -3448,7 +3447,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istGiriElettrom.Length >= numero)
{
- istGiriElettrom[numero - 1] = tabDatiMtz[i];
+ istGiriElettrom[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
else if (maintData[i].varName.EndsWith("_NumCambiUT"))
@@ -3461,7 +3460,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istNumCambiUt.Length >= numero)
{
- istNumCambiUt[numero - 1] = tabDatiMtz[i];
+ istNumCambiUt[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
}
@@ -3477,7 +3476,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istVacPumpWrkTime.Length >= numero)
{
- istVacPumpWrkTime[numero - 1] = tabDatiMtz[i];
+ istVacPumpWrkTime[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
}
@@ -3493,7 +3492,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istVacActCount.Length >= numero)
{
- istVacActCount[numero - 1] = tabDatiMtz[i];
+ istVacActCount[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
}
@@ -3509,7 +3508,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istLubroCount.Length >= numero)
{
- istLubroCount[numero - 1] = tabDatiMtz[i];
+ istLubroCount[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
}
@@ -3525,7 +3524,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istSlittaMag.Length >= numero)
{
- istSlittaMag[numero - 1] = tabDatiMtz[i];
+ istSlittaMag[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
}
@@ -3541,7 +3540,7 @@ namespace MTC_Adapter
{ }
if (numero > 0 && istProtMag.Length >= numero)
{
- istProtMag[numero - 1] = tabDatiMtz[i];
+ istProtMag[numero - 1].addValue(DateTime.Now, Convert.ToInt32(tabDatiMtz[i]));
}
}
}
@@ -4090,28 +4089,31 @@ namespace MTC_Adapter
///
public bool procOreMaccOn(bool needSave)
{
- double delta = istOreMaccOn - contOreMaccOn;
- // controllo delta < 50% max...
- if (delta < double.MaxValue / 2)
+ if (istOreMaccOn.vcValid)
{
- // processo comunque sempre...
- double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME");
- currAdpConf.ContOreMaccOn += delta;
- // salvo valore su persistent layer
- mAccTime.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture);
- // controllo incremento...
- if (delta > 0)
+ double delta = istOreMaccOn.vcMedian - contOreMaccOn;
+ // controllo delta < 50% max...
+ if (delta < double.MaxValue / 2)
{
- // segnalo necessità salvataggio!
- needSave = true;
- }
- // salvo su maschera...
- StringBuilder sb = new StringBuilder();
- sb.AppendLine(string.Format("ACC_TIME: {0}", mAccTime.Value));
- parentForm.dataMonitor_1 += sb.ToString();
+ // processo comunque sempre...
+ double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME");
+ currAdpConf.ContOreMaccOn += delta;
+ // salvo valore su persistent layer
+ mAccTime.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture);
+ // controllo incremento...
+ if (delta > 0)
+ {
+ // segnalo necessità salvataggio!
+ needSave = true;
+ }
+ // salvo su maschera...
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(string.Format("ACC_TIME: {0}", mAccTime.Value));
+ parentForm.dataMonitor_1 += sb.ToString();
- // ...aggiorno valore riferimento...
- contOreMaccOn = istOreMaccOn;
+ // ...aggiorno valore riferimento...
+ contOreMaccOn = istOreMaccOn.vcMedian;
+ }
}
return needSave;
}
@@ -4122,27 +4124,30 @@ namespace MTC_Adapter
///
public bool procOreMaccLav(bool needSave)
{
- double delta = istOreMaccLav - contOreMaccLav;
- // controllo delta < 50% max...
- if (delta < double.MaxValue / 2)
+ if (istOreMaccLav.vcValid)
{
- double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME_WORK");
- currAdpConf.ContOreMaccLav += delta;
- // salvo valore su persistent layer
- mAccTimeWork.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture);
- // controllo valore riferimento...
- if (delta > 0)
+ double delta = istOreMaccLav.vcMedian - contOreMaccLav;
+ // controllo delta < 50% max...
+ if (delta < double.MaxValue / 2)
{
- // segnalo necessità salvataggio!
- needSave = true;
- }
- // salvo su maschera...
- StringBuilder sb = new StringBuilder();
- sb.AppendLine(string.Format("ACC_TIME_WORK: {0}", mAccTimeWork.Value));
- parentForm.dataMonitor_1 += sb.ToString();
+ double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME_WORK");
+ currAdpConf.ContOreMaccLav += delta;
+ // salvo valore su persistent layer
+ mAccTimeWork.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture);
+ // controllo valore riferimento...
+ if (delta > 0)
+ {
+ // segnalo necessità salvataggio!
+ needSave = true;
+ }
+ // salvo su maschera...
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(string.Format("ACC_TIME_WORK: {0}", mAccTimeWork.Value));
+ parentForm.dataMonitor_1 += sb.ToString();
- // ...aggiorno valore riferimento...
- contOreMaccLav = istOreMaccLav;
+ // ...aggiorno valore riferimento...
+ contOreMaccLav = istOreMaccLav.vcMedian;
+ }
}
return needSave;
}
@@ -4153,27 +4158,30 @@ namespace MTC_Adapter
///
public bool procSlittaTast(bool needSave)
{
- double delta = istSlittaTast - contSlittaTast;
- // controllo delta < 50% max...
- if (delta < double.MaxValue / 2)
+ if (istSlittaTast.vcValid)
{
- double contatore = updateValDoubleByIncr(0, delta, "SlittaTastatore_Count");
- currAdpConf.ContSlittaTast += delta;
- // salvo valore su persistent layer
- mSlittaTast.Value = contatore.ToString("0", CultureInfo.InvariantCulture);
- // controllo valore riferimento...
- if (delta > 0)
+ double delta = istSlittaTast.vcMedian - contSlittaTast;
+ // controllo delta < 50% max...
+ if (delta < double.MaxValue / 2)
{
- // segnalo necessità salvataggio!
- needSave = true;
- }
- // salvo su maschera...
- StringBuilder sb = new StringBuilder();
- sb.AppendLine(string.Format("SlittaTastatore_Count: {0}", mSlittaTast.Value));
- parentForm.dataMonitor_1 += sb.ToString();
+ double contatore = updateValDoubleByIncr(0, delta, "SlittaTastatore_Count");
+ currAdpConf.ContSlittaTast += delta;
+ // salvo valore su persistent layer
+ mSlittaTast.Value = contatore.ToString("0", CultureInfo.InvariantCulture);
+ // controllo valore riferimento...
+ if (delta > 0)
+ {
+ // segnalo necessità salvataggio!
+ needSave = true;
+ }
+ // salvo su maschera...
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(string.Format("SlittaTastatore_Count: {0}", mSlittaTast.Value));
+ parentForm.dataMonitor_1 += sb.ToString();
- // ...aggiorno valore riferimento...
- contSlittaTast = istSlittaTast;
+ // ...aggiorno valore riferimento...
+ contSlittaTast = istSlittaTast.vcMedian;
+ }
}
return needSave;
}
@@ -4244,11 +4252,11 @@ namespace MTC_Adapter
for (int i = 0; i < currAdpConf.nPath; i++)
{
// controllo valore riferimento variato...
- if (istPathPartCount[i] != currPathPartCount[i])
+ if (istPathPartCount[i].vcMedian != currPathPartCount[i])
{
- if (istPathPartCount[i] > currPathPartCount[i])
+ if (istPathPartCount[i].vcMedian > currPathPartCount[i])
{
- uint delta = istPathPartCount[i] - currPathPartCount[i];
+ uint delta = Convert.ToUInt32(istPathPartCount[i].vcMedian) - currPathPartCount[i];
//uint contatore = updatePathRefListByIncr(i, delta, "Path_{0:00}_PZ_TOT");
uint contatore = updateValUIntByIncr(i, delta, "Path_{0:00}_PZ_TOT");
// passo valore num pz all'adapter
@@ -4256,7 +4264,7 @@ namespace MTC_Adapter
}
else // variato x difetto... azzero!!!
{
- uint newVal = istPathPartCount[i];
+ uint newVal = Convert.ToUInt32(istPathPartCount[i].vcMedian);
updateValUInt(i, newVal, "Path_{0:00}_PZ_TOT");
// passo valore num pz all'adapter
vettPath[i].mPathPartCount.Value = newVal;
@@ -4265,7 +4273,7 @@ namespace MTC_Adapter
// segnalo necessità salvataggio!
needSave = true;
// ...aggiorno valore riferimento...
- currPathPartCount[i] = istPathPartCount[i];
+ currPathPartCount[i] = Convert.ToUInt32(istPathPartCount[i]);
}
outString += string.Format("{0} | ", vettPath[i].mPathPartCount.Value);
}
@@ -4284,7 +4292,7 @@ namespace MTC_Adapter
string outString = string.Format("UnOp_[1-{0}]_KRev: ", currAdpConf.nUnOp);
for (int i = 0; i < currAdpConf.nUnOp; i++)
{
- delta = istGiriElettrom[i] - contGiriElettrom[i];
+ delta = Convert.ToUInt32(istGiriElettrom[i].vcMedian) - contGiriElettrom[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4299,7 +4307,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- contGiriElettrom[i] = istGiriElettrom[i];
+ contGiriElettrom[i] = Convert.ToUInt32(istGiriElettrom[i]);
}
outString += string.Format("{0} | ", vettUnOp[i].mUnOpAccTime.Value);
}
@@ -4318,7 +4326,7 @@ namespace MTC_Adapter
string outString = string.Format("UnOp_[1-{0}]_NumCU: ", currAdpConf.nUnOp);
for (int i = 0; i < currAdpConf.nUnOp; i++)
{
- delta = istNumCambiUt[i] - currNumCambiUt[i];
+ delta = Convert.ToUInt32(istNumCambiUt[i]) - currNumCambiUt[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4333,7 +4341,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- currNumCambiUt[i] = istNumCambiUt[i];
+ currNumCambiUt[i] = Convert.ToUInt32(istNumCambiUt[i]);
}
outString += string.Format("{0} | ", vettUnOp[i].mUnOpNumCU.Value);
}
@@ -4352,7 +4360,7 @@ namespace MTC_Adapter
string outString = string.Format("Axis_[1-{0}]_DistDone: ", currAdpConf.nAxis);
for (int i = 0; i < currAdpConf.nAxis; i++)
{
- delta = istDistMovAssi[i] - contDistMovAssi[i];
+ delta = Convert.ToUInt32(istDistMovAssi[i]) - contDistMovAssi[i];
// controllo delta < 50% max...
if (delta < double.MaxValue / 2)
{
@@ -4367,7 +4375,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- contDistMovAssi[i] = istDistMovAssi[i];
+ contDistMovAssi[i] = Convert.ToUInt32(istDistMovAssi[i]);
}
outString += string.Format("{0} | ", vettAxis[i].mAxDistDone.Value);
}
@@ -4386,7 +4394,7 @@ namespace MTC_Adapter
string outString = string.Format("Axis_[1-{0}]_AccTime: ", currAdpConf.nAxis);
for (int i = 0; i < currAdpConf.nAxis; i++)
{
- delta = istAccTimeAssi[i] - contAccTimeAssi[i];
+ delta = Convert.ToUInt32(istAccTimeAssi[i]) - contAccTimeAssi[i];
// controllo delta < 50% max...
if (delta < double.MaxValue / 2)
{
@@ -4400,7 +4408,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- contAccTimeAssi[i] = istAccTimeAssi[i];
+ contAccTimeAssi[i] = Convert.ToUInt32(istAccTimeAssi[i]);
}
outString += string.Format("{0} | ", vettAxis[i].mAxAccTime.Value);
}
@@ -4419,7 +4427,7 @@ namespace MTC_Adapter
string outString = string.Format("Axis_[1-{0}]_InvDDone: ", currAdpConf.nAxis);
for (int i = 0; i < currAdpConf.nAxis; i++)
{
- delta = istNumInvAssi[i] - contNumInvAssi[i];
+ delta = Convert.ToUInt32(istNumInvAssi[i]) - contNumInvAssi[i];
// controllo delta < 50% max...
if (delta < long.MaxValue / 2)
{
@@ -4434,7 +4442,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- contNumInvAssi[i] = istNumInvAssi[i];
+ contNumInvAssi[i] = Convert.ToUInt32(istNumInvAssi[i]);
}
outString += string.Format("{0} | ", vettAxis[i].mAxInvDDone.Value);
}
@@ -4453,7 +4461,7 @@ namespace MTC_Adapter
string outString = string.Format("VacPump_[1-{0}]_WrkTime: ", currAdpConf.nVacuumPump);
for (int i = 0; i < currAdpConf.nVacuumPump; i++)
{
- delta = istVacPumpWrkTime[i] - currVacPumpWrkTime[i];
+ delta = Convert.ToUInt32(istVacPumpWrkTime[i]) - currVacPumpWrkTime[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4468,7 +4476,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- currVacPumpWrkTime[i] = istVacPumpWrkTime[i];
+ currVacPumpWrkTime[i] = Convert.ToUInt32(istVacPumpWrkTime[i]);
}
outString += string.Format("{0} | ", vettVacPump[i].mVacPumpWrkTime.Value);
}
@@ -4487,7 +4495,7 @@ namespace MTC_Adapter
string outString = string.Format("VacPump_[1-{0}]_Count: ", currAdpConf.nVacuumPump);
for (int i = 0; i < currAdpConf.nVacuumAct; i++)
{
- delta = istVacActCount[i] - currVacActCount[i];
+ delta = Convert.ToUInt32(istVacActCount[i]) - currVacActCount[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4502,7 +4510,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- currVacActCount[i] = istVacActCount[i];
+ currVacActCount[i] = Convert.ToUInt32(istVacActCount[i]);
}
outString += string.Format("{0} | ", vettVacAct[i].mVacActCount.Value);
}
@@ -4521,7 +4529,7 @@ namespace MTC_Adapter
string outString = string.Format("Lubro_[1-{0}]_Count: ", currAdpConf.nLubro);
for (int i = 0; i < currAdpConf.nLubro; i++)
{
- delta = istLubroCount[i] - currLubroCount[i];
+ delta = Convert.ToUInt32(istLubroCount[i]) - currLubroCount[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4536,7 +4544,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- currLubroCount[i] = istLubroCount[i];
+ currLubroCount[i] = Convert.ToUInt32(istLubroCount[i]);
}
outString += string.Format("{0} | ", vettLubro[i].mLubroNum.Value);
}
@@ -4593,7 +4601,7 @@ namespace MTC_Adapter
string outString = string.Format("SlittaMagazzino_[1-{0}]_Count: ", currAdpConf.nSlittaMag);
for (int i = 0; i < currAdpConf.nSlittaMag; i++)
{
- delta = istSlittaMag[i] - currSlittaMag[i];
+ delta = Convert.ToUInt32(istSlittaMag[i]) - currSlittaMag[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4608,7 +4616,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- currSlittaMag[i] = istSlittaMag[i];
+ currSlittaMag[i] = Convert.ToUInt32(istSlittaMag[i]);
}
outString += string.Format("{0} | ", vettSlittaMag[i].mSlittaMagCount.Value);
}
@@ -4627,7 +4635,7 @@ namespace MTC_Adapter
string outString = string.Format("ProtMagazzino_[1-{0}]_Count: ", currAdpConf.nProtMag);
for (int i = 0; i < currAdpConf.nProtMag; i++)
{
- delta = istProtMag[i] - currProtMag[i];
+ delta = Convert.ToUInt32(istProtMag[i]) - currProtMag[i];
// controllo delta < 50% max...
if (delta < uint.MaxValue / 2)
{
@@ -4642,7 +4650,7 @@ namespace MTC_Adapter
needSave = true;
}
// ...aggiorno valore riferimento...
- currProtMag[i] = istProtMag[i];
+ currProtMag[i] = Convert.ToUInt32(istProtMag[i]);
}
outString += string.Format("{0} | ", vettProtMag[i].mProtMagCount.Value);
}