Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
GC_Branch
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
周磊
GC_Branch
Commits
a83f5998
Commit
a83f5998
authored
Aug 10, 2018
by
wangjunqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
切换为新地址版本
parent
6b7f5145
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
277 additions
and
277 deletions
+277
-277
GCModbusSlave.cs
GcDevicePc/Common/GCModbusSlave.cs
+277
-277
No files found.
GcDevicePc/Common/GCModbusSlave.cs
View file @
a83f5998
...
@@ -89,262 +89,50 @@ namespace GcDevicePc.Common
...
@@ -89,262 +89,50 @@ namespace GcDevicePc.Common
fnLibModbusSlaveHoldingRegister
(
hModbusHandle
,
MySlaveReadHoldingRegister
,
MySlaveWriteHoldingRegister
,
startaddr
,
nreg
);
fnLibModbusSlaveHoldingRegister
(
hModbusHandle
,
MySlaveReadHoldingRegister
,
MySlaveWriteHoldingRegister
,
startaddr
,
nreg
);
}
}
//static ushort slavereadhreg(ushort address)
//{
// ushort value = 0;
// ushort signalddress = 17;
// ushort baseaddress = 23;
// address = (ushort)(address - 1);
// int listnum = SharedSpace.Data.listValue.Count;
// if (address >= 17)
// {
// ushort[] s = new ushort[2];
// float[] f = new float[2];
// if (address >= 17 && address <= 22)
// {
// if (address == 17 || address == 18)
// f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.fDetValue.ToString("0.000"));
// if (address == 19 || address == 20)
// f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.iDetValue.ToString("0.000"));
// if (address == 21 || address == 22)
// f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.bDetValue.ToString("0.000"));
// Buffer.BlockCopy(f, 2, s, 0, 2);
// Buffer.BlockCopy(f, 0, s, 2, 2);
// value = s[(address - signalddress) % 2];
// }
// else if ( address >= 23 && listnum > 0)
// {
// int readnum = (address - baseaddress) / 2;
// if (readnum <= listnum - 1)
// {
// f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString());
// Buffer.BlockCopy(f, 2, s, 0, 2);
// Buffer.BlockCopy(f, 0, s, 2, 2);
// value = s[(address - baseaddress) % 2];
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// if (address >= 2 && address < 20)
// {
// switch (address)
// {
// case 2:
// {
// value = (ushort)SharedSpace.Data.typesint;
// }
// break;
// case 3:
// {
// value = SharedSpace.Data.change == true ? (ushort)1 : (ushort)0;
// }
// break;
// case 4:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[0];
// }
// break;
// case 5:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[1];
// }
// break;
// case 6:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[2];
// }
// break;
// case 7: //设备联机状态
// {
// value = (ushort)(globaldata.m_hmibuffer.gcinfo.hmioffline ? 1 : 0);
// }
// break;
// case 8: //HMI状态
// {
// value = globaldata.m_hmibuffer.gcinfo.methodstatus;
// }
// break;
// case 9: //前进样口
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.FPActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 10: //后进样口
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.BPActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 11: // 柱箱
// {
// if (CProfileDevice.m_DevParam.syspara.u16Col == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.ColActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 12: //前检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 13: //中检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp1 * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 14: //后检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp2 * 10);
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 15: //前点火信号
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
// {
// value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 16: //后点火信号
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
// {
// value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
// }
// else
// {
// value = 0;
// }
// }
// break;
// }
// }
// return value;
//}
static
ushort
slavereadhreg
(
ushort
address
)
static
ushort
slavereadhreg
(
ushort
address
)
{
{
ushort
value
=
0
;
ushort
value
=
0
;
ushort
baseaddress
=
20
;
ushort
signalddress
=
17
;
ushort
baseaddress
=
23
;
address
=
(
ushort
)(
address
-
1
);
address
=
(
ushort
)(
address
-
1
);
int
listnum
=
SharedSpace
.
Data
.
listValue
.
Count
;
int
listnum
=
SharedSpace
.
Data
.
listValue
.
Count
;
int
readnum
=
(
address
-
baseaddress
)
/
2
;
if
(
address
>=
17
)
if
(
readnum
<=
listnum
-
1
&&
listnum
>
0
&&
address
>=
20
)
{
// lock(CKVocAnalyzer.GlobalCKV.valueparamlist){
try
{
{
ushort
[]
s
=
new
ushort
[
2
];
ushort
[]
s
=
new
ushort
[
2
];
float
[]
f
=
new
float
[
2
];
float
[]
f
=
new
float
[
2
];
if
(
address
>=
17
&&
address
<=
22
)
{
if
(
address
==
17
||
address
==
18
)
f
[
0
]
=
float
.
Parse
(
globaldata
.
m_dpbuffer
.
ShowList
.
showDet
.
fDetValue
.
ToString
(
"0.000"
));
if
(
address
==
19
||
address
==
20
)
f
[
0
]
=
float
.
Parse
(
globaldata
.
m_dpbuffer
.
ShowList
.
showDet
.
iDetValue
.
ToString
(
"0.000"
));
if
(
address
==
21
||
address
==
22
)
f
[
0
]
=
float
.
Parse
(
globaldata
.
m_dpbuffer
.
ShowList
.
showDet
.
bDetValue
.
ToString
(
"0.000"
));
Buffer
.
BlockCopy
(
f
,
2
,
s
,
0
,
2
);
Buffer
.
BlockCopy
(
f
,
0
,
s
,
2
,
2
);
value
=
s
[(
address
-
signalddress
)
%
2
];
}
else
if
(
address
>=
23
&&
listnum
>
0
)
{
int
readnum
=
(
address
-
baseaddress
)
/
2
;
if
(
readnum
<=
listnum
-
1
)
{
{
f
[
0
]
=
float
.
Parse
(
SharedSpace
.
Data
.
listValue
[
readnum
].
vale
.
ToString
());
f
[
0
]
=
float
.
Parse
(
SharedSpace
.
Data
.
listValue
[
readnum
].
vale
.
ToString
());
Buffer
.
BlockCopy
(
f
,
2
,
s
,
0
,
2
);
Buffer
.
BlockCopy
(
f
,
2
,
s
,
0
,
2
);
Buffer
.
BlockCopy
(
f
,
0
,
s
,
2
,
2
);
Buffer
.
BlockCopy
(
f
,
0
,
s
,
2
,
2
);
}
value
=
s
[(
address
-
baseaddress
)
%
2
];
value
=
s
[(
address
-
baseaddress
)
%
2
];
}
}
catch
else
{
{
value
=
0
;
}
}
}
//}
else
{
value
=
0
;
}
}
}
if
(
address
>=
2
&&
address
<
20
)
if
(
address
>=
2
&&
address
<
20
)
{
{
...
@@ -522,48 +310,260 @@ namespace GcDevicePc.Common
...
@@ -522,48 +310,260 @@ namespace GcDevicePc.Common
}
}
}
}
break
;
break
;
case
17
:
//前检测器值
{
if
(
CProfileDevice
.
m_DevParam
.
syspara
.
u16DetFront
==
1
)
{
value
=
(
ushort
)(
globaldata
.
m_dpbuffer
.
ShowList
.
showDet
.
fDetValue
*
1000
);
}
else
{
value
=
0
;
}
}
}
}
break
;
case
18
:
//中检测器值
{
if
(
CProfileDevice
.
m_DevParam
.
syspara
.
u16DetInter
==
1
)
{
value
=
(
ushort
)(
globaldata
.
m_dpbuffer
.
ShowList
.
showDet
.
iDetValue
*
1000
);
}
else
{
value
=
0
;
}
}
break
;
case
19
:
//后检测器值
{
if
(
CProfileDevice
.
m_DevParam
.
syspara
.
u16DetBehind
==
1
)
{
value
=
(
ushort
)(
globaldata
.
m_dpbuffer
.
ShowList
.
showDet
.
bDetValue
*
1000
);
}
else
{
value
=
0
;
}
}
break
;
}
}
return
value
;
return
value
;
}
}
//static ushort slavereadhreg(ushort address)
//{
// ushort value = 0;
// ushort baseaddress = 20;
// address = (ushort)(address - 1);
// int listnum = SharedSpace.Data.listValue.Count;
// int readnum = (address - baseaddress) / 2;
// if (readnum <= listnum - 1 && listnum > 0 && address >= 20)
// {
// // lock(CKVocAnalyzer.GlobalCKV.valueparamlist){
// try
// {
// ushort[] s = new ushort[2];
// float[] f = new float[2];
// {
// f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString());
// Buffer.BlockCopy(f, 2, s, 0, 2);
// Buffer.BlockCopy(f, 0, s, 2, 2);
// }
// value = s[(address - baseaddress) % 2];
// }
// catch
// {
// }
// //}
// }
// if (address >= 2 && address < 20)
// {
// switch (address)
// {
// case 2:
// {
// value = (ushort)SharedSpace.Data.typesint;
// }
// break;
// case 3:
// {
// value = SharedSpace.Data.change == true ? (ushort)1 : (ushort)0;
// }
// break;
// case 4:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[0];
// }
// break;
// case 5:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[1];
// }
// break;
// case 6:
// {
// value = globaldata.m_hmibuffer.gcinfo.HMIMac[2];
// }
// break;
// case 7: //设备联机状态
// {
// value = (ushort)(globaldata.m_hmibuffer.gcinfo.hmioffline ? 1 : 0);
// }
// break;
// case 8: //HMI状态
// {
// value = globaldata.m_hmibuffer.gcinfo.methodstatus;
// }
// break;
// case 9: //前进样口
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.FPActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 10: //后进样口
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.BPActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 11: // 柱箱
// {
// if (CProfileDevice.m_DevParam.syspara.u16Col == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.ColActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 12: //前检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 13: //中检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
// }
// else
// {
// value = 0;
// }
// }
// else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp1 * 10);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 14: //后检测器
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
// }
// else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp2 * 10);
// }
// else
// {
// value = 0;
// }
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 15: //前点火信号
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
// {
// value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 16: //后点火信号
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
// {
// value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 17: //前检测器值
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showDet.fDetValue * 1000);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 18: //中检测器值
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showDet.iDetValue * 1000);
// }
// else
// {
// value = 0;
// }
// }
// break;
// case 19: //后检测器值
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// value = (ushort)(globaldata.m_dpbuffer.ShowList.showDet.bDetValue * 1000);
// }
// else
// {
// value = 0;
// }
// }
// break;
// }
// }
// return value;
//}
static
void
slavewirtehreg
(
ushort
address
,
ushort
value
)
static
void
slavewirtehreg
(
ushort
address
,
ushort
value
)
{
{
if
(
address
==
100
||
address
==
99
||
address
==
101
)
if
(
address
==
100
||
address
==
99
||
address
==
101
)
...
...
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