Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
PastureGateway
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
steven.sha
PastureGateway
Commits
4a5bdbd8
Commit
4a5bdbd8
authored
Jun 20, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Plain Diff
start test
parents
bfa5625c
de89515f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
375 additions
and
107 deletions
+375
-107
ModbusComm.cs
ModbusDemo/MessageFormat/ModbusComm.cs
+8
-3
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+212
-32
ModbusDemo.csproj
ModbusDemo/ModbusDemo.csproj
+0
-6
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+8
-3
AllPond.cs
ModbusDemo/application/AllPond.cs
+3
-3
AutoControl.cs
ModbusDemo/application/AutoControl.cs
+76
-28
ControlMap.cs
ModbusDemo/application/ControlMap.cs
+26
-5
ModualPool.cs
ModbusDemo/application/ModualPool.cs
+5
-4
Form1.cs
ModbusDemo/windows/Form1.cs
+37
-23
No files found.
ModbusDemo/MessageFormat/ModbusComm.cs
View file @
4a5bdbd8
...
@@ -28,9 +28,10 @@ namespace ModbusDemo.MessageFormat
...
@@ -28,9 +28,10 @@ namespace ModbusDemo.MessageFormat
MB_EMASTERSENT
,
MB_EMASTERSENT
,
MB_RTUERNOERR
MB_RTUERNOERR
}
}
public
static
ModbusMaster
Modbus
;
public
static
ushort
usCommunFailTimes
=
0
;
public
static
ModbusMaster
Modbus
;
static
object
oLock
=
new
object
();
public
static
ushort
usCommunFailTimes
=
0
;
private
static
object
oLock
=
new
object
();
public
static
eModbusErrorCode
Modbus_ReadHoldingRegistersTask
(
out
ushort
[]
OutputValue
,
byte
slaveAddress
,
ushort
startAddress
,
ushort
numberOfPoints
)
public
static
eModbusErrorCode
Modbus_ReadHoldingRegistersTask
(
out
ushort
[]
OutputValue
,
byte
slaveAddress
,
ushort
startAddress
,
ushort
numberOfPoints
)
{
{
lock
(
oLock
)
lock
(
oLock
)
...
@@ -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.
...
...
ModbusDemo/MessageFormat/ModualControl.cs
View file @
4a5bdbd8
This diff is collapsed.
Click to expand it.
ModbusDemo/ModbusDemo.csproj
View file @
4a5bdbd8
...
@@ -178,15 +178,9 @@
...
@@ -178,15 +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)' == ''"
/>
<!-- <<<<<<< HEAD -->
<!-- <<<<<<< HEAD -->
<!-- ======= -->
<!-- ======= -->
<!-- >>>>>>> 5635bdf708c90bb2146f99466d1145dda5dabb37 -->
<PropertyGroup>
<PropertyGroup>
<SsdtUnitTestVersion>
3.1
</SsdtUnitTestVersion>
<SsdtUnitTestVersion>
3.1
</SsdtUnitTestVersion>
</PropertyGroup>
</PropertyGroup>
<!-- >>>>>>> origin/master -->
<!-- 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">
...
...
ModbusDemo/Modular/ModualPoll.cs
View file @
4a5bdbd8
...
@@ -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
};
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
()
...
...
ModbusDemo/application/AllPond.cs
View file @
4a5bdbd8
...
@@ -19,9 +19,9 @@ namespace ModbusDemo.application
...
@@ -19,9 +19,9 @@ namespace ModbusDemo.application
strChannelNumber
=
new
string
[]
{
"d1"
,
"d2"
},
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
=
fals
e
,
bHadRefControl
=
tru
e
,
byResModbusID
=
0
,
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
);
...
...
ModbusDemo/application/AutoControl.cs
View file @
4a5bdbd8
...
@@ -35,15 +35,11 @@ namespace ModbusDemo.application
...
@@ -35,15 +35,11 @@ namespace ModbusDemo.application
public
string
Name
;
public
string
Name
;
public
double
StatusTime
;
public
double
StatusTime
;
public
int
modularx
;
public
int
modularx
;
public
byte
modbusID
;
}
}
public
static
void
CriticalValueMonitoring
(
ref
Control
usControl
,
bool
Enabl
,
string
Affiliation
,
out
Control
control
)
public
static
void
CriticalValueMonitoring
(
ref
Control
usControl
,
bool
Enabl
,
string
Affiliation
,
out
Control
control
)
{
{
//Control usControl = new Control
//{
// Enablation = Enabl,
// Name = Affiliation,
//};
if
(
usControl
.
Enablation
==
true
)
if
(
usControl
.
Enablation
==
true
)
{
{
if
(
usControl
.
maxLevel
!=
0.0
&&
usControl
.
minLevel
!=
0.0
)
if
(
usControl
.
maxLevel
!=
0.0
&&
usControl
.
minLevel
!=
0.0
)
...
@@ -67,7 +63,6 @@ namespace ModbusDemo.application
...
@@ -67,7 +63,6 @@ namespace ModbusDemo.application
}
}
else
if
(
usControl
.
realTimeLevel
<
usControl
.
maxLevel
&&
usControl
.
realTimeLevel
>
(
usControl
.
minLevel
+
usControl
.
minLevel
*
0.15
))
else
if
(
usControl
.
realTimeLevel
<
usControl
.
maxLevel
&&
usControl
.
realTimeLevel
>
(
usControl
.
minLevel
+
usControl
.
minLevel
*
0.15
))
{
{
//usControl.status = true;
usControl
.
normal
=
true
;
usControl
.
normal
=
true
;
}
}
...
@@ -99,7 +94,7 @@ namespace ModbusDemo.application
...
@@ -99,7 +94,7 @@ namespace ModbusDemo.application
public
static
bool
Wtimerun
=
false
;
public
static
bool
Wtimerun
=
false
;
static
System
.
Diagnostics
.
Stopwatch
ETime
=
new
System
.
Diagnostics
.
Stopwatch
();
static
System
.
Diagnostics
.
Stopwatch
ETime
=
new
System
.
Diagnostics
.
Stopwatch
();
static
System
.
Diagnostics
.
Stopwatch
WTime
=
new
System
.
Diagnostics
.
Stopwatch
();
static
System
.
Diagnostics
.
Stopwatch
WTime
=
new
System
.
Diagnostics
.
Stopwatch
();
//public static string
public
static
void
Automatic_control
(
bool
Eenabl
,
bool
Wenabl
)
public
static
void
Automatic_control
(
bool
Eenabl
,
bool
Wenabl
)
{
{
TimeSpan
Wtime
=
WTime
.
Elapsed
;
TimeSpan
Wtime
=
WTime
.
Elapsed
;
...
@@ -146,36 +141,54 @@ namespace ModbusDemo.application
...
@@ -146,36 +141,54 @@ namespace ModbusDemo.application
}
}
if
(
timespan
.
TotalMinutes
>
2
)
if
(
timespan
.
TotalMinutes
>
2
)
{
{
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
)
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
}
}
else
{
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
)
==
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
}
else
else
{
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
}
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
+
1
],
16
,
state_OFF
)
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
)
==
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
)
{
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
+
1
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
}
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
//timerun = false;
}
}
else
{
ETime
.
Reset
();
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
ETime
.
Stop
();
// 停止监视
timerun
=
false
;
timerun
=
false
;
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
);
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
+
1
],
16
,
state_OFF
);
}
}
if
(
Wenabl
==
true
)
if
(
Wenabl
==
true
)
...
@@ -216,26 +229,61 @@ namespace ModbusDemo.application
...
@@ -216,26 +229,61 @@ namespace ModbusDemo.application
WTime
.
Start
();
//开始监视
WTime
.
Start
();
//开始监视
Wtimerun
=
true
;
Wtimerun
=
true
;
}
}
if
(
Wtime
.
TotalMinutes
>
2
)
if
(
Wtime
.
TotalMinutes
>
1
)
{
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
WTime
.
Reset
();
WTime
.
Reset
();
WTime
.
Stop
();
//停止监视
WTime
.
Stop
();
//停止监视
Wtimerun
=
false
;
Wtimerun
=
false
;
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
],
16
,
state_OFF
);
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
+
1
],
16
,
state_OFF
);
}
}
}
}
else
else
{
{
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
],
16
,
state_OFF
)
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
+
1
],
16
,
state_OFF
)
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
+
1
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
WTime
.
Reset
();
WTime
.
Reset
();
WTime
.
Stop
();
//停止监视
WTime
.
Stop
();
//停止监视
Wtimerun
=
false
;
Wtimerun
=
false
;
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
],
16
,
state_OFF
);
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
+
1
],
16
,
state_OFF
);
}
}
double
Whours
=
Wtime
.
TotalHours
;
double
Whours
=
Wtime
.
TotalHours
;
double
Wminures
=
Wtime
.
TotalMinutes
;
double
Wminures
=
Wtime
.
TotalMinutes
;
double
Wseconds
=
Wtime
.
TotalSeconds
;
double
Wseconds
=
Wtime
.
TotalSeconds
;
...
...
ModbusDemo/application/ControlMap.cs
View file @
4a5bdbd8
...
@@ -14,10 +14,11 @@ namespace ModbusDemo.application
...
@@ -14,10 +14,11 @@ namespace ModbusDemo.application
public
static
byte
byMapIdleID
;
public
static
byte
byMapIdleID
;
public
static
bool
[]
byMapIdleControlData
;
public
static
bool
[]
byMapIdleControlData
;
public
static
string
[]
strMapIdleChannelName
;
public
static
string
[]
strMapIdleChannelName
;
public
static
bool
bMap_Idle_Ope
ratio
n_Control
(
bool
[]
bControldata
)
public
static
bool
bMap_Idle_Open_Control
(
bool
[]
bControldata
)
{
{
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
bool
bStatus
;
bool
bStatus
;
bool
bHadOperation
;
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
{
string
str
=
"d"
+
i
.
ToString
();
string
str
=
"d"
+
i
.
ToString
();
...
@@ -30,10 +31,30 @@ namespace ModbusDemo.application
...
@@ -30,10 +31,30 @@ namespace ModbusDemo.application
}
}
}
}
}
}
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byMapIdleID
,
bControldata
,
bControlBit
,
0
,
null
);
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byMapIdleID
,
bControldata
,
bControlBit
,
out
bHadOperation
,
0
,
null
);
return
bStatus
;
return
bStatus
;
}
}
public
static
bool
bControl_Map
(
bool
bOpen
,
byte
byControlID
,
bool
[]
bControlData
,
params
string
[]
strOperationChannelName
)
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
)
...
@@ -71,7 +92,7 @@ namespace ModbusDemo.application
...
@@ -71,7 +92,7 @@ namespace ModbusDemo.application
byMapIdleID
=
byControlID
;
byMapIdleID
=
byControlID
;
strMapIdleChannelName
=
strOperationChannelName
;
strMapIdleChannelName
=
strOperationChannelName
;
byMapIdleControlData
=
bControlData
;
byMapIdleControlData
=
bControlData
;
bDelege_Operation
=
bMap_Idle_Ope
ratio
n_Control
;
bDelege_Operation
=
bMap_Idle_Open_Control
;
}
}
}
}
else
else
...
@@ -109,7 +130,7 @@ namespace ModbusDemo.application
...
@@ -109,7 +130,7 @@ namespace ModbusDemo.application
byMapIdleID
=
byControlID
;
byMapIdleID
=
byControlID
;
strMapIdleChannelName
=
strOperationChannelName
;
strMapIdleChannelName
=
strOperationChannelName
;
byMapIdleControlData
=
bControlData
;
byMapIdleControlData
=
bControlData
;
bDelege_Operation
=
bMap_Idle_
Operation
_Control
;
bDelege_Operation
=
bMap_Idle_
Close
_Control
;
}
}
}
}
return
bMapStatus
;
return
bMapStatus
;
...
...
ModbusDemo/application/ModualPool.cs
View file @
4a5bdbd8
...
@@ -127,7 +127,7 @@ namespace ModbusDemo.application
...
@@ -127,7 +127,7 @@ 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
;
}
}
...
@@ -149,7 +149,7 @@ namespace ModbusDemo.application
...
@@ -149,7 +149,7 @@ 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
;
}
}
...
@@ -201,6 +201,7 @@ namespace ModbusDemo.application
...
@@ -201,6 +201,7 @@ namespace ModbusDemo.application
public
bool
bOpreation_Button
(
bool
[]
bControldata
)
public
bool
bOpreation_Button
(
bool
[]
bControldata
)
{
{
bool
bStatus
;
bool
bStatus
;
bool
bHadOpenButton
;
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
{
...
@@ -214,7 +215,7 @@ namespace ModbusDemo.application
...
@@ -214,7 +215,7 @@ namespace ModbusDemo.application
}
}
}
}
}
}
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
0
,
null
))
==
true
)
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
out
bHadOpenButton
,
0
,
null
))
==
true
)
{
{
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
{
...
@@ -228,7 +229,7 @@ namespace ModbusDemo.application
...
@@ -228,7 +229,7 @@ namespace ModbusDemo.application
}
}
}
}
}
}
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
0
,
null
);
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
out
bHadOpenButton
,
0
,
null
);
}
}
return
bStatus
;
return
bStatus
;
...
...
ModbusDemo/windows/Form1.cs
View file @
4a5bdbd8
...
@@ -137,6 +137,8 @@ namespace ModbusDemo
...
@@ -137,6 +137,8 @@ namespace ModbusDemo
//定义一个委托变量
//定义一个委托变量
public
UpdateTxt
updateTxt
;
public
UpdateTxt
updateTxt
;
private
Thread
ModbusControlThread
;
private
Thread
ModbusControlThread
;
private
Thread
MqttReceiveThread
;
public
List
<
string
>
ListHandle
=
new
List
<
string
>();
private
async
Task
Publish
()
private
async
Task
Publish
()
{
{
var
message
=
new
MqttApplicationMessageBuilder
()
var
message
=
new
MqttApplicationMessageBuilder
()
...
@@ -150,7 +152,7 @@ namespace ModbusDemo
...
@@ -150,7 +152,7 @@ namespace ModbusDemo
await
mqttClient
.
PublishAsync
(
message
);
await
mqttClient
.
PublishAsync
(
message
);
}
}
}
}
private
async
Task
vControlResponseBack
()
private
void
vControlResponseBack
()
{
{
var
message
=
new
MqttApplicationMessageBuilder
()
var
message
=
new
MqttApplicationMessageBuilder
()
.
WithTopic
(
mqttBackTopic
)
.
WithTopic
(
mqttBackTopic
)
...
@@ -158,7 +160,7 @@ namespace ModbusDemo
...
@@ -158,7 +160,7 @@ namespace ModbusDemo
.
WithAtLeastOnceQoS
()
.
WithAtLeastOnceQoS
()
.
WithRetainFlag
(
false
)
.
WithRetainFlag
(
false
)
.
Build
();
.
Build
();
await
mqttClient
.
PublishAsync
(
message
);
mqttClient
.
PublishAsync
(
message
);
totxt
.
Log
(
"我在247,执行了Back"
);
totxt
.
Log
(
"我在247,执行了Back"
);
}
}
...
@@ -203,6 +205,7 @@ namespace ModbusDemo
...
@@ -203,6 +205,7 @@ namespace ModbusDemo
//txtReceiveMessage.AppendText($"已订阅[{Data}]主题{Environment.NewLine}");
//txtReceiveMessage.AppendText($"已订阅[{Data}]主题{Environment.NewLine}");
})));
})));
}
}
//private async Task ConnectMqttServerAsync()
private
async
Task
ConnectMqttServerAsync
()
private
async
Task
ConnectMqttServerAsync
()
{
{
// Create a new MQTT client.
// Create a new MQTT client.
...
@@ -327,12 +330,11 @@ namespace ModbusDemo
...
@@ -327,12 +330,11 @@ namespace ModbusDemo
//收到的消息啦
//收到的消息啦
txtReceiveMessage
.
AppendText
(
$">>
{
"### RECEIVED APPLICATION MESSAGE ###"
}{
Environment
.
NewLine
}
"
);
txtReceiveMessage
.
AppendText
(
$">>
{
"### RECEIVED APPLICATION MESSAGE ###"
}{
Environment
.
NewLine
}
"
);
totxt
.
Log
(
$">>
{
"### RECEIVED APPLICATION MESSAGE ###"
}{
Environment
.
NewLine
}
"
);
totxt
.
Log
(
$">>
{
"### RECEIVED APPLICATION MESSAGE ###"
}{
Environment
.
NewLine
}
"
);
})));
Invoke
((
new
Action
(()
=>
{
//我的订阅主题是。。。。。
txtReceiveMessage
.
AppendText
(
$">> Topic =
{
e
.
ApplicationMessage
.
Topic
}{
Environment
.
NewLine
}
"
);
txtReceiveMessage
.
AppendText
(
$">> Topic =
{
e
.
ApplicationMessage
.
Topic
}{
Environment
.
NewLine
}
"
);
totxt
.
Log
(
$">> Topic =
{
e
.
ApplicationMessage
.
Topic
}{
Environment
.
NewLine
}
"
);
totxt
.
Log
(
$">> Topic =
{
e
.
ApplicationMessage
.
Topic
}{
Environment
.
NewLine
}
"
);
txtReceiveMessage
.
AppendText
(
$">> QoS =
{
e
.
ApplicationMessage
.
QualityOfServiceLevel
}{
Environment
.
NewLine
}
"
);
txtReceiveMessage
.
AppendText
(
$">> Retain =
{
e
.
ApplicationMessage
.
Retain
}{
Environment
.
NewLine
}
"
);
})));
})));
Invoke
((
new
Action
(
async
()
=>
Invoke
((
new
Action
(
async
()
=>
{
{
...
@@ -344,8 +346,7 @@ namespace ModbusDemo
...
@@ -344,8 +346,7 @@ namespace ModbusDemo
Console
.
WriteLine
(
stConvertString
);
Console
.
WriteLine
(
stConvertString
);
if
(
e
.
ApplicationMessage
.
Topic
==
mqttSubscribeControlTopic
)
if
(
e
.
ApplicationMessage
.
Topic
==
mqttSubscribeControlTopic
)
{
{
ModualControl
.
vGetaWay_Receive_Control
(
stConvertString
,
out
mqttData_Back
);
ListHandle
.
Add
(
stConvertString
);
await
vControlResponseBack
();
}
}
else
if
(
e
.
ApplicationMessage
.
Topic
==
mqttCfgTopic
)
else
if
(
e
.
ApplicationMessage
.
Topic
==
mqttCfgTopic
)
{
{
...
@@ -353,24 +354,28 @@ namespace ModbusDemo
...
@@ -353,24 +354,28 @@ namespace ModbusDemo
await
vCfgResponseBack
(
mqttData_Back
);
await
vCfgResponseBack
(
mqttData_Back
);
}
}
})));
})));
Invoke
((
new
Action
(()
=>
}
{
txtReceiveMessage
.
AppendText
(
$">> QoS =
{
e
.
ApplicationMessage
.
QualityOfServiceLevel
}{
Environment
.
NewLine
}
"
);
private
void
vMqtt_Receive_Handle
()
//totxt.Log($">> QoS = {e.ApplicationMessage.QualityOfServiceLevel}{Environment.NewLine}");
{
})));
while
(
true
)
Invoke
((
new
Action
(()
=>
{
{
txtReceiveMessage
.
AppendText
(
$">> Retain =
{
e
.
ApplicationMessage
.
Retain
}{
Environment
.
NewLine
}
"
);
for
(
int
i
=
0
;
i
<
ListHandle
.
Count
;
i
++)
//totxt.Log($">> Retain = {e.ApplicationMessage.Retain}{Environment.NewLine}");
{
})));
ModualControl
.
vGetaWay_Receive_Control
(
ListHandle
[
i
],
out
mqttData_Back
);
mqttData
=
null
;
vControlResponseBack
();
ListHandle
.
Remove
(
ListHandle
[
i
]);
}
Thread
.
Sleep
(
100
);
}
}
}
#
endregion
#
endregion
#
region
modbus
线程
#
region
modbus
线程
private
static
bool
bSetDataIsRunning
=
false
;
private
static
bool
bSetDataIsRunning
=
false
;
private
Thread
ModbusPollThread
;
private
Thread
ModbusPollThread
;
private
void
T_AutoControl
()
private
void
T_AutoControl
()
{
{
AutoControl
.
Control
usEcontrol
=
new
AutoControl
.
Control
();
AutoControl
.
Control
usEcontrol
=
new
AutoControl
.
Control
();
...
@@ -391,12 +396,14 @@ namespace ModbusDemo
...
@@ -391,12 +396,14 @@ namespace ModbusDemo
usWcontrol
.
realTimeLevel
=
usWcontrol
.
realTimeLevel
=
ModualPoll
.
cx18x
.
sX18xDataStruct
[
j
].
dNowConvertData
[
0
];
ModualPoll
.
cx18x
.
sX18xDataStruct
[
j
].
dNowConvertData
[
0
];
usWcontrol
.
modularx
=
j
;
usWcontrol
.
modularx
=
j
;
usWcontrol
.
modbusID
=
LevelmodbusID
[
0
];
}
}
if
(
ModualPoll
.
cx18x
.
byModbusID
[
j
]
==
LevelmodbusID
[
1
])
if
(
ModualPoll
.
cx18x
.
byModbusID
[
j
]
==
LevelmodbusID
[
1
])
{
{
usEcontrol
.
realTimeLevel
=
usEcontrol
.
realTimeLevel
=
ModualPoll
.
cx18x
.
sX18xDataStruct
[
j
].
dNowConvertData
[
0
];
ModualPoll
.
cx18x
.
sX18xDataStruct
[
j
].
dNowConvertData
[
0
];
usEcontrol
.
modularx
=
j
;
usEcontrol
.
modularx
=
j
;
usEcontrol
.
modbusID
=
LevelmodbusID
[
1
];
}
}
}
}
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
0
])
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
0
])
...
@@ -431,8 +438,7 @@ namespace ModbusDemo
...
@@ -431,8 +438,7 @@ namespace ModbusDemo
}
}
AutoControl
.
Automatic_control
(
usWcontrolB
.
status
,
usEcontrolB
.
status
);
AutoControl
.
Automatic_control
(
usWcontrolB
.
status
,
usEcontrolB
.
status
);
}
}
else
if
(
file
.
Length
!=
0
)
else
if
(
file
.
Length
!=
0
)
{
{
usEcontrol
.
modularx
=
InIHelper
.
ReadConfig
<
int
>(
"Channel number"
,
"东液位通道"
);
usEcontrol
.
modularx
=
InIHelper
.
ReadConfig
<
int
>(
"Channel number"
,
"东液位通道"
);
usWcontrol
.
modularx
=
InIHelper
.
ReadConfig
<
int
>(
"Channel number"
,
"西液位通道"
);
usWcontrol
.
modularx
=
InIHelper
.
ReadConfig
<
int
>(
"Channel number"
,
"西液位通道"
);
...
@@ -1083,7 +1089,6 @@ namespace ModbusDemo
...
@@ -1083,7 +1089,6 @@ namespace ModbusDemo
{
{
}
}
private
async
void
SubscribeBut_Click
(
object
sender
,
EventArgs
e
)
private
async
void
SubscribeBut_Click
(
object
sender
,
EventArgs
e
)
{
{
await
Subscribe
();
await
Subscribe
();
...
@@ -1138,7 +1143,7 @@ namespace ModbusDemo
...
@@ -1138,7 +1143,7 @@ namespace ModbusDemo
SetMqtt
();
SetMqtt
();
MQTT_thread
=
new
MethodInvoker
(
Sendout
);
MQTT_thread
=
new
MethodInvoker
(
Sendout
);
MQTT_thread
.
BeginInvoke
(
null
,
null
);
MQTT_thread
.
BeginInvoke
(
null
,
null
);
Task
.
Run
(
async
()
=>
{
await
ConnectMqttServerAsync
();
});
Task
.
Run
(
async
()
=>
{
await
ConnectMqttServerAsync
();
});
ModbusComm
.
Modbus
=
ModbusSerialMaster
.
CreateRtu
(
comPort
);
ModbusComm
.
Modbus
=
ModbusSerialMaster
.
CreateRtu
(
comPort
);
ModbusComm
.
Modbus
.
Transport
.
Retries
=
0
;
ModbusComm
.
Modbus
.
Transport
.
Retries
=
0
;
ModbusComm
.
Modbus
.
Transport
.
ReadTimeout
=
1000
;
ModbusComm
.
Modbus
.
Transport
.
ReadTimeout
=
1000
;
...
@@ -1155,9 +1160,18 @@ namespace ModbusDemo
...
@@ -1155,9 +1160,18 @@ namespace ModbusDemo
bCretaThead
=
true
;
bCretaThead
=
true
;
ModbusPollThread
=
new
Thread
(
vModbusPoll
);
ModbusPollThread
=
new
Thread
(
vModbusPoll
);
ModbusPollThread
.
Start
();
ModbusPollThread
.
Start
();
ModbusPollThread
.
Priority
=
ThreadPriority
.
Normal
;
ModbusControlThread
=
new
Thread
(
ModualControl
.
vControl_Poll
);
ModbusControlThread
=
new
Thread
(
ModualControl
.
vControl_Poll
);
ModbusControlThread
.
Start
();
ModbusControlThread
.
Start
();
ModbusControlThread
.
Priority
=
ThreadPriority
.
BelowNormal
;
MqttReceiveThread
=
new
Thread
(
vMqtt_Receive_Handle
);
MqttReceiveThread
.
Start
();
MqttReceiveThread
.
Priority
=
ThreadPriority
.
AboveNormal
;
Task
task1
=
Task
.
Factory
.
StartNew
(
async
()
=>
{
await
ModualControl
.
vControl_Res_Poll
();});
}
}
else
else
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment