diff --git a/MTC_Sim/MTC_Sim/AdapterFanuc.cs b/MTC_Sim/MTC_Sim/AdapterFanuc.cs
index 2c66146..ecc728d 100644
--- a/MTC_Sim/MTC_Sim/AdapterFanuc.cs
+++ b/MTC_Sim/MTC_Sim/AdapterFanuc.cs
@@ -707,7 +707,7 @@ namespace MTC_Adapter
base.getSlowChangingData();
// dati da PC
mClock.Value = DateTime.Now.Date.ToFileTimeUtc();
-
+
// reload dati da file...
reloadDataFromFile();
@@ -731,8 +731,10 @@ namespace MTC_Adapter
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiMtz", tabDatiMtz.Length), DateTime.Now.Subtract(inizio).Ticks);
// uno ad uno vado a inserirli nella mappa dei dati dell'adapter...
int shift = 0;
+ int numero = 0;
for (int i = 0; i < maintData.Length; i++)
{
+ numero = 0;
shift = Convert.ToInt32(maintData[i].codNum) - 1;
if (maintData[i].varName == "ACC_TIME")
@@ -743,41 +745,116 @@ namespace MTC_Adapter
{
istOreMaccLav = BitConverter.ToUInt32(tabDatiMtz, shift * i);
}
- else if (maintData[i].varName == "Path_01_PZ_TOT")
+ else if (maintData[i].varName.StartsWith("Path_"))
{
- vettPath[0].mPathPartCount.Value = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ if (maintData[i].varName.EndsWith("_PZ_TOT"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(maintData[i].varName.Replace("Path_", "").Replace("_PZ_TOT", ""));
+ }
+ catch
+ {
+ }
+ if (numero > 0)
+ {
+ vettPath[numero - 1].mPathPartCount.Value = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ }
+ }
}
else if (maintData[i].varName.StartsWith("Axis_"))
{
- int numAx = 0;
if (maintData[i].varName.EndsWith("_DistDone"))
{
try
{
- numAx = Convert.ToInt32(maintData[i].varName.Replace("Axis_", "").Replace("_DistDone", ""));
+ numero = Convert.ToInt32(maintData[i].varName.Replace("Axis_", "").Replace("_DistDone", ""));
}
catch
{ }
- if (numAx > 0)
+ if (numero > 0)
{
- istDistMovAssi[numAx - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ istDistMovAssi[numero - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
}
}
- else
+ else if (maintData[i].varName.EndsWith("_Invers"))
{
try
{
- numAx = Convert.ToInt32(maintData[i].varName.Replace("Axis_", "").Replace("_Invers", ""));
+ numero = Convert.ToInt32(maintData[i].varName.Replace("Axis_", "").Replace("_Invers", ""));
}
catch
{ }
- if (numAx > 0)
+ if (numero > 0)
{
- istNumInvAssi[numAx - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ istNumInvAssi[numero - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ }
+ }
+ }
+ else if (maintData[i].varName.StartsWith("UnOp_"))
+ {
+ if (maintData[i].varName.EndsWith("_AccTime"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(maintData[i].varName.Replace("UnOp_", "").Replace("_AccTime", ""));
+ }
+ catch
+ { }
+ if (numero > 0)
+ {
+ istGiriElettrom[numero - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ }
+ }
+ }
+ else if (maintData[i].varName.StartsWith("VacPump_"))
+ {
+ if (maintData[i].varName.EndsWith("_WrkTime"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(maintData[i].varName.Replace("VacPump_", "").Replace("_WrkTime", ""));
+ }
+ catch
+ { }
+ if (numero > 0)
+ {
+ istVacPumpWrkTime[numero - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ }
+ }
+ }
+ else if (maintData[i].varName.StartsWith("VacAct_"))
+ {
+ if (maintData[i].varName.EndsWith("_Count"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(maintData[i].varName.Replace("VacAct_", "").Replace("_Count", ""));
+ }
+ catch
+ { }
+ if (numero > 0)
+ {
+ istVacActCount[numero - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
+ }
+ }
+ }
+ else if (maintData[i].varName.StartsWith("Lubro_"))
+ {
+ if (maintData[i].varName.EndsWith("_Count"))
+ {
+ try
+ {
+ numero = Convert.ToInt32(maintData[i].varName.Replace("Lubro_", "").Replace("_Count", ""));
+ }
+ catch
+ { }
+ if (numero > 0)
+ {
+ istLubroCount[numero - 1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
}
}
}
-
}
// verifica se si debba aggiornare XML (e salva in adapter dati vari)
@@ -785,8 +862,12 @@ namespace MTC_Adapter
needSave = procOreMaccLav(needSave);
needSave = procPartId(needSave);
needSave = procPzProd(needSave);
+ needSave = procGiriTotUnOp(needSave);
needSave = procMovTotAssi(needSave);
needSave = procNumInvAssi(needSave);
+ needSave = procVacPump(needSave);
+ needSave = procVacAct(needSave);
+ needSave = procLubro(needSave);
// salvo se necessario!
if (needSave) parentForm.persistXmlData();
diff --git a/MTC_Sim/MTC_Sim/AdapterGeneric.cs b/MTC_Sim/MTC_Sim/AdapterGeneric.cs
index 3ea8fa5..5e24840 100644
--- a/MTC_Sim/MTC_Sim/AdapterGeneric.cs
+++ b/MTC_Sim/MTC_Sim/AdapterGeneric.cs
@@ -30,6 +30,10 @@ namespace MTC_Adapter
///
public Event mVacPumpStatus;
///
+ /// valore work time della pompa vuoto
+ ///
+ public Event mVacPumpWrkTime;
+ ///
/// Classe Vacuum Pump (pompa)
///
/// element base contenente parametri (da XML)
@@ -583,6 +587,18 @@ namespace MTC_Adapter
/// Vettore ATTUALE dei contatori del num pezzi fatti x PartId
///
public uint[] currPathPartCount;
+ ///
+ /// Vettore ATTUALE dei contatori del work time x VacPump
+ ///
+ public uint[] currVacPumpWrkTime;
+ ///
+ /// Vettore ATTUALE dei contatori del numero impieghi VacAct
+ ///
+ public uint[] currVacActCount;
+ ///
+ /// Vettore ATTUALE dei contatori del Lubro
+ ///
+ public uint[] currLubroCount;
///
@@ -613,6 +629,18 @@ namespace MTC_Adapter
/// Vettore ISTANTANEO dei contatori del num pezzi fatti x PartId
///
public uint[] istPathPartCount;
+ ///
+ /// Vettore ISTANTANEO dei contatori del work time x VacPump
+ ///
+ public uint[] istVacPumpWrkTime;
+ ///
+ /// Vettore ISTANTANEO dei contatori del numero impieghi VacAct
+ ///
+ public uint[] istVacActCount;
+ ///
+ /// Vettore ISTANTANEO dei contatori del Lubro
+ ///
+ public uint[] istLubroCount;
///
/// posizione precedente assi per calcolo distanze...
@@ -906,8 +934,8 @@ namespace MTC_Adapter
for (int i = 0; i < adpConf.nVacuumPump; i++)
{
vettVacPump[i] = new VacuumPomp(adpConf.VacuumPump[i]);
- //mAdapter.AddDataItem(vettVacPump[i].mVacPumpAlias);
mAdapter.AddDataItem(vettVacPump[i].mVacPumpStatus);
+ mAdapter.AddDataItem(vettVacPump[i].mVacPumpWrkTime);
}
// Attuatori vuoto
vettVacAct = new VacuumAct[adpConf.nVacuumAct];
@@ -1189,8 +1217,6 @@ namespace MTC_Adapter
istDistMovAssi = new uint[currAdpConf.nAxis];
contNumInvAssi = new uint[currAdpConf.nAxis];
istNumInvAssi = new uint[currAdpConf.nAxis];
- currPathPartId = new string[currAdpConf.nPath];
- istPathPartId = new string[currAdpConf.nPath];
for (int i = 0; i < currAdpConf.nAxis; i++)
{
// leggo tutti i dati...
@@ -1202,6 +1228,8 @@ namespace MTC_Adapter
contDistMovAssi[i] = Convert.ToUInt32(riContDist.Value);
contNumInvAssi[i] = Convert.ToUInt32(riNumInv.Value);
}
+ currPathPartId = new string[currAdpConf.nPath];
+ istPathPartId = new string[currAdpConf.nPath];
for (int i = 0; i < currAdpConf.nPath; i++)
{
// leggo tutti i dati...
@@ -1213,6 +1241,39 @@ namespace MTC_Adapter
currPathPartId[i] = riPathProgr.Value;
currPathPartCount[i] = Convert.ToUInt32(riPathPzTot.Value);
}
+ currVacPumpWrkTime = new uint[currAdpConf.nVacuumPump];
+ istVacPumpWrkTime = new uint[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);
+ }
+ currVacActCount = new uint[currAdpConf.nVacuumAct];
+ istVacActCount = new uint[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);
+ }
+ currLubroCount = new uint[currAdpConf.nLubro];
+ istLubroCount = new uint[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);
+ }
mAlarmSystem.Normal();
mAlarmCNC.Normal();
@@ -1835,6 +1896,58 @@ namespace MTC_Adapter
currAdpConf.UnOp[i].dataRefList = listaDR;
return contTot;
}
+ ///
+ /// Aggiorna un valore RefList del vettore VacPump in INCREMENTO e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private uint updateVacPumpRefListByIncr(int i, uint delta, string searchString)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.VacuumPump[i].dataRefList;
+ // recupero valore giri...
+ uint contTot = updateRefListByIncr(i, delta, searchString, ref listaDR);
+ // salvo in adapter!
+ currAdpConf.VacuumPump[i].dataRefList = listaDR;
+ return contTot;
+ }
+ ///
+ /// Aggiorna un valore RefList del vettore VacAct in INCREMENTO e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private uint updateVacActRefListByIncr(int i, uint delta, string searchString)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.VacuumAct[i].dataRefList;
+ // recupero valore giri...
+ uint contTot = updateRefListByIncr(i, delta, searchString, ref listaDR);
+ // salvo in adapter!
+ currAdpConf.VacuumAct[i].dataRefList = listaDR;
+ return contTot;
+ }
+ ///
+ /// Aggiorna un valore RefList del vettore Lubro in INCREMENTO e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private uint updateLubroRefListByIncr(int i, uint delta, string searchString)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.Lubro[i].dataRefList;
+ // recupero valore giri...
+ uint contTot = updateRefListByIncr(i, delta, searchString, ref listaDR);
+ // salvo in adapter!
+ currAdpConf.Lubro[i].dataRefList = listaDR;
+ return contTot;
+ }
+
///
/// Processing delle ore macchina ACCESA
///
@@ -1985,7 +2098,6 @@ namespace MTC_Adapter
return needSave;
}
-
///
/// Processing delle variabili sul totale num inversioni degli assi
///
@@ -2000,10 +2112,8 @@ namespace MTC_Adapter
{
uint delta = istNumInvAssi[i] - contNumInvAssi[i];
uint contTot = updateUnOpRefListByIncr(i, delta, "Axis_{0:00}_Invers");
-
// passo valore totale all'adapter
vettAxis[i].mAxInvDDone.Value = contTot.ToString();
-
// segnalo necessità salvataggio!
needSave = true;
}
@@ -2013,6 +2123,78 @@ namespace MTC_Adapter
return needSave;
}
+ ///
+ /// Processing delle variabili sulle VacPump
+ ///
+ ///
+ ///
+ public bool procVacPump(bool needSave)
+ {
+ for (int i = 0; i < currAdpConf.nVacuumPump; i++)
+ {
+ // controllo valore riferimento...
+ if (istVacPumpWrkTime[i] > currVacPumpWrkTime[i])
+ {
+ uint delta = istVacPumpWrkTime[i] - currVacPumpWrkTime[i];
+ uint contTot = updateVacPumpRefListByIncr(i, delta, "VacPump_{0:00}_WrkTime");
+ // passo valore totale all'adapter
+ vettVacPump[i].mVacPumpWrkTime.Value = contTot;
+ // segnalo necessità salvataggio!
+ needSave = true;
+ }
+ // ...aggiorno valore riferimento...
+ currVacPumpWrkTime[i] = istVacPumpWrkTime[i];
+ }
+ return needSave;
+ }
+ ///
+ /// Processing delle variabili sulle VacAct
+ ///
+ ///
+ ///
+ public bool procVacAct(bool needSave)
+ {
+ for (int i = 0; i < currAdpConf.nVacuumAct; i++)
+ {
+ // controllo valore riferimento...
+ if (istVacActCount[i] > currVacActCount[i])
+ {
+ uint delta = istVacActCount[i] - currVacActCount[i];
+ uint contTot = updateVacPumpRefListByIncr(i, delta, "VacAct_{0:00}_Count");
+ // passo valore totale all'adapter
+ vettVacAct[i].mVacActCount.Value = contTot;
+ // segnalo necessità salvataggio!
+ needSave = true;
+ }
+ // ...aggiorno valore riferimento...
+ currVacActCount[i] = istVacActCount[i];
+ }
+ return needSave;
+ }
+ ///
+ /// Processing delle variabili sui componenti Lubro
+ ///
+ ///
+ ///
+ public bool procLubro(bool needSave)
+ {
+ for (int i = 0; i < currAdpConf.nLubro; i++)
+ {
+ // controllo valore riferimento...
+ if (istLubroCount[i] > currLubroCount[i])
+ {
+ uint delta = istLubroCount[i] - currLubroCount[i];
+ uint contTot = updateVacPumpRefListByIncr(i, delta, "Lubro_{0:00}_Count");
+ // passo valore totale all'adapter
+ vettLubro[i].mLubroNum.Value = contTot;
+ // segnalo necessità salvataggio!
+ needSave = true;
+ }
+ // ...aggiorno valore riferimento...
+ currLubroCount[i] = istLubroCount[i];
+ }
+ return needSave;
+ }
#endregion