ancora pulizia e spostamento metodi in area AdapterGeneric (reloadDataFromFile)
This commit is contained in:
@@ -447,114 +447,6 @@ namespace MTC_Adapter
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Ricarica dati da file di scambio con CMSConnect
|
||||
/// </summary>
|
||||
private void reloadDataFromFile()
|
||||
{
|
||||
if (utils.CRB("verbose")) lg.Info("Inizio lettura dati da file");
|
||||
int totRighe = 0;
|
||||
// da rivedere: se sono N+1 file (N=path + generale) deve essere ad esempio nomeComune_*.mtc --> ciclo per leggerne N
|
||||
string fileName = string.Format(@"{0}\{1}", utils.dataDir, utils.CRS("GeneralStatusFilePath"));
|
||||
string linea;
|
||||
// creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
|
||||
generalStatus = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
totRighe = File.ReadLines(fileName).Count();
|
||||
// carica da file...
|
||||
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
|
||||
if (file != null)
|
||||
{
|
||||
// leggo 1 linea alla volta...
|
||||
string[] valori;
|
||||
while ((linea = file.ReadLine()) != null)
|
||||
{
|
||||
// SE non è un commento...
|
||||
if (linea.Substring(0, 1) != "#")
|
||||
{
|
||||
valori = linea.Split(utils.CRC("testCharSep"));
|
||||
generalStatus.Add(valori[0], valori[1]);
|
||||
}
|
||||
}
|
||||
// chiudo file
|
||||
file.Close();
|
||||
if (utils.CRB("verbose")) lg.Info("Fine lettura dati da file");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lg.Info("Errore in lettura dati da file");
|
||||
}
|
||||
|
||||
|
||||
// ora salvo valori letti...
|
||||
foreach (KeyValuePair<string, string> item in generalStatus)
|
||||
{
|
||||
// verifico la chiave e nel caso aggiorno...
|
||||
switch (item.Key)
|
||||
{
|
||||
case "OperatorId":
|
||||
mOperator.Value = item.Value;
|
||||
break;
|
||||
case "Path_01_CurrProg":
|
||||
istPathProgrName[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_CurrProg":
|
||||
istPathProgrName[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_CurrProg":
|
||||
istPathProgrName[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_CurrProg":
|
||||
istPathProgrName[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_CurrProg":
|
||||
istPathProgrName[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_CurrProg":
|
||||
istPathProgrName[5] = item.Value;
|
||||
break;
|
||||
case "Path_01_PartId":
|
||||
istPathPartId[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_PartId":
|
||||
istPathPartId[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_PartId":
|
||||
istPathPartId[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_PartId":
|
||||
istPathPartId[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_PartId":
|
||||
istPathPartId[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_PartId":
|
||||
istPathPartId[5] = item.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gestione strobe UserAction: salva dati e gestione ACK
|
||||
/// </summary>
|
||||
/// <param name="bitNum"></param>
|
||||
/// <param name="retACK_DW1"></param>
|
||||
/// <param name="UserAction"></param>
|
||||
/// <param name="azione"></param>
|
||||
private void gestStrobeUserAction(int bitNum, ref byte[] retACK_DW1, ref string UserAction, string azione)
|
||||
{
|
||||
if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
|
||||
{
|
||||
// salvo evento UserAction in variabile...
|
||||
UserAction += azione;
|
||||
// memorizzo allarme nel vettore ack....
|
||||
retACK_DW1 = utils.setBitOnStFlag(retACK_DW1, true, bitNum);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// recupera allarmi ed aggiorna strobe (privato) degli allarmi
|
||||
/// </summary>
|
||||
/// <param name="Alarm2Refresh">32bit mask degli allarmi da aggiornare</param>
|
||||
|
||||
@@ -2231,6 +2231,98 @@ namespace MTC_Adapter
|
||||
retACK_DW1 = utils.setBitOnStFlag(retACK_DW1, true, bitNum);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricarica dati da file di scambio con CMSConnect
|
||||
/// </summary>
|
||||
public void reloadDataFromFile()
|
||||
{
|
||||
if (utils.CRB("verbose")) lg.Info("Inizio lettura dati da file");
|
||||
int totRighe = 0;
|
||||
// da rivedere: se sono N+1 file (N=path + generale) deve essere ad esempio nomeComune_*.mtc --> ciclo per leggerne N
|
||||
string fileName = string.Format(@"{0}\{1}", utils.dataDir, utils.CRS("GeneralStatusFilePath"));
|
||||
string linea;
|
||||
// creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
|
||||
generalStatus = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
totRighe = File.ReadLines(fileName).Count();
|
||||
// carica da file...
|
||||
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
|
||||
if (file != null)
|
||||
{
|
||||
// leggo 1 linea alla volta...
|
||||
string[] valori;
|
||||
while ((linea = file.ReadLine()) != null)
|
||||
{
|
||||
// SE non è un commento...
|
||||
if (linea.Substring(0, 1) != "#")
|
||||
{
|
||||
valori = linea.Split(utils.CRC("testCharSep"));
|
||||
generalStatus.Add(valori[0], valori[1]);
|
||||
}
|
||||
}
|
||||
// chiudo file
|
||||
file.Close();
|
||||
if (utils.CRB("verbose")) lg.Info("Fine lettura dati da file");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lg.Info("Errore in lettura dati da file");
|
||||
}
|
||||
|
||||
|
||||
// ora salvo valori letti...
|
||||
foreach (KeyValuePair<string, string> item in generalStatus)
|
||||
{
|
||||
// verifico la chiave e nel caso aggiorno...
|
||||
switch (item.Key)
|
||||
{
|
||||
case "OperatorId":
|
||||
mOperator.Value = item.Value;
|
||||
break;
|
||||
case "Path_01_CurrProg":
|
||||
istPathProgrName[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_CurrProg":
|
||||
istPathProgrName[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_CurrProg":
|
||||
istPathProgrName[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_CurrProg":
|
||||
istPathProgrName[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_CurrProg":
|
||||
istPathProgrName[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_CurrProg":
|
||||
istPathProgrName[5] = item.Value;
|
||||
break;
|
||||
case "Path_01_PartId":
|
||||
istPathPartId[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_PartId":
|
||||
istPathPartId[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_PartId":
|
||||
istPathPartId[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_PartId":
|
||||
istPathPartId[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_PartId":
|
||||
istPathPartId[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_PartId":
|
||||
istPathPartId[5] = item.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// verifica gli status attivi
|
||||
/// </summary>
|
||||
|
||||
@@ -560,97 +560,6 @@ namespace MTC_Adapter
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Ricarica dati da file di scambio con CMSConnect
|
||||
/// </summary>
|
||||
private void reloadDataFromFile()
|
||||
{
|
||||
if (utils.CRB("verbose")) lg.Info("Inizio lettura dati da file");
|
||||
int totRighe = 0;
|
||||
// da rivedere: se sono N+1 file (N=path + generale) deve essere ad esempio nomeComune_*.mtc --> ciclo per leggerne N
|
||||
string fileName = string.Format(@"{0}\{1}", utils.dataDir, utils.CRS("GeneralStatusFilePath"));
|
||||
string linea;
|
||||
// creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
|
||||
generalStatus = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
totRighe = File.ReadLines(fileName).Count();
|
||||
// carica da file...
|
||||
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
|
||||
if (file != null)
|
||||
{
|
||||
// leggo 1 linea alla volta...
|
||||
string[] valori;
|
||||
while ((linea = file.ReadLine()) != null)
|
||||
{
|
||||
// SE non è un commento...
|
||||
if (linea.Substring(0, 1) != "#")
|
||||
{
|
||||
valori = linea.Split(utils.CRC("testCharSep"));
|
||||
generalStatus.Add(valori[0], valori[1]);
|
||||
}
|
||||
}
|
||||
// chiudo file
|
||||
file.Close();
|
||||
if (utils.CRB("verbose")) lg.Info("Fine lettura dati da file");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lg.Info("Errore in lettura dati da file");
|
||||
}
|
||||
|
||||
|
||||
// ora salvo valori letti...
|
||||
foreach (KeyValuePair<string, string> item in generalStatus)
|
||||
{
|
||||
// verifico la chiave e nel caso aggiorno...
|
||||
switch (item.Key)
|
||||
{
|
||||
case "OperatorId":
|
||||
mOperator.Value = item.Value;
|
||||
break;
|
||||
case "Path_01_CurrProg":
|
||||
istPathProgrName[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_CurrProg":
|
||||
istPathProgrName[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_CurrProg":
|
||||
istPathProgrName[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_CurrProg":
|
||||
istPathProgrName[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_CurrProg":
|
||||
istPathProgrName[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_CurrProg":
|
||||
istPathProgrName[5] = item.Value;
|
||||
break;
|
||||
case "Path_01_PartId":
|
||||
istPathPartId[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_PartId":
|
||||
istPathPartId[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_PartId":
|
||||
istPathPartId[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_PartId":
|
||||
istPathPartId[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_PartId":
|
||||
istPathPartId[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_PartId":
|
||||
istPathPartId[5] = item.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// recupera allarmi ed aggiorna strobe (privato) degli allarmi
|
||||
/// </summary>
|
||||
/// <param name="Alarm2Refresh">32bit mask degli allarmi da aggiornare</param>
|
||||
|
||||
@@ -495,8 +495,7 @@ namespace MTC_Adapter
|
||||
// recupero cod univoco test e numero parametri impiegati
|
||||
testNum = BitConverter.ToUInt16(BitConverter.GetBytes(MemBlockTestData[0]), 0);
|
||||
numPar = BitConverter.ToUInt16(BitConverter.GetBytes(MemBlockTestData[0]), 2);
|
||||
|
||||
|
||||
|
||||
// riporto separatore + numero test + num parametri
|
||||
answ = string.Format("{0}TN:{1}{0}NP:{2}", charSep, testNum, numPar);
|
||||
// se ci sono parametri da accodare li recupero!
|
||||
@@ -512,97 +511,6 @@ namespace MTC_Adapter
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Ricarica dati da file di scambio con CMSConnect
|
||||
/// </summary>
|
||||
private void reloadDataFromFile()
|
||||
{
|
||||
if (utils.CRB("verbose")) lg.Info("Inizio lettura dati da file");
|
||||
int totRighe = 0;
|
||||
// da rivedere: se sono N+1 file (N=path + generale) deve essere ad esempio nomeComune_*.mtc --> ciclo per leggerne N
|
||||
string fileName = string.Format(@"{0}\{1}", utils.dataDir, utils.CRS("GeneralStatusFilePath"));
|
||||
string linea;
|
||||
// creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
|
||||
generalStatus = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
totRighe = File.ReadLines(fileName).Count();
|
||||
// carica da file...
|
||||
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
|
||||
if (file != null)
|
||||
{
|
||||
// leggo 1 linea alla volta...
|
||||
string[] valori;
|
||||
while ((linea = file.ReadLine()) != null)
|
||||
{
|
||||
// SE non è un commento...
|
||||
if (linea.Substring(0, 1) != "#")
|
||||
{
|
||||
valori = linea.Split(utils.CRC("testCharSep"));
|
||||
generalStatus.Add(valori[0], valori[1]);
|
||||
}
|
||||
}
|
||||
// chiudo file
|
||||
file.Close();
|
||||
if (utils.CRB("verbose")) lg.Info("Fine lettura dati da file");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lg.Info("Errore in lettura dati da file");
|
||||
}
|
||||
|
||||
|
||||
// ora salvo valori letti...
|
||||
foreach (KeyValuePair<string, string> item in generalStatus)
|
||||
{
|
||||
// verifico la chiave e nel caso aggiorno...
|
||||
switch (item.Key)
|
||||
{
|
||||
case "OperatorId":
|
||||
mOperator.Value = item.Value;
|
||||
break;
|
||||
case "Path_01_CurrProg":
|
||||
istPathProgrName[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_CurrProg":
|
||||
istPathProgrName[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_CurrProg":
|
||||
istPathProgrName[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_CurrProg":
|
||||
istPathProgrName[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_CurrProg":
|
||||
istPathProgrName[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_CurrProg":
|
||||
istPathProgrName[5] = item.Value;
|
||||
break;
|
||||
case "Path_01_PartId":
|
||||
istPathPartId[0] = item.Value;
|
||||
break;
|
||||
case "Path_02_PartId":
|
||||
istPathPartId[1] = item.Value;
|
||||
break;
|
||||
case "Path_03_PartId":
|
||||
istPathPartId[2] = item.Value;
|
||||
break;
|
||||
case "Path_04_PartId":
|
||||
istPathPartId[3] = item.Value;
|
||||
break;
|
||||
case "Path_05_PartId":
|
||||
istPathPartId[4] = item.Value;
|
||||
break;
|
||||
case "Path_06_PartId":
|
||||
istPathPartId[5] = item.Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// recupera allarmi ed aggiorna strobe (privato) degli allarmi
|
||||
/// </summary>
|
||||
/// <param name="Alarm2Refresh">32bit mask degli allarmi da aggiornare</param>
|
||||
|
||||
Reference in New Issue
Block a user