Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
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
潘栩锋
Thick-Common
Commits
8d7e0f47
Commit
8d7e0f47
authored
May 15, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 modbus PLC 添加更多调试信息,可以在服务器查看
parent
aaddf320
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
14 deletions
+47
-14
DataToRegs.cs
Project.FLY.ModbusMapper/FLY.ModbusMapper/DataToRegs.cs
+11
-2
ModbusMapper.cs
Project.FLY.ModbusMapper/FLY.ModbusMapper/ModbusMapper.cs
+2
-2
PLCGroup.cs
Project.FLY.ModbusMapper/FLY.ModbusMapper/PLCGroup.cs
+17
-1
PLCProxySystem.cs
....FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
+17
-9
No files found.
Project.FLY.ModbusMapper/FLY.ModbusMapper/DataToRegs.cs
View file @
8d7e0f47
...
...
@@ -26,6 +26,14 @@ namespace FLY.Modbus
/// PLC 首地址
/// </summary>
public
int
addr
;
/// <summary>
/// 原始寄存器字符串
/// </summary>
public
string
regAddr
;
/// <summary>
/// 原始 owner 名字
/// </summary>
public
string
ownerName
;
/// <summary>
/// PLC 尾地址
...
...
@@ -81,7 +89,7 @@ namespace FLY.Modbus
/// <param name="scale"></param>
/// <param name="owner"></param>
/// <param name="propertyname"></param>
public
DataToRegs
(
ModbusMapper
mapper
,
PLCAddressArea
dataArea
,
int
addr
,
REG_TYPE
type
,
double
scale
,
object
owner
,
string
propertyname
)
public
DataToRegs
(
ModbusMapper
mapper
,
PLCAddressArea
dataArea
,
int
addr
,
REG_TYPE
type
,
double
scale
,
object
owner
,
string
propertyname
,
string
regAddr
,
string
ownerName
)
{
this
.
mapper
=
mapper
;
this
.
dataArea
=
dataArea
;
...
...
@@ -90,7 +98,8 @@ namespace FLY.Modbus
this
.
scale
=
scale
;
this
.
owner
=
owner
;
this
.
propertyName
=
string
.
Copy
(
propertyname
);
this
.
regAddr
=
regAddr
;
this
.
ownerName
=
ownerName
;
if
(
type
==
REG_TYPE
.
BOOL
)
{
plcValue
=
false
;
...
...
Project.FLY.ModbusMapper/FLY.ModbusMapper/ModbusMapper.cs
View file @
8d7e0f47
...
...
@@ -70,12 +70,12 @@ namespace FLY.Modbus
/// <param name="obj">Property 所属对象</param>
/// <param name="propertyname">Property Name</param>
/// <returns></returns>
public
DataToRegs
MapDataToRegs
(
PLCAddressArea
dataArea
,
int
addr
,
REG_TYPE
type
,
double
scale
,
object
obj
,
string
propertyname
)
public
DataToRegs
MapDataToRegs
(
PLCAddressArea
dataArea
,
int
addr
,
REG_TYPE
type
,
double
scale
,
object
obj
,
string
propertyname
,
string
regAddr
,
string
ownerName
)
{
DataToRegs
dr
=
FindDataMap
(
obj
,
propertyname
);
if
(
dr
==
null
)
{
dr
=
new
DataToRegs
(
this
,
dataArea
,
addr
,
type
,
scale
,
obj
,
propertyname
);
dr
=
new
DataToRegs
(
this
,
dataArea
,
addr
,
type
,
scale
,
obj
,
propertyname
,
regAddr
,
ownerName
);
DRmap
.
Add
(
dr
);
DRmap
.
Sort
(
delegate
(
DataToRegs
X
,
DataToRegs
Y
)
{
...
...
Project.FLY.ModbusMapper/FLY.ModbusMapper/PLCGroup.cs
View file @
8d7e0f47
...
...
@@ -55,14 +55,30 @@ namespace FLY.Modbus
/// </summary>
public
string
PropertyName
;
/// <summary>
/// 原始寄存器地址
/// </summary>
public
string
RegAddr
;
public
override
string
ToString
()
{
return
OwnerName
+
"."
+
PropertyName
+
" dev"
+
DeviceIndex
+
" ["
+
Mode
+
"]("
+
Addr
+
"
)"
;
return
$"
{
OwnerName
}
.
{
PropertyName
}
(
{
RegAddr
}
)=dev
{
DeviceIndex
}
[
{
Mode
}
](
{
Addr
}
)"
;
}
}
/// <summary>
/// 版本
/// </summary>
public
string
Version
;
/// <summary>
/// 设备列表
/// </summary>
public
List
<
PLCDevice
>
Devices
=
new
List
<
PLCDevice
>();
/// <summary>
/// 寄存器列表
/// </summary>
public
List
<
PLCVariable
>
Variables
=
new
List
<
PLCVariable
>();
}
}
Project.FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
View file @
8d7e0f47
...
...
@@ -86,15 +86,23 @@ namespace FLY.OBJComponents.Server
{
throw
new
Exception
(
$"DeviceIndex =
{
var
.
DeviceIndex
}
var.Addr=
{
var
.
Addr
}
var.Type=
{
var
.
Type
}
不能转换为 C#类型"
);
}
DataToRegs
dr
=
plc
.
MapDataToRegs
(
ModbusMapper
.
TranslateToPLCAddressArea
(
var
.
Mode
),
var
.
Addr
,
reg_type
,
var
.
Scale
,
this
.
ObjNames
[
var
.
OwnerName
],
var
.
PropertyName
);
if
(
dr
!=
null
)
drs
.
Add
(
dr
);
try
{
DataToRegs
dr
=
plc
.
MapDataToRegs
(
ModbusMapper
.
TranslateToPLCAddressArea
(
var
.
Mode
),
var
.
Addr
,
reg_type
,
var
.
Scale
,
this
.
ObjNames
[
var
.
OwnerName
],
var
.
PropertyName
,
var
.
RegAddr
,
var
.
OwnerName
);
if
(
dr
!=
null
)
drs
.
Add
(
dr
);
}
catch
(
Exception
e
)
{
throw
e
;
}
}
foreach
(
var
plc
in
this
.
PLCs
)
...
...
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