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
b925a8ff
Commit
b925a8ff
authored
Jun 25, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix alarm BUG
parent
7891ea44
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
463 additions
and
343 deletions
+463
-343
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+92
-51
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+0
-1
AllPond.cs
ModbusDemo/application/AllPond.cs
+271
-273
AutoControl.cs
ModbusDemo/application/AutoControl.cs
+79
-13
ControlMap.cs
ModbusDemo/application/ControlMap.cs
+20
-4
Form1.cs
ModbusDemo/windows/Form1.cs
+1
-1
No files found.
ModbusDemo/MessageFormat/ModualControl.cs
View file @
b925a8ff
This diff is collapsed.
Click to expand it.
ModbusDemo/Modular/ModualPoll.cs
View file @
b925a8ff
...
@@ -857,7 +857,6 @@ namespace ModbusDemo.Modular
...
@@ -857,7 +857,6 @@ namespace ModbusDemo.Modular
await
Form1
.
Publish
(
Form1
.
sAlarmTopic
,
ModualAlarm
.
sAgainAlarmJson
);
await
Form1
.
Publish
(
Form1
.
sAlarmTopic
,
ModualAlarm
.
sAgainAlarmJson
);
}
}
}
}
public
static
string
vRemove_Nodes_Data_String
(
string
strSendAllDataJson
)
public
static
string
vRemove_Nodes_Data_String
(
string
strSendAllDataJson
)
{
{
if
(
listDeleteNodesID
.
Count
()
!=
0
)
if
(
listDeleteNodesID
.
Count
()
!=
0
)
...
...
ModbusDemo/application/AllPond.cs
View file @
b925a8ff
This diff is collapsed.
Click to expand it.
ModbusDemo/application/AutoControl.cs
View file @
b925a8ff
...
@@ -33,18 +33,19 @@ namespace ModbusDemo.application
...
@@ -33,18 +33,19 @@ namespace ModbusDemo.application
public
int
modularx
;
public
int
modularx
;
public
byte
modbusID
;
public
byte
modbusID
;
}
}
public
static
byte
[]
EmodbusId
=
{
90
,
39
};
//39 CH0/1 CH2/3 //90 CH0/1 CH2/3
public
static
byte
[]
EmodbusId
=
{
90
,
39
};
//39 CH0/1 CH2/3 //90 CH0/1 CH2/3
public
static
byte
[]
WmodbusId
=
{
31
};
//31 CH2/3 CH4/5
public
static
byte
[]
WmodbusId
=
{
31
};
//31 CH2/3 CH4/5
public
static
byte
[]
LevelmodbusID
=
{
13
,
13
};
// CH0 CH3
public
static
byte
[]
LevelmodbusID
=
{
13
,
13
};
// CH0 CH3
public
static
bool
[]
state_ON
=
{
true
,
true
,
true
,
true
};
public
static
bool
[]
state_ON
=
{
true
,
true
,
true
,
true
};
public
static
bool
[]
state_OFF
=
{
false
,
false
,
false
,
false
};
public
static
bool
[]
state_OFF
=
{
false
,
false
,
false
,
false
};
public
static
bool
[]
Read_state
;
public
static
bool
Etimerun
=
false
;
public
static
bool
Etimerun
=
false
;
public
static
bool
Wtimerun
=
false
;
public
static
bool
Wtimerun
=
false
;
...
@@ -97,10 +98,10 @@ namespace ModbusDemo.application
...
@@ -97,10 +98,10 @@ namespace ModbusDemo.application
}
}
static
double
[]
MeanValue
=
new
double
[
10
];
static
double
[]
MeanValue
=
new
double
[
10
];
public
static
double
Meanfilter
(
double
Value
)
public
static
double
Meanfilter
(
double
Value
)
{
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
{
MeanValue
[
i
]
=
Value
;
MeanValue
[
i
]
=
Value
;
}
}
Value
=
MeanValue
[
0
]
*
0.1
+
MeanValue
[
5
]
*
0.3
+
MeanValue
[
9
]
*
0.6
;
Value
=
MeanValue
[
0
]
*
0.1
+
MeanValue
[
5
]
*
0.3
+
MeanValue
[
9
]
*
0.6
;
return
Value
;
return
Value
;
...
@@ -184,7 +185,7 @@ namespace ModbusDemo.application
...
@@ -184,7 +185,7 @@ namespace ModbusDemo.application
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
}
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
+
1
],
16
,
state_OFF
)
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
+
1
],
16
,
state_OFF
)
==
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
)
...
@@ -292,7 +293,7 @@ namespace ModbusDemo.application
...
@@ -292,7 +293,7 @@ namespace ModbusDemo.application
//Console.WriteLine(timespan);
//Console.WriteLine(timespan);
}
}
}
}
//static bool Run_flag_bit = false;
public
static
void
T_AutoControl
()
public
static
void
T_AutoControl
()
{
{
Control
usEcontrol
=
new
Control
();
Control
usEcontrol
=
new
Control
();
...
@@ -300,6 +301,7 @@ namespace ModbusDemo.application
...
@@ -300,6 +301,7 @@ namespace ModbusDemo.application
Control
usWcontrol
=
new
Control
();
Control
usWcontrol
=
new
Control
();
Control
usWcontrolB
=
new
Control
();
Control
usWcontrolB
=
new
Control
();
FileInfo
file
=
new
FileInfo
(
InIHelper
.
FileName
);
FileInfo
file
=
new
FileInfo
(
InIHelper
.
FileName
);
//Run_flag_bit = true;
while
(
true
)
while
(
true
)
{
{
if
(
ModualControl
.
cPoolLevelConfig
.
Count
!=
0
)
if
(
ModualControl
.
cPoolLevelConfig
.
Count
!=
0
)
...
@@ -325,7 +327,8 @@ namespace ModbusDemo.application
...
@@ -325,7 +327,8 @@ namespace ModbusDemo.application
}
}
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
0
])
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
0
]
&&
ModualControl
.
cPoolLevelConfig
[
i
].
stChannelNumber
==
"d0"
)
{
{
usWcontrol
.
maxLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dUpLevel
;
usWcontrol
.
maxLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dUpLevel
;
usWcontrol
.
minLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dDownLevel
;
usWcontrol
.
minLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dDownLevel
;
...
@@ -338,7 +341,8 @@ namespace ModbusDemo.application
...
@@ -338,7 +341,8 @@ namespace ModbusDemo.application
out
usWcontrolB
out
usWcontrolB
);
);
}
}
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
1
])
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
1
]
&&
ModualControl
.
cPoolLevelConfig
[
i
].
stChannelNumber
==
"d3"
)
{
{
usEcontrol
.
maxLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dUpLevel
;
usEcontrol
.
maxLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dUpLevel
;
usEcontrol
.
minLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dDownLevel
;
usEcontrol
.
minLevel
=
ModualControl
.
cPoolLevelConfig
[
i
].
dDownLevel
;
...
@@ -369,8 +373,8 @@ namespace ModbusDemo.application
...
@@ -369,8 +373,8 @@ namespace ModbusDemo.application
ModualPoll
.
cx18x
.
sX18xDataStruct
[
usEcontrol
.
modularx
].
dNowConvertData
[
0
];
ModualPoll
.
cx18x
.
sX18xDataStruct
[
usEcontrol
.
modularx
].
dNowConvertData
[
0
];
usWcontrol
.
realTimeLevel
=
usWcontrol
.
realTimeLevel
=
ModualPoll
.
cx18x
.
sX18xDataStruct
[
usWcontrol
.
modularx
].
dNowConvertData
[
3
];
ModualPoll
.
cx18x
.
sX18xDataStruct
[
usWcontrol
.
modularx
].
dNowConvertData
[
3
];
usEcontrol
.
Enablation
=
true
;
usEcontrol
.
Enablation
=
true
;
usWcontrol
.
Enablation
=
true
;
usWcontrol
.
Enablation
=
true
;
CriticalValueMonitoring
(
CriticalValueMonitoring
(
ref
usEcontrol
,
ref
usEcontrol
,
true
,
true
,
...
@@ -385,16 +389,78 @@ namespace ModbusDemo.application
...
@@ -385,16 +389,78 @@ namespace ModbusDemo.application
);
);
Automatic_control
(
usEcontrolB
.
status
,
usWcontrolB
.
status
);
Automatic_control
(
usEcontrolB
.
status
,
usWcontrolB
.
status
);
}
}
//else if (Run_flag_bit == true)
//{
// if (usEcontrolB.status == true)
// {
// }
// if (usWcontrolB.status == true)
// {
// }
//}
else
else
{
{
usWcontrol
.
status
=
false
;
usWcontrol
.
status
=
false
;
usEcontrol
.
status
=
false
;
usEcontrol
.
status
=
false
;
Automatic_control
(
usEcontrol
.
status
,
usWcontrol
.
status
);
Automatic_control
(
usEcontrol
.
status
,
usWcontrol
.
status
);
}
}
//Run_flag_bit = false;
}
}
}
}
}
}
/*
* else
{
if (ModbusComm.Modbus_ReadCoilsTask(out Read_state, EmodbusId[i],16,4)
==
ModbusComm.eModbusErrorCode.MB_EMASTERNOERR)
{
ModualAlarm.vSet_Modual_Alarm(EmodbusId[i],
(ushort)ModualAlarm.eAlarmCode.ChannelCommunError, false, 1,
"d0", "d1", "d2", "d3", "d4", "d5");
ModbusComm.Modbus_WriteMultipleCoils(EmodbusId[i], 16, state_OFF);
}
else
{
ModualAlarm.vSet_Modual_Alarm(EmodbusId[i],
(ushort)ModualAlarm.eAlarmCode.ChannelCommunError, true, 1,
"d0", "d1", "d2", "d3", "d4", "d5");
}
if (ModbusComm.Modbus_ReadCoilsTask(out Read_state, EmodbusId[i+1], 16, 4)
==
ModbusComm.eModbusErrorCode.MB_EMASTERNOERR)
{
ModualAlarm.vSet_Modual_Alarm(EmodbusId[i],
(ushort)ModualAlarm.eAlarmCode.ChannelCommunError, false, 1,
"d0", "d1", "d2", "d3", "d4", "d5");
ModbusComm.Modbus_WriteMultipleCoils(EmodbusId[i+1], 16, state_OFF);
}
else
{
ModualAlarm.vSet_Modual_Alarm(EmodbusId[i+1],
(ushort)ModualAlarm.eAlarmCode.ChannelCommunError, false, 1,
"d0", "d1", "d2", "d3", "d4", "d5");
}
}
if (ModbusComm.Modbus_ReadCoilsTask(out Read_state, WmodbusId[i], 18, 4)
==
ModbusComm.eModbusErrorCode.MB_EMASTERNOERR)
{
ModualAlarm.vSet_Modual_Alarm(EmodbusId[i],
(ushort)ModualAlarm.eAlarmCode.ChannelCommunError, false, 1,
"d0", "d1", "d2", "d3", "d4", "d5");
ModbusComm.Modbus_WriteMultipleCoils(WmodbusId[i], 18, state_OFF);
}
else
{
ModualAlarm.vSet_Modual_Alarm(WmodbusId[i],
(ushort)ModualAlarm.eAlarmCode.ChannelCommunError, true, 1,
"d0", "d1", "d2", "d3", "d4", "d5");
}
*/
#else
#else
public
class
AutoControl
public
class
AutoControl
{
{
...
...
ModbusDemo/application/ControlMap.cs
View file @
b925a8ff
...
@@ -113,14 +113,22 @@ namespace ModbusDemo.application
...
@@ -113,14 +113,22 @@ namespace ModbusDemo.application
}
}
#
endregion
#
endregion
#
region
沉砂池开映射
#
region
沉砂池开映射
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d4"
)
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d4"
)
{
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer1
.
bOpen_Machine
;
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer1
.
bOpen_Machine
;
}
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d5"
)
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d5"
)
{
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer2
.
bOpen_Machine
;
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer2
.
bOpen_Machine
;
}
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d4"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cPumb1
.
bOpen_Machine
;
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d5"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cPumb2
.
bOpen_Machine
;
}
#
endregion
#
endregion
#
region
出料池开映射
#
region
出料池开映射
#
endregion
#
endregion
...
@@ -201,14 +209,22 @@ namespace ModbusDemo.application
...
@@ -201,14 +209,22 @@ namespace ModbusDemo.application
}
}
#
endregion
#
endregion
#
region
沉砂池关映射
#
region
沉砂池关映射
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d4"
)
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d4"
)
{
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer1
.
bClose_Machine
;
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer1
.
bClose_Machine
;
}
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d5"
)
else
if
(
byControlID
==
90
&&
strOperationChannelName
[
0
]
==
"d5"
)
{
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer2
.
bClose_Machine
;
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cStirrer2
.
bClose_Machine
;
}
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d4"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cPumb1
.
bClose_Machine
;
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d5"
)
{
bDelege_Operation
=
AllPond
.
cDesiltingPool
.
cPumb2
.
bClose_Machine
;
}
#
endregion
#
endregion
#
region
出料池关映射
#
region
出料池关映射
#
endregion
#
endregion
...
...
ModbusDemo/windows/Form1.cs
View file @
b925a8ff
...
@@ -26,7 +26,7 @@ namespace ModbusDemo
...
@@ -26,7 +26,7 @@ namespace ModbusDemo
{
{
public
partial
class
Form1
:
Form
public
partial
class
Form1
:
Form
{
{
const
bool
LOCALDEBUG
=
fals
e
;
const
bool
LOCALDEBUG
=
tru
e
;
private
bool
bStart
=
false
;
private
bool
bStart
=
false
;
AutoResetEvent
exitEvent
;
AutoResetEvent
exitEvent
;
private
int
waitTime
;
private
int
waitTime
;
...
...
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