Update x test multivalore INT
This commit is contained in:
@@ -22,8 +22,16 @@
|
||||
// splitto per "="...
|
||||
var splitCond = rawConf.Split('=');
|
||||
sVal = splitCond[1];
|
||||
int.TryParse(sVal, out valDecoded);
|
||||
ValOk = valDecoded;
|
||||
// i valori INT sono "," separated
|
||||
var splitValOk = sVal.Split(',');
|
||||
ValOk = new int[splitValOk.Length];
|
||||
int i = 0;
|
||||
foreach (var item in splitValOk)
|
||||
{
|
||||
int.TryParse(item, out valDecoded);
|
||||
ValOk[i] = valDecoded;
|
||||
i++;
|
||||
}
|
||||
// il restante splitto per "."
|
||||
var splitMem = splitCond[0].Split('|');
|
||||
// BaseAddr
|
||||
@@ -82,7 +90,7 @@
|
||||
/// <summary>
|
||||
/// Valore target che porta a condizione OK = true
|
||||
/// </summary>
|
||||
public int ValOk { get; set; } = 0;
|
||||
public int[] ValOk { get; set; } = new int[1];
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
@@ -256,6 +257,35 @@ namespace IOB_WIN_NEXT
|
||||
return outVal;
|
||||
}
|
||||
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if ((enablePzCountByApp || enablePzCountByIob) && !(disablePzCounteByIob))
|
||||
{
|
||||
if (cIobConf.optPar.Count > 0 && !string.IsNullOrWhiteSpace(getOptPar("PZCOUNT_MODE")))
|
||||
{
|
||||
// cerco in lastDynData...
|
||||
string pzCountKey = getOptPar("PZCOUNT_MODE").Replace("STD.", "");
|
||||
if (lastDynData.ContainsKey(pzCountKey))
|
||||
{
|
||||
string rawVal = lastDynData[pzCountKey];
|
||||
double cntDouble = -1;
|
||||
if (!string.IsNullOrEmpty(rawVal))
|
||||
{
|
||||
double.TryParse(rawVal, out cntDouble);
|
||||
if (cntDouble >= 0)
|
||||
{
|
||||
contapezziPLC = (int)cntDouble;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"processContapezzi escluso: enablePzCountByApp = {enablePzCountByApp} | enablePzCountByIob: {enablePzCountByIob} | disablePzCounteByIob: {disablePzCounteByIob}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lettura valori Coils (1...)
|
||||
/// </summary>
|
||||
@@ -793,35 +823,6 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if ((enablePzCountByApp || enablePzCountByIob) && !(disablePzCounteByIob))
|
||||
{
|
||||
if (cIobConf.optPar.Count > 0 && !string.IsNullOrWhiteSpace(getOptPar("PZCOUNT_MODE")))
|
||||
{
|
||||
// cerco in lastDynData...
|
||||
string pzCountKey = getOptPar("PZCOUNT_MODE").Replace("STD.", "");
|
||||
if (lastDynData.ContainsKey(pzCountKey))
|
||||
{
|
||||
string rawVal = lastDynData[pzCountKey];
|
||||
double cntDouble = -1;
|
||||
if (!string.IsNullOrEmpty(rawVal))
|
||||
{
|
||||
double.TryParse(rawVal, out cntDouble);
|
||||
if (cntDouble >= 0)
|
||||
{
|
||||
contapezziPLC = (int)cntDouble;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"processContapezzi escluso: enablePzCountByApp = {enablePzCountByApp} | enablePzCountByIob: {enablePzCountByIob} | disablePzCounteByIob: {disablePzCounteByIob}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imposto parametri PLC
|
||||
/// </summary>
|
||||
@@ -965,63 +966,6 @@ 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>
|
||||
@@ -1053,6 +997,31 @@ 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>
|
||||
/// Test connessione CNC
|
||||
/// </summary>
|
||||
@@ -1118,6 +1087,40 @@ namespace IOB_WIN_NEXT
|
||||
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);
|
||||
}
|
||||
//answ = (currStatus == OptCheckCondInt[cKey].ValOk);
|
||||
// controllo se il valore sia in elenco di quelli validi...
|
||||
answ = OptCheckCondInt[cKey].ValOk.Contains(currStatus);
|
||||
lgTrace($"testIntCondition for {cKey} | BaseAddr: {OptCheckCondInt[cKey].BaseAddr} | currStatus: {currStatus} | ValOk: {string.Join(",",OptCheckCondInt[cKey].ValOk)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
lgTrace($"testIntCondition error: {cKey} not found");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
@@ -1274,9 +1277,7 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua scalatura valore secondo fattore
|
||||
/// Read --> * (moltiplico)
|
||||
/// Write --> / (divido)
|
||||
/// Effettua scalatura valore secondo fattore Read --> * (moltiplico) Write --> / (divido)
|
||||
/// </summary>
|
||||
/// <param name="currMem"></param>
|
||||
/// <param name="isWrite"></param>
|
||||
|
||||
Reference in New Issue
Block a user