spostata chiamata watchdog in adapterGeneric + gestione memoria specifica su ogni adapter tipizzato...
This commit is contained in:
@@ -344,34 +344,18 @@ namespace MTC_Adapter
|
||||
|
||||
sendWatchDog();
|
||||
}
|
||||
/// <summary>
|
||||
/// Invia (se necessario) il watchdog di stato in vita... blink 0/1 ogni secondo
|
||||
/// </summary>
|
||||
private void sendWatchDog()
|
||||
{
|
||||
int memIndex = 0;
|
||||
bool setFlag = false;
|
||||
byte[] retACK_DW = new byte[4];
|
||||
// 2016.10.18 aggiungo scrittura del bit di "watchdog" al primo bit della DW2... come resto tra secondi / 2
|
||||
if (utils.CRB("sendWatchDog"))
|
||||
{
|
||||
int resto = 0;
|
||||
Math.DivRem(DateTime.Now.Second, 2, out resto);
|
||||
setFlag = resto == 0;
|
||||
// se watchdog è cambiato lo invio, altrimenti lascio come è...
|
||||
if (setFlag != lastWatchDog)
|
||||
{
|
||||
lastWatchDog = setFlag;
|
||||
retACK_DW = utils.setBitOnStFlag(retACK_DW, setFlag, 0); // imposto primo bit!!!
|
||||
// scrivo su area PLC
|
||||
memIndex = 10508;
|
||||
inizio = DateTime.Now;
|
||||
FanucMemRW(W, FANUC.MemType.R, memIndex, ref retACK_DW);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-WatchDog", retACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrive watchdog
|
||||
/// </summary>
|
||||
/// <param name="retACK_DW"></param>
|
||||
/// <returns></returns>
|
||||
public override bool writeWatchDog(ref byte[] retACK_DW)
|
||||
{
|
||||
int memIndex = 10508;
|
||||
return FanucMemRW(W, FANUC.MemType.R, memIndex, ref retACK_DW);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info su test: numero + elenco parametri IN/OUT
|
||||
/// </summary>
|
||||
@@ -763,7 +747,7 @@ namespace MTC_Adapter
|
||||
uint[] tabDatiAnalog = new uint[analogData.Length];
|
||||
inizio = DateTime.Now;
|
||||
FanucMemRW(R, FANUC.MemType.R, memIndex, ref tabDatiAnalogByte);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiAnalog", tabDatiAnalogByte.Length*4), DateTime.Now.Subtract(inizio).Ticks);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiAnalog", tabDatiAnalogByte.Length * 4), DateTime.Now.Subtract(inizio).Ticks);
|
||||
// copio byte --> word!
|
||||
Buffer.BlockCopy(tabDatiAnalogByte, 0, tabDatiAnalog, 0, tabDatiAnalogByte.Length);
|
||||
// decodifico aree memoria secondo tab configurazione
|
||||
@@ -945,7 +929,7 @@ namespace MTC_Adapter
|
||||
inizio = DateTime.Now;
|
||||
FanucMemRW(R, FANUC.MemType.D, memIndex, ref unOpSpeedMem);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-SPEED_UNOP", unOpSpeedMem.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
|
||||
|
||||
procUnOp(unOpSpeedMem);
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -2140,6 +2140,7 @@ namespace MTC_Adapter
|
||||
|
||||
inizio = DateTime.Now;
|
||||
uint[] MemBlock;
|
||||
// !!! FARE verifica se convenga leggere SEMPRE 128 byte allarmi x avere MENO letture (in caso di concorrenza...) --> decidere post test SIEMENS, OSAI sembrerebbe giustificarlo...
|
||||
// controllo, SE devo leggere tutto uso un unico accesso ai 128byte, altrimenti leggo a blocchi di 32bit...
|
||||
if (Alarm2Refresh == (StFlag32)unchecked((int)UInt32.MaxValue))
|
||||
{
|
||||
@@ -2251,6 +2252,47 @@ namespace MTC_Adapter
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione altri strobe/ack
|
||||
|
||||
/// <summary>
|
||||
/// Invia (se necessario) il watchdog di stato in vita... blink 0/1 ogni secondo
|
||||
/// </summary>
|
||||
public void sendWatchDog()
|
||||
{
|
||||
bool setFlag = false;
|
||||
byte[] retACK_DW = new byte[1];
|
||||
// 2016.10.18 aggiungo scrittura del bit di "watchdog" al primo bit della DW2... come resto tra secondi / 2
|
||||
if (utils.CRB("sendWatchDog"))
|
||||
{
|
||||
int resto = 0;
|
||||
Math.DivRem(DateTime.Now.Second, 2, out resto);
|
||||
setFlag = resto == 0;
|
||||
// se watchdog è cambiato lo invio, altrimenti lascio come è...
|
||||
if (setFlag != lastWatchDog)
|
||||
{
|
||||
lastWatchDog = setFlag;
|
||||
retACK_DW = utils.setBitOnStFlag(retACK_DW, setFlag, 0); // imposto primo bit!!!
|
||||
// scrivo su area PLC
|
||||
inizio = DateTime.Now;
|
||||
writeWatchDog(ref retACK_DW);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-WatchDog", retACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Scrive watchdog
|
||||
/// </summary>
|
||||
/// <param name="retACK_DW"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool writeWatchDog(ref byte[] retACK_DW)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// recupero dati PATH
|
||||
/// </summary>
|
||||
|
||||
@@ -491,33 +491,18 @@ namespace MTC_Adapter
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-ACK_DW0", currACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invia (se necessario) il watchdog di stato in vita... blink 0/1 ogni secondo
|
||||
/// Scrive watchdog
|
||||
/// </summary>
|
||||
private void sendWatchDog()
|
||||
/// <param name="retACK_DW"></param>
|
||||
/// <returns></returns>
|
||||
public override bool writeWatchDog(ref byte[] retACK_DW)
|
||||
{
|
||||
int memIndex = 0;
|
||||
bool setFlag = false;
|
||||
byte[] retACK_DW = new byte[1];
|
||||
// 2016.10.18 aggiungo scrittura del bit di "watchdog" al primo bit della DW2... come resto tra secondi / 2
|
||||
if (utils.CRB("sendWatchDog"))
|
||||
{
|
||||
int resto = 0;
|
||||
Math.DivRem(DateTime.Now.Second, 2, out resto);
|
||||
setFlag = resto == 0;
|
||||
// se watchdog è cambiato lo invio, altrimenti lascio come è...
|
||||
if (setFlag != lastWatchDog)
|
||||
{
|
||||
lastWatchDog = setFlag;
|
||||
retACK_DW = utils.setBitOnStFlag(retACK_DW, setFlag, 0); // imposto primo bit!!!
|
||||
// scrivo su area PLC
|
||||
memIndex = 19022;
|
||||
inizio = DateTime.Now;
|
||||
OsaiMemRW_Byte(W, OSAI.MemTypeWord.MW_CODE, memIndex, 0, ref retACK_DW);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-WatchDog", retACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
}
|
||||
}
|
||||
int memIndex = 19022;
|
||||
return OsaiMemRW_Byte(W, OSAI.MemTypeWord.MW_CODE, memIndex, 0, ref retACK_DW);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info su test: numero + elenco parametri IN/OUT
|
||||
/// </summary>
|
||||
|
||||
@@ -444,31 +444,14 @@ namespace MTC_Adapter
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Invia (se necessario) il watchdog di stato in vita... blink 0/1 ogni secondo
|
||||
/// Scrive watchdog
|
||||
/// </summary>
|
||||
private void sendWatchDog()
|
||||
/// <param name="retACK_DW"></param>
|
||||
/// <returns></returns>
|
||||
public override bool writeWatchDog(ref byte[] retACK_DW)
|
||||
{
|
||||
int memIndex = 0;
|
||||
bool setFlag = false;
|
||||
byte[] retACK_DW = new byte[1];
|
||||
// 2016.10.18 aggiungo scrittura del bit di "watchdog" al primo bit della DW2... come resto tra secondi / 2
|
||||
if (utils.CRB("sendWatchDog"))
|
||||
{
|
||||
int resto = 0;
|
||||
Math.DivRem(DateTime.Now.Second, 2, out resto);
|
||||
setFlag = resto == 0;
|
||||
// se watchdog è cambiato lo invio, altrimenti lascio come è...
|
||||
if (setFlag != lastWatchDog)
|
||||
{
|
||||
lastWatchDog = setFlag;
|
||||
retACK_DW = utils.setBitOnStFlag(retACK_DW, setFlag, 0); // imposto primo bit!!!
|
||||
// scrivo su area PLC
|
||||
memIndex = 38;
|
||||
inizio = DateTime.Now;
|
||||
SIEMENSMemRW_Byte(W, baseMemDb, memIndex, ref retACK_DW);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-WatchDog", retACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
}
|
||||
}
|
||||
int memIndex = 38;
|
||||
return SIEMENSMemRW_Byte(W, baseMemDb, memIndex, ref retACK_DW);
|
||||
}
|
||||
/// <summary>
|
||||
/// Recupero info su test: numero + elenco parametri IN/OUT
|
||||
@@ -495,7 +478,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!
|
||||
@@ -547,7 +530,7 @@ namespace MTC_Adapter
|
||||
int memIndex = 118;
|
||||
return SIEMENSMemRW_DWord(R, baseMemDb, memIndex + blockIndex * 2, ref MemBlock);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// processing!
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user