Commit c7bb3e30 authored by shaxuezheng's avatar shaxuezheng

merge origin

parents 273a0479 918658a8
...@@ -27,7 +27,6 @@ namespace ModbusDemo.Common ...@@ -27,7 +27,6 @@ namespace ModbusDemo.Common
ChannelLevelError = 16, ChannelLevelError = 16,
ChannelControlError = 32, ChannelControlError = 32,
ChannelRunOverTimeError = 64, ChannelRunOverTimeError = 64,
} }
public static void vSetAlarmList(ushort usAddress, ushort[] usChannel, ushort[] usChannelAlarmcode) public static void vSetAlarmList(ushort usAddress, ushort[] usChannel, ushort[] usChannelAlarmcode)
{ {
...@@ -58,7 +57,6 @@ namespace ModbusDemo.Common ...@@ -58,7 +57,6 @@ namespace ModbusDemo.Common
.Build(); .Build();
await mqttClient.PublishAsync(message); await mqttClient.PublishAsync(message);
} }
public static void vSet_Modual_Alarm(byte byModbusID,ushort usAlarmCodde,bool bSetAlarm,byte byCommFailTimes,params string[] strChannalList) public static void vSet_Modual_Alarm(byte byModbusID,ushort usAlarmCodde,bool bSetAlarm,byte byCommFailTimes,params string[] strChannalList)
{ {
for (int i = 0; i < ModualPoll.byX14pNumber;i++) for (int i = 0; i < ModualPoll.byX14pNumber;i++)
......
...@@ -28,6 +28,7 @@ namespace ModbusDemo.MessageFormat ...@@ -28,6 +28,7 @@ namespace ModbusDemo.MessageFormat
MB_EMASTERSENT, MB_EMASTERSENT,
MB_RTUERNOERR MB_RTUERNOERR
} }
public static ModbusMaster Modbus; public static ModbusMaster Modbus;
public static ushort usCommunFailTimes = 0; public static ushort usCommunFailTimes = 0;
private static object oLock = new object(); private static object oLock = new object();
...@@ -53,6 +54,7 @@ namespace ModbusDemo.MessageFormat ...@@ -53,6 +54,7 @@ namespace ModbusDemo.MessageFormat
OutputValue = new ushort[numberOfPoints]; OutputValue = new ushort[numberOfPoints];
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++; usCommunFailTimes++;
Console.WriteLine(slaveAddress.ToString());
} }
//The server return error code. //The server return error code.
//You can get the function code and exception code. //You can get the function code and exception code.
...@@ -137,6 +139,7 @@ namespace ModbusDemo.MessageFormat ...@@ -137,6 +139,7 @@ namespace ModbusDemo.MessageFormat
OutputValue = new bool[numberOfPoints]; OutputValue = new bool[numberOfPoints];
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++; usCommunFailTimes++;
Console.WriteLine(slaveAddress.ToString());
} }
//The server return error code. //The server return error code.
//You can get the function code and exception code. //You can get the function code and exception code.
...@@ -220,6 +223,7 @@ namespace ModbusDemo.MessageFormat ...@@ -220,6 +223,7 @@ namespace ModbusDemo.MessageFormat
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message + "Modbus_WriteSingleCoil"); Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message + "Modbus_WriteSingleCoil");
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++; usCommunFailTimes++;
Console.WriteLine(slaveAddress.ToString());
} }
//The server return error code. //The server return error code.
//You can get the function code and exception code. //You can get the function code and exception code.
...@@ -302,6 +306,7 @@ namespace ModbusDemo.MessageFormat ...@@ -302,6 +306,7 @@ namespace ModbusDemo.MessageFormat
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message + "Modbus_WriteMultipleCoils"); Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message + "Modbus_WriteMultipleCoils");
ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++; usCommunFailTimes++;
Console.WriteLine(slaveAddress.ToString());
} }
//The server return error code. //The server return error code.
//You can get the function code and exception code. //You can get the function code and exception code.
......
This diff is collapsed.
...@@ -91,10 +91,8 @@ ...@@ -91,10 +91,8 @@
<Compile Include="application\AutoControl.cs" /> <Compile Include="application\AutoControl.cs" />
<Compile Include="application\ControlMap.cs" /> <Compile Include="application\ControlMap.cs" />
<Compile Include="application\InIHelper.cs" /> <Compile Include="application\InIHelper.cs" />
<Compile Include="application\PoolModbusSet.cs" />
<Compile Include="application\ModualPool.cs" /> <Compile Include="application\ModualPool.cs" />
<Compile Include="application\AllPond.cs" /> <Compile Include="application\AllPond.cs" />
<Compile Include="application\UsThread.cs" />
<Compile Include="Common\ModualAlarm.cs" /> <Compile Include="Common\ModualAlarm.cs" />
<Compile Include="Common\OperIni.cs" /> <Compile Include="Common\OperIni.cs" />
<Compile Include="MessageFormat\ModualControl.cs" /> <Compile Include="MessageFormat\ModualControl.cs" />
...@@ -180,6 +178,9 @@ ...@@ -180,6 +178,9 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" /> <Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" />
<PropertyGroup>
<SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ModbusDemo.MessageFormat; using ModbusDemo.MessageFormat;
using ModbusDemo.Common; using ModbusDemo.Common;
...@@ -35,7 +36,7 @@ namespace ModbusDemo.Modular ...@@ -35,7 +36,7 @@ namespace ModbusDemo.Modular
public static _414P c14formulasormual = new _414P(); public static _414P c14formulasormual = new _414P();
#if DEBUG_TEST #if DEBUG_TEST
public const byte byX18xNumber = 1; public const byte byX18xNumber = 1;
public static byte[] byX18xIdlist = {13,14}; public static byte[] byX18xIdlist = { 13,};
private static modual.eX18xSensorChannelType[,] sX18xChannelType = new modual.eX18xSensorChannelType[byX18xNumber, byX18xReadDataNumber] { { modual.eX18xSensorChannelType.NormalCurrent, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.NormalCurrent, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null } }; private static modual.eX18xSensorChannelType[,] sX18xChannelType = new modual.eX18xSensorChannelType[byX18xNumber, byX18xReadDataNumber] { { modual.eX18xSensorChannelType.NormalCurrent, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.NormalCurrent, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null, modual.eX18xSensorChannelType.Null } };
#else #else
public const byte byX18xNumber = 6; public const byte byX18xNumber = 6;
...@@ -59,7 +60,7 @@ namespace ModbusDemo.Modular ...@@ -59,7 +60,7 @@ namespace ModbusDemo.Modular
#if DEBUG_TEST #if DEBUG_TEST
public const byte byX78cNumber = 1; public const byte byX78cNumber = 1;
public static byte[] byX78cIdlist = { 20 }; public static byte[] byX78cIdlist = { 20};
#else #else
public const byte byX78cNumber = 0; public const byte byX78cNumber = 0;
public static byte[] byX78cIdlist = {11,20,33,34,55,56}; public static byte[] byX78cIdlist = {11,20,33,34,55,56};
...@@ -148,6 +149,7 @@ namespace ModbusDemo.Modular ...@@ -148,6 +149,7 @@ namespace ModbusDemo.Modular
cx14P.sX14pDataStruct[i].dBeforeConvertData[j] = cx14P.sX14pDataStruct[i].dNowConvertData[j]; cx14P.sX14pDataStruct[i].dBeforeConvertData[j] = cx14P.sX14pDataStruct[i].dNowConvertData[j];
} }
cx14P.sX14PAlarmStruct[i].bDataNotFirstIncreaseOrDecrease = true; cx14P.sX14PAlarmStruct[i].bDataNotFirstIncreaseOrDecrease = true;
Thread.Sleep(100);
} }
for (byte i = 0; i < byX18xNumber; i++) for (byte i = 0; i < byX18xNumber; i++)
...@@ -227,6 +229,7 @@ namespace ModbusDemo.Modular ...@@ -227,6 +229,7 @@ namespace ModbusDemo.Modular
cx18x.sX18xDataStruct[i].dBeforeConvertData[j] = cx18x.sX18xDataStruct[i].dNowConvertData[j]; cx18x.sX18xDataStruct[i].dBeforeConvertData[j] = cx18x.sX18xDataStruct[i].dNowConvertData[j];
} }
cx18x.sX18xAlarmstruct[i].bDataNotFirstIncreaseOrDecrease = true; cx18x.sX18xAlarmstruct[i].bDataNotFirstIncreaseOrDecrease = true;
Thread.Sleep(100);
} }
for (byte i = 0; i < byX78cNumber; i++) for (byte i = 0; i < byX78cNumber; i++)
{ {
...@@ -249,6 +252,7 @@ namespace ModbusDemo.Modular ...@@ -249,6 +252,7 @@ namespace ModbusDemo.Modular
cx78c.sX78cAlarmStruct[i].usCommFailTimes[j] = 0; cx78c.sX78cAlarmStruct[i].usCommFailTimes[j] = 0;
} }
} }
Thread.Sleep(100);
} }
for (byte i = 0; i < byX66cNumber; i++) for (byte i = 0; i < byX66cNumber; i++)
...@@ -271,6 +275,7 @@ namespace ModbusDemo.Modular ...@@ -271,6 +275,7 @@ namespace ModbusDemo.Modular
cx66c.sX66cAlarmStruct[i].usCommFailTimes[j] = 0; cx66c.sX66cAlarmStruct[i].usCommFailTimes[j] = 0;
} }
} }
Thread.Sleep(100);
} }
} }
public static string stAll_Poll_Package() public static string stAll_Poll_Package()
......
...@@ -89,8 +89,6 @@ namespace ModbusDemo.Modular ...@@ -89,8 +89,6 @@ namespace ModbusDemo.Modular
{ {
this.sX18xDataStruct[i].dBeforeConvertData = new double[ModualPoll.byX18xReadDataNumber]; this.sX18xDataStruct[i].dBeforeConvertData = new double[ModualPoll.byX18xReadDataNumber];
this.sX18xDataStruct[i].dNowConvertData = new double[ModualPoll.byX18xReadDataNumber]; this.sX18xDataStruct[i].dNowConvertData = new double[ModualPoll.byX18xReadDataNumber];
//this.sX18xDataStruct[i].usRegData = new ushort[ModualPoll.byX18xReadDataNumber];
//this.sX18xDataStruct[i].usTypeData = new ushort[ModualPoll.byX18xReadDataNumber];
this.sX18xAlarmstruct[i].usBeforeAlarmCode = new ushort[ModualPoll.byX18xReadDataNumber]; this.sX18xAlarmstruct[i].usBeforeAlarmCode = new ushort[ModualPoll.byX18xReadDataNumber];
this.sX18xAlarmstruct[i].usNowAlarmCode = new ushort[ModualPoll.byX18xReadDataNumber]; this.sX18xAlarmstruct[i].usNowAlarmCode = new ushort[ModualPoll.byX18xReadDataNumber];
this.sX18xAlarmstruct[i].usCommFailTimes = new ushort[ModualPoll.byX18xReadDataNumber]; this.sX18xAlarmstruct[i].usCommFailTimes = new ushort[ModualPoll.byX18xReadDataNumber];
......
...@@ -8,29 +8,28 @@ using ModbusDemo; ...@@ -8,29 +8,28 @@ using ModbusDemo;
using ModbusDemo.application; using ModbusDemo.application;
namespace ModbusDemo.application namespace ModbusDemo.application
{ {
public static class AllPond public static class AllPond
{ {
private static ModualPool.pcTemperature cEastTransitPoolTemper = new ModualPool.pcTemperature("EastTransitPoolTemper", 27, "d0"); private static ModualPool.pcTemperature cEastTransitPoolTemper = new ModualPool.pcTemperature("EastTransitPoolTemper", 27, "d0");
private static ModualPool.pcLiquidlevel cEastTransitPoolLevel = new ModualPool.pcLiquidlevel("EastTransitPoolLevel", 13, "d0"); private static ModualPool.pcLiquidlevel cEastTransitPoolLevel = new ModualPool.pcLiquidlevel("EastTransitPoolLevel", 13, "d0");
private static ModualPool.pcOperation cEastTransitPoolSouthWaterBase = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolSouthWaterBase = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 31,
strOperationNumber = "d0", strOperationNumber = "d1",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] { "d1","d2" },
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true,true },
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false,false },
bHadRefControl = false, bHadRefControl = true,
byResModbusID = 0xFF, byResModbusID = 13,
strResChannelNumber = null strResChannelNumber = "d0"
}; };
private static ModualPool.pcMachine cEastTransitPoolSouthWater = new ModualPool.pcMachine("EastTransitPoolSouthWater", cEastTransitPoolSouthWaterBase); private static ModualPool.pcMachine cEastTransitPoolSouthWater = new ModualPool.pcMachine("EastTransitPoolSouthWater", cEastTransitPoolSouthWaterBase);
private static ModualPool.pcOperation cEastTransitPoolNorthWaterBase = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolNorthWaterBase = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 16,
strOperationNumber = "d2", strOperationNumber = "d0",
strChannelNumber = new string[] { "d2", "d3" }, strChannelNumber = new string[] { "d0", "d1" },
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true, true },
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false, false },
bHadRefControl = false, bHadRefControl = false,
...@@ -42,60 +41,61 @@ namespace ModbusDemo.application ...@@ -42,60 +41,61 @@ namespace ModbusDemo.application
private static ModualPool.pcOperation cEastTransitPoolPumb1Base = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolPumb1Base = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 16,
strOperationNumber = "d0", strOperationNumber = "d2",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] { "d2","d3"},
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true ,true},
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false,false},
bHadRefControl = false, bHadRefControl = false,
byResModbusID = 0xFF, byResModbusID = 0,
strResChannelNumber = null strResChannelNumber = null
}; };
private static ModualPool.pcMachine cEastTransitPoolPumb1 = new ModualPool.pcMachine("EastTransitPoolPumb_1", cEastTransitPoolPumb1Base); private static ModualPool.pcMachine cEastTransitPoolPumb1 = new ModualPool.pcMachine("EastTransitPoolPumb_1", cEastTransitPoolPumb1Base);
private static ModualPool.pcOperation cEastTransitPoolPumb2Base = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolPumb2Base = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 35,
strOperationNumber = "d0", strOperationNumber = "d0",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] {"d0","d1"},
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true,true},
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false,true},
bHadRefControl = false, bHadRefControl = false,
byResModbusID = 0xFF, byResModbusID = 0,
strResChannelNumber = null strResChannelNumber = null
}; };
private static ModualPool.pcMachine cEastTransitPoolPumb2 = new ModualPool.pcMachine("EastTransitPoolPumb_2", cEastTransitPoolPumb2Base); private static ModualPool.pcMachine cEastTransitPoolPumb2 = new ModualPool.pcMachine("EastTransitPoolPumb_2", cEastTransitPoolPumb2Base);
private static ModualPool.pcOperation cEastTransitPoolStirrer1Base = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolStirrer1Base = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 35,
strOperationNumber = "d0", strOperationNumber = "d2",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] { "d2","d3" },
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true,true},
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false,false},
bHadRefControl = false, bHadRefControl = false,
byResModbusID = 0xFF, byResModbusID = 0,
strResChannelNumber = null strResChannelNumber = null
}; };
private static ModualPool.pcMachine cEastTransitPoolStirrer1 = new ModualPool.pcMachine("EastTransitPoolStirrer_1", cEastTransitPoolStirrer1Base); private static ModualPool.pcMachine cEastTransitPoolStirrer1 = new ModualPool.pcMachine("EastTransitPoolStirrer_1", cEastTransitPoolStirrer1Base);
private static ModualPool.pcOperation cEastTransitPoolStirrer2Base = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolStirrer2Base = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 39,
strOperationNumber = "d0", strOperationNumber = "d0",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] { "d0", "d1" },
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true, true },
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false, false },
bHadRefControl = false, bHadRefControl = true,
byResModbusID = 0xFF, byResModbusID = 13,
strResChannelNumber = null strResChannelNumber = "d0"
}; };
private static ModualPool.pcMachine cEastTransitPoolStirrer2 = new ModualPool.pcMachine("EastTransitPoolStirrer_2", cEastTransitPoolStirrer2Base); private static ModualPool.pcMachine cEastTransitPoolStirrer2 = new ModualPool.pcMachine("EastTransitPoolStirrer_2", cEastTransitPoolStirrer2Base);
private static ModualPool.pcOperation cEastTransitPoolStirrer3Base = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolStirrer3Base = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 39,
strOperationNumber = "d0", strOperationNumber = "d2",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] { "d2", "d3" },
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true, true },
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false, false },
bHadRefControl = false, bHadRefControl = false,
...@@ -107,16 +107,28 @@ namespace ModbusDemo.application ...@@ -107,16 +107,28 @@ namespace ModbusDemo.application
private static ModualPool.pcOperation cEastTransitPoolStirrer4Base = new ModualPool.pcOperation private static ModualPool.pcOperation cEastTransitPoolStirrer4Base = new ModualPool.pcOperation
{ {
byModbusID = 16, byModbusID = 16,
strOperationNumber = "d0", strOperationNumber = "d4",
strChannelNumber = new string[] { "d0", "d1" }, strChannelNumber = new string[] { "d4" },
bOpenOperation = new bool[] { true, true }, bOpenOperation = new bool[] { true },
bCloseOperation = new bool[] { false, false }, bCloseOperation = new bool[] { false },
bHadRefControl = false, bHadRefControl = false,
byResModbusID = 0xFF, byResModbusID = 0xFF,
strResChannelNumber = null strResChannelNumber = null
}; };
private static ModualPool.pcMachine cEastTransitPoolStirrer4 = new ModualPool.pcMachine("EastTransitPoolStirrer_4", cEastTransitPoolStirrer4Base); private static ModualPool.pcMachine cEastTransitPoolStirrer4 = new ModualPool.pcMachine("EastTransitPoolStirrer_4", cEastTransitPoolStirrer4Base);
private static ModualPool.pcButtonOperation cEastTransitPoolButton1Base = new ModualPool.pcButtonOperation
{
byModbusID = 16,
strOperationNumber = "d0",
strChannelNumber = new string[]{ "d0","d1"},
bOpenOperation = new bool[] { true,true},
bCloseOperation = new bool[] { false,false}
};
private static ModualPool.pcButton cEastTransitPoolButton1 = new ModualPool.pcButton("EastTransitPoolButton1",cEastTransitPoolButton1Base);
public static List<ModualPool.pcMachine> EastTransitPoolList = new List<ModualPool.pcMachine>(new ModualPool.pcMachine[] {cEastTransitPoolSouthWater,cEastTransitPoolNorthWater,cEastTransitPoolPumb1,cEastTransitPoolPumb2,cEastTransitPoolStirrer1,cEastTransitPoolStirrer2,cEastTransitPoolStirrer3,cEastTransitPoolStirrer4});
public static class cEastTransitPool public static class cEastTransitPool
{ {
public static double vSetMaxLevel; public static double vSetMaxLevel;
...@@ -131,7 +143,7 @@ namespace ModbusDemo.application ...@@ -131,7 +143,7 @@ namespace ModbusDemo.application
public static ModualPool.pcMachine cStirrer2 {get => cEastTransitPoolStirrer2; set => cEastTransitPoolStirrer2 = value; } public static ModualPool.pcMachine cStirrer2 {get => cEastTransitPoolStirrer2; set => cEastTransitPoolStirrer2 = value; }
public static ModualPool.pcMachine cStirrer3 {get => cEastTransitPoolStirrer3; set => cEastTransitPoolStirrer3 = value; } public static ModualPool.pcMachine cStirrer3 {get => cEastTransitPoolStirrer3; set => cEastTransitPoolStirrer3 = value; }
public static ModualPool.pcMachine cStirrer4 {get => cEastTransitPoolStirrer4; set => cEastTransitPoolStirrer4 = value; } public static ModualPool.pcMachine cStirrer4 {get => cEastTransitPoolStirrer4; set => cEastTransitPoolStirrer4 = value; }
public static ModualPool.pcButton cButton1 {get => cEastTransitPoolButton1; set => cEastTransitPoolButton1 = value; }
private static void vSet_Poll_Max_Level(double dData) private static void vSet_Poll_Max_Level(double dData)
{ {
vSetMaxLevel = dData; vSetMaxLevel = dData;
......
...@@ -4,39 +4,134 @@ using System.Linq; ...@@ -4,39 +4,134 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ModbusDemo.application; using ModbusDemo.application;
using ModbusDemo.MessageFormat;
namespace ModbusDemo.application namespace ModbusDemo.application
{ {
public class ControlMap public class ControlMap
{ {
public delegate bool bDelege_Handle(bool[] bControlData); public delegate bool bDelege_Handle(bool[] bControlData);
public static bDelege_Handle bDelege_Operation; public static bDelege_Handle bDelege_Operation;
public static byte byMapIdleID;
public static bool bControl_Map(bool bOpen, byte byControlID, params string[] strOperationChannelName) public static bool[] byMapIdleControlData;
public static string[] strMapIdleChannelName;
public static bool bMap_Idle_Open_Control(bool[] bControldata)
{
bool[] bControlBit = new bool[bControldata.Count()];
bool bStatus;
bool bHadOperation;
for (int i = 0; i < bControldata.Count(); i++)
{
string str = "d" + i.ToString();
for (int j = 0; j < strMapIdleChannelName.Count(); j++)
{
if (str == strMapIdleChannelName[j])
{
bControlBit[i] = true;
bControldata[i] = byMapIdleControlData[i];
}
}
}
bStatus = ModualControl.bOperation_Machine(true, byMapIdleID, bControldata, bControlBit,out bHadOperation, 0, null);
return bStatus;
}
public static bool bMap_Idle_Close_Control(bool[] bControldata)
{
bool[] bControlBit = new bool[bControldata.Count()];
bool bStatus;
bool bHadOperation;
for (int i = 0; i < bControldata.Count(); i++)
{
string str = "d" + i.ToString();
for (int j = 0; j < strMapIdleChannelName.Count(); j++)
{
if (str == strMapIdleChannelName[j])
{
bControlBit[i] = true;
bControldata[i] = byMapIdleControlData[i];
}
}
}
bStatus = ModualControl.bOperation_Machine(true, byMapIdleID, bControldata, bControlBit,out bHadOperation, 0, null);
return bStatus;
}
public static bool bControl_Map(bool bOpen, byte byControlID,bool[] bControlData, params string[] strOperationChannelName)
{ {
bool bMapStatus = true; bool bMapStatus = true;
if (bOpen == true) if (bOpen == true)
{ {
if (byControlID == 16 && strOperationChannelName[0] == "d0") if (byControlID == 31 && strOperationChannelName[0] == "d1")
{ {
bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bOpen_Machine; bDelege_Operation = AllPond.cEastTransitPool.cSouthWater.bOpen_Machine;
}
else if (byControlID == 16 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cNorthWater.bOpen_Machine;
} }
else if (byControlID == 16 && strOperationChannelName[0] == "d2") else if (byControlID == 16 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bOpen_Machine;
}
else if (byControlID == 35 && strOperationChannelName[0] == "d0")
{ {
bDelege_Operation = AllPond.cEastTransitPool.cPumb2.bOpen_Machine; bDelege_Operation = AllPond.cEastTransitPool.cPumb2.bOpen_Machine;
} }
else if (byControlID == 35 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer1.bOpen_Machine;
}
else if (byControlID == 39 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer2.bOpen_Machine;
}
else if (byControlID == 39 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer3.bOpen_Machine;
}
else
{
byMapIdleID = byControlID;
strMapIdleChannelName = strOperationChannelName;
byMapIdleControlData = bControlData;
bDelege_Operation = bMap_Idle_Open_Control;
}
} }
else else
{ {
if (byControlID == 16 && strOperationChannelName[0] == "d0") if (byControlID == 31 && strOperationChannelName[0] == "d1")
{ {
bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bClose_Machine; bDelege_Operation = AllPond.cEastTransitPool.cSouthWater.bClose_Machine;
}
else if (byControlID == 16 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cNorthWater.bClose_Machine;
} }
else if (byControlID == 16 && strOperationChannelName[0] == "d2") else if (byControlID == 16 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bClose_Machine;
}
else if (byControlID == 35 && strOperationChannelName[0] == "d0")
{ {
bDelege_Operation = AllPond.cEastTransitPool.cPumb2.bClose_Machine; bDelege_Operation = AllPond.cEastTransitPool.cPumb2.bClose_Machine;
} }
else if (byControlID == 35 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer1.bClose_Machine;
}
else if (byControlID == 39 && strOperationChannelName[0] == "d0")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer2.bClose_Machine;
}
else if (byControlID == 39 && strOperationChannelName[0] == "d2")
{
bDelege_Operation = AllPond.cEastTransitPool.cStirrer3.bClose_Machine;
}
else
{
byMapIdleID = byControlID;
strMapIdleChannelName = strOperationChannelName;
byMapIdleControlData = bControlData;
bDelege_Operation = bMap_Idle_Close_Control;
}
} }
return bMapStatus; return bMapStatus;
} }
......
...@@ -92,25 +92,13 @@ namespace ModbusDemo.application ...@@ -92,25 +92,13 @@ namespace ModbusDemo.application
public bool bHadRefControl; public bool bHadRefControl;
public byte byResModbusID; public byte byResModbusID;
public string strResChannelNumber; public string strResChannelNumber;
}
//public pcOperation(byte byControlID, string[] strChannelNumber,string strOperationNumber,bool bHadRefControl,byte byResID,string strResChannelName,bool[] bOpenData,bool[] bCloseData) public class pcMachine : pcOperation
//{
// this.byModbusID = byControlID;
// this.strChannelNumber = strChannelNumber;
// this.strOperationNumber = strOperationNumber;
// this.bHadRefControl = bHadRefControl;
// this.byResModbusID = byResID;
// this.strResChannelNumber = strResChannelName;
// this.bOpenOperation = bOpenData;
// this.bCloseOperation = bCloseData;
//}
}
public class pcMachine:pcOperation
{ {
public string strMachinebName; public string strMachinebName;
public double dChannelCurrent { get => vGet_ResCurrent();} public double dChannelCurrent { get => vGet_ResCurrent();}
public bool bHadOpenPumb; public bool bHadOpenPumb;
public bool[] bCurrentRelay; public bool[] bCurrentRelay { get => bGet_Current_Relay();}
public pcMachine(string strMachineName,pcOperation pcOperation) // base(pcOperation.byModbusID,pcOperation.strChannelNumber,pcOperation.strOperationNumber,pcOperation.bHadRefControl,pcOperation.byResModbusID,pcOperation.strResChannelNumber,pcOperation.bOpenOperation,pcOperation.bCloseOperation) public pcMachine(string strMachineName,pcOperation pcOperation) // base(pcOperation.byModbusID,pcOperation.strChannelNumber,pcOperation.strOperationNumber,pcOperation.bHadRefControl,pcOperation.byResModbusID,pcOperation.strResChannelNumber,pcOperation.bOpenOperation,pcOperation.bCloseOperation)
{ {
this.strMachinebName = strMachineName; this.strMachinebName = strMachineName;
...@@ -123,7 +111,6 @@ namespace ModbusDemo.application ...@@ -123,7 +111,6 @@ namespace ModbusDemo.application
this.bOpenOperation = pcOperation.bOpenOperation; this.bOpenOperation = pcOperation.bOpenOperation;
this.bCloseOperation = pcOperation.bCloseOperation; this.bCloseOperation = pcOperation.bCloseOperation;
} }
public bool bOpen_Machine(bool[] bControldata) public bool bOpen_Machine(bool[] bControldata)
{ {
bool[] bControlBit = new bool[bControldata.Count()]; bool[] bControlBit = new bool[bControldata.Count()];
...@@ -140,13 +127,12 @@ namespace ModbusDemo.application ...@@ -140,13 +127,12 @@ namespace ModbusDemo.application
} }
} }
} }
if ((bStatus = ModualControl.bOperation_Machine(true, byModbusID, bControldata, bControlBit, byResModbusID, strResChannelNumber)) == true) if ((bStatus = ModualControl.bOperation_Machine(true, byModbusID, bControldata, bControlBit,out bHadOpenPumb, byResModbusID, strResChannelNumber)) == true)
{ {
bHadOpenPumb = true; bHadOpenPumb = true;
} }
return bStatus; return bStatus;
} }
public bool bClose_Machine(bool[] bControldata) public bool bClose_Machine(bool[] bControldata)
{ {
bool[] bControlBit = new bool[bControldata.Count()]; bool[] bControlBit = new bool[bControldata.Count()];
...@@ -163,22 +149,103 @@ namespace ModbusDemo.application ...@@ -163,22 +149,103 @@ namespace ModbusDemo.application
} }
} }
} }
if ((bStatus = ModualControl.bOperation_Machine(false, byModbusID, bControldata, bControlBit, byResModbusID, strResChannelNumber)) == true) if ((bStatus = ModualControl.bOperation_Machine(false, byModbusID, bControldata, bControlBit,out bHadOpenPumb, byResModbusID, strResChannelNumber)) == true)
{ {
bHadOpenPumb = false; bHadOpenPumb = false;
} }
return bStatus; return bStatus;
} }
private double vGet_ResCurrent() private double vGet_ResCurrent()
{ {
double[] dConvertData; double[] dConvertData;
if (ModualPoll.bGet_channel_Value<double>(byResModbusID, out dConvertData, strResChannelNumber) == true) if (bHadRefControl == true && ModualPoll.bGet_channel_Value<double>(byResModbusID, out dConvertData, strResChannelNumber) == true)
{ {
return dConvertData[0]; return dConvertData[0];
} }
return 0; return 0;
} }
private bool[] bGet_Current_Relay()
{
bool[] bRelaydata;
if (ModualPoll.bGet_channel_Value<bool>(byModbusID, out bRelaydata, strChannelNumber) == true)
{
return bRelaydata;
}
else
{
return bRelaydata;
}
}
}
public class pcButtonOperation
{
public byte byModbusID;
public string[] strChannelNumber;
public string strOperationNumber;
public bool[] bOpenOperation;
public bool[] bCloseOperation;
}
public class pcButton :pcButtonOperation
{
public string strButtonName;
public bool[] bCurrentRelay { get => bGet_Current_Relay();}
public pcButton(string strButtonName,pcButtonOperation cButtonOperation)
{
this.strButtonName = strButtonName;
this.byModbusID = cButtonOperation.byModbusID;
this.strOperationNumber = cButtonOperation.strOperationNumber;
this.strChannelNumber = cButtonOperation.strChannelNumber;
this.bOpenOperation = cButtonOperation.bOpenOperation;
this.bCloseOperation = cButtonOperation.bCloseOperation;
}
public bool bOpreation_Button(bool[] bControldata)
{
bool bStatus;
bool bHadOpenButton;
bool[] bControlBit = new bool[bControldata.Count()];
for (int i = 0; i < bControldata.Count(); i++)
{
string str = "d" + i.ToString();
for (int j = 0; j < strChannelNumber.Count(); j++)
{
if (str == strChannelNumber[j])
{
bControlBit[i] = true;
bControldata[i] = bOpenOperation[j];
}
}
}
if ((bStatus = ModualControl.bOperation_Machine(true, byModbusID, bControldata, bControlBit,out bHadOpenButton, 0, null)) == true)
{
for (int i = 0; i < bControldata.Count(); i++)
{
string str = "d" + i.ToString();
for (int j = 0; j < strChannelNumber.Count(); j++)
{
if (str == strChannelNumber[j])
{
bControlBit[i] = true;
bControldata[i] = bCloseOperation[j];
}
}
}
bStatus = ModualControl.bOperation_Machine(true, byModbusID, bControldata, bControlBit, out bHadOpenButton,0, null);
}
return bStatus;
}
private bool[] bGet_Current_Relay()
{
bool[] bRelaydata;
if (ModualPoll.bGet_channel_Value<bool>(byModbusID, out bRelaydata, strChannelNumber) == true)
{
return bRelaydata;
}
else
{
return bRelaydata;
}
}
} }
} }
} }
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace ModbusDemo.application
{
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment