Merge branch 'feature/LascoStringFix' into develop

This commit is contained in:
Samuele Locatelli
2021-09-24 20:18:27 +02:00
12 changed files with 667 additions and 1784 deletions
+5
View File
@@ -269,6 +269,11 @@ namespace IOB_UT_NEXT
/// </summary>
ND,
/// <summary>
/// Adapter ModBus TCP
/// </summary>
MODBUS_TCP,
/// <summary>
/// Adapter MTConnect
/// </summary>
+78
View File
@@ -188,6 +188,84 @@ namespace IOB_UT_NEXT
#endregion Public Methods
}
/// <summary>
/// Struttura della conf memoria ModBus
/// </summary>
public class BaseModbusConf
{
#region Public Enums
public enum DataType
{
ND = 0,
Bit,
Int,
Real
}
public enum MemDirection
{
R,
W
}
public enum MemType
{
ND = 0,
DiscreteInput = 1,
Coil = 2,
InputRegister = 3,
HoldingRegister = 4
}
#endregion Public Enums
#region Public Properties
/// <summary>
/// Elenco aree memoria mobdus
/// </summary>
public List<ModbusMemArea> MemoryList { get; set; } = new List<ModbusMemArea>();
#endregion Public Properties
#region Public Classes
/// <summary>
/// struttura di base memoria ModBus
/// </summary>
public class ModbusMemArea
{
#region Public Properties
public ushort BaseAddr { get; set; } = 0;
public string RawAddr { get; set; } = "";
public ushort Size { get; set; } = 2;
public MemType Type { get; set; } = MemType.ND;
public List<VarConf> VarList { get; set; } = new List<VarConf>();
#endregion Public Properties
}
public class VarConf
{
#region Public Properties
public MemDirection Direction { get; set; } = MemDirection.R;
public ushort MemAddr { get; set; } = 0;
public string Name { get; set; } = "ND";
public int RangeMax { get; set; } = 0;
public int RangeMin { get; set; } = 0;
public ushort Size { get; set; } = 2;
public DataType Type { get; set; } = DataType.ND;
#endregion Public Properties
}
#endregion Public Classes
}
/// <summary>
/// Classe gestione configurazione parametri di base x configuraizone estesa (es MTConnect, OPC-UA, ...)
/// </summary>
+5
View File
@@ -1186,6 +1186,11 @@ namespace IOB_WIN_NEXT
start.Enabled = true;
break;
case tipoAdapter.MODBUS_TCP:
iobObj = new IobModbusTCP(this, IOBConf);
start.Enabled = true;
break;
case tipoAdapter.MTConnect:
iobObj = new IobMTC(this, IOBConf);
start.Enabled = true;
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -64,7 +64,9 @@ CLI_INST=SteamWareSim
;STARTLIST=TEST
;STARTLIST=SIMUL_01
;STARTLIST=1032
STARTLIST=PIZ08
;STARTLIST=1033
;STARTLIST=PIZ08
STARTLIST=PIZ04
;STARTLIST=OPC_UA
MAXCNC=10
+72
View File
@@ -0,0 +1,72 @@
;Configurazione IOB-WIN
[IOB]
;Impianto COMECA per Pizzaferri
CNCTYPE=MODBUS_TCP
PING_MS_TIMEOUT=500
[MACHINE]
VENDOR=HAM
MODEL=HAM
[CNC]
IP=hampizzaferri.dyndns.org
PORT=502
;CPUTYPE=S71500
;RACK=0
;SLOT=0
[SERVER]
;MPIP=https://localhost:44339
MPIP=https://gwms.egalware.com
MPURL=/api
CMDBASE=/IOB/input/
CMDFLOG=/IOB/flog/
CMDALIVE=/IOB
CMDENABLED=/IOB/enabled/
CMDADV1=?valore=
CMDREBO=/IOB/sendReboot?idxMacchina=
[MEMORY]
ADDR_READ=DB85.DBB0
ADDR_WRITE=DB85.DBB280
SIZE_READ=280
SIZE_WRITE=32
[BLINK]
;MAX_COUNTER_BLINK = 30
MAX_COUNTER_BLINK = 15
;bit0 = 0
;bit1 = 0
;bit2 = 1
;bit3 = 1
;bit4 = 1
;bit5 = 0
;bit6 = 0
;bit7 = 0
BLINK_FILT=0
;BLINK_FILT=28
[OPTPAR]
;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
PZCOUNT_MODE=STD.DB85.DBRE16
DISABLE_PZCOUNT=FALSE
ENABLE_SEND_PZC_BLOCK=TRUE
MIN_SEND_PZC_BLOCK=0
MAX_SEND_PZC_BLOCK=100
; GEST DATI DYN
ENABLE_DYN_DATA=TRUE
FORCE_DYN_DATA=TRUE
; clock base (da 10ms)
timerIntMs=20
; conf parametri memoria READ/WRITE
PARAM_CONF=PIZ03.json
NO_PING=TRUE
; conf aree allarme
ALARM_CONF=PIZ03_alarm.json
[BRANCH]
NAME=master
+247
View File
@@ -0,0 +1,247 @@
{
"mMapWrite": {
"setProg": {
"name": "setProg",
"description": "Programma",
"tipoMem": "String",
"memAddr": "DB6.DBB50",
"index": 50,
"size": 50
},
"setComm": {
"name": "setComm",
"description": "Commessa",
"tipoMem": "String",
"memAddr": "DB6.DBB0",
"index": 0,
"size": 50
},
"setArt": {
"name": "setArt",
"description": "Articolo",
"tipoMem": "String",
"memAddr": "DB6.DBB100",
"index": 100,
"size": 50
},
"setPzComm": {
"name": "setPzComm",
"description": "Qty",
"memAddr": "DB30.DBB212",
"tipoMem": "DInt",
"index": 212,
"size": 4
}
},
"mMapRead": {
"TE2A": {
"name": "TE2A",
"description": "Temperatura Controllo Tenute Pompa A",
"memAddr": "DB85.DBB0",
"tipoMem": "Real",
"index": 0,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE1A": {
"name": "TE1A",
"description": "Temperatura Raffreddamento Pompa A",
"memAddr": "DB85.DBB4",
"tipoMem": "Real",
"index": 4,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE3A": {
"name": "TE3A",
"description": "Temperatura Cavitazione Pompa A",
"memAddr": "DB85.DBB8",
"tipoMem": "Real",
"index": 8,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"Temp01": {
"name": "TE04",
"description": "Temperatura Torcia Aria Fredda",
"memAddr": "DB85.DBB12",
"tipoMem": "Real",
"index": 12,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"Level": {
"name": "LT15",
"description": "Livello Serbatoio",
"memAddr": "DB85.DBB16",
"tipoMem": "Real",
"index": 16,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"PressBH": {
"name": "PT01",
"description": "Pressione Linea CNG",
"memAddr": "DB85.DBB20",
"tipoMem": "Real",
"index": 20,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"PressBL": {
"name": "PT100",
"description": "Pressione Riduttrice",
"memAddr": "DB85.DBB24",
"tipoMem": "Real",
"index": 24,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"MainPress": {
"name": "PT16",
"description": "Pressione Serbatoio",
"memAddr": "DB85.DBB28",
"tipoMem": "Real",
"index": 28,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"Temp02": {
"name": "TT17",
"description": "Temperatura Spurgo Torcia Serbatoio",
"memAddr": "DB85.DBB36",
"tipoMem": "Real",
"index": 36,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE06": {
"name": "TE06",
"description": "Temperatura Uscita Vaporizzatore",
"memAddr": "DB85.DBB40",
"tipoMem": "Real",
"index": 40,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE05": {
"name": "TE05",
"description": "Temperatura Carica Fredda",
"memAddr": "DB85.DBB60",
"tipoMem": "Real",
"index": 60,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE2B ": {
"name": "TE2B",
"description": "Temperatura Controllo Tenute Pompa B",
"memAddr": "DB85.DBB64",
"tipoMem": "Real",
"index": 64,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE1B ": {
"name": "TE1B",
"description": "Temperatura Raffreddamento Pompa B",
"memAddr": "DB85.DBB68",
"tipoMem": "Real",
"index": 68,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"TE3B": {
"name": "TE3B",
"description": "Temperatura Cavitazione Pompa B",
"memAddr": "DB85.DBB72",
"tipoMem": "Real",
"index": 72,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"PressH": {
"name": "PT300A",
"description": "Alta Pressione",
"memAddr": "DB85.DBB120",
"tipoMem": "Real",
"index": 120,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"PressM": {
"name": "PT300M",
"description": "Media Pressione",
"memAddr": "DB85.DBB124",
"tipoMem": "Real",
"index": 124,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"LivelloPerc": {
"name": "LT15%",
"description": "Livello Serbatorio %",
"memAddr": "DB85.DBB148",
"tipoMem": "Real",
"index": 148,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"MinTemp01": {
"name": "MinTempTE04",
"description": "Minima Temperatura Linea Sfiato Gas TE04",
"memAddr": "DB85.DBB152",
"tipoMem": "Real",
"index": 152,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
},
"MinTemp02": {
"name": "MinTempTT17",
"description": "Minima Temperatura Linea Sfiato Gas Torcia Serbatoio TT17",
"memAddr": "DB85.DBB156",
"tipoMem": "Real",
"index": 156,
"size": 4,
"func": "MAX",
"period": 60,
"factor": 1
}
}
}
+125
View File
@@ -0,0 +1,125 @@
[
{
"description": "Allarmi Impianto",
"tipoMem": "Boolean",
"memAddr": "DB85.DBB232",
"index": 232,
"size": 6,
"messages": [
"Emergenza Non Ripristinata",
"Emergenza QE Intervenuta",
"Emergenza Puls. Dispencer B Invervenuta",
"Emergenza Puls. Dispencer A Invervenuta",
"Stato Interruttore Erogatore Liquido B",
"Allarme Controllo Tensione di Rete",
"Allarme Controllo Tensione Antincendio",
"Stato Interruttore Erogatore Liquido A",
"Stato Sezionatore Generale",
"Stato Interruttore Protezione SPD",
"Stato Interruttore Sirena e Rotoalarm",
"Stato Interruttore Luci Emergenza",
"Stato Interruttore Pompa PC1A",
"Stato Interruttore Pompa PC1B",
"Stato Interruttore Pompa Sommersa C",
"Stato Termica Boil-Off",
"##234.0",
"Preallarme Centralina Metano",
"Allarme Centralina Metano",
"Emergenza Puls. Dispencer C Invervenuta",
"Mancaza Pressione Aria",
"Minima Temperatura Linea Sfiato Gas TE04",
"Minima Temperatura Linea Sfiato Gas Torcia Serbatoio TT17",
"Massima Temperatura Linea Sfiato Gas Torcia Serbatoio TT17",
"Almeno Un Emergenza Intervenuta",
"Arresto Operativo da PT1(predisposizione)",
"Stato Interruttore Alimentazione Punto Zero",
"##234.11",
"##234.12",
"##234.13",
"##234.14",
"Configurazione Incongruente",
"Pulsante Emergenza 2 SB17.3A Premuto",
"Pulsante Emergenza 1 SB17.3B Premuto",
"Pulsante Emergenza SB17.3C Premuto",
"Pulsante Emergenza 3 SB17.5 Premuto",
"Pulsante Emergenza 4 SB17.7 Premuto",
"##236.5",
"##236.6",
"##236.7",
"GT_TE2A",
"GT_TE1A",
"GT_TE3A",
"GT_TE04",
"GT_LT15",
"GT_PT01",
"GT_PT300R",
"GT_PT16"
]
},
{
"description": "Allarmi Serbatoio",
"tipoMem": "Boolean",
"memAddr": "DB85.DBB248",
"index": 248,
"size": 2,
"messages": [
"Serbatoio Troppo Pieno",
"Serbatoio Pieno_HH",
"Serbatoio Pieno_H",
"Serbatoio Vuoto_LL",
"H Pressione Serbatoio",
"HH Pressione Serbatoio",
"LL Temperatura Ingresso BoilOff TE08",
"Minima Pressione Serbatoio per Partenza Pompe",
"Timeout Apertura Valvola PV1",
"Timeout Chiusura Valvola PV1",
"Timeout Apertura Valvola PV70",
"Timeout Chiusura Valvola PV70",
"##248.12",
"##248.13",
"##248.14",
"##248.15"
]
},
{
"description": "Allarmi Pompa Alta Pressione A",
"tipoMem": "Boolean",
"memAddr": "DB85.DBB252",
"index": 252,
"size": 4,
"messages": [
"Ritardo Avvio Pompa PC1B",
"##252.1",
"Temperatura Freddo TE1B NON Raggiunta",
"HH Temperatura Cavitazione TE3B",
"Allarme Temperatura Tenute Pompa TE2B",
"LL Temperatura Ingresso Stoccaggio TE06",
"Allarme Temperatura Ingresso Stoccaggio TE07",
"Aumento Pressione PT01",
"##Max Pressione PT01",
"##256.9",
"##256.10",
"##256.11",
"##256.12",
"##256.13",
"##256.14",
"##256.15",
"Timeout Apertura PV3B",
"Timeout Apertura PV5B",
"Timeout Apertura PV6B",
"Timeout Apertura PV7",
"##258.4",
"##258.5",
"##258.6",
"##258.7",
"##258.8",
"##258.9",
"##258.10",
"##258.11",
"##258.12",
"##258.13",
"##258.14",
"##258.15"
]
}
]
+2
View File
@@ -67,6 +67,8 @@ MAX_SEND_PZC_BLOCK=100
;GESTIONE DATI DYN
ENABLE_DYN_DATA=TRUE
FORCE_DYN_DATA=TRUE
; gestione scrittura string/char[]: true = string / false = char[]
WRITE_PRE=TRUE
USE_NEW_EXE_TASK=TRUE
; conf parametri memoria READ/WRITE
+13
View File
@@ -83,6 +83,9 @@
<Reference Include="CndexLinkDotNet">
<HintPath>..\CncLib\ExtLib\CndexLinkDotNet.dll</HintPath>
</Reference>
<Reference Include="EasyModbus, Version=5.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll</HintPath>
</Reference>
<Reference Include="krcc, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>ExtLib\krcc.dll</HintPath>
@@ -172,6 +175,7 @@
<Compile Include="ControlExtensions.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="IobFileEurom63.cs" />
<Compile Include="IobModbusTCP.cs" />
<Compile Include="IobOpcUa.cs" />
<Compile Include="IobMTC.cs" />
<Compile Include="IobOmron.cs" />
@@ -347,12 +351,21 @@
<None Include="DATA\CONF\IMI_50.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\PIZ04.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\PIZ04.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\PIZ03.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\PIZ03.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\PIZ04_alarm.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\PIZ03_alarm.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+116
View File
@@ -0,0 +1,116 @@
using EasyModbus;
using IOB_UT_NEXT;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IOB_WIN_NEXT
{
public class IobModbusTCP : IobGeneric
{
#region Protected Fields
protected string serverIp = "hampizzaferri.dyndns.org";
#endregion Protected Fields
//protected string serverIp = "127.0.0.1";
#region Public Constructors
/// Classe base con i metodi x Siemens
/// </summary>
/// <param name="caller"></param>
/// <param name="adpConf"></param>
public IobModbusTCP(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
{
lgInfo("NEW IOB ModBus TCP");
testRead();
}
#endregion Public Constructors
#region Private Methods
private void testConf()
{
BaseModbusConf.VarConf var01 = new BaseModbusConf.VarConf()
{
Name = "Giacenza Serbatoio",
Type = BaseModbusConf.DataType.Real,
MemAddr = 1,
Size = 2,
Direction = BaseModbusConf.MemDirection.R,
RangeMin = 0,
RangeMax = 100
};
BaseModbusConf.VarConf var02 = new BaseModbusConf.VarConf()
{
Name = "Pressione Serbatoio",
Type = BaseModbusConf.DataType.Real,
MemAddr = 3,
Size = 2,
Direction = BaseModbusConf.MemDirection.R,
RangeMin = 0,
RangeMax = 25
};
List<BaseModbusConf.VarConf> memList01 = new List<BaseModbusConf.VarConf>();
memList01.Add(var01);
memList01.Add(var02);
BaseModbusConf.ModbusMemArea block01 = new BaseModbusConf.ModbusMemArea()
{
RawAddr = "40001",
Type = BaseModbusConf.MemType.HoldingRegister,
BaseAddr = 1,
Size = 50,
VarList = memList01
};
List<BaseModbusConf.ModbusMemArea> DemoMem = new List<BaseModbusConf.ModbusMemArea>();
DemoMem.Add(block01);
// creo un area di memoria
BaseModbusConf demoConf = new BaseModbusConf()
{
MemoryList = DemoMem
};
// salvo conf con json x compilare...
var rawData = JsonConvert.SerializeObject(demoConf);
}
private void testRead()
{
//Ip-Address and Port of Modbus-TCP-Server
ModbusClient modbusClient = new ModbusClient(serverIp, 502);
//Connect to Server
modbusClient.Connect();
//modbusClient.WriteMultipleCoils(4, new bool[] { true, true, true, true, true, true, true, true, true, true }); //Write Coils starting with Address 5
//bool[] readCoils = modbusClient.ReadCoils(9, 10); //Read 10 Coils from Server, starting with address 10
int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(0, 34); //Read 10 Holding Registers from Server, starting with Address 1
int[] readHR1000 = modbusClient.ReadHoldingRegisters(0, 100); //Read 10 Holding Registers from Server, starting with Address 1
//Disconnect from Server
modbusClient.Disconnect();
//// Console Output
//for (int i = 0; i < readCoils.Length; i++)
// Console.WriteLine("Value of Coil " + (9 + i + 1) + " " + readCoils[i].ToString());
for (int i = 0; i < readHoldingRegisters.Length; i++)
{
Console.WriteLine("Value of HoldingRegister " + (i + 1) + " " + readHoldingRegisters[i].ToString());
int[] thisSet = new int[2];
Array.Copy(readHoldingRegisters, i, thisSet, 0, 2);
Console.WriteLine("Convert val HoldingRegister " + (i + 1) + " " + ModbusClient.ConvertRegistersToFloat(thisSet));
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
#endregion Private Methods
}
}
+1
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autoupdater.NET.Official" version="1.6.4" targetFramework="net462" />
<package id="EasyModbusTCP" version="5.6.0" targetFramework="net462" />
<package id="MapoSDK" version="6.13.2105.1421" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.NetAnalyzers" version="5.0.3" targetFramework="net462" developmentDependency="true" />
<package id="Microsoft.VisualStudio.SlowCheetah" version="3.2.26" targetFramework="net40-client" developmentDependency="true" />