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
6d9c15c0
Commit
6d9c15c0
authored
Jun 14, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Send down control and relate alarm
parent
ae9d62a8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
437 additions
and
329 deletions
+437
-329
ModualAlarm.cs
ModbusDemo/Common/ModualAlarm.cs
+9
-7
ModbusComm.cs
ModbusDemo/MessageFormat/ModbusComm.cs
+2
-2
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+398
-6
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+3
-2
Form1.cs
ModbusDemo/windows/Form1.cs
+25
-312
No files found.
ModbusDemo/Common/ModualAlarm.cs
View file @
6d9c15c0
...
...
@@ -12,17 +12,19 @@ namespace ModbusDemo.Common
public
static
class
ModualAlarm
{
public
const
ushort
usChannelNumber
=
8
;
private
const
string
sAlarmTopic
=
"Witium/WTDS78X/66666666/Alarm"
;
public
static
string
sAlarmJson
;
public
static
string
sAlarmJsonPackage
;
//private IMqttClient mqttClient = null;
public
enum
eAlarmCode
:
ushort
{
ChannelNoError
=
0
,
ChannelCommunError
=
1
,
ChannelCollectDataError
=
2
,
ChannelDataRespError
=
4
,
ChannelDataChangeError
=
8
ChannelNoError
=
0
,
ChannelCommunError
=
1
,
ChannelCollectDataError
=
2
,
ChannelDataRespError
=
4
,
ChannelDataChangeError
=
8
,
ChannelLevelError
=
16
,
ChannelControlError
=
32
,
}
public
static
void
vSetAlarmList
(
ushort
usAddress
,
ushort
[]
usChannel
,
ushort
[]
usChannelAlarmcode
)
{
...
...
@@ -46,7 +48,7 @@ namespace ModbusDemo.Common
public
static
async
Task
vPublishAlarmPackageJson
(
IMqttClient
mqttClient
)
{
var
message
=
new
MqttApplicationMessageBuilder
()
.
WithTopic
(
sAlarmTopic
)
.
WithTopic
(
Form1
.
sAlarmTopic
)
.
WithPayload
(
sAlarmJson
)
.
WithAtMostOnceQoS
()
.
WithRetainFlag
(
false
)
...
...
ModbusDemo/MessageFormat/ModbusComm.cs
View file @
6d9c15c0
...
...
@@ -200,7 +200,7 @@ namespace ModbusDemo.MessageFormat
return
ModbusErrorCode
;
}
}
public
static
eModbusErrorCode
Modbus_WriteSingleCoil
(
byte
slaveAddress
,
ushort
startAddress
,
bool
[]
value
)
public
static
eModbusErrorCode
Modbus_WriteSingleCoil
(
byte
slaveAddress
,
ushort
startAddress
,
bool
value
)
{
object
oLock
=
new
object
();
lock
(
oLock
)
...
...
@@ -208,7 +208,7 @@ namespace ModbusDemo.MessageFormat
eModbusErrorCode
ModbusErrorCode
;
try
{
Modbus
.
Write
MultipleCoils
(
slaveAddress
,
startAddress
,
value
);
Modbus
.
Write
SingleCoil
(
slaveAddress
,
startAddress
,
value
);
ModbusErrorCode
=
eModbusErrorCode
.
MB_ENOERR
;
}
catch
(
Exception
exception
)
...
...
ModbusDemo/MessageFormat/ModualControl.cs
View file @
6d9c15c0
This diff is collapsed.
Click to expand it.
ModbusDemo/Modular/ModualPoll.cs
View file @
6d9c15c0
...
...
@@ -10,6 +10,7 @@ using MQTTnet;
using
MQTTnet.Client
;
using
Newtonsoft.Json
;
using
ModbusDemo
;
namespace
ModbusDemo.Modular
{
class
ModualPoll
...
...
@@ -70,8 +71,8 @@ namespace ModbusDemo.Modular
public
static
modual
.
pcx78C
cx78c
=
new
modual
.
pcx78C
(
byX78cIdlist
);
#if DEBUG_TEST
public
const
byte
byX66cNumber
=
2
;
public
static
byte
[]
byX66cIdlist
=
{
16
,
31
};
public
const
byte
byX66cNumber
=
3
;
public
static
byte
[]
byX66cIdlist
=
{
16
,
31
,
35
};
#else
public
const
byte
byX66cNumber
=
32
;
public
static
byte
[]
byX66cIdlist
=
{
4
,
5
,
7
,
8
,
9
,
10
,
14
,
15
,
19
,
22
,
23
,
24
,
26
,
30
,
32
,
36
,
37
,
38
,
40
,
41
,
42
,
43
,
44
,
46
,
47
,
48
,
49
,
50
,
51
,
52
,
54
,
57
};
...
...
ModbusDemo/windows/Form1.cs
View file @
6d9c15c0
This diff is collapsed.
Click to expand it.
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