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
ff16860c
Commit
ff16860c
authored
Jun 20, 2019
by
leon.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify data
parent
468680e9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
177 additions
and
103 deletions
+177
-103
ModualControl.cs
ModbusDemo/MessageFormat/ModualControl.cs
+110
-71
AllPond.cs
ModbusDemo/application/AllPond.cs
+5
-13
AutoControl.cs
ModbusDemo/application/AutoControl.cs
+2
-2
InIHelper.cs
ModbusDemo/application/InIHelper.cs
+49
-0
ModualPool.cs
ModbusDemo/application/ModualPool.cs
+5
-5
Form1.cs
ModbusDemo/windows/Form1.cs
+6
-12
No files found.
ModbusDemo/MessageFormat/ModualControl.cs
View file @
ff16860c
This diff is collapsed.
Click to expand it.
ModbusDemo/application/AllPond.cs
View file @
ff16860c
...
...
@@ -11,7 +11,7 @@ namespace ModbusDemo.application
public
static
class
AllPond
{
private
static
ModualPool
.
pcTemperature
cEastTransitPoolTemper
=
new
ModualPool
.
pcTemperature
(
"EastTransitPoolTemper"
,
27
,
"d0"
);
private
static
ModualPool
.
pcLiquidlevel
cEastTransitPoolLevel
=
new
ModualPool
.
pcLiquidlevel
(
"EastTransitPoolLevel"
,
13
,
"d
0
"
);
private
static
ModualPool
.
pcLiquidlevel
cEastTransitPoolLevel
=
new
ModualPool
.
pcLiquidlevel
(
"EastTransitPoolLevel"
,
13
,
"d
2
"
);
private
static
ModualPool
.
pcOperation
cEastTransitPoolSouthWaterBase
=
new
ModualPool
.
pcOperation
{
byModbusID
=
31
,
...
...
@@ -19,9 +19,9 @@ namespace ModbusDemo.application
strChannelNumber
=
new
string
[]
{
"d1"
,
"d2"
},
bOpenOperation
=
new
bool
[]
{
true
,
true
},
bCloseOperation
=
new
bool
[]
{
false
,
false
},
bHadRefControl
=
tru
e
,
byResModbusID
=
13
,
strResChannelNumber
=
"d0"
bHadRefControl
=
fals
e
,
byResModbusID
=
0
,
strResChannelNumber
=
null
};
private
static
ModualPool
.
pcMachine
cEastTransitPoolSouthWater
=
new
ModualPool
.
pcMachine
(
"EastTransitPoolSouthWater"
,
cEastTransitPoolSouthWaterBase
);
...
...
@@ -131,7 +131,7 @@ namespace ModbusDemo.application
public
static
class
cEastTransitPool
{
public
static
double
vSetMaxLevel
;
public
static
double
vSetMaxLevel
;
public
static
double
vSetMinLevel
;
public
static
ModualPool
.
pcTemperature
cTemper
{
get
=>
cEastTransitPoolTemper
;
set
=>
cEastTransitPoolTemper
=
value
;}
public
static
ModualPool
.
pcLiquidlevel
cLevel
{
get
=>
cEastTransitPoolLevel
;
set
=>
cEastTransitPoolLevel
=
value
;}
...
...
@@ -144,15 +144,7 @@ namespace ModbusDemo.application
public
static
ModualPool
.
pcMachine
cStirrer3
{
get
=>
cEastTransitPoolStirrer3
;
set
=>
cEastTransitPoolStirrer3
=
value
;
}
public
static
ModualPool
.
pcMachine
cStirrer4
{
get
=>
cEastTransitPoolStirrer4
;
set
=>
cEastTransitPoolStirrer4
=
value
;
}
public
static
ModualPool
.
pcButton
cButton1
{
get
=>
cEastTransitPoolButton1
;
set
=>
cEastTransitPoolButton1
=
value
;
}
private
static
void
vSet_Poll_Max_Level
(
double
dData
)
{
vSetMaxLevel
=
dData
;
}
private
static
void
vSet_Poll_Min_Level
(
double
dData
)
{
vSetMinLevel
=
dData
;
}
}
...
...
ModbusDemo/application/AutoControl.cs
View file @
ff16860c
...
...
@@ -38,7 +38,7 @@ namespace ModbusDemo.application
public
int
modularx
;
public
byte
modbusID
;
}
public
static
byte
[]
EmodbusId
=
{
5
,
51
};
public
static
byte
[]
EmodbusId
=
{
16
,
51
};
public
static
byte
[]
WmodbusId
=
{
35
,
31
};
public
static
byte
[]
LevelmodbusID
=
{
6
,
13
};
public
static
bool
[]
state_ON
=
{
true
,
true
,
true
,
true
,
true
,
true
};
...
...
@@ -47,7 +47,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
();
private
static
readonly
int
Runtimeout
=
1
;
private
static
readonly
int
Runtimeout
=
1
0
;
public
static
void
CriticalValueMonitoring
(
ref
Control
usControl
,
bool
Enabl
,
string
Affiliation
,
out
Control
control
)
{
...
...
ModbusDemo/application/InIHelper.cs
View file @
ff16860c
...
...
@@ -58,4 +58,53 @@ namespace ModbusDemo.application
f
.
WriteContentValue
(
section
,
key
,
value
);
}
}
public
class
pcConfig
{
public
static
string
FileName
=
Application
.
StartupPath
+
"\\PoolConfig.ini"
;
/// <summary>
/// 读取配置文件
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="section"></param>
/// <param name="key"></param>
/// <returns></returns>
public
static
T
ReadConfig
<
T
>(
string
section
,
string
key
)
{
if
(
File
.
Exists
(
FileName
))
{
OperIni
f
=
new
OperIni
(
FileName
);
string
value
=
f
.
ReadContentValue
(
section
,
key
);
if
(
String
.
IsNullOrWhiteSpace
(
value
))
return
default
(
T
);
if
(
typeof
(
T
).
IsEnum
)
return
(
T
)
Enum
.
Parse
(
typeof
(
T
),
value
,
true
);
return
(
T
)
Convert
.
ChangeType
(
value
,
typeof
(
T
));
}
else
{
return
default
(
T
);
}
}
/// <summary>
/// 写配置文件
/// </summary>
/// <param name="section"></param>
/// <param name="key"></param>
/// <param name="value"></param>
public
static
void
WriteConfig
(
string
section
,
string
key
,
string
value
)
{
//如果文件不存在,则创建
if
(!
File
.
Exists
(
FileName
))
{
using
(
FileStream
myFs
=
new
FileStream
(
FileName
,
FileMode
.
Create
))
{
}
}
OperIni
f
=
new
OperIni
(
FileName
);
f
.
WriteContentValue
(
section
,
key
,
value
);
}
}
}
ModbusDemo/application/ModualPool.cs
View file @
ff16860c
...
...
@@ -15,8 +15,8 @@ namespace ModbusDemo.application
{
private
string
strTemperName
;
public
double
dCurrentTemperate
{
get
=>
vGet_ResCurrent
();}
p
rivate
byte
byModbusID
;
p
rivate
string
[]
strChannelNumber
;
p
ublic
byte
byModbusID
;
p
ublic
string
[]
strChannelNumber
;
public
pcTemperature
(
string
strName
,
byte
byModbusID
,
params
string
[]
strChannelNumber
)
{
this
.
strTemperName
=
strName
;
...
...
@@ -50,8 +50,8 @@ namespace ModbusDemo.application
{
private
string
strLevel
;
public
double
dCurrentlevel
{
get
=>
vGet_ResCurrent
();}
p
rivate
byte
byModbusID
;
p
rivate
string
[]
strChannelNumber
;
p
ublic
byte
byModbusID
;
p
ublic
string
[]
strChannelNumber
;
public
pcLiquidlevel
(
string
strName
,
byte
byModbusID
,
params
string
[]
strChannelNumber
)
{
this
.
strLevel
=
strName
;
...
...
@@ -67,7 +67,7 @@ namespace ModbusDemo.application
List
<
double
>
ConvertData
=
new
List
<
double
>();
for
(
int
i
=
0
;
i
<
dConvertData
.
Count
();
i
++)
{
if
(
dConvertData
[
i
]
>
0
&&
dConvertData
[
i
]
<
5
)
if
(
dConvertData
[
i
]
>
0
&&
dConvertData
[
i
]
<
20
)
{
ConvertData
.
Add
(
dConvertData
[
i
]);
}
...
...
ModbusDemo/windows/Form1.cs
View file @
ff16860c
...
...
@@ -289,11 +289,11 @@ namespace ModbusDemo
//Reconnecting
if
(
isReconnect
)
{
Invoke
((
new
Action
(()
=>
Invoke
((
new
Action
(
async
()
=>
{
txtReceiveMessage
.
AppendText
(
"正在尝试重新连接"
+
Environment
.
NewLine
);
totxt
.
Log
(
"正在尝试重新连接"
+
Environment
.
NewLine
);
await
Subscribe
();
//Console.WriteLine("正在尝试重新连接" + Environment.NewLine);
})));
...
...
@@ -1061,17 +1061,11 @@ namespace ModbusDemo
ModbusComm
.
Modbus
.
Transport
.
ReadTimeout
=
1000
;
ModbusComm
.
Modbus
.
Transport
.
WriteTimeout
=
1000
;
ModbusComm
.
Modbus
.
Transport
.
WaitToRetryMilliseconds
=
0
;
<<<<<<<
HEAD
//t_AutoControl = new Thread(
T_AutoControl
);
//t_AutoControl = new Thread(
AtuoControl_run
);
//t_AutoControl.IsBackground = true;
//t_AutoControl.Start();
=======
//t_AutoControl = new Thread(T_AutoControl)
//{
// IsBackground = true
//};
//t_AutoControl.Start();
modbus_Timer
.
Enabled
=
true
;
btOpenCOM
.
Enabled
=
false
;
...
...
@@ -1110,7 +1104,7 @@ namespace ModbusDemo
}
private
async
void
run
()
{
comPort
.
PortName
=
"COM
6
"
;
comPort
.
PortName
=
"COM
2
"
;
comPort
.
BaudRate
=
9600
;
comPort
.
Parity
=
Parity
.
None
;
comPort
.
StopBits
=
StopBits
.
One
;
...
...
@@ -1130,7 +1124,7 @@ namespace ModbusDemo
ModbusComm
.
Modbus
.
Transport
.
WriteTimeout
=
1000
;
ModbusComm
.
Modbus
.
Transport
.
WaitToRetryMilliseconds
=
0
;
//t_AutoControl = new Thread(
T_AutoControl
)
//t_AutoControl = new Thread(
AtuoControl_run
)
//{
// IsBackground = true
//};
...
...
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