portato in generic procPathStrobe
This commit is contained in:
@@ -83,7 +83,6 @@ namespace MTC_Adapter
|
||||
|
||||
public override void processStrobe()
|
||||
{
|
||||
base.processStrobe();
|
||||
// qui forzo la gestione di update dei path & co...
|
||||
getPath();
|
||||
getUnOp();
|
||||
|
||||
@@ -203,8 +203,6 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
public override void processStrobe()
|
||||
{
|
||||
base.processStrobe();
|
||||
|
||||
// inizializzo userAction
|
||||
string UserAction = "";
|
||||
string TestingData = "";
|
||||
|
||||
@@ -966,7 +966,7 @@ namespace MTC_Adapter
|
||||
public List<string>[] codaT;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Events & samples
|
||||
|
||||
/// <summary>
|
||||
@@ -1613,7 +1613,7 @@ namespace MTC_Adapter
|
||||
}
|
||||
|
||||
#region metodi adapter
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// lettura file di persistenza
|
||||
@@ -2504,7 +2504,128 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
public virtual void processStrobe()
|
||||
{
|
||||
// da gestire su ogni adapter...
|
||||
// ...da gestire su ogni adapter...
|
||||
}
|
||||
/// <summary>
|
||||
/// Processa strobe x un dato path
|
||||
/// </summary>
|
||||
/// <param name="idxPath">path corrente</param>
|
||||
/// <param name="currStrobe">Byte di strobe del path corrente</param>
|
||||
/// <param name="currAck">Byte di strobe del path corrente</param>
|
||||
/// <param name="memIndexMST">indice x lettura memoria MST del path</param>
|
||||
/// <param name="memIndexAck">indice x scrittura ACK x path</param>
|
||||
/// <param name="UserAction">stringa COMPLESSIVA azioni utente</param>
|
||||
public void procPathStrobes(int idxPath, StFlag8 currStrobe, StFlag8 currAck, int memIndexMST, int memIndexAck, ref string UserAction)
|
||||
{
|
||||
// byte di strobe e di acknowledge... inizializzo!!!
|
||||
byte[] currACK_DW = new byte[1];
|
||||
// altre variabili
|
||||
int bitNum = 0;
|
||||
inizio = DateTime.Now;
|
||||
// incomincio vera e propria gestione...
|
||||
try
|
||||
{
|
||||
// controllo TUTTI i flag: se ce ne sono di alzati DEVO processare...
|
||||
if (currStrobe != StFlag8.NONE)
|
||||
{
|
||||
// se ho un M/S/T leggo area...
|
||||
if (currStrobe.HasFlag(StFlag8.B0) || currStrobe.HasFlag(StFlag8.B1) || currStrobe.HasFlag(StFlag8.B2))
|
||||
{
|
||||
|
||||
// blocco memoria x lettura TUTTI i dati di buffer M/S/T: 26 short(16bit) x (12+7+7) aree (attenzione: secondo set di 2 bit è VUOTO...)
|
||||
ushort[] MemBlock_W = new ushort[26];
|
||||
// leggo memoria!
|
||||
readMST_data(idxPath, memIndexMST, ref MemBlock_W);
|
||||
|
||||
// converto a byte x compatibilità...
|
||||
byte[] MemBlock = new byte[MemBlock_W.Length * 2];
|
||||
Buffer.BlockCopy(MemBlock_W, 0, MemBlock, 0, MemBlock.Length);
|
||||
|
||||
// check COD_M
|
||||
bitNum = 0;
|
||||
gestStrobeCodMST(currStrobe, bitNum, ref currACK_DW, 0, MemBlock, "M", idxPath);
|
||||
|
||||
// check COD_S
|
||||
bitNum = 1;
|
||||
gestStrobeCodMST(currStrobe, bitNum, ref currACK_DW, 12, MemBlock, "S", idxPath);
|
||||
|
||||
// check COD_T
|
||||
bitNum = 2;
|
||||
gestStrobeCodMST(currStrobe, bitNum, ref currACK_DW, 19, MemBlock, "T", idxPath);
|
||||
|
||||
}
|
||||
|
||||
// check FILE DATI MODIFICATO: ricaricare...
|
||||
bitNum = 3;
|
||||
if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
|
||||
{
|
||||
lg.Info("Notifica file modificato");
|
||||
try
|
||||
{
|
||||
// reload dati da file...
|
||||
reloadDataFromFile();
|
||||
|
||||
// memorizzo allarme nel vettore ack....
|
||||
currACK_DW = utils.setBitOnStFlag(currACK_DW, true, bitNum);
|
||||
}
|
||||
catch
|
||||
{
|
||||
lg.Info("Errore lettura dati da file");
|
||||
}
|
||||
}
|
||||
|
||||
// AREA strobe USER ACTION
|
||||
// chiamato Start...
|
||||
bitNum = 4;
|
||||
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} START) ", idxPath));
|
||||
// chiamato Stop...
|
||||
bitNum = 5;
|
||||
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} STOP) ", idxPath));
|
||||
// chiamato Reset...
|
||||
bitNum = 6;
|
||||
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} RESET) ", idxPath));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// inizializzo 4 byte a zero!!!
|
||||
currACK_DW = new byte[1];
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error(string.Format("Errore in strobe:{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
|
||||
// scrivo update ad ack SE VARIATO!!!
|
||||
if (currAck != (StFlag8)currACK_DW[0])
|
||||
{
|
||||
writeMST_ACK(memIndexAck, ref currACK_DW);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Legge area memoria dati MST
|
||||
/// </summary>
|
||||
/// <param name="idxPath"></param>
|
||||
/// <param name="memIndexMST"></param>
|
||||
/// <param name="MemBlock_W"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool readMST_data(int idxPath, int memIndexMST, ref ushort[] MemBlock_W)
|
||||
{
|
||||
bool fatto = false;
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Scrive ACK x dati MST
|
||||
/// </summary>
|
||||
/// <param name="idxPath"></param>
|
||||
/// <param name="memIndexMST"></param>
|
||||
/// <param name="MemBlock_W"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool writeMST_ACK(int memIndexAck, ref byte[] currACK_DW)
|
||||
{
|
||||
bool fatto = false;
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// processo il vettore LOCALE degli allarmi
|
||||
|
||||
@@ -307,8 +307,6 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
public override void processStrobe()
|
||||
{
|
||||
base.processStrobe();
|
||||
|
||||
// inizializzo userAction
|
||||
string UserAction = "";
|
||||
// oggetti "accessori" x processing (1 byte di strobe x ogni path)
|
||||
@@ -343,6 +341,7 @@ namespace MTC_Adapter
|
||||
// gestione bit di watchdog... sulal DWord successiva
|
||||
sendWatchDog();
|
||||
}
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Processa strobe x un dato path
|
||||
/// </summary>
|
||||
@@ -444,7 +443,8 @@ namespace MTC_Adapter
|
||||
OsaiMemRW_Byte(W, OSAI.MemTypeWord.MW_CODE, memIndexAck, 0, ref currACK_DW);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-ACK_DW0", currACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Verifica strobe autotest
|
||||
/// </summary>
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
protected int baseMemUO = 254;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// wrapper chiamata lettura/scrittura SINGOLO BYTE...
|
||||
/// </summary>
|
||||
@@ -150,6 +151,7 @@ namespace MTC_Adapter
|
||||
tryConnect();
|
||||
lg.Info("End init Adapter SIEMENS");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override disconnessione
|
||||
/// </summary>
|
||||
@@ -259,8 +261,6 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
public override void processStrobe()
|
||||
{
|
||||
base.processStrobe();
|
||||
|
||||
// inizializzo userAction
|
||||
string UserAction = "";
|
||||
// oggetti "accessori" x processing (1 byte di strobe x ogni path)
|
||||
@@ -296,107 +296,53 @@ namespace MTC_Adapter
|
||||
sendWatchDog();
|
||||
}
|
||||
/// <summary>
|
||||
/// Processa strobe x un dato path
|
||||
/// Scrive ACK x dati MST
|
||||
/// </summary>
|
||||
/// <param name="idxPath">path corrente</param>
|
||||
/// <param name="currStrobe">Byte di strobe del path corrente</param>
|
||||
/// <param name="currAck">Byte di strobe del path corrente</param>
|
||||
/// <param name="memIndexMST">indice x lettura memoria MST del path</param>
|
||||
/// <param name="memIndexAck">indice x scrittura ACK x path</param>
|
||||
/// <param name="UserAction">stringa COMPLESSIVA azioni utente</param>
|
||||
private void procPathStrobes(int idxPath, StFlag8 currStrobe, StFlag8 currAck, int memIndexMST, int memIndexAck, ref string UserAction)
|
||||
/// <param name="idxPath"></param>
|
||||
/// <param name="memIndexMST"></param>
|
||||
/// <param name="MemBlock_W"></param>
|
||||
/// <returns></returns>
|
||||
public override bool writeMST_ACK(int memIndexAck, ref byte[] currACK_DW)
|
||||
{
|
||||
// byte di strobe e di acknowledge... inizializzo!!!
|
||||
byte[] currACK_DW = new byte[1];
|
||||
// altre variabili
|
||||
int bitNum = 0;
|
||||
inizio = DateTime.Now;
|
||||
// incomincio vera e propria gestione...
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
// controllo TUTTI i flag: se ce ne sono di alzati DEVO processare...
|
||||
if (currStrobe != StFlag8.NONE)
|
||||
{
|
||||
// se ho un M/S/T leggo area...
|
||||
if (currStrobe.HasFlag(StFlag8.B0) || currStrobe.HasFlag(StFlag8.B1) || currStrobe.HasFlag(StFlag8.B2))
|
||||
{
|
||||
|
||||
// blocco memoria x lettura TUTTI i dati di buffer M/S/T: 26 short(16bit) x (12+7+7) aree (attenzione: secondo set di 2 bit è VUOTO...)
|
||||
ushort[] MemBlock_W = new ushort[26];
|
||||
|
||||
// leggo tutto!!!
|
||||
inizio = DateTime.Now;
|
||||
SIEMENSMemRW_Word(R, baseMemDb, memIndexMST, ref MemBlock_W);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-STRB_DW1-P{1:00}", MemBlock_W.Length, idxPath), DateTime.Now.Subtract(inizio).Ticks);
|
||||
|
||||
// converto a byte x compatibilità...
|
||||
byte[] MemBlock = new byte[MemBlock_W.Length * 2];
|
||||
Buffer.BlockCopy(MemBlock_W, 0, MemBlock, 0, MemBlock.Length);
|
||||
|
||||
// check COD_M
|
||||
bitNum = 0;
|
||||
gestStrobeCodMST(currStrobe, bitNum, ref currACK_DW, 0, MemBlock, "M", idxPath);
|
||||
|
||||
// check COD_S
|
||||
bitNum = 1;
|
||||
gestStrobeCodMST(currStrobe, bitNum, ref currACK_DW, 12, MemBlock, "S", idxPath);
|
||||
|
||||
// check COD_T
|
||||
bitNum = 2;
|
||||
gestStrobeCodMST(currStrobe, bitNum, ref currACK_DW, 19, MemBlock, "T", idxPath);
|
||||
|
||||
}
|
||||
|
||||
// check FILE DATI MODIFICATO: ricaricare...
|
||||
bitNum = 3;
|
||||
if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
|
||||
{
|
||||
lg.Info("Notifica file modificato");
|
||||
try
|
||||
{
|
||||
// reload dati da file...
|
||||
reloadDataFromFile();
|
||||
|
||||
// memorizzo allarme nel vettore ack....
|
||||
currACK_DW = utils.setBitOnStFlag(currACK_DW, true, bitNum);
|
||||
}
|
||||
catch
|
||||
{
|
||||
lg.Info("Errore lettura dati da file");
|
||||
}
|
||||
}
|
||||
|
||||
// AREA strobe USER ACTION
|
||||
// chiamato Start...
|
||||
bitNum = 4;
|
||||
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} START) ", idxPath));
|
||||
// chiamato Stop...
|
||||
bitNum = 5;
|
||||
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} STOP) ", idxPath));
|
||||
// chiamato Reset...
|
||||
bitNum = 6;
|
||||
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} RESET) ", idxPath));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// inizializzo 4 byte a zero!!!
|
||||
currACK_DW = new byte[1];
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error(string.Format("Errore in strobe:{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
|
||||
// scrivo update ad ack SE VARIATO!!!
|
||||
if (currAck != (StFlag8)currACK_DW[0])
|
||||
{
|
||||
inizio = DateTime.Now;
|
||||
SIEMENSMemRW_Byte(W, baseMemDb, memIndexAck, ref currACK_DW);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-ACK_DW0", currACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error(string.Format("Errore in scrittura dati ACK MST:{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Legge area memoria dati MST
|
||||
/// </summary>
|
||||
/// <param name="idxPath"></param>
|
||||
/// <param name="memIndexMST"></param>
|
||||
/// <param name="MemBlock_W"></param>
|
||||
/// <returns></returns>
|
||||
public override bool readMST_data(int idxPath, int memIndexMST, ref ushort[] MemBlock_W)
|
||||
{
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
// leggo tutto!!!
|
||||
inizio = DateTime.Now;
|
||||
SIEMENSMemRW_Word(R, baseMemDb, memIndexMST, ref MemBlock_W);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-STRB_DW1-P{1:00}", MemBlock_W.Length, idxPath), DateTime.Now.Subtract(inizio).Ticks);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error(string.Format("Errore in lettura dati MST:{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica strobe autotest
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user