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
de89515f
Commit
de89515f
authored
Jun 19, 2019
by
shaxuezheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AutoControl Updata
parent
e3cca5ae
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
60 deletions
+81
-60
ModualAlarm.cs
ModbusDemo/Common/ModualAlarm.cs
+2
-0
ModbusComm.cs
ModbusDemo/MessageFormat/ModbusComm.cs
+0
-21
ModbusDemo.csproj
ModbusDemo/ModbusDemo.csproj
+0
-9
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+1
-1
AutoControl.cs
ModbusDemo/application/AutoControl.cs
+76
-28
Form1.cs
ModbusDemo/windows/Form1.cs
+2
-1
No files found.
ModbusDemo/Common/ModualAlarm.cs
View file @
de89515f
...
...
@@ -26,6 +26,8 @@ namespace ModbusDemo.Common
ChannelDataChangeError
=
8
,
ChannelLevelError
=
16
,
ChannelControlError
=
32
,
ChannelRunOverTimeError
=
64
,
}
public
static
void
vSetAlarmList
(
ushort
usAddress
,
ushort
[]
usChannel
,
ushort
[]
usChannelAlarmcode
)
{
...
...
ModbusDemo/MessageFormat/ModbusComm.cs
View file @
de89515f
...
...
@@ -28,20 +28,11 @@ namespace ModbusDemo.MessageFormat
MB_EMASTERSENT
,
MB_RTUERNOERR
}
<<<<<<<
HEAD
public
static
ModbusMaster
Modbus
;
public
static
ushort
usCommunFailTimes
=
0
;
private
static
object
oLock
=
new
object
();
public
static
eModbusErrorCode
Modbus_ReadHoldingRegistersTask
(
out
ushort
[]
OutputValue
,
byte
slaveAddress
,
ushort
startAddress
,
ushort
numberOfPoints
)
{
=======
public
static
ModbusMaster
Modbus
;
public
static
ushort
usCommunFailTimes
=
0
;
static
object
oLock
=
new
object
();
public
static
eModbusErrorCode
Modbus_ReadHoldingRegistersTask
(
out
ushort
[]
OutputValue
,
byte
slaveAddress
,
ushort
startAddress
,
ushort
numberOfPoints
)
{
>>>>>>>
5635
bdf708c90bb2146f99466d1145dda5dabb37
lock
(
oLock
)
{
eModbusErrorCode
ModbusErrorCode
;
...
...
@@ -126,10 +117,6 @@ namespace ModbusDemo.MessageFormat
}
public
static
eModbusErrorCode
Modbus_ReadCoilsTask
(
out
bool
[]
OutputValue
,
byte
slaveAddress
,
ushort
startAddress
,
ushort
numberOfPoints
)
{
<<<<<<<
HEAD
=======
//object oLock = new object();
>>>>>>>
5635
bdf708c90bb2146f99466d1145dda5dabb37
lock
(
oLock
)
{
eModbusErrorCode
ModbusErrorCode
;
...
...
@@ -214,10 +201,6 @@ namespace ModbusDemo.MessageFormat
}
public
static
eModbusErrorCode
Modbus_WriteSingleCoil
(
byte
slaveAddress
,
ushort
startAddress
,
bool
value
)
{
<<<<<<<
HEAD
=======
//object oLock = new object();
>>>>>>>
5635
bdf708c90bb2146f99466d1145dda5dabb37
lock
(
oLock
)
{
eModbusErrorCode
ModbusErrorCode
;
...
...
@@ -300,10 +283,6 @@ namespace ModbusDemo.MessageFormat
}
public
static
eModbusErrorCode
Modbus_WriteMultipleCoils
(
byte
slaveAddress
,
ushort
startAddress
,
bool
[]
data
)
{
<<<<<<<
HEAD
=======
//object oLock = new object();
>>>>>>>
5635
bdf708c90bb2146f99466d1145dda5dabb37
lock
(
oLock
)
{
eModbusErrorCode
ModbusErrorCode
;
...
...
ModbusDemo/ModbusDemo.csproj
View file @
de89515f
...
...
@@ -180,15 +180,6 @@
</PropertyGroup>
<Import
Project=
"$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets"
Condition=
"$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''"
/>
<Import
Project=
"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets"
Condition=
"$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''"
/>
<<<<<<
< HEAD
<<<<<<<
HEAD
=
======
=======
>
>>>>>> 5635bdf708c90bb2146f99466d1145dda5dabb37
<PropertyGroup>
<SsdtUnitTestVersion>
3.1
</SsdtUnitTestVersion>
</PropertyGroup>
>>>>>>> origin/master
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
...
...
ModbusDemo/Modular/ModualPoll.cs
View file @
de89515f
...
...
@@ -36,7 +36,7 @@ namespace ModbusDemo.Modular
#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
.
Mike_6
,
modual
.
eX18xSensorChannelType
.
Null
,
modual
.
eX18xSensorChannelType
.
NormalCurrent
,
modual
.
eX18xSensorChannelType
.
Null
,
modual
.
eX18xSensorChannelType
.
Null
,
modual
.
eX18xSensorChannelType
.
Null
,
modual
.
eX18xSensorChannelType
.
Null
,
modual
.
eX18xSensorChannelType
.
Null
}
};
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
;
public
static
byte
[]
byX18xIdlist
=
{
3
,
53
,
6
,
12
,
21
,
25
};
...
...
ModbusDemo/application/AutoControl.cs
View file @
de89515f
...
...
@@ -35,15 +35,11 @@ namespace ModbusDemo.application
public
string
Name
;
public
double
StatusTime
;
public
int
modularx
;
public
byte
modbusID
;
}
public
static
void
CriticalValueMonitoring
(
ref
Control
usControl
,
bool
Enabl
,
string
Affiliation
,
out
Control
control
)
{
//Control usControl = new Control
//{
// Enablation = Enabl,
// Name = Affiliation,
//};
if
(
usControl
.
Enablation
==
true
)
{
if
(
usControl
.
maxLevel
!=
0.0
&&
usControl
.
minLevel
!=
0.0
)
...
...
@@ -67,7 +63,6 @@ namespace ModbusDemo.application
}
else
if
(
usControl
.
realTimeLevel
<
usControl
.
maxLevel
&&
usControl
.
realTimeLevel
>
(
usControl
.
minLevel
+
usControl
.
minLevel
*
0.15
))
{
//usControl.status = true;
usControl
.
normal
=
true
;
}
...
...
@@ -99,7 +94,7 @@ namespace ModbusDemo.application
public
static
bool
Wtimerun
=
false
;
static
System
.
Diagnostics
.
Stopwatch
ETime
=
new
System
.
Diagnostics
.
Stopwatch
();
static
System
.
Diagnostics
.
Stopwatch
WTime
=
new
System
.
Diagnostics
.
Stopwatch
();
//public static string
public
static
void
Automatic_control
(
bool
Eenabl
,
bool
Wenabl
)
{
TimeSpan
Wtime
=
WTime
.
Elapsed
;
...
...
@@ -146,36 +141,54 @@ namespace ModbusDemo.application
}
if
(
timespan
.
TotalMinutes
>
2
)
{
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
)
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
}
}
else
{
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
)
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
+
1
],
16
,
state_OFF
)
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
)
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
}
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
//timerun = false;
}
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
EmodbusId
[
i
+
1
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
ETime
.
Reset
();
ETime
.
Stop
();
// 停止监视
timerun
=
false
;
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
],
16
,
state_OFF
);
ModbusComm
.
Modbus_WriteMultipleCoils
(
EmodbusId
[
i
+
1
],
16
,
state_OFF
);
}
if
(
Wenabl
==
true
)
...
...
@@ -216,26 +229,61 @@ namespace ModbusDemo.application
WTime
.
Start
();
//开始监视
Wtimerun
=
true
;
}
if
(
Wtime
.
TotalMinutes
>
2
)
if
(
Wtime
.
TotalMinutes
>
1
)
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelRunOverTimeError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
WTime
.
Reset
();
WTime
.
Stop
();
//停止监视
Wtimerun
=
false
;
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
],
16
,
state_OFF
);
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
+
1
],
16
,
state_OFF
);
}
}
else
{
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
],
16
,
state_OFF
)
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
if
(
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
+
1
],
16
,
state_OFF
)
==
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
)
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
+
1
],
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelControlError
,
false
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
else
{
ModualAlarm
.
vSet_Modual_Alarm
(
WmodbusId
[
i
+
1
],
(
ushort
)
ModbusComm
.
eModbusErrorCode
.
MB_EMASTERNOERR
|
(
ushort
)
ModualAlarm
.
eAlarmCode
.
ChannelCommunError
,
true
,
1
,
"d0"
,
"d1"
,
"d2"
,
"d3"
,
"d4"
,
"d5"
,
"d6"
,
"d7"
);
}
WTime
.
Reset
();
WTime
.
Stop
();
//停止监视
Wtimerun
=
false
;
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
],
16
,
state_OFF
);
ModbusComm
.
Modbus_WriteMultipleCoils
(
WmodbusId
[
i
+
1
],
16
,
state_OFF
);
}
double
Whours
=
Wtime
.
TotalHours
;
double
Wminures
=
Wtime
.
TotalMinutes
;
double
Wseconds
=
Wtime
.
TotalSeconds
;
...
...
ModbusDemo/windows/Form1.cs
View file @
de89515f
...
...
@@ -391,12 +391,14 @@ namespace ModbusDemo
usWcontrol
.
realTimeLevel
=
ModualPoll
.
cx18x
.
sX18xDataStruct
[
j
].
dNowConvertData
[
0
];
usWcontrol
.
modularx
=
j
;
usWcontrol
.
modbusID
=
LevelmodbusID
[
0
];
}
if
(
ModualPoll
.
cx18x
.
byModbusID
[
j
]
==
LevelmodbusID
[
1
])
{
usEcontrol
.
realTimeLevel
=
ModualPoll
.
cx18x
.
sX18xDataStruct
[
j
].
dNowConvertData
[
0
];
usEcontrol
.
modularx
=
j
;
usEcontrol
.
modbusID
=
LevelmodbusID
[
1
];
}
}
if
(
ModualControl
.
cPoolLevelConfig
[
i
].
byModbusID
==
LevelmodbusID
[
0
])
...
...
@@ -431,7 +433,6 @@ namespace ModbusDemo
}
AutoControl
.
Automatic_control
(
usWcontrolB
.
status
,
usEcontrolB
.
status
);
}
else
if
(
file
.
Length
!=
0
)
{
usEcontrol
.
modularx
=
InIHelper
.
ReadConfig
<
int
>(
"Channel number"
,
"东液位通道"
);
...
...
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