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
92ca049e
Commit
92ca049e
authored
Dec 19, 2019
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PLC 写入调试
parent
e8649d39
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
1 deletion
+65
-1
IsErrorAttribute.cs
Project.FLY.Misc/MISC/IsErrorAttribute.cs
+29
-0
Misc.csproj
Project.FLY.Misc/MISC/Misc.csproj
+1
-0
OBJComponents.csproj
Project.FLY.OBJComponents/OBJComponents/OBJComponents.csproj
+3
-0
PLCProxySystem.cs
....FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
+31
-0
FLY.Thick.Base.UI.csproj
...FLY.Thick.Base/FLY.Thick.Base.UI/FLY.Thick.Base.UI.csproj
+1
-1
No files found.
Project.FLY.Misc/MISC/IsErrorAttribute.cs
0 → 100644
View file @
92ca049e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Misc
{
/// <summary>
/// PLC 寄存器用于报警
/// </summary>
public
class
IsErrorAttribute
:
Attribute
{
/// <summary>
/// 这个属性用于报警
/// </summary>
/// <param name="offIsError"></param>
public
IsErrorAttribute
(
bool
offIsError
=
false
)
{
OffIsError
=
offIsError
;
}
/// <summary>
/// 属性的值为false, 为报警状态
/// </summary>
public
bool
OffIsError
{
get
;
private
set
;
}
}
}
Project.FLY.Misc/MISC/Misc.csproj
View file @
92ca049e
...
...
@@ -82,6 +82,7 @@
<Compile
Include=
"DATARANGE.cs"
/>
<Compile
Include=
"Enumerable.cs"
/>
<Compile
Include=
"IgnoreAttribute.cs"
/>
<Compile
Include=
"IsErrorAttribute.cs"
/>
<Compile
Include=
"PropertiesManager.cs"
/>
<Compile
Include=
"PropertyBinding.cs"
/>
<Compile
Include=
"Range.cs"
/>
...
...
Project.FLY.OBJComponents/OBJComponents/OBJComponents.csproj
View file @
92ca049e
...
...
@@ -112,6 +112,9 @@
<PackageReference
Include=
"Newtonsoft.Json"
>
<Version>
12.0.3
</Version>
</PackageReference>
<PackageReference
Include=
"NLog"
>
<Version>
4.6.8
</Version>
</PackageReference>
<PackageReference
Include=
"PropertyChanged.Fody"
>
<Version>
2.6.1
</Version>
</PackageReference>
...
...
Project.FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
View file @
92ca049e
...
...
@@ -14,6 +14,8 @@ namespace FLY.OBJComponents.Server
/// </summary>
public
class
PLCProxySystem
:
IPLCProxySystemService
,
IPropertyOpt
{
NLog
.
ILogger
logger
=
NLog
.
LogManager
.
GetCurrentClassLogger
();
class
Plan
{
/// <summary>
...
...
@@ -86,11 +88,40 @@ namespace FLY.OBJComponents.Server
if
(
dr
==
null
)
return
;
//不会刷新PLC
if
(
logger
.
IsInfoEnabled
)
{
//注解
var
property
=
sender
.
GetType
().
GetProperty
(
e
.
PropertyName
);
var
attrs
=
property
.
GetCustomAttributes
(
typeof
(
DescriptionAttribute
),
false
);
string
desp
=
""
;
if
(
attrs
.
Count
()
>
0
)
{
desp
=
(
attrs
.
First
()
as
DescriptionAttribute
).
Description
;
}
//新值
var
new_value
=
property
.
GetValue
(
sender
,
null
);
//旧值
var
old_value
=
dr
.
mapper
.
GetNameData
(
sender
,
e
.
PropertyName
);
//PLC地址
string
plcAddr
=
$"
{(
dr
.
dataArea
==
PLCAddressArea
.
Coil
?
"M"
:
"D"
)}{
dr
.
addr
}
"
;
logger
.
Info
(
$"
{
e
.
PropertyName
}
[
{
desp
}
] [
{
plcAddr
}
] (
{
old_value
}
)->(
{
new_value
}
)"
);
}
//向PLC写入数据,mRegs每次只能写入一个,它有列表保存功能。
//SetNameData可以执行很多次,不过它只能一个个发。
dr
.
mapper
.
SetNameData
(
dr
,
Misc
.
PropertiesManager
.
GetValue
(
sender
,
e
.
PropertyName
));
}
/// <summary>
/// 屏蔽 "属性变化 写入PLC"
/// </summary>
bool
isShield
=
false
;
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/FLY.Thick.Base.UI.csproj
View file @
92ca049e
...
...
@@ -578,7 +578,7 @@
<Version>
2.0.0-alpha0316
</Version>
</PackageReference>
<PackageReference
Include=
"MahApps.Metro.IconPacks"
>
<Version>
3.0.0-alpha02
13
</Version>
<Version>
3.0.0-alpha02
70
</Version>
</PackageReference>
<PackageReference
Include=
"MvvmLight"
>
<Version>
5.4.1.1
</Version>
...
...
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