Commit 1dfb305f authored by leon.huang's avatar leon.huang

add modbus poll all modual

parent 0b293b14
...@@ -233,7 +233,6 @@ namespace ModbusDemo.windows ...@@ -233,7 +233,6 @@ namespace ModbusDemo.windows
public String GetVersion(Byte slaveid) public String GetVersion(Byte slaveid)
{ {
int ret; int ret;
String version = "0.0"; String version = "0.0";
String ip = "127.0.0.1"; String ip = "127.0.0.1";
UInt16[] buf = new ushort[2]; UInt16[] buf = new ushort[2];
...@@ -247,6 +246,5 @@ namespace ModbusDemo.windows ...@@ -247,6 +246,5 @@ namespace ModbusDemo.windows
} }
return version; return version;
} }
} }
} }
...@@ -13,14 +13,29 @@ namespace ModbusDemo.MessageFormat ...@@ -13,14 +13,29 @@ namespace ModbusDemo.MessageFormat
{ {
public static class ModbusComm public static class ModbusComm
{ {
public enum eModbusErrorCode : byte
{
MB_ENOERR, /*!< no error. */
MB_ENOREG, /*!< illegal register address. */
MB_EINVAL, /*!< illegal argument. */
MB_EPORTERR, /*!< porting layer error. */
MB_ENORES, /*!< insufficient resources. */
MB_EIO, /*!< I/O error. */
MB_EILLSTATE, /*!< protocol stack in illegal state. */
MB_ETIMEDOUT, /*!< timeout error occurred. */
MB_EMASTERNOERR, /*!< master mode no error. */
MB_EMASTERERR, /*!< master mode error. */
MB_EMASTERSENT,
MB_RTUERNOERR
}
public static ModbusMaster Modbus; public static ModbusMaster Modbus;
public static ushort usCommunFailTimes = 0;
public static void Modbus_ReadHoldingRegistersTask(out ushort[] OutputValue, byte slaveAddress, ushort startAddress, ushort numberOfPoints, out bool bCommStatus) public static void Modbus_ReadHoldingRegistersTask(out ushort[] OutputValue, byte slaveAddress, ushort startAddress, ushort numberOfPoints, out eModbusErrorCode ModbusErrorCode)
{ {
try try
{ {
OutputValue = Modbus.ReadHoldingRegisters(slaveAddress, startAddress, numberOfPoints); OutputValue = Modbus.ReadHoldingRegisters(slaveAddress, startAddress, numberOfPoints);
bCommStatus = true; ModbusErrorCode = eModbusErrorCode.MB_EMASTERNOERR;
} }
catch (Exception exception) catch (Exception exception)
{ {
...@@ -32,7 +47,8 @@ namespace ModbusDemo.MessageFormat ...@@ -32,7 +47,8 @@ namespace ModbusDemo.MessageFormat
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message); Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message); Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
OutputValue = new ushort[numberOfPoints]; OutputValue = new ushort[numberOfPoints];
bCommStatus = false; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++;
} }
//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.
...@@ -90,15 +106,15 @@ namespace ModbusDemo.MessageFormat ...@@ -90,15 +106,15 @@ namespace ModbusDemo.MessageFormat
} }
} }
OutputValue = new ushort[numberOfPoints]; OutputValue = new ushort[numberOfPoints];
bCommStatus = false; ModbusErrorCode = eModbusErrorCode.MB_EMASTERERR;
} }
} }
public static void Modbus_ReadCoilsTask(out bool[] OutputValue, byte slaveAddress, ushort startAddress, ushort numberOfPoints, out bool bComStatus) public static void Modbus_ReadCoilsTask(out bool[] OutputValue, byte slaveAddress, ushort startAddress, ushort numberOfPoints, out eModbusErrorCode ModbusErrorCode)
{ {
try try
{ {
OutputValue = Modbus.ReadCoils(slaveAddress, startAddress, numberOfPoints); OutputValue = Modbus.ReadCoils(slaveAddress, startAddress, numberOfPoints);
bComStatus = true; ModbusErrorCode = eModbusErrorCode.MB_EMASTERNOERR;
} }
catch (Exception exception) catch (Exception exception)
{ {
...@@ -110,7 +126,8 @@ namespace ModbusDemo.MessageFormat ...@@ -110,7 +126,8 @@ namespace ModbusDemo.MessageFormat
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message); Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message); Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
OutputValue = new bool[numberOfPoints]; OutputValue = new bool[numberOfPoints];
bComStatus = false; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
usCommunFailTimes++;
} }
//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.
...@@ -168,15 +185,15 @@ namespace ModbusDemo.MessageFormat ...@@ -168,15 +185,15 @@ namespace ModbusDemo.MessageFormat
} }
} }
OutputValue = new bool[numberOfPoints]; OutputValue = new bool[numberOfPoints];
bComStatus = false; ModbusErrorCode = eModbusErrorCode.MB_EMASTERERR;
} }
} }
public static void Modbus_WriteSingleCoil(byte slaveAddress, ushort startAddress, bool[] value, out bool bComStatus) public static void Modbus_WriteSingleCoil(byte slaveAddress, ushort startAddress, bool[] value, out eModbusErrorCode ModbusErrorCode)
{ {
try try
{ {
Modbus.WriteMultipleCoils(slaveAddress, startAddress, value); Modbus.WriteMultipleCoils(slaveAddress, startAddress, value);
bComStatus = true; ModbusErrorCode = eModbusErrorCode.MB_ENOERR;
} }
catch (Exception exception) catch (Exception exception)
{ {
...@@ -187,7 +204,7 @@ namespace ModbusDemo.MessageFormat ...@@ -187,7 +204,7 @@ namespace ModbusDemo.MessageFormat
{ {
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message); Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message); Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
bComStatus = false; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
} }
//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.
...@@ -244,16 +261,15 @@ namespace ModbusDemo.MessageFormat ...@@ -244,16 +261,15 @@ namespace ModbusDemo.MessageFormat
break; break;
} }
} }
bComStatus = false; ModbusErrorCode = eModbusErrorCode.MB_EMASTERERR;
} }
} }
public static void Modbus_WriteMultipleCoils(byte slaveAddress, ushort startAddress, bool[] data, out bool bComStatus) public static void Modbus_WriteMultipleCoils(byte slaveAddress, ushort startAddress, bool[] data, out eModbusErrorCode ModbusErrorCode)
{
{ {
try try
{ {
Modbus.WriteMultipleCoils(slaveAddress, startAddress, data); Modbus.WriteMultipleCoils(slaveAddress, startAddress, data);
bComStatus = true; ModbusErrorCode = eModbusErrorCode.MB_ENOERR;
} }
catch (Exception exception) catch (Exception exception)
{ {
...@@ -264,7 +280,7 @@ namespace ModbusDemo.MessageFormat ...@@ -264,7 +280,7 @@ namespace ModbusDemo.MessageFormat
{ {
Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message); Console.WriteLine(DateTime.Now.ToString() + " " + exception.Message);
Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message); Form1.totxt.Log(DateTime.Now.ToString() + " " + exception.Message);
bComStatus = false; ModbusErrorCode = eModbusErrorCode.MB_ETIMEDOUT;
} }
//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.
...@@ -321,8 +337,7 @@ namespace ModbusDemo.MessageFormat ...@@ -321,8 +337,7 @@ namespace ModbusDemo.MessageFormat
break; break;
} }
} }
bComStatus = false; ModbusErrorCode = eModbusErrorCode.MB_EMASTERERR;
}
} }
} }
//private void Init_Read_data() //private void Init_Read_data()
......
...@@ -98,6 +98,8 @@ ...@@ -98,6 +98,8 @@
<Compile Include="Modular\478C.cs" /> <Compile Include="Modular\478C.cs" />
<Compile Include="Modular\418X.cs" /> <Compile Include="Modular\418X.cs" />
<Compile Include="Common\Modbuslib.cs" /> <Compile Include="Common\Modbuslib.cs" />
<Compile Include="Modular\ModualPoll.cs" />
<Compile Include="Modular\modual.cs" />
<Compile Include="windows\Form1.cs"> <Compile Include="windows\Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ModbusDemo.MessageFormat;
namespace ModbusDemo.Modular
{
class ModualPoll
{
const byte byX14pNumber = 3;
const byte byX14pReadDataStartAddress = 0;
const byte byX14pReadDataNumber = 4;
const byte byX14pReadTypeStartAddress = 10;
const byte byX14pReadTypeNumber = 4;
static byte[] byX14pIdlist = {17,28,29};
modual.pcx14P cx14P = new modual.pcx14P(byX14pIdlist);
_414P c14formulasormual = new _414P();
const byte byX18xNumber = 6;
const byte byX18xReadDataStartAddress = 0;
const byte byX18xReadDataNumber = 8;
const byte byX18xReadTypeStartAddress = 10;
const byte byX18xReadTypeNumber = 8;
static byte[] byX18xIdlist = {12,13,21,25,45,53};
static modual.eX18xSensorChannelType[,] sX18xChannelType = new modual.eX18xSensorChannelType[byX18xNumber,byX18xReadDataNumber]{{modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal},
{modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal},
{modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal},
{modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal},
{modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal},
{modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal,modual.eX18xSensorChannelType.Normal}};
modual.pcx18X cx18x = new modual.pcx18X(byX18xIdlist, sX18xChannelType);
_418X c18xformulasormual= new _418X();
const byte byX78cNumber = 6;
const byte byX78cInputRegStartAddress = 0;
const byte byX78cInputRegNumber = 8;
const byte byX78cOutputRegStartAddress = 16;
const byte byX78cOutputRegNumber = 8;
static byte[] byX78cIdlist = {11,20,33,34,55,56};
modual.pcx78C cx78c = new modual.pcx78C(byX78cIdlist);
const byte byX66cNumber = 32;
const byte byX66cRelayRegStartAddress = 16;
const byte byX66cRelayRegNumber = 6;
static byte[] byX66cIdlist = {9,10,14,15,16,19,22,23,24,26,30,31,32,35,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,54,57};
modual.pcx66C cx66c = new modual.pcx66C(byX66cIdlist);
void vAllNodePoll()
{
for (byte i = 0; i < byX14pNumber; i++)
{
string[][] sTempString = new string[byX14pNumber][];
ModbusComm.Modbus_ReadHoldingRegistersTask(out cx14P.sX14pDataStruct[i].usX14pRegData, cx14P.byModbusID[i], byX14pReadDataStartAddress, byX14pReadDataNumber, out cx14P.ModbusErrorCode[i]);
ModbusComm.Modbus_ReadHoldingRegistersTask(out cx14P.sX14pDataStruct[i].usX14pRegType, cx14P.byModbusID[i], byX14pReadTypeStartAddress, byX14pReadTypeNumber, out cx14P.ModbusErrorCode[i]);
sTempString[i] = c14formulasormual.RtdValue(cx14P.sX14pDataStruct[i].usX14pRegData, cx14P.sX14pDataStruct[i].usX14pRegType);
for (byte j = 0; j < byX14pReadTypeNumber; j++)
{
cx14P.sX14pDataStruct[i].dX14pConvertData[j] = double.Parse(sTempString[i][j]);
}
}
for (byte i = 0; i < byX18xNumber; i++)
{
string[][] sTempString = new string[byX18xNumber][];
ModbusComm.Modbus_ReadHoldingRegistersTask(out cx18x.sX18xDataStruct[i].usRegData, cx18x.byModbusID[i], byX18xReadDataStartAddress, byX18xReadDataNumber, out cx18x.ModbusErrorCode[i]);
ModbusComm.Modbus_ReadHoldingRegistersTask(out cx18x.sX18xDataStruct[i].usTypeData,cx18x.byModbusID[i], byX18xReadTypeStartAddress, byX18xReadTypeNumber, out cx18x.ModbusErrorCode[i]);
sTempString[i] = c18xformulasormual.Value(cx14P.sX14pDataStruct[i].usX14pRegData, cx14P.sX14pDataStruct[i].usX14pRegType);
for (byte j = 0; j < byX18xReadTypeNumber; j++)
{
if(cx18x.sX18xDataStruct[i].eChannelType[j] == modual.eX18xSensorChannelType.Normal)
cx18x.sX18xDataStruct[i].dConvertData[j] = (double.Parse(sTempString[i][j])- 4)/ 16 * 6;
}
}
for (byte i = 0; i < byX78cNumber; i++)
{
ModbusComm.Modbus_ReadCoilsTask(out cx78c.sx78CRegDataStructStatus[i].bInputRegStatus, cx78c.byModbusID[i], byX78cInputRegStartAddress, byX78cInputRegNumber, out cx78c.ModbusErrorCode[i]);
ModbusComm.Modbus_ReadCoilsTask(out cx78c.sx78CRegDataStructStatus[i].bOutPutRegStatus, cx78c.byModbusID[i], byX78cOutputRegStartAddress, byX78cOutputRegNumber, out cx78c.ModbusErrorCode[i]);
}
for (byte i = 0; i < byX66cNumber; i++)
{
ModbusComm.Modbus_ReadCoilsTask(out cx66c.sx78CDatastructStatus[i].bOutPutRegStatus, cx66c.byModbusID[i], byX66cRelayRegStartAddress, byX66cRelayRegNumber, out cx66c.ModbusErrorCode[i]);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ModbusDemo.MessageFormat;
namespace ModbusDemo.Modular
{
class modual
{
public struct psx14p
{
public ushort[] usX14pRegData;
public ushort[] usX14pRegType;
public double[] dX14pConvertData;
}
public class pcx14P
{
public byte[] byModbusID;
public psx14p[] sX14pDataStruct;
public ModbusComm.eModbusErrorCode[] ModbusErrorCode;
public pcx14P(byte[] InitIDlist)
{
this.byModbusID = InitIDlist;
}
}
public enum eX18xSensorChannelType : byte
{
Normal = 0,
Level,
}
public struct psX18x
{
public ushort[] usRegData;
public ushort[] usTypeData;
public eX18xSensorChannelType[] eChannelType;
public double[] dConvertData;
}
public class pcx18X
{
public byte[] byModbusID;
public psX18x[] sX18xDataStruct;
public ModbusComm.eModbusErrorCode[] ModbusErrorCode;
public pcx18X(byte[] InitIDlist, eX18xSensorChannelType[,] eChannnelType)
{
this.byModbusID = InitIDlist;
for (ushort i = 0; i < eChannnelType.GetLength(0); i++)
{
for (ushort j = 0; j < eChannnelType.GetLength(1); j++)
{
this.sX18xDataStruct[i].eChannelType[j] = eChannnelType[i,j];
}
}
}
}
public struct psx78C
{
public bool[] bInputRegStatus;
public bool[] bOutPutRegStatus;
}
public class pcx78C
{
public byte[] byModbusID;
public psx78C[] sx78CRegDataStructStatus;
public ModbusComm.eModbusErrorCode[] ModbusErrorCode;
public pcx78C(byte[] InitIDlist)
{
this.byModbusID = InitIDlist;
}
}
public struct psx66C
{
public bool[] bRegRelayStatus;
}
public class pcx66C
{
public byte[] byModbusID;
public psx78C[] sx78CDatastructStatus;
public ModbusComm.eModbusErrorCode[] ModbusErrorCode;
public pcx66C(byte[] InitIDlist)
{
this.byModbusID = InitIDlist;
}
}
}
}
...@@ -77,26 +77,26 @@ namespace ModbusDemo.application ...@@ -77,26 +77,26 @@ namespace ModbusDemo.application
// } // }
//} //}
public class pcPump //public class pcPump
{ //{
public double dPumpCurrent; // public double dPumpCurrent;
public double dPumpVoltage; // public double dPumpVoltage;
public bool bPumpStatus; // public bool bPumpStatus;
public bool bPumpHasOpen; // public bool bPumpHasOpen;
public void vOpen_Pump() // public void vOpen_Pump()
{ // {
} // }
public void vClose_Pump() // public void vClose_Pump()
{ // {
} // }
public void vGet_Pump_Status() // public void vGet_Pump_Status()
{ // {
} // }
} //}
public class pcTemperatureData public class pcTemperatureData
......
...@@ -18,7 +18,6 @@ namespace ModbusDemo.application ...@@ -18,7 +18,6 @@ namespace ModbusDemo.application
this.usTypeRegAddress = usSetRegAddress; this.usTypeRegAddress = usSetRegAddress;
} }
} }
public struct psLevelData public struct psLevelData
{ {
public byte byModbusID; public byte byModbusID;
...@@ -31,7 +30,6 @@ namespace ModbusDemo.application ...@@ -31,7 +30,6 @@ namespace ModbusDemo.application
this.usTypeAddressList = usDataTypeRegAddress; this.usTypeAddressList = usDataTypeRegAddress;
} }
} }
public struct psBumpOperation public struct psBumpOperation
{ {
public byte byModbusID; public byte byModbusID;
...@@ -44,7 +42,6 @@ namespace ModbusDemo.application ...@@ -44,7 +42,6 @@ namespace ModbusDemo.application
this.bOpenStatus = bInitOPen; this.bOpenStatus = bInitOPen;
} }
} }
public struct psPumbData public struct psPumbData
{ {
public byte byModbusID; public byte byModbusID;
...@@ -55,7 +52,6 @@ namespace ModbusDemo.application ...@@ -55,7 +52,6 @@ namespace ModbusDemo.application
this.usRegAddList = usInitRegAddressInit; this.usRegAddList = usInitRegAddressInit;
} }
} }
public struct psAgitatorOperation public struct psAgitatorOperation
{ {
public byte byModbusID; public byte byModbusID;
...@@ -68,7 +64,6 @@ namespace ModbusDemo.application ...@@ -68,7 +64,6 @@ namespace ModbusDemo.application
this.bOpenStatus = bInitOPen; this.bOpenStatus = bInitOPen;
} }
} }
public struct psAgitatorData public struct psAgitatorData
{ {
public byte byModbusID; public byte byModbusID;
...@@ -164,7 +159,7 @@ namespace ModbusDemo.application ...@@ -164,7 +159,7 @@ namespace ModbusDemo.application
} }
catch (Exception exception) catch (Exception exception)
{ {
Form1.totxt.Log("Bump Open Operation Error"); Form1.totxt.Log(exception + "Bump Open Operation Error");
throw; throw;
} }
} }
...@@ -182,7 +177,7 @@ namespace ModbusDemo.application ...@@ -182,7 +177,7 @@ namespace ModbusDemo.application
} }
catch (Exception exception) catch (Exception exception)
{ {
Form1.totxt.Log("Bump Close Operation Error"); Form1.totxt.Log(exception + "Bump Close Operation Error");
throw; throw;
} }
} }
...@@ -195,12 +190,11 @@ namespace ModbusDemo.application ...@@ -195,12 +190,11 @@ namespace ModbusDemo.application
} }
catch (Exception exception) catch (Exception exception)
{ {
Form1.totxt.Log("Bump Read Status Error"); Form1.totxt.Log(exception + "Bump Read Status Error");
throw; throw;
} }
} }
} }
public class pcAgitator public class pcAgitator
{ {
private double[] dAgitatorCurrent = new double[pcPoolInit.PoolAgitatorCurrentNumber] { pcPoolInit.cAgitatorCurrent[0].vRead_Agitator_Data() }; private double[] dAgitatorCurrent = new double[pcPoolInit.PoolAgitatorCurrentNumber] { pcPoolInit.cAgitatorCurrent[0].vRead_Agitator_Data() };
...@@ -208,8 +202,7 @@ namespace ModbusDemo.application ...@@ -208,8 +202,7 @@ namespace ModbusDemo.application
public bool[] bAgitatorStatus = new bool[pcPoolInit.PoolBumpOperatNumber]; public bool[] bAgitatorStatus = new bool[pcPoolInit.PoolBumpOperatNumber];
public bool[] bAgitatorHasOpen = new bool[pcPoolInit.PoolBumpOperatNumber]; public bool[] bAgitatorHasOpen = new bool[pcPoolInit.PoolBumpOperatNumber];
public void vOpen_Agitator(ushort usAgitatorNumber)
public void vOpen_Bump(ushort usAgitatorNumber)
{ {
try try
{ {
...@@ -220,11 +213,11 @@ namespace ModbusDemo.application ...@@ -220,11 +213,11 @@ namespace ModbusDemo.application
} }
catch (Exception exception) catch (Exception exception)
{ {
Form1.totxt.Log("Agitator Open Operation Error"); Form1.totxt.Log(exception + "Agitator Open Operation Error");
throw; throw;
} }
} }
public void vClose_Bump(ushort usAgitatorNumber) public void vClose_Agitator(ushort usAgitatorNumber)
{ {
try try
{ {
...@@ -238,12 +231,12 @@ namespace ModbusDemo.application ...@@ -238,12 +231,12 @@ namespace ModbusDemo.application
} }
catch(Exception exception) catch(Exception exception)
{ {
Form1.totxt.Log("Agitator Close Operation Error"); Form1.totxt.Log(exception + "Agitator Close Operation Error");
throw; throw;
} }
} }
public bool[] vGet_Pumb_Status(ushort usAgitatorNumber) public bool[] vGet_Agitator_Status(ushort usAgitatorNumber)
{ {
try try
{ {
...@@ -251,13 +244,11 @@ namespace ModbusDemo.application ...@@ -251,13 +244,11 @@ namespace ModbusDemo.application
} }
catch (Exception exception) catch (Exception exception)
{ {
Form1.totxt.Log("Agitator Read Status Error"); Form1.totxt.Log(exception + "Agitator Read Status Error");
throw; throw;
} }
} }
} }
public class pcPool public class pcPool
{ {
public string ePondName; public string ePondName;
...@@ -268,14 +259,13 @@ namespace ModbusDemo.application ...@@ -268,14 +259,13 @@ namespace ModbusDemo.application
public double dMaxTemper; public double dMaxTemper;
public double dMinTemper; public double dMinTemper;
public pcPump cPump; public pcBump cBump;
public pcAgitator cAgitator; public pcAgitator cAgitator;
public double dPondCurrentLevel { get => pcPoolInit.Get_Current_Level(); } public double dPondCurrentLevel { get => pcPoolInit.Get_Current_Level(); }
public double dPondCurentTemper { get => pcPoolInit.Get_Current_temper(); } public double dPondCurentTemper { get => pcPoolInit.Get_Current_temper(); }
public pcPool(string eInitPondName) public pcPool(string eInitPondName)
{ {
this.ePondName = eInitPondName; this.ePondName = eInitPondName;
} }
} }
} }
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.SubscribeBut = new System.Windows.Forms.Button(); this.SubscribeBut = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.updateops.SuspendLayout(); this.updateops.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
...@@ -327,7 +329,7 @@ ...@@ -327,7 +329,7 @@
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(44, 492); this.label2.Location = new System.Drawing.Point(44, 487);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(69, 20); this.label2.Size = new System.Drawing.Size(69, 20);
...@@ -347,7 +349,7 @@ ...@@ -347,7 +349,7 @@
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(108, 498); this.label4.Location = new System.Drawing.Point(108, 492);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(55, 15); this.label4.Size = new System.Drawing.Size(55, 15);
...@@ -376,11 +378,31 @@ ...@@ -376,11 +378,31 @@
this.SubscribeBut.UseVisualStyleBackColor = true; this.SubscribeBut.UseVisualStyleBackColor = true;
this.SubscribeBut.Click += new System.EventHandler(this.SubscribeBut_Click); this.SubscribeBut.Click += new System.EventHandler(this.SubscribeBut_Click);
// //
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(111, 528);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(55, 15);
this.label5.TabIndex = 99;
this.label5.Text = "label5";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(23, 528);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(82, 15);
this.label6.TabIndex = 100;
this.label6.Text = "超时次数:";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1184, 672); this.ClientSize = new System.Drawing.Size(1184, 672);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.SubscribeBut); this.Controls.Add(this.SubscribeBut);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
...@@ -445,5 +467,7 @@ ...@@ -445,5 +467,7 @@
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button SubscribeBut; private System.Windows.Forms.Button SubscribeBut;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
} }
} }
\ No newline at end of file
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