portata gestione InvDir a adapter generic
This commit is contained in:
@@ -189,8 +189,7 @@ namespace MTC_Adapter
|
||||
}
|
||||
needSave = procGiriTotUnOp(needSave);
|
||||
|
||||
// giri spostamento totale assi!
|
||||
|
||||
// spostamento totale assi!
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
// primo è metri, secondo km (moltiplico x 1000)
|
||||
@@ -364,6 +363,15 @@ namespace MTC_Adapter
|
||||
}
|
||||
vettAxis[i].mAxDir.Value = newDir;
|
||||
|
||||
// se la direzione è variata salvo il cambio direzione...
|
||||
if (newDir != prevDirAxis[i])
|
||||
{
|
||||
// salvo "+1" come cambi direzione
|
||||
istNumInvAssi[i]++;
|
||||
}
|
||||
|
||||
// 2016.06.05 tolto x gestione con procNumInvAssi
|
||||
#if false
|
||||
// se la direzione è variata salvo il cambio direzione...
|
||||
if (newDir != prevDirAxis[i])
|
||||
{
|
||||
@@ -374,7 +382,8 @@ namespace MTC_Adapter
|
||||
{
|
||||
// salvo "0" come aumento...
|
||||
vettAxis[i].mAxInvDDone.Value = incrNumInvAssi(i, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// salvo valori vettore prec...
|
||||
prevPosAxis[i] = newPos;
|
||||
|
||||
@@ -713,6 +713,7 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
private void getMtzDataFromPlc()
|
||||
{
|
||||
bool needSave = false;
|
||||
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
|
||||
int memIndex = 14000;
|
||||
byte[] tabDatiMtz = new byte[4 * maintData.Length];
|
||||
@@ -735,11 +736,55 @@ namespace MTC_Adapter
|
||||
case "Path_01_PZ_TOT":
|
||||
vettPath[0].mPathPartCount.Value = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_01_DistDone":
|
||||
istDistMovAssi[0] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_01_Invers":
|
||||
istNumInvAssi[0] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_02_DistDone":
|
||||
istDistMovAssi[1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_02_Invers":
|
||||
istNumInvAssi[1] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_03_DistDone":
|
||||
istDistMovAssi[2] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_03_Invers":
|
||||
istNumInvAssi[2] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_04_DistDone":
|
||||
istDistMovAssi[3] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_04_Invers":
|
||||
istNumInvAssi[3] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_05_DistDone":
|
||||
istDistMovAssi[4] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_05_Invers":
|
||||
istNumInvAssi[4] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_06_DistDone":
|
||||
istDistMovAssi[5] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
case "Axis_06_Invers":
|
||||
istNumInvAssi[5] = BitConverter.ToUInt32(tabDatiMtz, shift * i);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// verifica se si debba aggiornare XML (e salva in adapter dati spostamento assi)
|
||||
needSave = procMovTotAssi(needSave);
|
||||
needSave = procNumInvAssi(needSave);
|
||||
|
||||
// salvo se necessario!
|
||||
if (needSave) parentForm.persistXmlData();
|
||||
// -------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1245,6 +1290,8 @@ namespace MTC_Adapter
|
||||
}
|
||||
vettAxis[i].mAxDir.Value = newDir;
|
||||
|
||||
// 2016.06.05 tolto x gestione da procNumInvAssi
|
||||
#if false
|
||||
// se la direzione è variata salvo il cambio direzione...
|
||||
if (newDir != prevDirAxis[i])
|
||||
{
|
||||
@@ -1255,7 +1302,8 @@ namespace MTC_Adapter
|
||||
{
|
||||
// salvo "0"...
|
||||
vettAxis[i].mAxInvDDone.Value = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// salvo valori vettore prec...
|
||||
prevPosAxis[i] = newPos;
|
||||
|
||||
@@ -571,6 +571,10 @@ namespace MTC_Adapter
|
||||
/// Vettore ATTUALE dei contatori del movimento degli assi
|
||||
/// </summary>
|
||||
public uint[] contDistMovAssi;
|
||||
/// <summary>
|
||||
/// Vettore ATTUALE dei contatori del num inv degli assi
|
||||
/// </summary>
|
||||
public uint[] contNumInvAssi;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -589,6 +593,10 @@ namespace MTC_Adapter
|
||||
/// Vettore ISTANTANEO dei contatori del movimento degli assi
|
||||
/// </summary>
|
||||
public uint[] istDistMovAssi;
|
||||
/// <summary>
|
||||
/// Vettore ISTANTANEO dei contatori del num inv degli assi
|
||||
/// </summary>
|
||||
public uint[] istNumInvAssi;
|
||||
|
||||
/// <summary>
|
||||
/// posizione precedente assi per calcolo distanze...
|
||||
@@ -1160,18 +1168,21 @@ namespace MTC_Adapter
|
||||
// salvo valore letto
|
||||
contGiriElettrom[i] = contTotGiri;
|
||||
}
|
||||
// imposto fisso a 3 assi...
|
||||
contDistMovAssi = new uint[3];
|
||||
istDistMovAssi = new uint[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
// imposto num assi...
|
||||
contDistMovAssi = new uint[currAdpConf.nAxis];
|
||||
istDistMovAssi = new uint[currAdpConf.nAxis];
|
||||
contNumInvAssi= new uint[currAdpConf.nAxis];
|
||||
istNumInvAssi = new uint[currAdpConf.nAxis];
|
||||
for (int i = 0; i < currAdpConf.nAxis; i++)
|
||||
{
|
||||
// leggo tutti i dati...
|
||||
List<DataRefItem<string, string>> listaDR = currAdpConf.Axis[i].dataRefList;
|
||||
// punto all'item
|
||||
DataRefItem<string, string> riContDist = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_DistDone", i + 1));
|
||||
// recupero valore giri...
|
||||
uint contTotKm = Convert.ToUInt32(riContDist.Value);
|
||||
contDistMovAssi[i] = contTotKm;
|
||||
DataRefItem<string, string> riNumInv = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_Invers", i + 1));
|
||||
// recupero valori...
|
||||
contDistMovAssi[i] = Convert.ToUInt32(riContDist.Value);
|
||||
contNumInvAssi[i] = Convert.ToUInt32(riNumInv.Value);
|
||||
}
|
||||
|
||||
mAlarmSystem.Normal();
|
||||
@@ -1757,7 +1768,6 @@ namespace MTC_Adapter
|
||||
if (istGiriElettrom[i] > contGiriElettrom[i])
|
||||
{
|
||||
int deltaGiri = istGiriElettrom[i] - contGiriElettrom[i];
|
||||
contGiriElettrom[i] = istGiriElettrom[i];
|
||||
// leggo tutti i dati...
|
||||
List<DataRefItem<string, string>> listaDR = currAdpConf.UnOp[i].dataRefList;
|
||||
// punto all'item
|
||||
@@ -1789,39 +1799,38 @@ namespace MTC_Adapter
|
||||
return needSave;
|
||||
}
|
||||
/// <summary>
|
||||
/// Processing delle variabili sul totale km percorsi dagli assi
|
||||
/// Processing delle variabili sul totale m percorsi dagli assi
|
||||
/// </summary>
|
||||
/// <param name="needSave"></param>
|
||||
/// <returns></returns>
|
||||
public bool procMovTotAssi(bool needSave)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < currAdpConf.nAxis; i++)
|
||||
{
|
||||
// controllo valore riferimento...
|
||||
if (istDistMovAssi[i] > contDistMovAssi[i])
|
||||
{
|
||||
uint deltaMov = istDistMovAssi[i] - contDistMovAssi[i];
|
||||
contDistMovAssi[i] = istDistMovAssi[i];
|
||||
uint delta = istDistMovAssi[i] - contDistMovAssi[i];
|
||||
// leggo tutti i dati...
|
||||
List<DataRefItem<string, string>> listaDR = currAdpConf.Axis[i].dataRefList;
|
||||
// punto all'item
|
||||
DataRefItem<string, string> riContDist = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_DistDone", i + 1));
|
||||
// recupero valore giri...
|
||||
uint contTotKm = Convert.ToUInt32(riContDist.Value);
|
||||
uint contTot = Convert.ToUInt32(riContDist.Value);
|
||||
// aggiungo giri...
|
||||
contTotKm += deltaMov;
|
||||
contTot += delta;
|
||||
// tolgo vecchio item
|
||||
listaDR.Remove(riContDist);
|
||||
// lo aggiorno...
|
||||
riContDist.Value = contTotKm.ToString();
|
||||
riContDist.Value = contTot.ToString();
|
||||
// riaggiungo item
|
||||
listaDR.Add(riContDist);
|
||||
|
||||
// salvo in adapter!
|
||||
currAdpConf.Axis[i].dataRefList = listaDR;
|
||||
|
||||
// passo valore num giri (migliaia) all'adapter
|
||||
vettAxis[i].mAxAccTime.Value = contTotKm.ToString();
|
||||
// passo valore totale all'adapter
|
||||
vettAxis[i].mAxDistDone.Value = contTot.ToString();
|
||||
|
||||
// segnalo necessità salvataggio!
|
||||
needSave = true;
|
||||
@@ -1833,6 +1842,53 @@ namespace MTC_Adapter
|
||||
return needSave;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processing delle variabili sul totale num inversioni degli assi
|
||||
/// </summary>
|
||||
/// <param name="needSave"></param>
|
||||
/// <returns></returns>
|
||||
public bool procNumInvAssi(bool needSave)
|
||||
{
|
||||
for (int i = 0; i < currAdpConf.nAxis; i++)
|
||||
{
|
||||
// controllo valore riferimento...
|
||||
if (istNumInvAssi[i] > contNumInvAssi[i])
|
||||
{
|
||||
uint delta = istNumInvAssi[i] - contNumInvAssi[i];
|
||||
// leggo tutti i dati...
|
||||
List<DataRefItem<string, string>> listaDR = currAdpConf.Axis[i].dataRefList;
|
||||
// punto all'item
|
||||
DataRefItem<string, string> riNumInv = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_Invers", i + 1));
|
||||
// recupero valore giri...
|
||||
uint contTot = Convert.ToUInt32(riNumInv.Value);
|
||||
// aggiungo giri...
|
||||
contTot += delta;
|
||||
// tolgo vecchio item
|
||||
listaDR.Remove(riNumInv);
|
||||
// lo aggiorno...
|
||||
riNumInv.Value = contTot.ToString();
|
||||
// riaggiungo item
|
||||
listaDR.Add(riNumInv);
|
||||
|
||||
// salvo in adapter!
|
||||
currAdpConf.Axis[i].dataRefList = listaDR;
|
||||
|
||||
// passo valore totale all'adapter
|
||||
vettAxis[i].mAxInvDDone.Value = contTot.ToString();
|
||||
|
||||
// segnalo necessità salvataggio!
|
||||
needSave = true;
|
||||
}
|
||||
// ...aggiorno valore riferimento...
|
||||
contNumInvAssi[i] = istNumInvAssi[i];
|
||||
}
|
||||
|
||||
return needSave;
|
||||
}
|
||||
|
||||
|
||||
// 2016.06.05 tolto x gestione con procNumInvAssi
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Incrementa valore salvato del numero inversioni assi effettuate
|
||||
/// </summary>
|
||||
@@ -1860,7 +1916,8 @@ namespace MTC_Adapter
|
||||
currAdpConf.Axis[idxAsse].dataRefList = listaDR;
|
||||
|
||||
return contInvers;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user