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
5f108282
Commit
5f108282
authored
Jun 24, 2019
by
shaxuezheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Intranet Deployment Function Confirmation
parent
506c66e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
672 additions
and
103 deletions
+672
-103
ModSearch.cs
ModbusDemo/Common/ModSearch.cs
+1
-1
ModualAlarm.cs
ModbusDemo/Common/ModualAlarm.cs
+19
-0
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+8
-8
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+119
-3
AutoControl.cs
ModbusDemo/application/AutoControl.cs
+502
-86
Form1.cs
ModbusDemo/windows/Form1.cs
+23
-5
No files found.
ModbusDemo/Common/ModSearch.cs
View file @
5f108282
...
...
@@ -32,7 +32,7 @@ namespace ModbusDemo.windows
public
DeviceInfo
m_DeviceInfo
;
public
ArrayList
myHMIList
=
new
ArrayList
();
string
FMAC
=
null
;
//
string FMAC =null;
string
localip
=
null
;
...
...
ModbusDemo/Common/ModualAlarm.cs
View file @
5f108282
...
...
@@ -15,6 +15,7 @@ namespace ModbusDemo.Common
public
const
ushort
usChannelNumber
=
8
;
public
static
string
sAlarmJson
;
public
static
string
sAgainAlarmJson
;
public
static
string
sAlarmJsonPackage
;
//private IMqttClient mqttClient = null;
public
enum
eAlarmCode
:
ushort
...
...
@@ -47,6 +48,24 @@ namespace ModbusDemo.Common
sAlarmJson
+=
JsonConvert
.
SerializeObject
(
hMqtttAlarmMap
);
}
public
static
void
vSet_Alarm_Again_List
(
ushort
usAddress
,
ushort
[]
usChannel
,
ushort
[]
usChannelAlarmcode
)
{
ushort
i
=
0
;
Hashtable
hMqtttAlarmMap
=
new
Hashtable
();
hMqtttAlarmMap
.
Add
(
"addr"
,
usAddress
.
ToString
());
string
sAlarm
=
"alm"
;
foreach
(
ushort
usdata
in
usChannelAlarmcode
)
{
hMqtttAlarmMap
.
Add
(
sAlarm
+
usChannel
[
i
],
usChannelAlarmcode
[
i
]);
i
++;
}
hMqtttAlarmMap
.
Add
(
"ts"
,
Form1
.
GetTimeStamp
());
if
(
sAgainAlarmJson
!=
"["
)
{
sAgainAlarmJson
+=
","
;
}
sAgainAlarmJson
+=
JsonConvert
.
SerializeObject
(
hMqtttAlarmMap
);
}
public
static
async
Task
vPublishAlarmPackageJson
(
IMqttClient
mqttClient
)
{
if
(
mqttClient
.
IsConnected
==
true
)
...
...
ModbusDemo/MessageFormat/ModualControl.cs
View file @
5f108282
...
...
@@ -266,7 +266,7 @@ namespace ModbusDemo.MessageFormat
if
((
liModuualControl
[
i
].
usDurationTime
+
liModuualControl
[
i
].
ulStartTime
)
<=
Form1
.
GetTimeStamp
())
{
bool
[]
bControlData
;
string
str
;
//
string str;
liModuualControl
[
i
].
bControlStatus
=
ModualPoll
.
bGet_channel_Value
<
bool
>(
liModuualControl
[
i
].
sbModbusID
,
out
bControlData
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
//for (int j = 0; j < 8; j++)
//{
...
...
@@ -608,7 +608,7 @@ namespace ModbusDemo.MessageFormat
dUpLevel
=
double
.
Parse
(
cCfgRoot
.
ss
[
i
].
cfg
.
upper
),
dDownLevel
=
double
.
Parse
(
cCfgRoot
.
ss
[
i
].
cfg
.
down
)
};
vSet_Pool_Alarm_Level
(
cLiquidLevelConfig
.
byModbusID
,
cLiquidLevelConfig
.
dUpLevel
,
cLiquidLevelConfig
.
dDownLevel
);
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
string
strChannelString
=
"d"
+
j
.
ToString
();
...
...
@@ -619,7 +619,7 @@ namespace ModbusDemo.MessageFormat
break
;
}
}
vSet_Pool_Alarm_Level
(
cLiquidLevelConfig
.
byModbusID
,
cLiquidLevelConfig
.
dUpLevel
,
cLiquidLevelConfig
.
dDownLevel
,
cLiquidLevelConfig
.
stChannelNumber
);
if
(
jsonObj
[
"ss"
][
i
][
"cfg"
][
"ts"
]
!=
null
)
{
jsonObj
[
"ss"
][
i
][
"cfg"
][
"ts"
]
=
Form1
.
GetTimeStamp
();
...
...
@@ -637,30 +637,30 @@ namespace ModbusDemo.MessageFormat
stResponseStrign
=
jsonObj
.
ToString
();
}
}
public
static
void
vSet_Pool_Alarm_Level
(
byte
byModbusID
,
double
dMaxLevel
,
double
dMinLevel
)
public
static
void
vSet_Pool_Alarm_Level
(
byte
byModbusID
,
double
dMaxLevel
,
double
dMinLevel
,
string
strChannelName
)
{
if
(
byModbusID
==
AllPond
.
cSlurryPool
.
cLevel
.
byModbusID
)
if
(
byModbusID
==
AllPond
.
cSlurryPool
.
cLevel
.
byModbusID
&&
((
IList
<
string
>)
AllPond
.
cSlurryPool
.
cLevel
.
strChannelNumber
).
Contains
(
strChannelName
)
==
true
)
{
AllPond
.
cSlurryPool
.
vSetMaxLevel
=
dMaxLevel
;
AllPond
.
cSlurryPool
.
vSetMinLevel
=
dMinLevel
;
pcConfig
.
WriteConfig
(
"匀浆池配置"
,
"报警最高液位"
,
AllPond
.
cSlurryPool
.
vSetMaxLevel
.
ToString
());
pcConfig
.
WriteConfig
(
"匀浆池配置"
,
"报警最低液位"
,
AllPond
.
cSlurryPool
.
vSetMinLevel
.
ToString
());
}
else
if
(
byModbusID
==
AllPond
.
cDesiltingPool
.
cLevel
.
byModbusID
)
else
if
(
byModbusID
==
AllPond
.
cDesiltingPool
.
cLevel
.
byModbusID
&&
((
IList
<
string
>)
AllPond
.
cDesiltingPool
.
cLevel
.
strChannelNumber
).
Contains
(
strChannelName
)
==
true
)
{
AllPond
.
cDesiltingPool
.
vSetMaxLevel
=
dMaxLevel
;
AllPond
.
cDesiltingPool
.
vSetMinLevel
=
dMinLevel
;
pcConfig
.
WriteConfig
(
"沉砂池池配置"
,
"报警最高液位"
,
AllPond
.
cDesiltingPool
.
vSetMaxLevel
.
ToString
());
pcConfig
.
WriteConfig
(
"沉砂池池配置"
,
"报警最低液位"
,
AllPond
.
cDesiltingPool
.
vSetMinLevel
.
ToString
());
}
else
if
(
byModbusID
==
AllPond
.
cOctagonalPool
.
cLevel
.
byModbusID
)
else
if
(
byModbusID
==
AllPond
.
cOctagonalPool
.
cLevel
.
byModbusID
&&
((
IList
<
string
>)
AllPond
.
cOctagonalPool
.
cLevel
.
strChannelNumber
).
Contains
(
strChannelName
)
==
true
)
{
AllPond
.
cOctagonalPool
.
vSetMaxLevel
=
dMaxLevel
;
AllPond
.
cOctagonalPool
.
vSetMinLevel
=
dMinLevel
;
pcConfig
.
WriteConfig
(
"八角池配置"
,
"报警最高液位"
,
AllPond
.
cOctagonalPool
.
vSetMaxLevel
.
ToString
());
pcConfig
.
WriteConfig
(
"八角池配置"
,
"报警最低液位"
,
AllPond
.
cOctagonalPool
.
vSetMinLevel
.
ToString
());
}
else
if
(
byModbusID
==
AllPond
.
cDischargePool
.
cLevel
.
byModbusID
)
else
if
(
byModbusID
==
AllPond
.
cDischargePool
.
cLevel
.
byModbusID
&&
((
IList
<
string
>)
AllPond
.
cDischargePool
.
cLevel
.
strChannelNumber
).
Contains
(
strChannelName
)
==
true
)
{
AllPond
.
cDischargePool
.
vSetMaxLevel
=
dMaxLevel
;
AllPond
.
cDischargePool
.
vSetMinLevel
=
dMinLevel
;
...
...
ModbusDemo/Modular/ModualPoll.cs
View file @
5f108282
...
...
@@ -36,8 +36,8 @@ namespace ModbusDemo.Modular
public
static
_414P
c14formulasormual
=
new
_414P
();
#if DEBUG_TEST
public
const
byte
byX18xNumber
=
1
;
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
}
};
public
static
byte
[]
byX18xIdlist
=
{
13
};
private
static
modual
.
eX18xSensorChannelType
[,]
sX18xChannelType
=
new
modual
.
eX18xSensorChannelType
[
byX18xNumber
,
byX18xReadDataNumber
]
{
{
modual
.
eX18xSensorChannelType
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Null
,
modual
.
eX18xSensorChannelType
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Mike_6
}
};
#else
public
const
byte
byX18xNumber
=
6
;
public
static
byte
[]
byX18xIdlist
=
{
3
,
53
,
6
,
12
,
21
,
25
};
...
...
@@ -550,7 +550,7 @@ namespace ModbusDemo.Modular
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
5
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_6
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
6
)
/
16
*
6
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
6
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_7
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
7
);
...
...
@@ -736,6 +736,122 @@ namespace ModbusDemo.Modular
}
return
bControlStatus
;
}
public
static
async
Task
bSend_Alarm_Again
()
{
bool
bOccurErrorChange
=
false
;
ModualAlarm
.
sAgainAlarmJson
=
"["
;
for
(
byte
i
=
0
;
i
<
byX14pNumber
;
i
++)
{
bool
bX14pError
=
false
;
List
<
ushort
>
usChannelErrorlist
=
new
List
<
ushort
>();
List
<
ushort
>
usChannelErrorCodeList
=
new
List
<
ushort
>();
for
(
byte
j
=
0
;
j
<
byX14pReadDataNumber
;
j
++)
{
if
((
cx14P
.
sX14PAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
||
(
cx14P
.
sX14PAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
||
(
cx14P
.
sX14PAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
||
(
cx14P
.
sX14PAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
{
bOccurErrorChange
=
true
;
bX14pError
=
true
;
usChannelErrorlist
.
Add
(
j
);
usChannelErrorCodeList
.
Add
((
ushort
)
cx14P
.
sX14PAlarmStruct
[
i
].
usNowAlarmCode
[
j
]);
}
//cx14P.sX14PAlarmStruct[i].usBeforeAlarmCode[j] = cx14P.sX14PAlarmStruct[i].usNowAlarmCode[j];
}
if
(
bX14pError
==
true
)
{
ushort
[]
usChannelList
=
usChannelErrorlist
.
ToArray
();
ushort
[]
usCodeList
=
usChannelErrorCodeList
.
ToArray
();
ModualAlarm
.
vSet_Alarm_Again_List
(
cx14P
.
byModbusID
[
i
],
usChannelList
,
usCodeList
);
}
}
for
(
byte
i
=
0
;
i
<
byX18xNumber
;
i
++)
{
bool
bX18xError
=
false
;
List
<
ushort
>
usChannelErrorlist
=
new
List
<
ushort
>();
List
<
ushort
>
usChannelErrorCodeList
=
new
List
<
ushort
>();
for
(
byte
j
=
0
;
j
<
byX18xReadTypeNumber
;
j
++)
{
if
((
cx18x
.
sX18xAlarmstruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
||
(
cx18x
.
sX18xAlarmstruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
||
(
cx18x
.
sX18xAlarmstruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
||
(
cx18x
.
sX18xAlarmstruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
{
bX18xError
=
true
;
bOccurErrorChange
=
true
;
usChannelErrorlist
.
Add
(
j
);
usChannelErrorCodeList
.
Add
((
ushort
)
cx18x
.
sX18xAlarmstruct
[
i
].
usNowAlarmCode
[
j
]);
}
//cx18x.sX18xAlarmstruct[i].usBeforeAlarmCode[j] = cx18x.sX18xAlarmstruct[i].usNowAlarmCode[j];
}
if
(
bX18xError
==
true
)
{
ushort
[]
usChannelList
=
usChannelErrorlist
.
ToArray
();
ushort
[]
usCodeList
=
usChannelErrorCodeList
.
ToArray
();
ModualAlarm
.
vSet_Alarm_Again_List
(
cx18x
.
byModbusID
[
i
],
usChannelList
,
usCodeList
);
}
}
for
(
byte
i
=
0
;
i
<
byX78cNumber
;
i
++)
{
bool
bX78CError
=
false
;
List
<
ushort
>
usChannelErrorlist
=
new
List
<
ushort
>();
List
<
ushort
>
usChannelErrorCodeList
=
new
List
<
ushort
>();
for
(
byte
j
=
0
;
j
<
byX78cOutputRegNumber
+
byX78cInputRegNumber
;
j
++)
{
if
((
cx78c
.
sX78cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
||
(
cx78c
.
sX78cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
||
(
cx78c
.
sX78cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
||
(
cx78c
.
sX78cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
{
bOccurErrorChange
=
true
;
bX78CError
=
true
;
usChannelErrorlist
.
Add
(
j
);
usChannelErrorCodeList
.
Add
((
ushort
)
cx78c
.
sX78cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]);
}
//cx78c.sX78cAlarmStruct[i].usBeforeAlarmCode[j] = cx78c.sX78cAlarmStruct[i].usNowAlarmCode[j];
}
if
(
bX78CError
==
true
)
{
ushort
[]
usChannelList
=
usChannelErrorlist
.
ToArray
();
ushort
[]
usCodeList
=
usChannelErrorCodeList
.
ToArray
();
ModualAlarm
.
vSet_Alarm_Again_List
(
cx78c
.
byModbusID
[
i
],
usChannelList
,
usCodeList
);
}
}
for
(
byte
i
=
0
;
i
<
byX66cNumber
;
i
++)
{
bool
bX66cError
=
false
;
List
<
ushort
>
usChannelErrorlist
=
new
List
<
ushort
>();
List
<
ushort
>
usChannelErrorCodeList
=
new
List
<
ushort
>();
for
(
byte
j
=
0
;
j
<
byX66cRelayRegNumber
;
j
++)
{
if
((
cx66c
.
sX66cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
||
(
cx66c
.
sX66cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelLevelError
||
(
cx66c
.
sX66cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
||
(
cx66c
.
sX66cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]
&
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
==
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
)
{
bOccurErrorChange
=
true
;
bX66cError
=
true
;
usChannelErrorlist
.
Add
(
j
);
usChannelErrorCodeList
.
Add
((
ushort
)
cx66c
.
sX66cAlarmStruct
[
i
].
usNowAlarmCode
[
j
]);
}
//cx66c.sX66cAlarmStruct[i].usBeforeAlarmCode[j] = cx66c.sX66cAlarmStruct[i].usNowAlarmCode[j];
}
if
(
bX66cError
==
true
)
{
ushort
[]
usChannelList
=
usChannelErrorlist
.
ToArray
();
ushort
[]
usCodeList
=
usChannelErrorCodeList
.
ToArray
();
ModualAlarm
.
vSet_Alarm_Again_List
(
cx66c
.
byModbusID
[
i
],
usChannelList
,
usCodeList
);
}
}
if
(
bOccurErrorChange
==
true
)
{
ModualAlarm
.
sAgainAlarmJson
+=
"]"
;
await
Form1
.
Publish
(
Form1
.
sAlarmTopic
,
ModualAlarm
.
sAgainAlarmJson
);
}
}
}
}
ModbusDemo/application/AutoControl.cs
View file @
5f108282
This diff is collapsed.
Click to expand it.
ModbusDemo/windows/Form1.cs
View file @
5f108282
...
...
@@ -26,7 +26,7 @@ namespace ModbusDemo
{
public
partial
class
Form1
:
Form
{
const
bool
LOCALDEBUG
=
fals
e
;
const
bool
LOCALDEBUG
=
tru
e
;
private
bool
bStart
=
false
;
AutoResetEvent
exitEvent
;
private
int
waitTime
;
...
...
@@ -35,6 +35,7 @@ namespace ModbusDemo
public
delegate
void
invokeDelegate
();
System
.
Timers
.
Timer
MQTTTimer
=
new
System
.
Timers
.
Timer
();
System
.
Timers
.
Timer
tSendAlarmAgainTimer
=
new
System
.
Timers
.
Timer
();
BackgroundWorker
m_bgw0
=
new
BackgroundWorker
();
bool
m_Isbgw0_CanContinueRun
=
true
;
bool
bCreatThead
=
false
;
...
...
@@ -93,7 +94,7 @@ namespace ModbusDemo
private
bool
isReconnect
=
true
;
private
void
SetMqtt
()
{
if
(
LOCALDEBUG
==
tru
e
)
if
(
LOCALDEBUG
==
fals
e
)
{
mqttIp
=
"47.101.50.24"
;
mqttClientId
=
GetTimeStamp
()
+
"sxz"
;
...
...
@@ -251,7 +252,7 @@ namespace ModbusDemo
}
private
void
MqttClient_Connected
(
object
sender
,
EventArgs
e
)
{
Invoke
(
(
new
Action
(
async
()
=>
Invoke
(
(
new
Action
(
()
=>
{
txtReceiveMessage
.
AppendText
(
"已连接到MQTT服务器!"
+
Environment
.
NewLine
);
})));
...
...
@@ -270,7 +271,7 @@ namespace ModbusDemo
//Reconnecting
if
(
isReconnect
)
{
Invoke
((
new
Action
(
async
()
=>
Invoke
((
new
Action
(()
=>
{
txtReceiveMessage
.
AppendText
(
"正在尝试重新连接"
+
Environment
.
NewLine
);
totxt
.
Log
(
"正在尝试重新连接"
+
Environment
.
NewLine
);
...
...
@@ -389,6 +390,23 @@ namespace ModbusDemo
return
;
}
};
tSendAlarmAgainTimer
.
Interval
=
600000
;
tSendAlarmAgainTimer
.
Enabled
=
true
;
tSendAlarmAgainTimer
.
AutoReset
=
true
;
tSendAlarmAgainTimer
.
Start
();
tSendAlarmAgainTimer
.
Elapsed
+=
async
(
o
,
a
)
=>
{
try
{
await
ModualPoll
.
bSend_Alarm_Again
();
}
catch
(
Exception
ex
)
{
totxt
.
Log
(
ex
+
","
+
Environment
.
NewLine
+
"\n"
);
return
;
}
};
}
//声明委托
...
...
@@ -986,7 +1004,7 @@ namespace ModbusDemo
{
if
(
LOCALDEBUG
==
true
)
{
comPort
.
PortName
=
"COM
6
"
;
comPort
.
PortName
=
"COM
2
"
;
comPort
.
BaudRate
=
9600
;
comPort
.
Parity
=
Parity
.
None
;
comPort
.
StopBits
=
StopBits
.
One
;
...
...
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