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
c7bb3e30
Commit
c7bb3e30
authored
Jun 20, 2019
by
shaxuezheng
Browse files
Options
Browse Files
Download
Plain Diff
merge origin
parents
273a0479
918658a8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
690 additions
and
674 deletions
+690
-674
ModualAlarm.cs
ModbusDemo/Common/ModualAlarm.cs
+0
-2
ModbusComm.cs
ModbusDemo/MessageFormat/ModbusComm.cs
+5
-0
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+230
-117
ModbusDemo.csproj
ModbusDemo/ModbusDemo.csproj
+3
-2
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+8
-3
modual.cs
ModbusDemo/Modular/modual.cs
+0
-2
AllPond.cs
ModbusDemo/application/AllPond.cs
+86
-74
ControlMap.cs
ModbusDemo/application/ControlMap.cs
+103
-8
ModualPool.cs
ModbusDemo/application/ModualPool.cs
+104
-37
PoolModbusSet.cs
ModbusDemo/application/PoolModbusSet.cs
+0
-400
UsThread.cs
ModbusDemo/application/UsThread.cs
+0
-12
Form1.cs
ModbusDemo/windows/Form1.cs
+151
-17
No files found.
ModbusDemo/Common/ModualAlarm.cs
View file @
c7bb3e30
...
...
@@ -27,7 +27,6 @@ namespace ModbusDemo.Common
ChannelLevelError
=
16
,
ChannelControlError
=
32
,
ChannelRunOverTimeError
=
64
,
}
public
static
void
vSetAlarmList
(
ushort
usAddress
,
ushort
[]
usChannel
,
ushort
[]
usChannelAlarmcode
)
{
...
...
@@ -58,7 +57,6 @@ namespace ModbusDemo.Common
.
Build
();
await
mqttClient
.
PublishAsync
(
message
);
}
public
static
void
vSet_Modual_Alarm
(
byte
byModbusID
,
ushort
usAlarmCodde
,
bool
bSetAlarm
,
byte
byCommFailTimes
,
params
string
[]
strChannalList
)
{
for
(
int
i
=
0
;
i
<
ModualPoll
.
byX14pNumber
;
i
++)
...
...
ModbusDemo/MessageFormat/ModbusComm.cs
View file @
c7bb3e30
...
...
@@ -28,6 +28,7 @@ namespace ModbusDemo.MessageFormat
MB_EMASTERSENT
,
MB_RTUERNOERR
}
public
static
ModbusMaster
Modbus
;
public
static
ushort
usCommunFailTimes
=
0
;
private
static
object
oLock
=
new
object
();
...
...
@@ -53,6 +54,7 @@ namespace ModbusDemo.MessageFormat
OutputValue
=
new
ushort
[
numberOfPoints
];
ModbusErrorCode
=
eModbusErrorCode
.
MB_ETIMEDOUT
;
usCommunFailTimes
++;
Console
.
WriteLine
(
slaveAddress
.
ToString
());
}
//The server return error code.
//You can get the function code and exception code.
...
...
@@ -137,6 +139,7 @@ namespace ModbusDemo.MessageFormat
OutputValue
=
new
bool
[
numberOfPoints
];
ModbusErrorCode
=
eModbusErrorCode
.
MB_ETIMEDOUT
;
usCommunFailTimes
++;
Console
.
WriteLine
(
slaveAddress
.
ToString
());
}
//The server return error code.
//You can get the function code and exception code.
...
...
@@ -220,6 +223,7 @@ namespace ModbusDemo.MessageFormat
Form1
.
totxt
.
Log
(
DateTime
.
Now
.
ToString
()
+
" "
+
exception
.
Message
+
"Modbus_WriteSingleCoil"
);
ModbusErrorCode
=
eModbusErrorCode
.
MB_ETIMEDOUT
;
usCommunFailTimes
++;
Console
.
WriteLine
(
slaveAddress
.
ToString
());
}
//The server return error code.
//You can get the function code and exception code.
...
...
@@ -302,6 +306,7 @@ namespace ModbusDemo.MessageFormat
Form1
.
totxt
.
Log
(
DateTime
.
Now
.
ToString
()
+
" "
+
exception
.
Message
+
"Modbus_WriteMultipleCoils"
);
ModbusErrorCode
=
eModbusErrorCode
.
MB_ETIMEDOUT
;
usCommunFailTimes
++;
Console
.
WriteLine
(
slaveAddress
.
ToString
());
}
//The server return error code.
//You can get the function code and exception code.
...
...
ModbusDemo/MessageFormat/ModualControl.cs
View file @
c7bb3e30
This diff is collapsed.
Click to expand it.
ModbusDemo/ModbusDemo.csproj
View file @
c7bb3e30
...
...
@@ -91,10 +91,8 @@
<Compile
Include=
"application\AutoControl.cs"
/>
<Compile
Include=
"application\ControlMap.cs"
/>
<Compile
Include=
"application\InIHelper.cs"
/>
<Compile
Include=
"application\PoolModbusSet.cs"
/>
<Compile
Include=
"application\ModualPool.cs"
/>
<Compile
Include=
"application\AllPond.cs"
/>
<Compile
Include=
"application\UsThread.cs"
/>
<Compile
Include=
"Common\ModualAlarm.cs"
/>
<Compile
Include=
"Common\OperIni.cs"
/>
<Compile
Include=
"MessageFormat\ModualControl.cs"
/>
...
...
@@ -180,6 +178,9 @@
</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)' == ''"
/>
<PropertyGroup>
<SsdtUnitTestVersion>
3.1
</SsdtUnitTestVersion>
</PropertyGroup>
<!-- 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 @
c7bb3e30
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
ModbusDemo.MessageFormat
;
using
ModbusDemo.Common
;
...
...
@@ -35,7 +36,7 @@ namespace ModbusDemo.Modular
public
static
_414P
c14formulasormual
=
new
_414P
();
#if DEBUG_TEST
public
const
byte
byX18xNumber
=
1
;
public
static
byte
[]
byX18xIdlist
=
{
13
,
14
};
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
}
};
#else
public
const
byte
byX18xNumber
=
6
;
...
...
@@ -58,8 +59,8 @@ namespace ModbusDemo.Modular
private
static
_418X
c18xformulasormual
=
new
_418X
();
#if DEBUG_TEST
public
const
byte
byX78cNumber
=
1
;
public
static
byte
[]
byX78cIdlist
=
{
20
};
public
const
byte
byX78cNumber
=
1
;
public
static
byte
[]
byX78cIdlist
=
{
20
};
#else
public
const
byte
byX78cNumber
=
0
;
public
static
byte
[]
byX78cIdlist
=
{
11
,
20
,
33
,
34
,
55
,
56
};
...
...
@@ -148,6 +149,7 @@ namespace ModbusDemo.Modular
cx14P
.
sX14pDataStruct
[
i
].
dBeforeConvertData
[
j
]
=
cx14P
.
sX14pDataStruct
[
i
].
dNowConvertData
[
j
];
}
cx14P
.
sX14PAlarmStruct
[
i
].
bDataNotFirstIncreaseOrDecrease
=
true
;
Thread
.
Sleep
(
100
);
}
for
(
byte
i
=
0
;
i
<
byX18xNumber
;
i
++)
...
...
@@ -227,6 +229,7 @@ namespace ModbusDemo.Modular
cx18x
.
sX18xDataStruct
[
i
].
dBeforeConvertData
[
j
]
=
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
];
}
cx18x
.
sX18xAlarmstruct
[
i
].
bDataNotFirstIncreaseOrDecrease
=
true
;
Thread
.
Sleep
(
100
);
}
for
(
byte
i
=
0
;
i
<
byX78cNumber
;
i
++)
{
...
...
@@ -249,6 +252,7 @@ namespace ModbusDemo.Modular
cx78c
.
sX78cAlarmStruct
[
i
].
usCommFailTimes
[
j
]
=
0
;
}
}
Thread
.
Sleep
(
100
);
}
for
(
byte
i
=
0
;
i
<
byX66cNumber
;
i
++)
...
...
@@ -271,6 +275,7 @@ namespace ModbusDemo.Modular
cx66c
.
sX66cAlarmStruct
[
i
].
usCommFailTimes
[
j
]
=
0
;
}
}
Thread
.
Sleep
(
100
);
}
}
public
static
string
stAll_Poll_Package
()
...
...
ModbusDemo/Modular/modual.cs
View file @
c7bb3e30
...
...
@@ -89,8 +89,6 @@ namespace ModbusDemo.Modular
{
this
.
sX18xDataStruct
[
i
].
dBeforeConvertData
=
new
double
[
ModualPoll
.
byX18xReadDataNumber
];
this
.
sX18xDataStruct
[
i
].
dNowConvertData
=
new
double
[
ModualPoll
.
byX18xReadDataNumber
];
//this.sX18xDataStruct[i].usRegData = new ushort[ModualPoll.byX18xReadDataNumber];
//this.sX18xDataStruct[i].usTypeData = new ushort[ModualPoll.byX18xReadDataNumber];
this
.
sX18xAlarmstruct
[
i
].
usBeforeAlarmCode
=
new
ushort
[
ModualPoll
.
byX18xReadDataNumber
];
this
.
sX18xAlarmstruct
[
i
].
usNowAlarmCode
=
new
ushort
[
ModualPoll
.
byX18xReadDataNumber
];
this
.
sX18xAlarmstruct
[
i
].
usCommFailTimes
=
new
ushort
[
ModualPoll
.
byX18xReadDataNumber
];
...
...
ModbusDemo/application/AllPond.cs
View file @
c7bb3e30
This diff is collapsed.
Click to expand it.
ModbusDemo/application/ControlMap.cs
View file @
c7bb3e30
...
...
@@ -4,39 +4,134 @@ using System.Linq;
using
System.Text
;
using
System.Threading.Tasks
;
using
ModbusDemo.application
;
using
ModbusDemo.MessageFormat
;
namespace
ModbusDemo.application
{
public
class
ControlMap
{
public
delegate
bool
bDelege_Handle
(
bool
[]
bControlData
);
public
static
bDelege_Handle
bDelege_Operation
;
public
static
bool
bControl_Map
(
bool
bOpen
,
byte
byControlID
,
params
string
[]
strOperationChannelName
)
public
static
byte
byMapIdleID
;
public
static
bool
[]
byMapIdleControlData
;
public
static
string
[]
strMapIdleChannelName
;
public
static
bool
bMap_Idle_Open_Control
(
bool
[]
bControldata
)
{
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
bool
bStatus
;
bool
bHadOperation
;
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
string
str
=
"d"
+
i
.
ToString
();
for
(
int
j
=
0
;
j
<
strMapIdleChannelName
.
Count
();
j
++)
{
if
(
str
==
strMapIdleChannelName
[
j
])
{
bControlBit
[
i
]
=
true
;
bControldata
[
i
]
=
byMapIdleControlData
[
i
];
}
}
}
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byMapIdleID
,
bControldata
,
bControlBit
,
out
bHadOperation
,
0
,
null
);
return
bStatus
;
}
public
static
bool
bMap_Idle_Close_Control
(
bool
[]
bControldata
)
{
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
bool
bStatus
;
bool
bHadOperation
;
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
string
str
=
"d"
+
i
.
ToString
();
for
(
int
j
=
0
;
j
<
strMapIdleChannelName
.
Count
();
j
++)
{
if
(
str
==
strMapIdleChannelName
[
j
])
{
bControlBit
[
i
]
=
true
;
bControldata
[
i
]
=
byMapIdleControlData
[
i
];
}
}
}
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byMapIdleID
,
bControldata
,
bControlBit
,
out
bHadOperation
,
0
,
null
);
return
bStatus
;
}
public
static
bool
bControl_Map
(
bool
bOpen
,
byte
byControlID
,
bool
[]
bControlData
,
params
string
[]
strOperationChannelName
)
{
bool
bMapStatus
=
true
;
if
(
bOpen
==
true
)
{
if
(
byControlID
==
16
&&
strOperationChannelName
[
0
]
==
"d0
"
)
if
(
byControlID
==
31
&&
strOperationChannelName
[
0
]
==
"d1
"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cPumb1
.
bOpen_Machine
;
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cSouthWater
.
bOpen_Machine
;
}
else
if
(
byControlID
==
16
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cNorthWater
.
bOpen_Machine
;
}
else
if
(
byControlID
==
16
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cPumb1
.
bOpen_Machine
;
}
else
if
(
byControlID
==
35
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cPumb2
.
bOpen_Machine
;
}
else
if
(
byControlID
==
35
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cStirrer1
.
bOpen_Machine
;
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cStirrer2
.
bOpen_Machine
;
}
else
if
(
byControlID
==
39
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cStirrer3
.
bOpen_Machine
;
}
else
{
byMapIdleID
=
byControlID
;
strMapIdleChannelName
=
strOperationChannelName
;
byMapIdleControlData
=
bControlData
;
bDelege_Operation
=
bMap_Idle_Open_Control
;
}
}
else
{
if
(
byControlID
==
16
&&
strOperationChannelName
[
0
]
==
"d0
"
)
if
(
byControlID
==
31
&&
strOperationChannelName
[
0
]
==
"d1
"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cPumb1
.
bClose_Machine
;
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
;
}
}
return
bMapStatus
;
}
...
...
ModbusDemo/application/ModualPool.cs
View file @
c7bb3e30
...
...
@@ -48,15 +48,15 @@ namespace ModbusDemo.application
}
public
class
pcLiquidlevel
{
private
string
strLevel
;
public
double
dCurrentlevel
{
get
=>
vGet_ResCurrent
();}
private
byte
byModbusID
;
private
string
strLevel
;
public
double
dCurrentlevel
{
get
=>
vGet_ResCurrent
();}
private
byte
byModbusID
;
private
string
[]
strChannelNumber
;
public
pcLiquidlevel
(
string
strName
,
byte
byModbusID
,
params
string
[]
strChannelNumber
)
{
this
.
strLevel
=
strName
;
this
.
byModbusID
=
byModbusID
;
this
.
strChannelNumber
=
strChannelNumber
;
this
.
strLevel
=
strName
;
this
.
byModbusID
=
byModbusID
;
this
.
strChannelNumber
=
strChannelNumber
;
}
private
double
vGet_ResCurrent
()
{
...
...
@@ -83,34 +83,22 @@ namespace ModbusDemo.application
}
public
class
pcOperation
{
public
byte
byModbusID
;
public
string
[]
strChannelNumber
;
public
string
strOperationNumber
;
public
bool
[]
bOpenOperation
;
public
bool
[]
bCloseOperation
;
public
bool
bHadRefControl
;
public
byte
byResModbusID
;
public
string
strResChannelNumber
;
public
byte
byModbusID
;
public
string
[]
strChannelNumber
;
public
string
strOperationNumber
;
public
bool
[]
bOpenOperation
;
public
bool
[]
bCloseOperation
;
//public pcOperation(byte byControlID, string[] strChannelNumber,string strOperationNumber,bool bHadRefControl,byte byResID,string strResChannelName,bool[] bOpenData,bool[] bCloseData)
//{
// this.byModbusID = byControlID;
// this.strChannelNumber = strChannelNumber;
// this.strOperationNumber = strOperationNumber;
// this.bHadRefControl = bHadRefControl;
// this.byResModbusID = byResID;
// this.strResChannelNumber = strResChannelName;
// this.bOpenOperation = bOpenData;
// this.bCloseOperation = bCloseData;
//}
public
bool
bHadRefControl
;
public
byte
byResModbusID
;
public
string
strResChannelNumber
;
}
public
class
pcMachine
:
pcOperation
public
class
pcMachine
:
pcOperation
{
public
string
strMachinebName
;
public
double
dChannelCurrent
{
get
=>
vGet_ResCurrent
();}
public
bool
bHadOpenPumb
;
public
bool
[]
bCurrentRelay
;
public
string
strMachinebName
;
public
double
dChannelCurrent
{
get
=>
vGet_ResCurrent
();}
public
bool
bHadOpenPumb
;
public
bool
[]
bCurrentRelay
{
get
=>
bGet_Current_Relay
();}
public
pcMachine
(
string
strMachineName
,
pcOperation
pcOperation
)
// base(pcOperation.byModbusID,pcOperation.strChannelNumber,pcOperation.strOperationNumber,pcOperation.bHadRefControl,pcOperation.byResModbusID,pcOperation.strResChannelNumber,pcOperation.bOpenOperation,pcOperation.bCloseOperation)
{
this
.
strMachinebName
=
strMachineName
;
...
...
@@ -123,7 +111,6 @@ namespace ModbusDemo.application
this
.
bOpenOperation
=
pcOperation
.
bOpenOperation
;
this
.
bCloseOperation
=
pcOperation
.
bCloseOperation
;
}
public
bool
bOpen_Machine
(
bool
[]
bControldata
)
{
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
...
...
@@ -140,13 +127,12 @@ namespace ModbusDemo.application
}
}
}
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
byResModbusID
,
strResChannelNumber
))
==
true
)
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
out
bHadOpenPumb
,
byResModbusID
,
strResChannelNumber
))
==
true
)
{
bHadOpenPumb
=
true
;
}
return
bStatus
;
}
public
bool
bClose_Machine
(
bool
[]
bControldata
)
{
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
...
...
@@ -163,22 +149,103 @@ namespace ModbusDemo.application
}
}
}
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
false
,
byModbusID
,
bControldata
,
bControlBit
,
byResModbusID
,
strResChannelNumber
))
==
true
)
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
false
,
byModbusID
,
bControldata
,
bControlBit
,
out
bHadOpenPumb
,
byResModbusID
,
strResChannelNumber
))
==
true
)
{
bHadOpenPumb
=
false
;
}
return
bStatus
;
}
private
double
vGet_ResCurrent
()
{
double
[]
dConvertData
;
if
(
ModualPoll
.
bGet_channel_Value
<
double
>(
byResModbusID
,
out
dConvertData
,
strResChannelNumber
)
==
true
)
if
(
bHadRefControl
==
true
&&
ModualPoll
.
bGet_channel_Value
<
double
>(
byResModbusID
,
out
dConvertData
,
strResChannelNumber
)
==
true
)
{
return
dConvertData
[
0
];
}
return
0
;
}
private
bool
[]
bGet_Current_Relay
()
{
bool
[]
bRelaydata
;
if
(
ModualPoll
.
bGet_channel_Value
<
bool
>(
byModbusID
,
out
bRelaydata
,
strChannelNumber
)
==
true
)
{
return
bRelaydata
;
}
else
{
return
bRelaydata
;
}
}
}
public
class
pcButtonOperation
{
public
byte
byModbusID
;
public
string
[]
strChannelNumber
;
public
string
strOperationNumber
;
public
bool
[]
bOpenOperation
;
public
bool
[]
bCloseOperation
;
}
public
class
pcButton
:
pcButtonOperation
{
public
string
strButtonName
;
public
bool
[]
bCurrentRelay
{
get
=>
bGet_Current_Relay
();}
public
pcButton
(
string
strButtonName
,
pcButtonOperation
cButtonOperation
)
{
this
.
strButtonName
=
strButtonName
;
this
.
byModbusID
=
cButtonOperation
.
byModbusID
;
this
.
strOperationNumber
=
cButtonOperation
.
strOperationNumber
;
this
.
strChannelNumber
=
cButtonOperation
.
strChannelNumber
;
this
.
bOpenOperation
=
cButtonOperation
.
bOpenOperation
;
this
.
bCloseOperation
=
cButtonOperation
.
bCloseOperation
;
}
public
bool
bOpreation_Button
(
bool
[]
bControldata
)
{
bool
bStatus
;
bool
bHadOpenButton
;
bool
[]
bControlBit
=
new
bool
[
bControldata
.
Count
()];
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
string
str
=
"d"
+
i
.
ToString
();
for
(
int
j
=
0
;
j
<
strChannelNumber
.
Count
();
j
++)
{
if
(
str
==
strChannelNumber
[
j
])
{
bControlBit
[
i
]
=
true
;
bControldata
[
i
]
=
bOpenOperation
[
j
];
}
}
}
if
((
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
out
bHadOpenButton
,
0
,
null
))
==
true
)
{
for
(
int
i
=
0
;
i
<
bControldata
.
Count
();
i
++)
{
string
str
=
"d"
+
i
.
ToString
();
for
(
int
j
=
0
;
j
<
strChannelNumber
.
Count
();
j
++)
{
if
(
str
==
strChannelNumber
[
j
])
{
bControlBit
[
i
]
=
true
;
bControldata
[
i
]
=
bCloseOperation
[
j
];
}
}
}
bStatus
=
ModualControl
.
bOperation_Machine
(
true
,
byModbusID
,
bControldata
,
bControlBit
,
out
bHadOpenButton
,
0
,
null
);
}
return
bStatus
;
}
private
bool
[]
bGet_Current_Relay
()
{
bool
[]
bRelaydata
;
if
(
ModualPoll
.
bGet_channel_Value
<
bool
>(
byModbusID
,
out
bRelaydata
,
strChannelNumber
)
==
true
)
{
return
bRelaydata
;
}
else
{
return
bRelaydata
;
}
}
}
}
}
ModbusDemo/application/PoolModbusSet.cs
deleted
100644 → 0
View file @
273a0479
This diff is collapsed.
Click to expand it.
ModbusDemo/application/UsThread.cs
deleted
100644 → 0
View file @
273a0479
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading
;
namespace
ModbusDemo.application
{
}
ModbusDemo/windows/Form1.cs
View file @
c7bb3e30
This diff is collapsed.
Click to expand it.
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