Merge branch 'develop' into current

This commit is contained in:
Samuele E. Locatelli
2020-10-29 15:20:54 +01:00
3 changed files with 217 additions and 161 deletions
+116 -79
View File
@@ -17,6 +17,8 @@ namespace IOB_WIN
{
#region Protected Fields
protected static DateTime lastStatusDecr = DateTime.Now;
/// <summary>
/// step di comunicazione attivo
/// </summary>
@@ -87,18 +89,24 @@ namespace IOB_WIN
private void checkSessionActive(Eurom63.Session currSession, Eurom63.ComLevel nextLevel)
{
// SOLO SE ha senso che controllo (sono in sampling...)
if (actLevel > Eurom63.ComLevel.ChannelOk)
if (actLevel > Eurom63.ComLevel.HasInfo)
{
DateTime adesso = DateTime.Now;
// devono essere ATTIVE le sessioni di campionamento... e NON scadute
if (!currSession.Active || currSession.SessionValidUntil < adesso)
{
// elimino TUTTE le risposte...
cleanupResp(currSession.SessionName);
// imposto livellotornando indietro di 1 alla volta... senza andare in negativoS
actLevel = actLevel - 1;
actLevel = actLevel > 0 ? actLevel : 0;
lgInfo($"Sessione inattiva, {actLevel + 1} --> {actLevel}");
// controllo ultimo downgrade status
if (lastStatusDecr.AddSeconds(3) < adesso)
{
// elimino TUTTE le risposte...
cleanupResp(currSession.SessionName);
// registro downgrade status...
lastStatusDecr = adesso;
// imposto livellotornando indietro di 1 alla volta... senza andare in negativoS
actLevel = actLevel - 1;
actLevel = actLevel > 0 ? actLevel : 0;
lgInfo($"Sessione inattiva, {actLevel + 1} --> {actLevel}");
}
}
}
}
@@ -523,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}");
}
}
}
@@ -747,6 +766,21 @@ namespace IOB_WIN
lgError($"Lettura file stato in errore: trovate {numRow} linee");
}
}
// se valido RILEGGO ultimo curr status
if (Last_CurrStatus.ValidUntil > adesso)
{
currStatus = Last_CurrStatus.Value;
}
}
else
{
// se valido RILEGGO ultimo curr status
if (Last_CurrStatus.ValidUntil > adesso)
{
currStatus = Last_CurrStatus.Value;
}
// abbasso status...
actLevel--;
}
}
else
@@ -756,10 +790,14 @@ namespace IOB_WIN
{
currStatus = Last_CurrStatus.Value;
}
else
{
actLevel = Eurom63.ComLevel.ChannelOk;
}
}
}
else
{
// se valido RILEGGO ultimo curr status
if (Last_CurrStatus.ValidUntil > adesso)
{
currStatus = Last_CurrStatus.Value;
}
}
@@ -773,7 +811,6 @@ namespace IOB_WIN
switch (currStatus[1])
{
case 'A':
case '0':
B_input += (1 << 1);
break;
+100 -81
View File
@@ -9,21 +9,21 @@ namespace IOB_WIN
/// </summary>
public class IobSiemensSimec : IobSiemens
{
/* --------------------------------------------------------------------------------
/* --------------------------------------------------------------------------------
* Controlli SIEMENS SIMEC
* - basasto su SIEMENS
* - S7 vers 1500
*
*
* STRUTTURA MEMORIA DB29: (lettura) 10byte,
* G:\Drive condivisi\30_Clienti\Valvital\Comunicazione PLC\26 - SIMEC Taglio\
*
*
* Si intende lettura con DB29.DBxx, scrittura DB30.DBxx
*
* DB30 blocco dati scritto dal MES
* CodArt Array[0..19] of Char DBB0..19
* CodComm Array[0..9] of Char DBB20..29
* CodProgr Array[0..9] of Char DBB30..39
*
*
* DB30 blocco dati scritto dal MES
* CodArt Array[0..19] of Char DBB0..19
* CodComm Array[0..9] of Char DBB20..29
* CodProgr Array[0..9] of Char DBB30..39
*
* DB29 blocco dati letto dal MES Byte Bit
* CicloOn Bool 0 0
* MacchOn Bool 0 1
@@ -41,12 +41,14 @@ namespace IOB_WIN
* b15 Bool 1 5
* b16 Bool 1 6
* b17 Bool 1 7
* ContapezziAssoluto DInt 2
* Comtapezzi parziale DInt 6
* ContapezziAssoluto DInt 2
* Comtapezzi parziale DInt 6
* -------------------------------------------------------------------------------- */
#region Public Constructors
/// <summary>
/// Classe base con i metodi x Siemens
/// Classe base con i metodi x Siemens
/// </summary>
/// <param name="caller"></param>
/// <param name="adpConf"></param>
@@ -55,7 +57,85 @@ namespace IOB_WIN
lgInfo("NEW IOB SIEMENS versione SIMEC");
}
#region Metodi specifici (da verificare/completare in implementazione)
#endregion Public Constructors
#region Protected Methods
/// <summary>
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
/// </summary>
protected override void decodeToBaseBitmap()
{
// init a zero...
B_input = 0;
/* -----------------------------------------------------
* bitmap MAPO STANDARD
* B0: POWER_ON
* B1: RUN
* B2: pzCount
* B3: allarme
* B4: manuale
* B5: emergenza (1=attiva/premuta, 0=armed)
*
* - BIT di stato
* DB29 blocco dati letto dal MES Byte Bit
* CicloOn Bool 0 0
* MacchOn Bool 0 1
* ManualeOn Bool 0 2
* AllarmiOn Bool 0 3
* EmergenzaOn Bool 0 4
* EmergenzaPremuta Bool 0 5
* ContapezziAssoluto DInt 2
* Comtapezzi parziale DInt 6
*
----------------------------------------------------- */
byte mainData = RawInput[0];
int byteSignals = 0;
// bit 0 (poweron) imposto a 1 SE connected...
if (currPLC.IsConnected)
{
byteSignals += (1 << 0);
}
// lavora --> bit0 e bit1: cicloOn AND macchOn
if ((mainData & (1 << 0)) != 0 && (mainData & (1 << 1)) != 0)
{
byteSignals += (1 << 1);
}
// controllo il bit ALARM
if ((mainData & (1 << 3)) != 0)
{
byteSignals += (1 << 3);
}
// controllo il bit emergenza dello status
if ((mainData & (1 << 5)) != 0)
{
byteSignals += (1 << 5);
}
// check MANUALE ...
if ((mainData & (1 << 2)) != 0)
{
byteSignals += (1 << 4);
}
// salvo!
B_input = byteSignals;
// log opzionale!
if (verboseLog)
{
lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}");
}
}
#endregion Protected Methods
#region Public Methods
/// <summary>
/// Processo i task richiesti e li elimino dalla coda 1:1
@@ -92,6 +172,7 @@ namespace IOB_WIN
case taskType.setPzComm:
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
break;
case taskType.setArt:
case taskType.setComm:
saveProdData(item);
@@ -122,18 +203,21 @@ namespace IOB_WIN
}
taskVal = item.Value;
break;
case taskType.startSetup:
//// processo scrittura BIT su DB150.DBX4.0
//MemBlock = new byte[1];
//MemBlock[0] = (byte)1;
//memAddrWrite = "DB150.DBB4";
break;
case taskType.stopSetup:
//// processo scrittura BIT su DB150.DBX4.0
//MemBlock = new byte[1];
//MemBlock[0] = (byte)0;
//memAddrWrite = "DB150.DBB4";
break;
case taskType.setParameter:
// richiedo da URL i parametri WRITE da popolare
lgInfo("Chiamata processMemWriteRequests");
@@ -153,6 +237,7 @@ namespace IOB_WIN
}
}
break;
default:
taskVal = "SKIPPED | NO EXEC";
break;
@@ -173,72 +258,6 @@ namespace IOB_WIN
return taskDone;
}
/// <summary>
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
/// </summary>
protected override void decodeToBaseBitmap()
{
// init a zero...
B_input = 0;
/* -----------------------------------------------------
* bitmap MAPO STANDARD
* B0: POWER_ON
* B1: RUN
* B2: pzCount
* B3: allarme
* B4: manuale
*
* - BIT di stato
* DB29 blocco dati letto dal MES Byte Bit
* CicloOn Bool 0 0
* MacchOn Bool 0 1
* ManualeOn Bool 0 2
* AllarmiOn Bool 0 3
* EmergenzaOn Bool 0 4
* EmergenzaPremuta Bool 0 5
* ContapezziAssoluto DInt 2
* Comtapezzi parziale DInt 6
*
----------------------------------------------------- */
byte mainData = RawInput[0];
int byteSignals = 0;
// bit 0 (poweron) imposto a 1 SE connected...
if (currPLC.IsConnected)
{
byteSignals += (1 << 0);
}
// lavora --> bit0 e bit1: cicloOn AND macchOn
if ((mainData & (1 << 0)) != 0 && (mainData & (1 << 1)) != 0)
{
byteSignals += (1 << 1);
}
// controllo il bit ALARM OR emergenza dello status
if ((mainData & (1 << 3)) != 0 || (mainData & (1 << 5)) != 0)
{
byteSignals += (1 << 3);
}
// check MANUALE ...
if ((mainData & (1 << 2)) != 0)
{
byteSignals += (1 << 4);
}
// salvo!
B_input = byteSignals;
// log opzionale!
if (verboseLog)
{
lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}");
}
}
#endregion
#endregion Public Methods
}
}
}
Vendored
+1 -1
View File
@@ -9,7 +9,7 @@ pipeline {
steps {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=737']) {
withEnv(['NEXT_BUILD_NUMBER=740']) {
// 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'