Accorpati metodi x gestione accodamento IN e FLog
This commit is contained in:
+3
-2
@@ -23,9 +23,10 @@
|
||||
<add key="verySlowCount" value="1000" />
|
||||
<add key="sampleMemCount" value="6000" />
|
||||
<add key="waitEndCycle" value="0" />
|
||||
<!-- watchdog -->
|
||||
<!-- watchdog, ping, check disconnesso -->
|
||||
<add key="pingTestSec" value="5" />
|
||||
<add key="watchdogMaxSec" value="59" />
|
||||
<add key="watchdogMaxSec" value="8" />
|
||||
<add key="disconMaxSec" value="4" />
|
||||
<!--Modalità DEMO: DemoOUT indica che NON invia davvero al server e DemoIN che simula e NON legge da PLC-->
|
||||
<add key="DemoIn" value="false" />
|
||||
<add key="DemoInSample" value="false" />
|
||||
|
||||
+5
-1
@@ -423,10 +423,14 @@ namespace IOB_WIN
|
||||
string descrMode = Enum.GetName(typeof(CNC_MODE), currMode);
|
||||
// accodo x invio
|
||||
string sVal = string.Format("[CNC_MODE]{0}", descrMode);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("CNC_MODE", descrMode));
|
||||
#if false
|
||||
displayOtherData(sVal);
|
||||
QueueFLog.Enqueue(qEncodeFLog("CNC_MODE", descrMode));
|
||||
// log nuovo MODE
|
||||
lg.Info("CNC_MODE: " + descrMode);
|
||||
lg.Info("CNC_MODE: " + descrMode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
+180
-122
@@ -46,6 +46,10 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
public static Logger lg;
|
||||
/// <summary>
|
||||
/// ULtimo valore inviato (in caso di disconnessione lo reinvia x garantire watchdog...)
|
||||
/// </summary>
|
||||
public string lastSignInVal = "";
|
||||
/// <summary>
|
||||
/// dataOra ultimo log periodico...
|
||||
/// </summary>
|
||||
public DateTime lastPeriodicLog;
|
||||
@@ -54,6 +58,10 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
public DateTime lastWatchDog;
|
||||
/// <summary>
|
||||
/// dataOra ultima verifica CNC disconnesso...
|
||||
/// </summary>
|
||||
public DateTime lastDisconnCheck;
|
||||
/// <summary>
|
||||
/// dataOra ultimo PING inviato...
|
||||
/// </summary>
|
||||
public DateTime lastPING;
|
||||
@@ -343,6 +351,7 @@ namespace IOB_WIN
|
||||
dtAvvioAdp = DateTime.Now;
|
||||
lastWatchDog = dtAvvioAdp;
|
||||
lastPING = dtAvvioAdp;
|
||||
lastDisconnCheck = dtAvvioAdp;
|
||||
TimingData.resetData();
|
||||
// aggiungo altri defaults
|
||||
setDefaults();
|
||||
@@ -1221,8 +1230,10 @@ namespace IOB_WIN
|
||||
// SE ho qualcosa in coda...
|
||||
if (QueueIN.Count > 0)
|
||||
{
|
||||
// recupero ed aggiorno ULTIMO valore...
|
||||
lastSignInVal = QueueIN.Dequeue();
|
||||
// INVIO!!!
|
||||
sendToMoonPro(urlType.SignIN, QueueIN.Dequeue());
|
||||
sendToMoonPro(urlType.SignIN, lastSignInVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1238,6 +1249,7 @@ namespace IOB_WIN
|
||||
parentForm.sOUT = Semaforo.SR;
|
||||
}
|
||||
}
|
||||
//controllo se è passato oltre watchdog e non ho inviato nulla --> RE-INVIO (ultimo inviato)!!!!
|
||||
}
|
||||
/// <summary>
|
||||
/// Processo la coda FLog...
|
||||
@@ -1276,6 +1288,12 @@ namespace IOB_WIN
|
||||
parentForm.sOUT = Semaforo.SR;
|
||||
}
|
||||
}
|
||||
// ...controllo se è passato oltre watchdog e non ho inviato nulla --> INVIO!!!!
|
||||
if (DateTime.Now.Subtract(lastWatchDog).TotalSeconds > utils.CRI("watchdogMaxSec"))
|
||||
{
|
||||
// se ultimo valore è coerente...
|
||||
if (lastSignInVal != "") sendToMoonPro(urlType.SignIN, lastSignInVal);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Classe fittizia in caso di processing GLOBALE di tutto in 1 solo colpo...
|
||||
@@ -1291,15 +1309,7 @@ namespace IOB_WIN
|
||||
// effettuo confronto valori vecchi/nuovi... SE trovo variazione
|
||||
if (B_output != B_previous)
|
||||
{
|
||||
// mostro dati variati letti...
|
||||
displayInData();
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueIN.Enqueue(qEncodeIN);
|
||||
nReadFilt++;
|
||||
// Gestione counter SignIn!
|
||||
counterSigIN++;
|
||||
// se supera 10k resetto...
|
||||
if (counterSigIN > 9999) counterSigIN = 0;
|
||||
accodaSigIN();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1310,20 +1320,11 @@ namespace IOB_WIN
|
||||
// sono disconensso... x prima cosa RESETTO A ZERO VALORI...
|
||||
RawInput = new byte[6];
|
||||
// controllo contatore invio "keepalive"... invio solo a scadenza
|
||||
if (DateTime.Now.Subtract(lastWatchDog).TotalSeconds > utils.CRI("watchdogMaxSec"))
|
||||
if (DateTime.Now.Subtract(lastDisconnCheck).TotalSeconds > utils.CRI("disconMaxSec"))
|
||||
{
|
||||
// accodo nuovo valore
|
||||
// invio POWEROFF... è ZERO valore IN --> accodo (valore già formattato)!
|
||||
QueueIN.Enqueue(qEncodeIN);
|
||||
// aggiorno counters
|
||||
nReadFilt++;
|
||||
if (nReadFilt > int.MaxValue - 1) nReadFilt = 0; // per evitare buffer overflow...
|
||||
counterSigIN++;
|
||||
if (counterSigIN > 9999) counterSigIN = 0; // se supera 10k resetto...
|
||||
// update display
|
||||
displayInData();
|
||||
//// invio svuotando...
|
||||
//svuotaCodaSignIN();
|
||||
accodaSigIN();
|
||||
// update controllo
|
||||
lastDisconnCheck = DateTime.Now;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -1393,49 +1394,7 @@ namespace IOB_WIN
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce il valore letto da BITMAP in formato valido x messa in coda nel formato dtEve#value#cont
|
||||
/// </summary>
|
||||
protected string qEncodeIN
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format("{0:yyyyMMddHHmmssfff}#{1:X2}#{2}", DateTime.Now, (int)B_output, counterSigIN);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce il valore di flusso e valore in formato valido x messa in coda nel formato dtEve#flux#value#cont
|
||||
/// </summary>
|
||||
public string qEncodeFLog(string flusso, string valore)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format("{0:yyyyMMddHHmmssfff}#{1}#{2}#{3}", DateTime.Now, flusso, valore, counterFLog);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodifica valore della coda IN nel formato
|
||||
/// answ[0]=dtEve
|
||||
/// answ[1]=valore
|
||||
/// answ[2]=counter
|
||||
/// </summary>
|
||||
/// <param name="queueVal">dtEve + '#' + value + '#' + cont</param>
|
||||
/// <returns></returns>
|
||||
protected string[] qDecodeIN(string queueVal)
|
||||
{
|
||||
return queueVal.Split('#');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura dati
|
||||
/// </summary>
|
||||
@@ -1483,13 +1442,18 @@ namespace IOB_WIN
|
||||
// salvo!
|
||||
lastPrgName = currPrgName;
|
||||
string sVal = string.Format("[PROG]{0}", currPrgName);
|
||||
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("PROG", currPrgName));
|
||||
#if false
|
||||
displayOtherData(sVal);
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueFLog.Enqueue(qEncodeFLog("PROG", currPrgName));
|
||||
// Gestione counter FLog!
|
||||
counterFLog++;
|
||||
// se supera 10k resetto...
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1517,13 +1481,17 @@ namespace IOB_WIN
|
||||
foreach (var item in currSysInfo)
|
||||
{
|
||||
sVal = string.Format("[SYSINFO]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
#if false
|
||||
displayOtherData(sVal);
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueFLog.Enqueue(qEncodeFLog(item.Key, item.Value));
|
||||
// Gestione counter FLog!
|
||||
counterFLog++;
|
||||
// se supera 10k resetto...
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1567,57 +1535,7 @@ namespace IOB_WIN
|
||||
public virtual void readSemafori()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua invio a MoonPro del valore richiesto
|
||||
/// </summary>
|
||||
/// <param name="tipoUrl"></param>
|
||||
/// <param name="queueVal">Valore da trasmettere: es
|
||||
/// INPUT: lo status rilevato in HEX
|
||||
/// FLog: il valore da trasmettere per il flusso indicato</param>
|
||||
public void sendToMoonPro(urlType tipoUrl, string queueVal)
|
||||
{
|
||||
// recupero e formatto URL dati da coda...
|
||||
switch (tipoUrl)
|
||||
{
|
||||
case urlType.FLog:
|
||||
lastUrl = urlFLog(queueVal);
|
||||
break;
|
||||
case urlType.SignIN:
|
||||
lastUrl = urlInput(queueVal);
|
||||
break;
|
||||
default:
|
||||
lastUrl = "";
|
||||
break;
|
||||
}
|
||||
// se NON sono in demo effettuo invio!
|
||||
if (!DemoOut)
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = callUrl(lastUrl);
|
||||
// loggo!
|
||||
lg.Info(string.Format("{0} -> {1}", queueVal, answ));
|
||||
// se "OK" verde, altrimenti errore --> ROSSO
|
||||
if (answ == "OK")
|
||||
{
|
||||
parentForm.sOUT = Semaforo.SV;
|
||||
}
|
||||
else
|
||||
{
|
||||
parentForm.sOUT = Semaforo.SR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parentForm.sOUT = Semaforo.SV;
|
||||
// loggo!
|
||||
lg.Info(string.Format("{0} -> [SIM]", queueVal));
|
||||
}
|
||||
nSendOut++;
|
||||
// riporto cosa inviato
|
||||
displayOutData();
|
||||
// aggiorno data ultimo watchdog...
|
||||
lastWatchDog = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing contapezzi (ed eventualmente alza il bit di contapezzo...)
|
||||
/// </summary>
|
||||
@@ -1652,13 +1570,17 @@ namespace IOB_WIN
|
||||
foreach (var item in currDynData)
|
||||
{
|
||||
sVal = string.Format("[DYNDATA]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
#if false
|
||||
displayOtherData(sVal);
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueFLog.Enqueue(qEncodeFLog(item.Key, item.Value));
|
||||
// Gestione counter FLog!
|
||||
counterFLog++;
|
||||
// se supera 10k resetto...
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1690,13 +1612,17 @@ namespace IOB_WIN
|
||||
foreach (var item in currOverride)
|
||||
{
|
||||
sVal = string.Format("[OVERRIDES]{0}|{1}", item.Key, item.Value);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog(item.Key, item.Value));
|
||||
#if false
|
||||
displayOtherData(sVal);
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueFLog.Enqueue(qEncodeFLog(item.Key, item.Value));
|
||||
// Gestione counter FLog!
|
||||
counterFLog++;
|
||||
// se supera 10k resetto...
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1716,7 +1642,139 @@ namespace IOB_WIN
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione dataMonitor (accodamento valori)
|
||||
#region gestione code (accumulo, invio)
|
||||
|
||||
/// <summary>
|
||||
/// Fornisce il valore letto da BITMAP in formato valido x messa in coda nel formato dtEve#value#cont
|
||||
/// </summary>
|
||||
protected string qEncodeIN
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format("{0:yyyyMMddHHmmssfff}#{1:X2}#{2}", DateTime.Now, (int)B_output, counterSigIN);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Fornisce il valore di flusso e valore in formato valido x messa in coda nel formato dtEve#flux#value#cont
|
||||
/// </summary>
|
||||
public string qEncodeFLog(string flusso, string valore)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format("{0:yyyyMMddHHmmssfff}#{1}#{2}#{3}", DateTime.Now, flusso, valore, counterFLog);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodifica valore della coda IN nel formato
|
||||
/// answ[0]=dtEve
|
||||
/// answ[1]=valore
|
||||
/// answ[2]=counter
|
||||
/// </summary>
|
||||
/// <param name="queueVal">dtEve + '#' + value + '#' + cont</param>
|
||||
/// <returns></returns>
|
||||
protected string[] qDecodeIN(string queueVal)
|
||||
{
|
||||
return queueVal.Split('#');
|
||||
}
|
||||
/// <summary>
|
||||
/// Accumula in coda i valori Signal IN e logga...
|
||||
/// </summary>
|
||||
public void accodaSigIN()
|
||||
{
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueIN.Enqueue(qEncodeIN);
|
||||
// loggo!
|
||||
lg.Info(string.Format("[QUEUE-IN] {0}", qEncodeIN));
|
||||
// aggiorno counters ed eventuale reset
|
||||
nReadFilt++;
|
||||
if (nReadFilt > int.MaxValue - 1) nReadFilt = 0; // per evitare buffer overflow...
|
||||
counterSigIN++;
|
||||
if (counterSigIN > 9999) counterSigIN = 0;
|
||||
// mostro dati variati letti...
|
||||
displayInData();
|
||||
}
|
||||
/// <summary>
|
||||
/// Accumula in coda i valori Signal IN e logga...
|
||||
/// </summary>
|
||||
/// <param name="val">VALORE RAW (x display)</param>
|
||||
/// <param name="encodedVal">VALORE già processato con qEncodeFLog(...)</param>
|
||||
public void accodaFLog(string val, string encodedVal)
|
||||
{
|
||||
// mostro dati variati letti...
|
||||
displayOtherData(val);
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueFLog.Enqueue(encodedVal);
|
||||
// loggo!
|
||||
lg.Info(string.Format("[QUEUE-FLOG] {0}", encodedVal));
|
||||
counterFLog++;
|
||||
if (counterFLog > 9999) counterFLog = 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua invio a MoonPro del valore richiesto
|
||||
/// </summary>
|
||||
/// <param name="tipoUrl"></param>
|
||||
/// <param name="queueVal">Valore da trasmettere: es
|
||||
/// INPUT: lo status rilevato in HEX
|
||||
/// FLog: il valore da trasmettere per il flusso indicato</param>
|
||||
public void sendToMoonPro(urlType tipoUrl, string queueVal)
|
||||
{
|
||||
// recupero e formatto URL dati da coda...
|
||||
switch (tipoUrl)
|
||||
{
|
||||
case urlType.FLog:
|
||||
lastUrl = urlFLog(queueVal);
|
||||
break;
|
||||
case urlType.SignIN:
|
||||
lastUrl = urlInput(queueVal);
|
||||
break;
|
||||
default:
|
||||
lastUrl = "";
|
||||
break;
|
||||
}
|
||||
// se NON sono in demo effettuo invio!
|
||||
if (!DemoOut)
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = callUrl(lastUrl);
|
||||
// loggo!
|
||||
lg.Info(string.Format("[SEND] {0} -> {1}", queueVal, answ));
|
||||
// se "OK" verde, altrimenti errore --> ROSSO
|
||||
if (answ == "OK")
|
||||
{
|
||||
parentForm.sOUT = Semaforo.SV;
|
||||
}
|
||||
else
|
||||
{
|
||||
parentForm.sOUT = Semaforo.SR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parentForm.sOUT = Semaforo.SV;
|
||||
// loggo!
|
||||
lg.Info(string.Format("{0} -> [SIM]", queueVal));
|
||||
}
|
||||
nSendOut++;
|
||||
// riporto cosa inviato
|
||||
displayOutData();
|
||||
// aggiorno data ultimo watchdog...
|
||||
lastWatchDog = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione dataMonitor (update visualizzazione valori)
|
||||
|
||||
/// <summary>
|
||||
/// Mostra i dati grezzi letti in esadecimale
|
||||
|
||||
+5
-5
@@ -171,15 +171,15 @@ namespace IOB_WIN
|
||||
|
||||
#if DEBUG
|
||||
// Setup the logging view for Sentinel - http://sentinel.codeplex.com
|
||||
var sentinalTarget = new NLogViewerTarget()
|
||||
var sentinelTarget = new NLogViewerTarget()
|
||||
{
|
||||
Name = "sentinal",
|
||||
Name = "sentinel",
|
||||
Address = "udp://127.0.0.1:9999",
|
||||
IncludeNLogData = false
|
||||
};
|
||||
var sentinalRule = new LoggingRule("*", LogLevel.Trace, sentinalTarget);
|
||||
LogManager.Configuration.AddTarget("sentinal", sentinalTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(sentinalRule);
|
||||
var sentinelRule = new LoggingRule("*", LogLevel.Trace, sentinelTarget);
|
||||
LogManager.Configuration.AddTarget("sentinel", sentinelTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(sentinelRule);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ pipeline {
|
||||
|
||||
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
|
||||
script {
|
||||
withEnv(['NEXT_BUILD_NUMBER=187']) {
|
||||
withEnv(['NEXT_BUILD_NUMBER=188']) {
|
||||
// env.versionNumber = VersionNumber(versionNumberString : '1.15.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
|
||||
env.versionNumber = VersionNumber(versionNumberString : '1.15.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
|
||||
env.APP_NAME = 'MAPO-IOB-WIN'
|
||||
|
||||
Reference in New Issue
Block a user