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
6de5408f
Commit
6de5408f
authored
Jun 23, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add North and south water repel each other
parent
41afdcdc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1214 additions
and
66 deletions
+1214
-66
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+190
-49
ModbusDemo.csproj
ModbusDemo/ModbusDemo.csproj
+1
-1
ModualPoll.cs
ModbusDemo/Modular/ModualPoll.cs
+8
-8
AllPond.cs
ModbusDemo/application/AllPond.cs
+877
-0
ControlMap.cs
ModbusDemo/application/ControlMap.cs
+131
-1
Form1.cs
ModbusDemo/windows/Form1.cs
+7
-7
No files found.
ModbusDemo/MessageFormat/ModualControl.cs
View file @
6de5408f
This diff is collapsed.
Click to expand it.
ModbusDemo/ModbusDemo.csproj
View file @
6de5408f
...
...
@@ -43,7 +43,7 @@
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
TRACE;DEBUG;DEBUG_TEST
</DefineConstants>
<DefineConstants>
TRACE;DEBUG;DEBUG_TEST
1
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<Prefer32Bit>
false
</Prefer32Bit>
...
...
ModbusDemo/Modular/ModualPoll.cs
View file @
6de5408f
...
...
@@ -182,16 +182,16 @@ namespace ModbusDemo.Modular
switch
(
cx18x
.
beChannelType
[
i
,
j
])
{
case
modual
.
eX18xSensorChannelType
.
Weiertai
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
8
-
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
8
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
8
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_5
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
5
-
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
5
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
5
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_6
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
6
-
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
6
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
6
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_7
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
7
-
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
7
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
((
double
.
Parse
(
sTempString
[
i
][
j
])
-
4
)
/
16
*
7
);
break
;
case
modual
.
eX18xSensorChannelType
.
NormalCurrent
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
j
]
=
double
.
Parse
(
sTempString
[
i
][
j
]);
...
...
@@ -544,16 +544,16 @@ namespace ModbusDemo.Modular
switch
(
cx18x
.
beChannelType
[
i
,
k
])
{
case
modual
.
eX18xSensorChannelType
.
Weiertai
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
8
-
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
8
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
8
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_5
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
5
-
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
5
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
5
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_6
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
6
-
((
double
.
Parse
(
strCalculData
[
k
])
-
6
)
/
16
*
6
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
6
)
/
16
*
6
);
break
;
case
modual
.
eX18xSensorChannelType
.
Mike_7
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
7
-
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
7
);
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
((
double
.
Parse
(
strCalculData
[
k
])
-
4
)
/
16
*
7
);
break
;
case
modual
.
eX18xSensorChannelType
.
NormalCurrent
:
cx18x
.
sX18xDataStruct
[
i
].
dNowConvertData
[
k
]
=
double
.
Parse
(
strCalculData
[
k
]);
...
...
ModbusDemo/application/AllPond.cs
View file @
6de5408f
This diff is collapsed.
Click to expand it.
ModbusDemo/application/ControlMap.cs
View file @
6de5408f
...
...
@@ -7,7 +7,8 @@ using ModbusDemo.application;
using
ModbusDemo.MessageFormat
;
namespace
ModbusDemo.application
{
public
class
ControlMap
#if DEBUG_TEST
public
class
ControlMap
{
public
delegate
bool
bDelege_Handle
(
bool
[]
bControlData
);
public
static
bDelege_Handle
bDelege_Operation
;
...
...
@@ -136,4 +137,133 @@ namespace ModbusDemo.application
return
bMapStatus
;
}
}
#else
public
class
ControlMap
{
public
delegate
bool
bDelege_Handle
(
bool
[]
bControlData
);
public
static
bDelege_Handle
bDelege_Operation
;
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
)
{
#
region
东中转池开映射
if
(
byControlID
==
4
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cSouthWater
.
bOpen_Machine
;
}
else
if
(
byControlID
==
4
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cNorthWater
.
bOpen_Machine
;
}
#
endregion
#
region
西中转池开映射
else
if
(
byControlID
==
49
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cWestTransitPool
.
cSouthWater
.
bOpen_Machine
;
}
else
if
(
byControlID
==
49
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cWestTransitPool
.
cNorthWater
.
bOpen_Machine
;
}
#
endregion
#
region
中控柜开映射和暂停映射
else
if
(
byControlID
==
47
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cCentralControlRoom
.
cStartButton1
.
bOpreation_Button
;
}
else
if
(
byControlID
==
44
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cCentralControlRoom
.
cPauseButton1
.
bOpreation_Button
;
}
#
endregion
else
{
bMapStatus
=
false
;
}
}
else
{
#
region
东中转池关映射
if
(
byControlID
==
4
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cSouthWater
.
bClose_Machine
;
}
else
if
(
byControlID
==
4
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cEastTransitPool
.
cNorthWater
.
bClose_Machine
;
}
#
endregion
#
region
西中转池开映射
else
if
(
byControlID
==
49
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cWestTransitPool
.
cSouthWater
.
bClose_Machine
;
}
else
if
(
byControlID
==
49
&&
strOperationChannelName
[
0
]
==
"d2"
)
{
bDelege_Operation
=
AllPond
.
cWestTransitPool
.
cNorthWater
.
bClose_Machine
;
}
#
endregion
#
region
中控柜关映射和手动映射
else
if
(
byControlID
==
47
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cCentralControlRoom
.
cStopButton1
.
bOpreation_Button
;
}
else
if
(
byControlID
==
44
&&
strOperationChannelName
[
0
]
==
"d0"
)
{
bDelege_Operation
=
AllPond
.
cCentralControlRoom
.
cHandButton1
.
bOpreation_Button
;
}
#
endregion
else
{
bMapStatus
=
false
;
}
}
return
bMapStatus
;
}
}
#endif
}
ModbusDemo/windows/Form1.cs
View file @
6de5408f
...
...
@@ -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
;
...
...
@@ -1128,12 +1128,12 @@ namespace ModbusDemo
MqttReceiveThread
.
Priority
=
ThreadPriority
.
AboveNormal
;
Task
task1
=
Task
.
Factory
.
StartNew
(
async
()
=>
{
await
ModualControl
.
vControl_Res_Poll
();});
t_AutoControl
=
new
Thread
(
AtuoControl_run
)
{
IsBackground
=
true
};
t_AutoControl
.
Start
();
t_AutoControl
.
Priority
=
ThreadPriority
.
Normal
;
//
t_AutoControl = new Thread(AtuoControl_run)
//
{
//
IsBackground = true
//
};
//
t_AutoControl.Start();
//
t_AutoControl.Priority = ThreadPriority.Normal;
}
totxt
.
Log
(
DateTime
.
Now
.
ToString
()
+
" =>Open "
+
comPort
.
PortName
+
" sucessfully!"
);
await
Subscribe
();
...
...
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