Zetapack:
- aggiunto metodo test INT - conf aggiornata
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
/// Inizializza un oggetto da usare per testing bit condition
|
||||
/// </summary>
|
||||
/// <param name="keyName">Nome della chiave registrata</param>
|
||||
/// <param name="rawConf">Configuraizone nel formato BaseAddr.BitNum=ValOk</param>
|
||||
/// <param name="rawConf">Configurazione nel formato BaseAddr.BitNum=ValOk</param>
|
||||
public BitConditionCheck(string keyName, string rawConf)
|
||||
{
|
||||
Logging.Instance.Info($"Init BitConditionCheck | {keyName} | {rawConf}");
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IntConditionCheck.cs" />
|
||||
<Compile Include="BitConditionCheck.cs" />
|
||||
<Compile Include="CustomObj.cs" />
|
||||
<Compile Include="DataExport.cs" />
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
namespace IOB_UT_NEXT
|
||||
{
|
||||
public class IntConditionCheck
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza un oggetto da usare per testing INT condition
|
||||
/// </summary>
|
||||
/// <param name="keyName">Nome della chiave registrata</param>
|
||||
/// <param name="rawConf">Configurazione nel formato BaseAddr|IntIndex=ValOk</param>
|
||||
public IntConditionCheck(string keyName, string rawConf)
|
||||
{
|
||||
Logging.Instance.Info($"Init IntConditionCheck | {keyName} | {rawConf}");
|
||||
KeyName = keyName;
|
||||
RawVal = rawConf;
|
||||
string sVal = "";
|
||||
int valDecoded = 0;
|
||||
// check preliminare
|
||||
if (rawConf.Contains(".") && rawConf.Contains("="))
|
||||
{
|
||||
// splitto per "="...
|
||||
var splitCond = rawConf.Split('=');
|
||||
sVal = splitCond[1];
|
||||
int.TryParse(sVal, out valDecoded);
|
||||
ValOk = valDecoded;
|
||||
// il restante splitto per "."
|
||||
var splitMem = splitCond[0].Split('|');
|
||||
// BaseAddr
|
||||
sVal = splitMem[0];
|
||||
int.TryParse(sVal, out valDecoded);
|
||||
BaseAddr = valDecoded;
|
||||
// BitNum
|
||||
sVal = splitMem[1];
|
||||
int.TryParse(sVal, out valDecoded);
|
||||
IntIndex = valDecoded;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza un oggetto fake/empty
|
||||
/// </summary>
|
||||
public IntConditionCheck()
|
||||
{
|
||||
Logging.Instance.Info("Init empty IntConditionCheck");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza un oggetto solo per key
|
||||
/// </summary>
|
||||
/// <param name="keyName">Nome della chiave registrata</param>
|
||||
public IntConditionCheck(string keyName)
|
||||
{
|
||||
Logging.Instance.Info($"Init IntConditionCheck | {keyName}");
|
||||
KeyName = keyName;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo base x memoria da testare come iny condition
|
||||
/// </summary>
|
||||
public int BaseAddr { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo base x memoria da testare come int condition (0/1) dell'int[], 2=DWord
|
||||
/// </summary>
|
||||
public int IntIndex { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Valore chiave
|
||||
/// </summary>
|
||||
public string KeyName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore raw decodificato
|
||||
/// </summary>
|
||||
public string RawVal { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore target che porta a condizione OK = true
|
||||
/// </summary>
|
||||
public int ValOk { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ MODEL=Linea imballo
|
||||
|
||||
[CNC]
|
||||
IP=192.168.16.11
|
||||
PORT=502
|
||||
PORT=8000
|
||||
|
||||
[SERVER]
|
||||
MPIP=http://192.168.1.7
|
||||
|
||||
@@ -3,108 +3,53 @@
|
||||
|
||||
},
|
||||
"mMapRead": {
|
||||
//"StatusWord": {
|
||||
// "name": "StatusWord",
|
||||
// "description": "Word di Status",
|
||||
// "memAddr": "40002",
|
||||
// "tipoMem": "Int",
|
||||
// "index": 2,
|
||||
// "size": 1,
|
||||
// "func": "POINT",
|
||||
// "period": 90,
|
||||
// "factor": 1,
|
||||
// "minVal": 0,
|
||||
// "maxVal": 65536,
|
||||
// "unit": "BMap"
|
||||
//},
|
||||
//"StatusDetWord": {
|
||||
// "name": "StatusDetWord",
|
||||
// "description": "Word di Status",
|
||||
// "memAddr": "40005",
|
||||
// "tipoMem": "Int",
|
||||
// "index": 5,
|
||||
// "size": 1,
|
||||
// "func": "POINT",
|
||||
// "period": 90,
|
||||
// "factor": 1,
|
||||
// "minVal": 0,
|
||||
// "maxVal": 65536,
|
||||
// "unit": "BMap"
|
||||
//},
|
||||
"FreqInverter": {
|
||||
"name": "FreqInverter",
|
||||
"description": "Frequenza Inverter",
|
||||
"memAddr": "40011",
|
||||
"tipoMem": "Real",
|
||||
"index": 11,
|
||||
"size": 2,
|
||||
"func": "MEDIAN",
|
||||
"period": 90,
|
||||
"factor": 1,
|
||||
"minVal": 0,
|
||||
"maxVal": 999999999,
|
||||
"unit": "Hz"
|
||||
},
|
||||
"CDOreManuten": {
|
||||
"name": "CDOreManuten",
|
||||
"description": "Residuo ore a prossimo service",
|
||||
"memAddr": "40013",
|
||||
"AmpMot1": {
|
||||
"name": "AmpMot1",
|
||||
"description": "Assorbimento motore 1 - calibratrice",
|
||||
"memAddr": "40001",
|
||||
"tipoMem": "Int",
|
||||
"index": 13,
|
||||
"index": 1,
|
||||
"size": 1,
|
||||
"func": "MEDIAN",
|
||||
"period": 90,
|
||||
"factor": 1,
|
||||
"factor": 100,
|
||||
"minVal": 0,
|
||||
"maxVal": 999999999,
|
||||
"unit": "h"
|
||||
"maxVal": 999,
|
||||
"unit": "%"
|
||||
},
|
||||
"COreTAsp1": {
|
||||
"name": "COreTAsp1",
|
||||
"description": "Totale ore funzionamento impianto",
|
||||
"memAddr": "40014",
|
||||
"AmpMot2": {
|
||||
"name": "AmpMot2",
|
||||
"description": "Assorbimento Motore 2 - nastro dosi",
|
||||
"memAddr": "40002",
|
||||
"tipoMem": "Int",
|
||||
"index": 14,
|
||||
"index": 2,
|
||||
"size": 1,
|
||||
"func": "MEDIAN",
|
||||
"period": 90,
|
||||
"factor": 1,
|
||||
"factor": 100,
|
||||
"minVal": 0,
|
||||
"maxVal": 999999999,
|
||||
"unit": "h"
|
||||
"maxVal": 999,
|
||||
"unit": "%"
|
||||
},
|
||||
"COrePAsp1": {
|
||||
"name": "COrePAsp1",
|
||||
"description": "Parziale ore funzionamento impianto da ultimo service",
|
||||
"memAddr": "40015",
|
||||
"AmpMot3": {
|
||||
"name": "AmpMot3",
|
||||
"description": "Assorbimento motore 3 - curva ingresso",
|
||||
"memAddr": "40003",
|
||||
"tipoMem": "Int",
|
||||
"index": 15,
|
||||
"index": 3,
|
||||
"size": 1,
|
||||
"func": "MEDIAN",
|
||||
"period": 90,
|
||||
"factor": 1,
|
||||
"factor": 100,
|
||||
"minVal": 0,
|
||||
"maxVal": 999999999,
|
||||
"unit": "h"
|
||||
},
|
||||
"AmpereReale": {
|
||||
"name": "AmpereReale",
|
||||
"description": "Assorbimento aspiratore 1",
|
||||
"memAddr": "40016",
|
||||
"tipoMem": "Real",
|
||||
"index": 16,
|
||||
"size": 2,
|
||||
"func": "MEDIAN",
|
||||
"period": 90,
|
||||
"factor": 1,
|
||||
"minVal": 0,
|
||||
"maxVal": 999999999,
|
||||
"unit": "A"
|
||||
"maxVal": 999,
|
||||
"unit": "%"
|
||||
}
|
||||
},
|
||||
"optMemPar": {
|
||||
"AutoBitCond": "40002.14=1",
|
||||
"EStopBitCond": "40002.9=0",
|
||||
"WorkBitCond": "40002.0=1"
|
||||
"AlarmIntCond": "40000|0=0",
|
||||
"ManualIntCond": "40000|0=1",
|
||||
"EStopBitCond": "40001.0=1",
|
||||
"WorkIntCond": "40000|0=2"
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ CLI_INST=SteamWareSim
|
||||
;STARTLIST=FINASSI_HELPI_01
|
||||
;STARTLIST=FINASSI_OMP_01
|
||||
;STARTLIST=BAGLIETTO_CIMOLAI_01
|
||||
STARTLIST=SIMUL_01
|
||||
;STARTLIST=SIMUL_01
|
||||
STARTLIST=GIACO_ZPACK_1
|
||||
|
||||
MAXCNC=10
|
||||
@@ -360,6 +360,18 @@
|
||||
<None Include="DATA\CONF\GIACO_NWSE.ini" />
|
||||
<None Include="DATA\CONF\GIACO_NWSE.json" />
|
||||
<None Include="DATA\CONF\GIACO_NWSE_alarm.json" />
|
||||
<None Include="DATA\CONF\GIACO_ZPACK_1.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\GIACO_ZPACK_1.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\GIACO_ZPACK_1_alarm.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\GIACO_ZPACK_1_MBlock.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\GT594.ini" />
|
||||
<None Include="DATA\CONF\GT594.json" />
|
||||
<None Include="DATA\CONF\L018.ini" />
|
||||
|
||||
+47
-14
@@ -4301,10 +4301,13 @@ namespace IOB_WIN_NEXT
|
||||
protected int numSim { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario condizioni di check (opzionali) da usare x valori controllo bitmap (es ModBUs
|
||||
/// TCP Imax)
|
||||
/// Dizionario condizioni di check BIT da usare x valori controllo (es ModBus TCP Imax)
|
||||
/// </summary>
|
||||
protected Dictionary<string, BitConditionCheck> OptCheckConditions { get; set; } = new Dictionary<string, BitConditionCheck>();
|
||||
protected Dictionary<string, BitConditionCheck> OptCheckCondBit { get; set; } = new Dictionary<string, BitConditionCheck>();
|
||||
/// <summary>
|
||||
/// Dizionario condizioni di check INT da usare x valori controllo bitmap (es ModBus TCP Zetapack)
|
||||
/// </summary>
|
||||
protected Dictionary<string, IntConditionCheck> OptCheckCondInt { get; set; } = new Dictionary<string, IntConditionCheck>();
|
||||
|
||||
/// <summary>
|
||||
/// Indica se sia stato resettato un contapezzi
|
||||
@@ -5600,20 +5603,32 @@ namespace IOB_WIN_NEXT
|
||||
lgInfo($"setupMemMap | salvata conf memoria R/W");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup aprametri memoria opzionali
|
||||
/// es: BitCond e IntCond x ricerca valori target
|
||||
/// </summary>
|
||||
protected virtual void setupOptMemPar()
|
||||
{
|
||||
// verifica se siano necessari configuraizoni speciali dalla optMemPar (es per ricerca
|
||||
// condizioni status bolleane come ModbusTCP...)
|
||||
// verifica se siano necessari configuraizoni speciali dalla optMemPar:
|
||||
// es: per ricerca condizioni status bolleane come ModbusTCP...
|
||||
if (memMap.optMemPar != null && memMap.optMemPar.Count > 0)
|
||||
{
|
||||
// cerco condizioni speciali x Auto, Estop, Work.. devono essere *BitCond
|
||||
// cerco condizioni BIT speciali x Auto, Estop, Work.. devono essere *BitCond
|
||||
var listPar2add = memMap.optMemPar.Where(x => x.Key.EndsWith("BitCond")).ToList();
|
||||
if (listPar2add != null && listPar2add.Count > 0)
|
||||
{
|
||||
foreach (var item in listPar2add)
|
||||
{
|
||||
addCheckCondition(item.Key, item.Value);
|
||||
addCheckConditionBit(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
// cerco condizioni INT speciali x Auto, Estop, Work.. devono essere *IntCond
|
||||
var listParInt2add = memMap.optMemPar.Where(x => x.Key.EndsWith("IntCond")).ToList();
|
||||
if (listParInt2add != null && listParInt2add.Count > 0)
|
||||
{
|
||||
foreach (var item in listParInt2add)
|
||||
{
|
||||
addCheckConditionInt(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5859,21 +5874,39 @@ namespace IOB_WIN_NEXT
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge in setup memoria la checkCondition ricevuta già "decodificata"
|
||||
/// Aggiunge in setup memoria la checkCondition BIT "decodificata"
|
||||
/// </summary>
|
||||
/// <param name="ompKey">Chiave da aggiungere</param>
|
||||
/// <param name="ompVal">Valore da decodificare e poi aggiungere</param>
|
||||
private void addCheckCondition(string ompKey, string ompVal)
|
||||
private void addCheckConditionBit(string ompKey, string ompVal)
|
||||
{
|
||||
var newCond = new BitConditionCheck(ompVal);
|
||||
var newCond = new BitConditionCheck(ompKey, ompVal);
|
||||
// cerco x aggiornare o aggiungere...
|
||||
if (OptCheckConditions.ContainsKey(ompKey))
|
||||
if (OptCheckCondBit.ContainsKey(ompKey))
|
||||
{
|
||||
OptCheckConditions[ompKey] = newCond;
|
||||
OptCheckCondBit[ompKey] = newCond;
|
||||
}
|
||||
else
|
||||
{
|
||||
OptCheckConditions.Add(ompKey, newCond);
|
||||
OptCheckCondBit.Add(ompKey, newCond);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Aggiunge in setup memoria la checkCondition INT "decodificata"
|
||||
/// </summary>
|
||||
/// <param name="ompKey">Chiave da aggiungere</param>
|
||||
/// <param name="ompVal">Valore da decodificare e poi aggiungere</param>
|
||||
private void addCheckConditionInt(string ompKey, string ompVal)
|
||||
{
|
||||
var newCond = new IntConditionCheck(ompKey, ompVal);
|
||||
// cerco x aggiornare o aggiungere...
|
||||
if (OptCheckCondInt.ContainsKey(ompKey))
|
||||
{
|
||||
OptCheckCondInt[ompKey] = newCond;
|
||||
}
|
||||
else
|
||||
{
|
||||
OptCheckCondInt.Add(ompKey, newCond);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
lgInfo("ModBus TCP: tryConnect step 02");
|
||||
|
||||
// reimporto parametri PLC se necessario...
|
||||
// reimposto parametri PLC se necessario...
|
||||
setParamPlc();
|
||||
}
|
||||
lgInfo("ModBus TCP: tryConnect step 03");
|
||||
@@ -912,48 +912,50 @@ namespace IOB_WIN_NEXT
|
||||
lgError(exc, "Errore in contapezzi ModBusTCP");
|
||||
}
|
||||
}
|
||||
|
||||
// ora tento avvio PLC... SE PING OK...
|
||||
lastPING = adesso;
|
||||
IPStatus esitoPing = testPingMachine;
|
||||
if (esitoPing == IPStatus.Success)
|
||||
// verifico se sia connessa...
|
||||
if (!connectionOk)
|
||||
{
|
||||
needRefresh = false;
|
||||
try
|
||||
// ora tento avvio PLC... SE PING OK...
|
||||
lastPING = adesso;
|
||||
IPStatus esitoPing = testPingMachine;
|
||||
if (esitoPing == IPStatus.Success)
|
||||
{
|
||||
//Ip-Address and Port of Modbus-TCP-Server
|
||||
currPLC = new ModbusClient(parametri.ipAdrr, parametri.port);
|
||||
currPLC.ConnectionTimeout = 3000;
|
||||
|
||||
currPLC.ConnectedChanged += CurrPLC_ConnectedChanged;
|
||||
|
||||
// disconnetto e connetto...
|
||||
if (isVerboseLog)
|
||||
{
|
||||
lgInfoStartup("ModBus TCP: tryDisconnect");
|
||||
}
|
||||
tryDisconnect();
|
||||
|
||||
// lo ripeto x evitare che ci sia un loop... e tryConnect richiami la
|
||||
// procedura corrente...
|
||||
needRefresh = false;
|
||||
lgInfoStartup("ModBus TCP: tryConnect");
|
||||
tryConnect();
|
||||
lgInfoStartup("End init Adapter ModBusTCP");
|
||||
if (isVerboseLog)
|
||||
try
|
||||
{
|
||||
lgInfo("ModBus TCP CONNESSIONE AVVENUTA");
|
||||
//Ip-Address and Port of Modbus-TCP-Server
|
||||
currPLC = new ModbusClient(parametri.ipAdrr, parametri.port);
|
||||
currPLC.ConnectionTimeout = 5000;
|
||||
|
||||
currPLC.ConnectedChanged += CurrPLC_ConnectedChanged;
|
||||
|
||||
// disconnetto e connetto...
|
||||
if (isVerboseLog)
|
||||
{
|
||||
lgInfoStartup("ModBus TCP: tryDisconnect");
|
||||
}
|
||||
tryDisconnect();
|
||||
|
||||
// tolgo needRefresh x evitare un loop... (tryConnect richiama setParamPlc)
|
||||
needRefresh = false;
|
||||
lgInfoStartup("ModBus TCP: tryConnect");
|
||||
tryConnect();
|
||||
lgInfoStartup("End init Adapter ModBusTCP");
|
||||
if (isVerboseLog)
|
||||
{
|
||||
lgInfo("ModBus TCP CONNESSIONE AVVENUTA");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Errore in INIT ModBusTCP");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
else
|
||||
{
|
||||
lgError(exc, "Errore in INIT ModBusTCP");
|
||||
lgError($"ModBusTCP IOB | Errore in ping: esito {esitoPing}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"ModBusTCP IOB | Errore in ping: esito {esitoPing}");
|
||||
}
|
||||
parentForm.commPlcActive = false;
|
||||
}
|
||||
else
|
||||
@@ -963,6 +965,63 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Testa la condition modbus da LUT + configurazione, valori tipo BIT
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
/// <returns></returns>
|
||||
protected bool testBitCondition(string cKey)
|
||||
{
|
||||
bool answ = false;
|
||||
if (OptCheckCondBit.ContainsKey(cKey))
|
||||
{
|
||||
int currStatus = 0;
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[OptCheckCondBit[cKey].BaseAddr];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// controllo valore del bit richiesto
|
||||
answ = ((currStatus & (1 << OptCheckCondBit[cKey].BitNum)) == OptCheckCondBit[cKey].ValOk);
|
||||
lgTrace($"testBitCondition for {cKey} | BaseAddr: {OptCheckCondBit[cKey].BaseAddr} | BitNum: {OptCheckCondBit[cKey].BitNum} | ValOk: {OptCheckCondBit[cKey].ValOk}");
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"testBitCondition error: {cKey} not found");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Testa la condition modbus da LUT + configurazione, valori tipo INT
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
/// <returns></returns>
|
||||
protected bool testIntCondition(string cKey)
|
||||
{
|
||||
bool answ = false;
|
||||
if (OptCheckCondInt.ContainsKey(cKey))
|
||||
{
|
||||
int currStatus = 0;
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[OptCheckCondInt[cKey].BaseAddr];
|
||||
// leggo da conf OptCheckCondInt[cKey].IntIndex
|
||||
if (OptCheckCondInt[cKey].IntIndex < 2)
|
||||
{
|
||||
currStatus = listInt[OptCheckCondInt[cKey].IntIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
}
|
||||
// controllo se il valore sia quello configurato...
|
||||
answ = (currStatus == OptCheckCondInt[cKey].ValOk);
|
||||
lgTrace($"testIntCondition for {cKey} | BaseAddr: {OptCheckCondInt[cKey].BaseAddr} | ValOk: {OptCheckCondInt[cKey].ValOk}");
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"testIntCondition error: {cKey} not found");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua il setup dei memblock da gestire (NON leggo intera memoria ma tanti blocchi...)
|
||||
/// </summary>
|
||||
|
||||
@@ -203,15 +203,15 @@ namespace IOB_WIN_NEXT
|
||||
private bool testCondition(string cKey)
|
||||
{
|
||||
bool answ = false;
|
||||
if (OptCheckConditions.ContainsKey(cKey))
|
||||
if (OptCheckCondBit.ContainsKey(cKey))
|
||||
{
|
||||
int currStatus = 0;
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[OptCheckConditions[cKey].BaseAddr];
|
||||
listInt = HoldingRegisterLUT[OptCheckCondBit[cKey].BaseAddr];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// hard coded il 9° bit a zero
|
||||
answ = ((currStatus & (1 << OptCheckConditions[cKey].BitNum)) == OptCheckConditions[cKey].ValOk);
|
||||
lgTrace($"testCondition for {cKey} | BaseAddr: {OptCheckConditions[cKey].BaseAddr} | BitNum: {OptCheckConditions[cKey].BitNum} | ValOk: {OptCheckConditions[cKey].ValOk}");
|
||||
answ = ((currStatus & (1 << OptCheckCondBit[cKey].BitNum)) == OptCheckCondBit[cKey].ValOk);
|
||||
lgTrace($"testCondition for {cKey} | BaseAddr: {OptCheckCondBit[cKey].BaseAddr} | BitNum: {OptCheckCondBit[cKey].BitNum} | ValOk: {OptCheckCondBit[cKey].ValOk}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -46,25 +46,23 @@ namespace IOB_WIN_NEXT
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce status di AUTOmatico, hard coded
|
||||
/// Restituisce status di WORK (auto + lavora), hard coded
|
||||
/// </summary>
|
||||
protected bool Auto
|
||||
protected bool WorkState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testCondition("WorkBitCond");
|
||||
#if false
|
||||
bool answ = false;
|
||||
int currStatus = 0;
|
||||
// hard coded
|
||||
int statusReg = 40002;
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[statusReg];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// hard coded il 5° bit
|
||||
answ = ((currStatus & (1 << 14)) > 0);
|
||||
return answ;
|
||||
#endif
|
||||
return testIntCondition("WorkIntCond");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce status di Manuale, hard coded
|
||||
/// </summary>
|
||||
protected bool ManualState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testIntCondition("ManualIntCond");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +73,20 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
get
|
||||
{
|
||||
return testCondition("EStopBitCond");
|
||||
return testBitCondition("EStopBitCond");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce controllo IN ALLARME
|
||||
/// </summary>
|
||||
protected bool AlarmState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testIntCondition("AlarmIntCond");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce status di LAVORA, hard coded
|
||||
/// </summary>
|
||||
@@ -86,20 +94,7 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
get
|
||||
{
|
||||
return testCondition("WorkBitCond");
|
||||
#if false
|
||||
|
||||
bool answ = false;
|
||||
int currStatus = 0;
|
||||
// hard coded
|
||||
int statusReg = 40002;
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[statusReg];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// hard coded il 5° bit
|
||||
answ = ((currStatus & (1 << 0)) > 0);
|
||||
return answ;
|
||||
#endif
|
||||
return testIntCondition("WorkIntCond");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,27 +131,29 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
// se ho qualcosa nella holding register...
|
||||
if (HoldingRegisterLUT != null && HoldingRegisterLUT.Count > 0)
|
||||
{
|
||||
// se emergenza NON premuta (triggered) indico OK (armata...)
|
||||
if (!EStopTriggered)
|
||||
// se emergenza NON premuta (triggered) indico OK (armata...) FARE !!! togliere true
|
||||
//if (!EStopTriggered)
|
||||
if (true)
|
||||
{
|
||||
byteSignals += (1 << 7);
|
||||
}
|
||||
|
||||
// processo dagli stati + gravi...
|
||||
if (hasAlarms())
|
||||
// impiego controlli da setup IntConditions... processo dagli stati + gravi...
|
||||
if (AlarmState || hasAlarms())
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
if (Work)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
if (!Auto)
|
||||
else if (ManualState)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
else if (WorkState)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -195,30 +192,7 @@ namespace IOB_WIN_NEXT
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Testa la condition modbus da LUT + configurazione
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
/// <returns></returns>
|
||||
private bool testCondition(string cKey)
|
||||
{
|
||||
bool answ = false;
|
||||
if (OptCheckConditions.ContainsKey(cKey))
|
||||
{
|
||||
int currStatus = 0;
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[OptCheckConditions[cKey].BaseAddr];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// hard coded il 9° bit a zero
|
||||
answ = ((currStatus & (1 << OptCheckConditions[cKey].BitNum)) == OptCheckConditions[cKey].ValOk);
|
||||
lgTrace($"testCondition for {cKey} | BaseAddr: {OptCheckConditions[cKey].BaseAddr} | BitNum: {OptCheckConditions[cKey].BitNum} | ValOk: {OptCheckConditions[cKey].ValOk}");
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"testCondition error: {cKey} not found");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
2) verificare sia avviato e configurato
|
||||
3) verificare esistenza cartella C:\Steamware\IOB-WIN-NEXT-DEB\
|
||||
4) impostare path di avvio come C:\Steamware\IOB-WIN-NEXT-DEB\IOB-WIN-NEXT.exe
|
||||
5) impostare la remote machine con ip: porta, ad esempio sotto si trovano i aprametri x i vari clienti
|
||||
5) impostare la remote machine con ip: porta, ad esempio sotto si trovano i parametri x i vari clienti
|
||||
6) modificare il path dello script di replica post build
|
||||
7) impostare nel file di avvio la machcina corretta: DATA/CONF/MAIN.ini (in fondo, sezione [IOB] ad esempio STARTLIST=FINASSI_OMP_01)
|
||||
|
||||
@@ -16,3 +16,7 @@ Remote Machine conf:
|
||||
|
||||
Cereria Finassi:
|
||||
- 10.150.0.1:4026
|
||||
|
||||
|
||||
Giacovelli:
|
||||
- 192.168.1.93:4026
|
||||
|
||||
@@ -60,9 +60,11 @@ REM FINASSI
|
||||
REM ROBOCOPY . \\10.150.0.1\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
REM Baglietto
|
||||
REM ROBOCOPY . \\192.168.60.15\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
REM GIACOVELLI LOCOROTONDO
|
||||
ROBOCOPY . \\192.168.1.93\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
|
||||
REM IOB-WIN-SIM
|
||||
ROBOCOPY . \\IOB-WIN-SIMULA\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
REM ROBOCOPY . \\IOB-WIN-SIMULA\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
|
||||
goto END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user