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;
...@@ -58,8 +59,8 @@ namespace ModbusDemo.Modular ...@@ -58,8 +59,8 @@ namespace ModbusDemo.Modular
private static _418X c18xformulasormual = new _418X(); private static _418X c18xformulasormual = new _418X();
#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];
......
This diff is collapsed.
...@@ -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;
} }
......
...@@ -48,15 +48,15 @@ namespace ModbusDemo.application ...@@ -48,15 +48,15 @@ namespace ModbusDemo.application
} }
public class pcLiquidlevel public class pcLiquidlevel
{ {
private string strLevel; private string strLevel;
public double dCurrentlevel { get => vGet_ResCurrent();} public double dCurrentlevel { get => vGet_ResCurrent();}
private byte byModbusID; private byte byModbusID;
private string[] strChannelNumber; private string[] strChannelNumber;
public pcLiquidlevel(string strName, byte byModbusID,params string[] strChannelNumber) public pcLiquidlevel(string strName, byte byModbusID,params string[] strChannelNumber)
{ {
this.strLevel = strName; this.strLevel = strName;
this.byModbusID = byModbusID; this.byModbusID = byModbusID;
this.strChannelNumber = strChannelNumber; this.strChannelNumber = strChannelNumber;
} }
private double vGet_ResCurrent() private double vGet_ResCurrent()
{ {
...@@ -83,34 +83,22 @@ namespace ModbusDemo.application ...@@ -83,34 +83,22 @@ namespace ModbusDemo.application
} }
public class pcOperation public class pcOperation
{ {
public byte byModbusID; public byte byModbusID;
public string[] strChannelNumber; public string[] strChannelNumber;
public string strOperationNumber; public string strOperationNumber;
public bool[] bOpenOperation; public bool[] bOpenOperation;
public bool[] bCloseOperation; public bool[] bCloseOperation;
public bool bHadRefControl;
public byte byResModbusID;
public string strResChannelNumber;
//public pcOperation(byte byControlID, string[] strChannelNumber,string strOperationNumber,bool bHadRefControl,byte byResID,string strResChannelName,bool[] bOpenData,bool[] bCloseData) public bool bHadRefControl;
//{ public byte byResModbusID;
// this.byModbusID = byControlID; public string strResChannelNumber;
// 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 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