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
b5aebba5
Commit
b5aebba5
authored
Jun 10, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temperte mergr
parent
c089422c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
244 additions
and
246 deletions
+244
-246
ModualAlarm.cs
ModbusDemo/Common/ModualAlarm.cs
+6
-8
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+91
-50
modual.cs
ModbusDemo/Modular/modual.cs
+10
-4
Form1.cs
ModbusDemo/windows/Form1.cs
+137
-184
No files found.
ModbusDemo/Common/ModualAlarm.cs
View file @
b5aebba5
...
@@ -9,14 +9,12 @@ using MQTTnet.Client;
...
@@ -9,14 +9,12 @@ using MQTTnet.Client;
using
Newtonsoft.Json
;
using
Newtonsoft.Json
;
namespace
ModbusDemo.Common
namespace
ModbusDemo.Common
{
{
public
class
ModualAlarm
public
static
class
ModualAlarm
{
{
public
const
ushort
usChannelNumber
=
8
;
public
const
ushort
usChannelNumber
=
8
;
private
const
string
sAlarmTopic
=
"Witium/WTDS78X/20193261/Alarm"
;
private
const
string
sAlarmTopic
=
"Witium/WTDS78X/20193261/Alarm"
;
public
Hashtable
hMqtttAlarmMap
=
new
Hashtable
();
public
static
string
sAlarmJson
;
public
bool
bErrorHasSend
=
false
;
public
static
string
sAlarmJsonPackage
;
private
string
sAlarmJson
;
private
string
sAlarmJsonPackage
;
//private IMqttClient mqttClient = null;
//private IMqttClient mqttClient = null;
public
enum
eAlarmCode
:
ushort
public
enum
eAlarmCode
:
ushort
{
{
...
@@ -26,9 +24,10 @@ namespace ModbusDemo.Common
...
@@ -26,9 +24,10 @@ namespace ModbusDemo.Common
ChannelDataRespError
=
4
,
ChannelDataRespError
=
4
,
ChannelDataChangeError
=
8
ChannelDataChangeError
=
8
}
}
public
void
vSetAlarmList
(
ushort
usAddress
,
ushort
[]
usChannel
,
ushort
[]
usChannelAlarmcode
,
bool
bStringIncrease
)
public
static
void
vSetAlarmList
(
ushort
usAddress
,
ushort
[]
usChannel
,
ushort
[]
usChannelAlarmcode
,
bool
bStringIncrease
)
{
{
ushort
i
=
0
;
ushort
i
=
0
;
Hashtable
hMqtttAlarmMap
=
new
Hashtable
();
hMqtttAlarmMap
.
Add
(
"addr"
,
usAddress
.
ToString
());
hMqtttAlarmMap
.
Add
(
"addr"
,
usAddress
.
ToString
());
string
sAlarm
=
"alm"
;
string
sAlarm
=
"alm"
;
foreach
(
ushort
usdata
in
usChannelAlarmcode
)
foreach
(
ushort
usdata
in
usChannelAlarmcode
)
...
@@ -43,9 +42,8 @@ namespace ModbusDemo.Common
...
@@ -43,9 +42,8 @@ namespace ModbusDemo.Common
sAlarmJson
+=
","
;
sAlarmJson
+=
","
;
}
}
}
}
public
async
Task
vPublishAlarmPackageJson
(
IMqttClient
mqttClient
)
public
static
async
Task
vPublishAlarmPackageJson
(
IMqttClient
mqttClient
)
{
{
sAlarmJson
=
"["
+
sAlarmJson
+
"]"
;
var
message
=
new
MqttApplicationMessageBuilder
()
var
message
=
new
MqttApplicationMessageBuilder
()
.
WithTopic
(
sAlarmTopic
)
.
WithTopic
(
sAlarmTopic
)
.
WithPayload
(
sAlarmJson
)
.
WithPayload
(
sAlarmJson
)
...
...
ModbusDemo/Modular/ModualPoll.cs
View file @
b5aebba5
This diff is collapsed.
Click to expand it.
ModbusDemo/Modular/modual.cs
View file @
b5aebba5
...
@@ -16,21 +16,27 @@ namespace ModbusDemo.Modular
...
@@ -16,21 +16,27 @@ namespace ModbusDemo.Modular
public
double
[]
dNowConvertData
;
public
double
[]
dNowConvertData
;
public
double
[]
dBeforeConvertData
;
public
double
[]
dBeforeConvertData
;
}
}
public
enum
eX14pSensorChannelType
:
byte
{
Normal
=
0
,
Null
,
}
public
struct
psxModualAlarm
public
struct
psxModualAlarm
{
{
public
bool
bDataNotFirstIncreaseOrDecrease
;
public
bool
bDataNotFirstIncreaseOrDecrease
;
public
ushort
[]
usNowAlarmCode
;
public
ushort
[]
usNowAlarmCode
;
public
ushort
[]
usBeforeAlarmCode
;
public
ushort
[]
usBeforeAlarmCode
;
}
}
public
class
pcx14P
public
class
pcx14P
{
{
public
byte
[]
byModbusID
;
public
byte
[]
byModbusID
;
public
psx14pData
[]
sX14pDataStruct
=
new
psx14pData
[
ModualPoll
.
byX14pNumber
];
public
psx14pData
[]
sX14pDataStruct
=
new
psx14pData
[
ModualPoll
.
byX14pNumber
];
public
psxModualAlarm
[]
sX14PAlarmStruct
=
new
psxModualAlarm
[
ModualPoll
.
byX14pNumber
];
public
psxModualAlarm
[]
sX14PAlarmStruct
=
new
psxModualAlarm
[
ModualPoll
.
byX14pNumber
];
public
pcx14P
(
byte
[]
InitIDlist
)
public
eX14pSensorChannelType
[,]
eChannelType
;
public
pcx14P
(
byte
[]
InitIDlist
,
eX14pSensorChannelType
[,]
ChannelType
)
{
{
this
.
byModbusID
=
InitIDlist
;
this
.
byModbusID
=
InitIDlist
;
this
.
eChannelType
=
ChannelType
;
for
(
byte
i
=
0
;
i
<
ModualPoll
.
byX14pNumber
;
i
++)
for
(
byte
i
=
0
;
i
<
ModualPoll
.
byX14pNumber
;
i
++)
{
{
this
.
sX14pDataStruct
[
i
].
dBeforeConvertData
=
new
double
[
ModualPoll
.
byX14pReadDataNumber
];
this
.
sX14pDataStruct
[
i
].
dBeforeConvertData
=
new
double
[
ModualPoll
.
byX14pReadDataNumber
];
...
@@ -49,7 +55,7 @@ namespace ModbusDemo.Modular
...
@@ -49,7 +55,7 @@ namespace ModbusDemo.Modular
Mike_5
,
Mike_5
,
Mike_6
,
Mike_6
,
Mike_7
,
Mike_7
,
Level
,
NormalCurrent
,
}
}
public
struct
psX18xData
public
struct
psX18xData
...
...
ModbusDemo/windows/Form1.cs
View file @
b5aebba5
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