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
c873e72e
Commit
c873e72e
authored
Jun 25, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete dirty data from all nodes
parent
cf469d03
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
40 deletions
+64
-40
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+25
-2
ControlMap.cs
ModbusDemo/application/ControlMap.cs
+36
-36
Form1.cs
ModbusDemo/windows/Form1.cs
+3
-2
No files found.
ModbusDemo/Modular/ModualPoll.cs
View file @
c873e72e
...
...
@@ -11,7 +11,7 @@ using MQTTnet;
using
MQTTnet.Client
;
using
Newtonsoft.Json
;
using
ModbusDemo
;
using
Newtonsoft.Json.Linq
;
namespace
ModbusDemo.Modular
{
class
ModualPoll
...
...
@@ -81,7 +81,7 @@ namespace ModbusDemo.Modular
private
const
byte
byX66cRelayRegStartAddress
=
16
;
public
const
byte
byX66cRelayRegNumber
=
6
;
public
static
modual
.
pcx66C
cx66c
=
new
modual
.
pcx66C
(
byX66cIdlist
);
public
static
List
<
byte
>
listDeleteNodesID
=
new
List
<
byte
>();
public
const
byte
COMMFAILALARM
=
3
;
public
static
void
vAllNodePoll
()
{
...
...
@@ -445,6 +445,7 @@ namespace ModbusDemo.Modular
public
static
void
vSend_Actual_Data
(
byte
byModbusID
)
{
string
strRes
=
null
;
listDeleteNodesID
.
Add
(
byModbusID
);
for
(
int
i
=
0
;
i
<
ModualPoll
.
byX18xNumber
;
i
++)
{
if
(
byModbusID
==
ModualPoll
.
cx18x
.
byModbusID
[
i
])
...
...
@@ -852,6 +853,28 @@ namespace ModbusDemo.Modular
await
Form1
.
Publish
(
Form1
.
sAlarmTopic
,
ModualAlarm
.
sAgainAlarmJson
);
}
}
public
static
string
vRemove_Nodes_Data_String
(
string
strSendAllDataJson
)
{
if
(
listDeleteNodesID
.
Count
()
!=
0
)
{
var
jsonArray
=
new
JArray
();
jsonArray
=
JArray
.
Parse
(
strSendAllDataJson
);
for
(
int
i
=
0
;
i
<
listDeleteNodesID
.
Count
();
i
++)
{
for
(
int
j
=
0
;
j
<
jsonArray
.
Count
();
j
++)
{
if
(
jsonArray
[
j
].
Value
<
string
>(
"addr"
)
==
listDeleteNodesID
[
i
].
ToString
())
{
jsonArray
.
Remove
(
jsonArray
[
j
]);
}
}
}
listDeleteNodesID
.
Clear
();
return
jsonArray
.
ToString
();
}
return
strSendAllDataJson
;
}
}
}
ModbusDemo/application/ControlMap.cs
View file @
c873e72e
...
...
@@ -113,11 +113,11 @@ namespace ModbusDemo.application
}
#
endregion
#
region
沉砂池开映射
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d4"
)
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d4"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer1
.
bOpen_Machine
;
}
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d5"
)
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d5"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer2
.
bOpen_Machine
;
}
...
...
@@ -201,11 +201,11 @@ namespace ModbusDemo.application
}
#
endregion
#
region
沉砂池关映射
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d4"
)
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d4"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer1
.
bClose_Machine
;
}
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d5"
)
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d5"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer2
.
bClose_Machine
;
}
...
...
@@ -226,40 +226,40 @@ namespace ModbusDemo.application
#
endregion
#
region
中控柜关映射和手动映射
#
endregion
if
(
byControlID
==
31
&&
strOperationChannelName
[
0
]
==
"d1"
)
{
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"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cPumb1
.
bClose_Machine
;
}
else
if
(
byControlID
==
35
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
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
if (byControlID == 31 && strOperationChannelName[0] == "d1")
//
{
//
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")
//
{
//
bDelege_Operation = AllPond.cEastTransitPool.cPumb1.bClose_Machine;
//
}
//
else if (byControlID == 35 && strOperationChannelName[0] == "d0")
//
{
//
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
;
byMapIdleID
=
byControlID
;
strMapIdleChannelName
=
strOperationChannelName
;
byMapIdleControlData
=
bControlData
;
bDelege_Operation
=
bMap_Idle_Close_Control
;
}
}
return
bMapStatus
;
...
...
ModbusDemo/windows/Form1.cs
View file @
c873e72e
...
...
@@ -26,7 +26,7 @@ namespace ModbusDemo
{
public
partial
class
Form1
:
Form
{
const
bool
LOCALDEBUG
=
tru
e
;
const
bool
LOCALDEBUG
=
fals
e
;
private
bool
bStart
=
false
;
AutoResetEvent
exitEvent
;
private
int
waitTime
;
...
...
@@ -382,6 +382,7 @@ namespace ModbusDemo
{
try
{
mqttData
=
ModualPoll
.
vRemove_Nodes_Data_String
(
mqttData
);
await
Publish
(
mqttTopic
,
mqttData
);
}
catch
(
Exception
ex
)
...
...
@@ -426,7 +427,7 @@ namespace ModbusDemo
{
totxt
.
Log
(
"开始执行"
);
ModualPoll
.
vAllNodePoll
();
mqttData
=
ModualPoll
.
stAll_Poll_Package
(
);
mqttData
=
ModualPoll
.
vRemove_Nodes_Data_String
(
ModualPoll
.
stAll_Poll_Package
()
);
ModualPoll
.
vCheckAlarm_And_Send
(
mqttClient
);
totxt
.
Log
(
"执行结束"
);
});
...
...
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