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
273a0479
Commit
273a0479
authored
Jun 20, 2019
by
shaxuezheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify AutoControl
parent
fc5bbaa0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
30 deletions
+24
-30
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+1
-1
AutoControl.cs
ModbusDemo/application/AutoControl.cs
+4
-2
Form1.cs
ModbusDemo/windows/Form1.cs
+19
-27
No files found.
ModbusDemo/Modular/ModualPoll.cs
View file @
273a0479
...
...
@@ -35,7 +35,7 @@ namespace ModbusDemo.Modular
public
static
_414P
c14formulasormual
=
new
_414P
();
#if DEBUG_TEST
public
const
byte
byX18xNumber
=
1
;
public
static
byte
[]
byX18xIdlist
=
{
13
};
public
static
byte
[]
byX18xIdlist
=
{
13
,
14
};
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
public
const
byte
byX18xNumber
=
6
;
...
...
ModbusDemo/application/AutoControl.cs
View file @
273a0479
...
...
@@ -152,7 +152,7 @@ namespace ModbusDemo.application
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
if
(
Runtimeout
>
Runtimeout
*
2
)
if
(
timespan
.
TotalMinutes
>
Runtimeout
*
2
)
{
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
...
...
@@ -245,7 +245,7 @@ namespace ModbusDemo.application
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
if
(
Runtimeout
>
Runtimeout
*
2
)
if
(
Wtime
.
TotalMinutes
>
Runtimeout
*
2
)
{
WTime
.
Reset
();
WTime
.
Stop
();
//停止监视
...
...
@@ -334,6 +334,8 @@ namespace ModbusDemo.application
usEcontrol
.
modbusID
=
LevelmodbusID
[
1
];
}
}
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
0
])
{
usWcontrol
.
maxLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dUpLevel
;
...
...
ModbusDemo/windows/Form1.cs
View file @
273a0479
...
...
@@ -80,7 +80,7 @@ namespace ModbusDemo
string
mqttUsername
;
string
mqttPwd
;
public
const
string
mqttSn
=
"
256333344
"
;
public
const
string
mqttSn
=
"
66666666
"
;
public
const
string
mqttSubscribeControlTopic
=
"Witium/WTDS78X/"
+
mqttSn
+
"/Ctrl"
;
public
const
string
mqttBackTopic
=
"Witium/WTDS78X/"
+
mqttSn
+
"/Back"
;
public
const
string
mqttCfgTopic
=
"Witium/WTDS78X/"
+
mqttSn
+
"/Config"
;
...
...
@@ -374,26 +374,17 @@ namespace ModbusDemo
{
while
(
true
)
{
Parallel
.
Invoke
(
()
=>
{
bSetDataIsRunning
=
true
;
ModualPoll
.
vAllNodePoll
();
mqttData
=
ModualPoll
.
stAll_Poll_Package
();
ModualPoll
.
vCheckAlarm_And_Send
(
mqttClient
);
label5
.
Text
=
ModbusComm
.
usCommunFailTimes
.
ToString
();
},
()
=>
{
AutoControl
.
T_AutoControl
();
})
;
bSetDataIsRunning
=
true
;
ModualPoll
.
vAllNodePoll
();
mqttData
=
ModualPoll
.
stAll_Poll_Package
();
ModualPoll
.
vCheckAlarm_And_Send
(
mqttClient
);
label5
.
Text
=
ModbusComm
.
usCommunFailTimes
.
ToString
();
}
}
private
void
Sendout
()
{
Control
.
CheckForIllegalCrossThreadCalls
=
false
;
MQTTTimer
.
Interval
=
20000
;
//120500
MQTTTimer
.
Interval
=
20000
l
;
//120500
MQTTTimer
.
Enabled
=
true
;
MQTTTimer
.
AutoReset
=
true
;
//设置是执行一次(false)还是一直执行(true);
MQTTTimer
.
Start
();
...
...
@@ -1055,11 +1046,6 @@ namespace ModbusDemo
ModbusComm
.
Modbus
.
Transport
.
WriteTimeout
=
1000
;
ModbusComm
.
Modbus
.
Transport
.
WaitToRetryMilliseconds
=
0
;
//t_AutoControl = new Thread(T_AutoControl)
//{
// IsBackground = true
//};
//t_AutoControl.Start();
modbus_Timer
.
Enabled
=
true
;
btOpenCOM
.
Enabled
=
false
;
...
...
@@ -1089,7 +1075,7 @@ namespace ModbusDemo
}
private
async
void
run
()
{
comPort
.
PortName
=
"COM
1
"
;
comPort
.
PortName
=
"COM
6
"
;
comPort
.
BaudRate
=
9600
;
comPort
.
Parity
=
Parity
.
None
;
comPort
.
StopBits
=
StopBits
.
One
;
...
...
@@ -1109,11 +1095,9 @@ namespace ModbusDemo
ModbusComm
.
Modbus
.
Transport
.
WriteTimeout
=
1000
;
ModbusComm
.
Modbus
.
Transport
.
WaitToRetryMilliseconds
=
0
;
//t_AutoControl = new Thread(T_AutoControl)
//{
// IsBackground = true
//};
//t_AutoControl.Start();
t_AutoControl
=
new
Thread
(
AtuoControl_run
);
t_AutoControl
.
IsBackground
=
true
;
t_AutoControl
.
Start
();
modbus_Timer
.
Enabled
=
true
;
btOpenCOM
.
Enabled
=
false
;
...
...
@@ -1155,6 +1139,14 @@ namespace ModbusDemo
comPort
.
Close
();
totxt
.
Log
(
DateTime
.
Now
.
ToString
()
+
" =>Disconnect "
+
comPort
.
PortName
);
}
private
void
AtuoControl_run
()
{
while
(
true
)
{
AutoControl
.
T_AutoControl
();
}
}
}
}
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