COmpletata review codice x IOB SIEMENS FAPE, da testare...
This commit is contained in:
@@ -53,7 +53,7 @@ BLINK_FILT=0
|
||||
[OPTPAR]
|
||||
;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
|
||||
; attenzione memoria sempre base BYTE (1604 DW --> 6416...)
|
||||
PZCOUNT_MODE=STD.DB15.DBW22
|
||||
PZCOUNT_MODE=STD.DB15.DBDW40
|
||||
;PZ_CAD_MADDR=1602
|
||||
;PZ_REQ_MADDR=1603
|
||||
;PZ_DONE_MADDR=1604
|
||||
|
||||
+1
-23
@@ -533,10 +533,6 @@ namespace IOB_WIN
|
||||
case "DW":
|
||||
uint valDW = S7.Net.Types.Word.FromByteArray(RawInput.Skip(areaCounter.indiceMem).Take(4).ToArray());
|
||||
outputVal = valDW;
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
lgInfo("[2] outputVal contapezzi: {0}", outputVal);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -546,6 +542,7 @@ namespace IOB_WIN
|
||||
Int32.TryParse(outputVal.ToString(), out lastCountCNC);
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
lgInfo("[2] outputVal contapezzi: {0}", outputVal);
|
||||
lgInfo("[3] lastCountCNC contapezzi: {0}", lastCountCNC);
|
||||
}
|
||||
}
|
||||
@@ -560,25 +557,6 @@ namespace IOB_WIN
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Recupero dati override in formato dictionary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getOverrides()
|
||||
{
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
uint valDW = 0;
|
||||
// !!!FARE!!! recuperare da conf memoria, ora HARD CODED
|
||||
outVal.Add("FEED_OVER", RawInput[19].ToString());
|
||||
outVal.Add("RAPID_OVER", RawInput[20].ToString());
|
||||
outVal.Add("CURR_MODE", decodeCurrMode(RawInput[21]));
|
||||
// recupero RPM pezzo/mola !!!FARE!!! cambio nome da config, qui sono 01:conduttrice e 02:operatrice (3013), mentre sono pezzo/mola nella V100
|
||||
valDW = S7.Net.Types.DWord.FromByteArray(RawInput.Skip(24).Take(4).ToArray());
|
||||
outVal.Add("RPM_01", valDW.ToString());
|
||||
valDW = S7.Net.Types.DWord.FromByteArray(RawInput.Skip(28).Take(4).ToArray());
|
||||
outVal.Add("RPM_02", valDW.ToString());
|
||||
return outVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// lettura bit semafori
|
||||
/// </summary>
|
||||
public override void readSemafori()
|
||||
|
||||
+64
-205
@@ -1,6 +1,6 @@
|
||||
using IOB_UT;
|
||||
using S7.Net;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IOB_WIN
|
||||
{
|
||||
@@ -87,202 +87,28 @@ namespace IOB_WIN
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensFape(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
// dovebbe fare init della classe base, VERIFICARE...
|
||||
lgInfo("NEW IOB SIEMENS versione FAPE");
|
||||
|
||||
#if false
|
||||
// gestione invio ritardato contapezzi
|
||||
pzCountDelay = utils.CRI("pzCountDelay");
|
||||
lastPzCountSend = DateTime.Now;
|
||||
lastWarnODL = DateTime.Now;
|
||||
// init conf
|
||||
_IOBConf = IOBConf;
|
||||
// inizializzo parametri...
|
||||
parametri = new connParamS7()
|
||||
{
|
||||
ipAdrr = "127.0.0.1",
|
||||
tipoCpu = CpuType.S7200,
|
||||
slot = 0,
|
||||
rack = 0,
|
||||
pingMsTimeout = IOBConf.pingMsTimeout,
|
||||
memAddrRead = "DB1.DBB0",
|
||||
memAddrWrite = "DB2.DBB0",
|
||||
memSizeRead = 0,
|
||||
memSizeWrite = 0
|
||||
};
|
||||
setParamPlc();
|
||||
#endif
|
||||
// dovebbe fare init della classe base, VERIFICARE...
|
||||
lgInfo("NEW IOB SIEMENS versione FAPE");
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// Recupero dati override in formato dictionary
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
// process contapezzi FAPE...
|
||||
#if false
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
try
|
||||
{
|
||||
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
|
||||
if (currIobConf.optPar.Count > 0 && currIobConf.optPar["PZCOUNT_MODE"] != "")
|
||||
{
|
||||
string memAddr = currIobConf.optPar["PZCOUNT_MODE"];
|
||||
if (memAddr.StartsWith("STD"))
|
||||
{
|
||||
// inizio verifica area memoria/parametro levando prima parte codice
|
||||
memAddr = memAddr.Replace("STD.", "");
|
||||
object outputVal = new object();
|
||||
// verifico se si tratta di lettura area DB... formato tipo STD.DB700.DBB22.W
|
||||
if (memAddr.StartsWith("DB"))
|
||||
{
|
||||
memAreaSiemens areaCounter = new memAreaSiemens(memAddr);
|
||||
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
lgInfo("[0] area memoria: {1}.{2}.{3}", memAddr, areaCounter.DbNum, areaCounter.indiceMem, areaCounter.tipoMem);
|
||||
}
|
||||
// copio da blocco già letto... con switch x tipo dati --> tipo lettura... e salvo ultimo conteggio rilevato
|
||||
switch (areaCounter.tipoMem)
|
||||
{
|
||||
case "B":
|
||||
byte valB = RawInput[areaCounter.indiceMem];
|
||||
outputVal = valB;
|
||||
break;
|
||||
case "W":
|
||||
ushort valW = S7.Net.Types.Word.FromByteArray(RawInput.Skip(areaCounter.indiceMem).Take(2).ToArray());
|
||||
outputVal = valW;
|
||||
break;
|
||||
case "DW":
|
||||
uint valDW = S7.Net.Types.Word.FromByteArray(RawInput.Skip(areaCounter.indiceMem).Take(4).ToArray());
|
||||
outputVal = valDW;
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
lgInfo("[2] outputVal contapezzi: {0}", outputVal);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// salvo...
|
||||
Int32.TryParse(outputVal.ToString(), out lastCountCNC);
|
||||
if (utils.CRB("verbose"))
|
||||
{
|
||||
lgInfo("[3] lastCountCNC contapezzi: {0}", lastCountCNC);
|
||||
}
|
||||
}
|
||||
stopwatch.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Errore in contapezzi SIEMENS");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// lettura bit semafori
|
||||
/// </summary>
|
||||
public override void readSemafori()
|
||||
{
|
||||
base.readSemafori();
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo("inizio read semafori");
|
||||
}
|
||||
|
||||
parentForm.sIN = Semaforo.SV;
|
||||
// leggo TUTTI i byte configurati...
|
||||
byte[] MemBlock = new byte[parametri.memSizeRead];
|
||||
bool fatto = S7ReadBB(ref MemBlock);
|
||||
Buffer.BlockCopy(MemBlock, 0, RawInput, 0, parametri.memSizeRead);
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format("RawInput[0]: {0}", utils.binaryForm(RawInput[0])));
|
||||
}
|
||||
// salvo il solo BYTE dell'input decifrando il semaforo...
|
||||
decodeToBaseBitmap();
|
||||
decodeOtherData();
|
||||
}
|
||||
/// <summary>
|
||||
/// decodifica da bitmap il CURRENT MODE del controllo
|
||||
/// </summary>
|
||||
/// <param name="currModeBitmap"></param>
|
||||
/// <returns></returns>
|
||||
protected override string decodeCurrMode(byte currModeBitmap)
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
string answ = "";
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format("CURR_MODE raw data: {0}", utils.binaryForm(currModeBitmap)));
|
||||
}
|
||||
// decodifica del MODO... B21
|
||||
/*
|
||||
* CURR MODE diviso in BIT:
|
||||
* B0 (01) = AUTO
|
||||
* B1 (02) = MDI
|
||||
* B2 (04) = JOG
|
||||
* B3 (08) = TeachIN (associato a MDI --> 10)
|
||||
* B4 (16) = Repos (associato a JOG --> 20)
|
||||
* B5 (32) = RefPoint (associato a Jog --> 36)
|
||||
* B6 (64) = Incr1 (associato a Jog --> 68)
|
||||
* B7 (128) = Incr10 (associato a Jog --> -124 / 132 se UInt)
|
||||
* */
|
||||
|
||||
// modi principali
|
||||
if (currModeBitmap.SelectBit(0))
|
||||
{
|
||||
answ = "AUTO";
|
||||
}
|
||||
else if (currModeBitmap.SelectBit(1))
|
||||
{
|
||||
answ = "MDI";
|
||||
}
|
||||
else if (currModeBitmap.SelectBit(2))
|
||||
{
|
||||
answ = "JOG";
|
||||
}
|
||||
// modi accessori
|
||||
if (currModeBitmap.SelectBit(3))
|
||||
{
|
||||
answ += " | TEACH-IN";
|
||||
}
|
||||
if (currModeBitmap.SelectBit(4))
|
||||
{
|
||||
answ += " | REPOS";
|
||||
}
|
||||
if (currModeBitmap.SelectBit(5))
|
||||
{
|
||||
answ += " | REF-POINT";
|
||||
}
|
||||
if (currModeBitmap.SelectBit(6))
|
||||
{
|
||||
answ += " | INCR-1";
|
||||
}
|
||||
if (currModeBitmap.SelectBit(7))
|
||||
{
|
||||
answ += " | INCR-10";
|
||||
}
|
||||
return answ;
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
ushort valStatus = S7.Net.Types.Word.FromByteArray(RawInput.Skip(0).Take(2).ToArray());
|
||||
ushort valPosit = S7.Net.Types.Word.FromByteArray(RawInput.Skip(2).Take(2).ToArray());
|
||||
outVal.Add("CURR_STATO", ((statoMacchina)valStatus).ToString());
|
||||
outVal.Add("CURR_POSIT", ((posizioneSequenza)valPosit).ToString());
|
||||
return outVal;
|
||||
}
|
||||
/// <summary>
|
||||
/// Decodifica il resto dell'area x i dati accessori (allarmi, ...)
|
||||
/// </summary>
|
||||
private void decodeOtherData()
|
||||
{
|
||||
if (verboseLog)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
@@ -290,16 +116,56 @@ namespace IOB_WIN
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
// TORRI: leggo i primi 8 bit hard coded...
|
||||
int byteSem = RawInput[0];
|
||||
// azzero i bit NON gestiti (2-5-6-7)
|
||||
byteSem &= ~(1 << 2);
|
||||
byteSem &= ~(1 << 5);
|
||||
byteSem &= ~(1 << 6);
|
||||
byteSem &= ~(1 << 7);
|
||||
// salvo infine variabile bit x invio
|
||||
B_input = byteSem;
|
||||
// FAPE: leggo i primi 2 WORD x decodifica stato e posizione...
|
||||
ushort valStatus = S7.Net.Types.Word.FromByteArray(RawInput.Skip(0).Take(2).ToArray());
|
||||
ushort valPosit = S7.Net.Types.Word.FromByteArray(RawInput.Skip(2).Take(2).ToArray());
|
||||
statoMacchina _stMacch = ((statoMacchina)valStatus);
|
||||
posizioneSequenza _posSeq = ((posizioneSequenza)valPosit);
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: emergenza
|
||||
----------------------------------------------------- */
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
// controllo stato macchina x impostare altri bit...
|
||||
switch (_stMacch)
|
||||
{
|
||||
case statoMacchina.EMERGENZA_INSERITA:
|
||||
B_input &= (1 << 5);
|
||||
break;
|
||||
case statoMacchina.COMUNICAZIONE_ASSENTE:
|
||||
case statoMacchina.AVARIA_ARIA:
|
||||
case statoMacchina.AVARIA_PRESSIONE_OLIO:
|
||||
case statoMacchina.AVARIA_LIVELLO_OLIO:
|
||||
case statoMacchina.AVARIA_TEMPERATURA_OLIO:
|
||||
case statoMacchina.AVARIA_MOTORE_POMPA_IDRAULICA:
|
||||
case statoMacchina.AVARIA_MOTORE_RAFFREDDO_IDRAULICA:
|
||||
case statoMacchina.AVARIA_SINCRONISMO_PORTE:
|
||||
case statoMacchina.AVARIA_LIBERA:
|
||||
case statoMacchina.ATTIVAZIONE_IN_CORSO:
|
||||
B_input &= (1 << 3);
|
||||
break;
|
||||
case statoMacchina.MODO_MANUALE_ATTREZZAGGIO:
|
||||
B_input &= (1 << 4);
|
||||
break;
|
||||
case statoMacchina.CICLO_IN_CORSO:
|
||||
B_input &= (1 << 1);
|
||||
break;
|
||||
case statoMacchina.MODO_AUTOMATICO_LOCALE:
|
||||
case statoMacchina.MODO_AUTOMATICO_ROBOT:
|
||||
B_input &= ~(1 << 5);
|
||||
break;
|
||||
case statoMacchina.LIBERO:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
string currODL = "";
|
||||
try
|
||||
@@ -333,14 +199,7 @@ namespace IOB_WIN
|
||||
}
|
||||
// registro contapezzi
|
||||
lgInfo(string.Format("Contapezzi SIEMENS: {0} | Contapezzi interno {1}", lastCountCNC, contapezzi));
|
||||
|
||||
// 2018.06.26 NON resetto perché si deve resettare da solo da conteggio TC POST cambio ODL...
|
||||
#if false
|
||||
else if (contapezzi > lastCountCNC) // in questo caso resetto
|
||||
{
|
||||
contapezzi = lastCountCNC;
|
||||
}
|
||||
#endif
|
||||
|
||||
// invio a server contapezzi (aggiornato)
|
||||
string retVal = utils.callUrl(urlSetPzCount + contapezzi.ToString());
|
||||
// verifica se tutto OK
|
||||
|
||||
Reference in New Issue
Block a user