maybe fix x status bloccato solo con contapezzi

This commit is contained in:
Samuele E. Locatelli
2020-10-21 18:52:23 +02:00
parent 15d4cc2af5
commit 32f855307d
2 changed files with 81 additions and 68 deletions
+80 -67
View File
@@ -531,85 +531,96 @@ namespace IOB_WIN
{
if (utils.CRB("enableContapezzi"))
{
// controllo se sono in sampling della produzione
if (actLevel >= Eurom63.ComLevel.ProdRequested)
try
{
/************************************************************
*
* EXAMPLE
* DATE, TIME, ActCntCyc, ActTimCyc, ActTimFill, @OutXhour, SetDescJob
* 20201007, 21:29:52, 5302, 8.61, 0.50, 10058, Nr. 1000987654.01
*
* devo prendere il 3° valore
*
*
************************************************************/
// leggo il file della produzione HARD CODED...
var sessProd = confE63.ActiveSessions[5];
string currPzCount = "";
if (sessProd != null)
// controllo se sono in sampling della produzione
if (actLevel >= Eurom63.ComLevel.ProdRequested)
{
if (sessProd.Active)
{
// nome file...
string fileName = $"{BaseDir}\\{sessProd.SessionName}.DAT";
if (File.Exists(fileName))
{
string rawData = "";
using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var textReader = new StreamReader(fileStream))
{
rawData = textReader.ReadToEnd();
}
// ora splitto in linee
string[] rawLines = Regex.Split(rawData, "\r\n|\r|\n");
int numRow = rawLines.Length;
/************************************************************
*
* EXAMPLE
* DATE, TIME, ActCntCyc, ActTimCyc, ActTimFill, @OutXhour, SetDescJob
* 20201007, 21:29:52, 5302, 8.61, 0.50, 10058, Nr. 1000987654.01
*
* devo prendere il 3° valore
*
*
************************************************************/
// devo avere almeno 2 righe...
if (numRow >= 2)
// leggo il file della produzione HARD CODED...
var sessProd = confE63.ActiveSessions[5];
string currPzCount = "";
if (sessProd != null)
{
if (sessProd.Active)
{
// nome file...
string fileName = $"{BaseDir}\\{sessProd.SessionName}.DAT";
if (File.Exists(fileName))
{
string[] statusData = rawLines[1].Split(',');
currPzCount = statusData[2].Trim();
// salvo se valido
if (!string.IsNullOrEmpty(currPzCount))
string rawData = "";
using (var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var textReader = new StreamReader(fileStream))
{
int newVal = -1;
Int32.TryParse(currPzCount, out newVal);
// verifico SE il contapezzi vada moltiplicato x il fattore pzPallet...
if (confE63.PzPallet > 1)
rawData = textReader.ReadToEnd();
}
// ora splitto in linee
string[] rawLines = Regex.Split(rawData, "\r\n|\r|\n");
int numRow = rawLines.Length;
// devo avere almeno 2 righe...
if (numRow >= 2)
{
string[] statusData = rawLines[1].Split(',');
currPzCount = statusData[2].Trim();
// salvo se valido
if (!string.IsNullOrEmpty(currPzCount))
{
newVal = newVal * confE63.PzPallet;
int newVal = -1;
Int32.TryParse(currPzCount, out newVal);
// verifico SE il contapezzi vada moltiplicato x il fattore pzPallet...
if (confE63.PzPallet > 1)
{
newVal = newVal * confE63.PzPallet;
}
// aggiorno contapezzi
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
}
// ora verifico SE siano validi anche le dataora dei valori letti (< 20 sec ritardo da ora...)
string data = statusData[0].Trim();
string ora = statusData[1].Trim();
DateTime adesso = DateTime.Now;
DateTime lastPub = adesso.AddMinutes(-1);
CultureInfo provider = CultureInfo.InvariantCulture;
try
{
lastPub = DateTime.ParseExact($"{data} {ora}", "yyyyMMdd HH:mm:ss", provider);
}
catch
{ }
if (Math.Abs(lastPub.Subtract(adesso).TotalSeconds) > maxDelaySec)
{
sessProd.SessionValidUntil = adesso;
// elimino file RSP...
cleanupResp(sessProd.SessionName);
}
// aggiorno contapezzi
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
}
// ora verifico SE siano validi anche le dataora dei valori letti (< 20 sec ritardo da ora...)
string data = statusData[0].Trim();
string ora = statusData[1].Trim();
DateTime adesso = DateTime.Now;
DateTime lastPub = adesso.AddMinutes(-1);
CultureInfo provider = CultureInfo.InvariantCulture;
try
{
lastPub = DateTime.ParseExact($"{data} {ora}", "yyyyMMdd HH:mm:ss", provider);
}
catch
{ }
if (Math.Abs(lastPub.Subtract(adesso).TotalSeconds) > maxDelaySec)
{
sessProd.SessionValidUntil = adesso;
// elimino file RSP...
cleanupResp(sessProd.SessionName);
}
}
}
else
{
actLevel = Eurom63.ComLevel.StatusRequested;
}
}
else
{
actLevel = Eurom63.ComLevel.StatusRequested;
}
}
else
{
actLevel = Eurom63.ComLevel.StatusRequested;
}
}
catch (Exception exc)
{
lgError($"Eccezione in processContapezzi:{Environment.NewLine}{exc}");
}
}
}
@@ -768,6 +779,8 @@ namespace IOB_WIN
{
currStatus = Last_CurrStatus.Value;
}
// abbasso status...
actLevel--;
}
}
else
Vendored
+1 -1
View File
@@ -9,7 +9,7 @@ pipeline {
steps {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=738']) {
withEnv(['NEXT_BUILD_NUMBER=739']) {
// env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '3.3.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO-IOB-WIN'