Continuo implementazione ModBus
This commit is contained in:
@@ -57,7 +57,7 @@ ENABLE_DYN_DATA=TRUE
|
||||
FORCE_DYN_DATA=TRUE
|
||||
|
||||
; clock base (da 10ms)
|
||||
timerIntMs=20
|
||||
timerIntMs=100
|
||||
|
||||
; conf parametri memoria READ/WRITE
|
||||
PARAM_CONF=PIZ04.json
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
"description": "Pressione Serbatoio",
|
||||
"memAddr": "40003",
|
||||
"tipoMem": "Real",
|
||||
"index": 28,
|
||||
"size": 4,
|
||||
"index": 3,
|
||||
"size": 2,
|
||||
"func": "MAX",
|
||||
"period": 60,
|
||||
"factor": 1,
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.7.9\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.7.11\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OmronFinsTCP.Net, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OmronFinsTCP.Net.3.0.0.0\lib\net40\OmronFinsTCP.Net.dll</HintPath>
|
||||
|
||||
@@ -4072,7 +4072,8 @@ namespace IOB_WIN_NEXT
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle speed (RPM, feedrate) degli assi
|
||||
/// Effettua processing del recupero dei valori dinamici:
|
||||
/// es: speed (RPM, feedrate) degli assi, valori pressioni, temeprature
|
||||
/// </summary>
|
||||
public void processDynData()
|
||||
{
|
||||
|
||||
@@ -563,7 +563,6 @@ namespace IOB_WIN_NEXT
|
||||
// procedo x ogni valore configurato......
|
||||
foreach (var item in memMap.mMapRead)
|
||||
{
|
||||
#if false
|
||||
// in primis DEVO determinare di quale TIPO di valore ho bisogno...
|
||||
switch (item.Value.tipoMem)
|
||||
{
|
||||
@@ -603,7 +602,6 @@ namespace IOB_WIN_NEXT
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -628,6 +626,70 @@ namespace IOB_WIN_NEXT
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lettura valori Coils (1...)
|
||||
/// </summary>
|
||||
/// <param name="startAddr"></param>
|
||||
/// <param name="qty"></param>
|
||||
/// <returns></returns>
|
||||
public bool[] readCoil(int startAddr, int qty)
|
||||
{
|
||||
bool[] answ = new bool[1];
|
||||
if (currPLC.Connected)
|
||||
{
|
||||
answ = currPLC.ReadCoils(startAddr, qty);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lettura valori DiscreteInputs (2...)
|
||||
/// </summary>
|
||||
/// <param name="startAddr"></param>
|
||||
/// <param name="qty"></param>
|
||||
/// <returns></returns>
|
||||
public bool[] readDiscrInputs(int startAddr, int qty)
|
||||
{
|
||||
bool[] answ = new bool[1];
|
||||
if (currPLC.Connected)
|
||||
{
|
||||
answ = currPLC.ReadDiscreteInputs(startAddr, qty);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lettura valori Holding Register (3...)
|
||||
/// </summary>
|
||||
/// <param name="startAddr"></param>
|
||||
/// <param name="qty"></param>
|
||||
/// <returns></returns>
|
||||
public int[] readHoldReg(int startAddr, int qty)
|
||||
{
|
||||
int[] answ = new int[2];
|
||||
if (currPLC.Connected)
|
||||
{
|
||||
answ = currPLC.ReadHoldingRegisters(startAddr, qty);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lettura valori Input Register (4...)
|
||||
/// </summary>
|
||||
/// <param name="startAddr"></param>
|
||||
/// <param name="qty"></param>
|
||||
/// <returns></returns>
|
||||
public int[] readInReg(int startAddr, int qty)
|
||||
{
|
||||
int[] answ = new int[2];
|
||||
if (currPLC.Connected)
|
||||
{
|
||||
answ = currPLC.ReadInputRegisters(startAddr, qty);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura semafori principale
|
||||
/// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
|
||||
@@ -645,14 +707,14 @@ namespace IOB_WIN_NEXT
|
||||
lgInfo("inizio read semafori");
|
||||
}
|
||||
|
||||
// ciclo a leggere TUTTI i blocchi di memoria impostati
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
// leggo TUTTI i byte configurati...
|
||||
MemBlock = new byte[item.Value];
|
||||
S7ReadBB(ref MemBlock, $"{item.Key}", item.Value);
|
||||
Buffer.BlockCopy(MemBlock, 0, RawInput, 0, parametri.memSizeRead);
|
||||
}
|
||||
//// ciclo a leggere TUTTI i blocchi di memoria impostati
|
||||
//foreach (var item in memSetR)
|
||||
//{
|
||||
// // leggo TUTTI i byte configurati...
|
||||
// MemBlock = new byte[item.Value];
|
||||
// S7ReadBB(ref MemBlock, $"{item.Key}", item.Value);
|
||||
// Buffer.BlockCopy(MemBlock, 0, RawInput, item.Key, item.Value);
|
||||
//}
|
||||
|
||||
//// leggo TUTTI i byte configurati...
|
||||
//MemBlock = new byte[parametri.memSizeRead];
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace IOB_WIN_NEXT
|
||||
lgInfo("NEW IOB ModBus TCP HAM");
|
||||
|
||||
// provo una lettura
|
||||
testRead();
|
||||
//testRead();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
@@ -466,7 +466,10 @@ namespace IOB_WIN_NEXT
|
||||
try
|
||||
{
|
||||
var currForm = (AdapterForm)item;
|
||||
numAttivi += currForm.iobObj.IobOnline ? 1 : 0;
|
||||
if (currForm.iobObj != null)
|
||||
{
|
||||
numAttivi += currForm.iobObj.IobOnline ? 1 : 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<package id="Microsoft.VisualStudio.SlowCheetah" version="3.2.26" targetFramework="net40-client" developmentDependency="true" />
|
||||
<package id="MTConnect.NET" version="2.9.1.28314" targetFramework="net40-client" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
|
||||
<package id="NLog" version="4.7.9" targetFramework="net462" />
|
||||
<package id="NLog" version="4.7.11" targetFramework="net462" />
|
||||
<package id="OmronFinsTCP.Net" version="3.0.0.0" targetFramework="net40-client" />
|
||||
<package id="OPCFoundation.NetStandard.Opc.Ua.Client" version="1.4.365.48" targetFramework="net462" />
|
||||
<package id="OPCFoundation.NetStandard.Opc.Ua.Configuration" version="1.4.365.48" targetFramework="net462" />
|
||||
|
||||
Reference in New Issue
Block a user