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
698dda0b
Commit
698dda0b
authored
Jan 07, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加寄存器写入调试忽略
parent
6113b027
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
26 deletions
+42
-26
PLCProxySystem.cs
....FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
+42
-26
No files found.
Project.FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
View file @
698dda0b
...
...
@@ -15,7 +15,10 @@ namespace FLY.OBJComponents.Server
public
class
PLCProxySystem
:
IPLCProxySystemService
,
IPropertyOpt
{
NLog
.
ILogger
logger
=
NLog
.
LogManager
.
GetCurrentClassLogger
();
/// <summary>
/// 用于调试, 在这个表内的属性不输出调试
/// </summary>
public
List
<
SenderProperty
>
IgnoreLogProperties
=
new
List
<
SenderProperty
>();
class
Plan
{
/// <summary>
...
...
@@ -78,21 +81,12 @@ namespace FLY.OBJComponents.Server
//PLCs[0].Start();
}
private
void
Obj_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
isShield
)
return
;
List
<
DataToRegs
>
drs
=
DRMap
;
DataToRegs
dr
=
drs
.
Find
((
_dr
)
=>
{
return
(
_dr
.
propertyName
==
e
.
PropertyName
)
&&
(
_dr
.
owner
==
sender
);
});
if
(
dr
==
null
)
return
;
//不会刷新PLC
if
(
logger
.
IsInfoEnabled
)
void
LogProperty
(
object
sender
,
string
propertyName
,
DataToRegs
dr
)
{
//注解
var
property
=
sender
.
GetType
().
GetProperty
(
e
.
P
ropertyName
);
var
property
=
sender
.
GetType
().
GetProperty
(
p
ropertyName
);
var
attrs
=
property
.
GetCustomAttributes
(
typeof
(
DescriptionAttribute
),
false
);
string
desp
=
""
;
if
(
attrs
.
Count
()
>
0
)
...
...
@@ -104,25 +98,41 @@ namespace FLY.OBJComponents.Server
var
new_value
=
property
.
GetValue
(
sender
,
null
);
//旧值
var
old_value
=
dr
.
mapper
.
GetNameData
(
sender
,
e
.
P
ropertyName
);
var
old_value
=
dr
.
mapper
.
GetNameData
(
sender
,
p
ropertyName
);
//PLC地址
string
plcAddr
=
$"
{(
dr
.
dataArea
==
PLCAddressArea
.
Coil
?
"M"
:
"D"
)}{
dr
.
addr
}
"
;
//对象名称
string
objName
=
""
;
var
names
=
from
kv
in
ObjNames
where
kv
.
Value
==
sender
select
kv
.
Key
;
if
(
names
.
Count
()>
0
)
string
objName
=
""
;
var
names
=
from
kv
in
ObjNames
where
kv
.
Value
==
sender
select
kv
.
Key
;
if
(
names
.
Count
()
>
0
)
objName
=
names
.
First
();
logger
.
Info
(
$"
{
objName
}
.
{
e
.
PropertyName
}
[
{
desp
}
] [
{
plcAddr
}
] (
{
old_value
}
)->(
{
new_value
}
)"
);
logger
.
Info
(
$"
{
objName
}
.
{
propertyName
}
[
{
desp
}
] [
{
plcAddr
}
] (
{
old_value
}
)->(
{
new_value
}
)"
);
}
private
void
Obj_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
isShield
)
return
;
List
<
DataToRegs
>
drs
=
DRMap
;
DataToRegs
dr
=
drs
.
Find
((
_dr
)
=>
{
return
(
_dr
.
propertyName
==
e
.
PropertyName
)
&&
(
_dr
.
owner
==
sender
);
});
if
(
dr
==
null
)
return
;
//不会刷新PLC
if
(
logger
.
IsInfoEnabled
)
{
if
(!
IgnoreLogProperties
.
Exists
(
sp
=>
sp
.
sender
==
sender
&&
sp
.
propertyName
==
e
.
PropertyName
))
{
LogProperty
(
sender
,
e
.
PropertyName
,
dr
);
}
}
//向PLC写入数据,mRegs每次只能写入一个,它有列表保存功能。
//SetNameData可以执行很多次,不过它只能一个个发。
dr
.
mapper
.
SetNameData
(
dr
,
Misc
.
PropertiesManager
.
GetValue
(
sender
,
e
.
PropertyName
));
}
/// <summary>
...
...
@@ -303,4 +313,10 @@ namespace FLY.OBJComponents.Server
return
null
;
}
}
public
class
SenderProperty
{
public
object
sender
;
public
string
propertyName
;
}
}
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