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
c8c14e01
Commit
c8c14e01
authored
Jul 04, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 添加 FlyADIODefine 添加 输入输出口数量
2. 修改 FlyADIODefine.Instance 必须在环境启动时,第1时间赋值子类单例。 确保全局只有一个FlyADIODefine
parent
85ecf9c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
47 deletions
+96
-47
WdIOTip.xaml.cs
....FLY.Thick.Base/FLY.Thick.Base.UI/PgError/WdIOTip.xaml.cs
+55
-38
FlyADIODefine.cs
...ect.FLY.Thick.Base/FLY.Thick.Base/Common/FlyADIODefine.cs
+24
-8
IFlyAdIoDefineService.cs
...ick.Base/FLY.Thick.Base/IService/IFlyAdIoDefineService.cs
+17
-1
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgError/WdIOTip.xaml.cs
View file @
c8c14e01
...
...
@@ -58,13 +58,13 @@ namespace FLY.Thick.Base.UI
this
.
dynArea
=
gageService
.
DynArea
;
this
.
iODefineService
=
iODefineService
;
for
(
int
i
=
0
;
i
<
1
6
;
i
++)
{
for
(
int
i
=
0
;
i
<
1
2
;
i
++)
{
IStatus
.
Add
(
new
FlyAdIoStatus
()
{
Number
=
$"i
{
i
+
1
}
"
});
};
for
(
int
i
=
0
;
i
<
8
;
i
++)
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
OStatus
.
Add
(
new
FlyAdIoStatus
()
{
...
...
@@ -119,53 +119,70 @@ namespace FLY.Thick.Base.UI
{
iODefineService
.
GetIODefine
((
asyncContext
,
retData
)
=>
{
var
reponse
=
retData
as
List
<
IODefine
>
;
if
(
reponse
==
null
||
reponse
.
Count
()
==
0
)
var
reponse
=
retData
as
IODefineCollection
;
if
(
reponse
==
null
)
{
return
;
string
[]
istatus_desps
=
new
string
[
IStatus
.
Count
()];
string
[]
ostatus_desps
=
new
string
[
OStatus
.
Count
()];
for
(
int
i
=
0
;
i
<
reponse
.
Count
();
i
++)
{
var
ioDefine
=
reponse
[
i
];
if
(
ioDefine
.
IoType
==
IODefine
.
IOTYPE
.
Input
)
{
if
(
ioDefine
.
Index
<
istatus_desps
.
Count
())
{
istatus_desps
[
ioDefine
.
Index
]
=
ioDefine
.
Description
;
}
}
else
{
if
(
ioDefine
.
Index
<
ostatus_desps
.
Count
())
{
ostatus_desps
[
ioDefine
.
Index
]
=
ioDefine
.
Description
;
}
}
}
var
list
=
reponse
.
List
;
if
(
list
==
null
||
list
.
Count
()
==
0
)
return
;
for
(
int
i
=
0
;
i
<
istatus_desps
.
Count
();
i
++)
{
if
(
string
.
IsNullOrEmpty
(
istatus_desps
[
i
]))
{
IStatus
[
i
].
Desp
=
""
;
}
else
update
(
IODefine
.
IOTYPE
.
Input
,
IStatus
,
reponse
.
InCount
,
list
);
update
(
IODefine
.
IOTYPE
.
Output
,
OStatus
,
reponse
.
OutCount
,
list
);
},
this
);
}
void
update
(
IODefine
.
IOTYPE
ioType
,
ObservableCollection
<
FlyAdIoStatus
>
ioStatus
,
int
ioCnt
,
List
<
IODefine
>
list
)
{
//补够数量
if
(
ioStatus
.
Count
()
!=
ioCnt
&&
ioCnt
>
0
)
{
while
(
ioStatus
.
Count
()
>
ioCnt
)
{
ioStatus
.
RemoveAt
(
ioStatus
.
Count
()
-
1
);
}
while
(
ioStatus
.
Count
()
<
ioCnt
)
{
int
i
=
ioStatus
.
Count
();
ioStatus
.
Add
(
new
FlyAdIoStatus
()
{
IStatus
[
i
].
Desp
=
istatus_desps
[
i
];
}
Number
=
$"i
{
i
+
1
}
"
}
);
}
}
//获取中文
string
[]
iostatus_desps
=
new
string
[
ioCnt
];
for
(
int
i
=
0
;
i
<
ostatus_desps
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
list
.
Count
();
i
++)
{
var
ioDefine
=
list
[
i
];
if
(
ioDefine
.
IoType
==
ioType
)
{
if
(
string
.
IsNullOrEmpty
(
ostatus_desps
[
i
]))
{
OStatus
[
i
].
Desp
=
""
;
}
else
if
(
ioDefine
.
Index
<
iostatus_desps
.
Count
())
{
OStatus
[
i
].
Desp
=
ostatus_desps
[
i
]
;
iostatus_desps
[
ioDefine
.
Index
]
=
ioDefine
.
Description
;
}
}
},
this
);
}
}
//填入
for
(
int
i
=
0
;
i
<
iostatus_desps
.
Count
();
i
++)
{
if
(
string
.
IsNullOrEmpty
(
iostatus_desps
[
i
]))
{
ioStatus
[
i
].
Desp
=
""
;
}
else
{
ioStatus
[
i
].
Desp
=
iostatus_desps
[
i
];
}
}
}
}
public
class
FlyAdIoStatus
:
INotifyPropertyChanged
{
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Common/FlyADIODefine.cs
View file @
c8c14e01
...
...
@@ -12,8 +12,11 @@ namespace FLY.Thick.Base.Common
/// </summary>
public
class
FlyADIODefine
:
IFlyAdIoDefineService
{
public
static
FlyADIODefine
Instance
{
get
;
}
=
new
FlyADIODefine
();
/// <summary>
/// 子类 需要 重新 把子类对象 赋值给 Instance, 确保整个环境只用一个版本的 单例
/// </summary>
public
static
FlyADIODefine
Instance
{
get
;
set
;
}
=
new
FlyADIODefine
();
#
region
输入口
/// <summary>
/// 归零信号
...
...
@@ -114,13 +117,15 @@ namespace FLY.Thick.Base.Common
#
endregion
private
int
version
=
2
;
/// <summary>
/// 根据AD盒的版本,设置
/// </summary>
/// <param name="version"></param>
public
virtual
void
SerVersion
(
int
version
)
{
if
(
version
==
3
)
this
.
version
=
version
;
if
(
this
.
version
==
3
)
{
InNo_Org
=
13
-
1
;
InNo_Limit_Forw
=
14
-
1
;
...
...
@@ -181,8 +186,19 @@ namespace FLY.Thick.Base.Common
public
void
GetIODefine
(
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
//获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX
List
<
IODefine
>
reponse
=
new
List
<
IODefine
>();
IODefineCollection
reponse
=
new
IODefineCollection
();
List
<
IODefine
>
list
=
new
List
<
IODefine
>();
reponse
.
List
=
list
;
if
(
version
==
3
)
{
reponse
.
InCount
=
16
;
reponse
.
OutCount
=
8
;
}
else
{
reponse
.
InCount
=
12
;
reponse
.
OutCount
=
4
;
}
var
inputPropertyNames
=
GetInputPropertyNames
();
var
outputPropertyNames
=
GetOutputPropertyNames
();
...
...
@@ -209,7 +225,7 @@ namespace FLY.Thick.Base.Common
Index
=
index
,
Description
=
desp
};
reponse
.
Add
(
iodefine
);
list
.
Add
(
iodefine
);
}
foreach
(
var
propertyName
in
outputPropertyNames
)
...
...
@@ -232,10 +248,10 @@ namespace FLY.Thick.Base.Common
Index
=
index
,
Description
=
desp
};
reponse
.
Add
(
iodefine
);
list
.
Add
(
iodefine
);
}
asyncDelegate
?.
Invoke
(
asyncContext
,
reponse
);
asyncDelegate
?.
Invoke
(
asyncContext
,
list
);
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/IService/IFlyAdIoDefineService.cs
View file @
c8c14e01
...
...
@@ -18,10 +18,26 @@ namespace FLY.Thick.Base.IService
/// </summary>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
[
Call
(
typeof
(
List
<
IODefine
>
))]
[
Call
(
typeof
(
IODefineCollection
))]
void
GetIODefine
(
AsyncCBHandler
asyncDelegate
,
object
asyncContext
);
}
public
class
IODefineCollection
{
/// <summary>
/// 输入口数量
/// </summary>
public
int
InCount
;
/// <summary>
/// 输出口数量
/// </summary>
public
int
OutCount
;
/// <summary>
/// 列表
/// </summary>
public
List
<
IODefine
>
List
;
}
/// <summary>
/// 输入输出口描述
/// </summary>
...
...
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