|
|
@@ -1,8 +1,10 @@
|
|
|
using System.Collections.Concurrent;
|
|
|
+using System.Reflection;
|
|
|
using TwinCAT;
|
|
|
using TwinCAT.Ads;
|
|
|
using TwinCAT.PlcOpen;
|
|
|
using TwinCAT.TypeSystem;
|
|
|
+using YSAI.Core.attribute;
|
|
|
using YSAI.Core.data;
|
|
|
using YSAI.Core.@interface;
|
|
|
using YSAI.Core.virtualAddress;
|
|
|
@@ -731,19 +733,23 @@ namespace YSAI.Beckhoff
|
|
|
{
|
|
|
//通过反射得到参数信息
|
|
|
List<LibInstanceParam>? libInstanceParams = ReflexTool.GetClassAllPropertyData<BeckhoffData.Basics>();
|
|
|
- string message = TAG.Replace("Operate", string.Empty);
|
|
|
+ //名称
|
|
|
+ string name = TAG.Replace("Operate", string.Empty);
|
|
|
+ //命名空间
|
|
|
string nameSpace = "YSAI.Beckhoff.BeckhoffOperate";
|
|
|
+ //对象实例
|
|
|
BeckhoffData.Basics beckhoffData = new BeckhoffData.Basics();
|
|
|
+ //参数结构体
|
|
|
ParamStructure? ParamStructure = new ParamStructure()
|
|
|
{
|
|
|
- Name = message,
|
|
|
- Description = message,
|
|
|
+ Name = name,
|
|
|
+ Description = name,
|
|
|
Subset = new List<ParamStructure.subset>
|
|
|
{
|
|
|
new ParamStructure.subset
|
|
|
{
|
|
|
- Description = message,
|
|
|
- Name = message,
|
|
|
+ Description = name,
|
|
|
+ Name = name,
|
|
|
Propertie = new List<ParamStructure.subset.propertie>()
|
|
|
}
|
|
|
}
|
|
|
@@ -751,29 +757,38 @@ namespace YSAI.Beckhoff
|
|
|
ParamStructure.Subset[0].Propertie.Add(new ParamStructure.subset.propertie
|
|
|
{
|
|
|
PropertyName = "ServiceName",
|
|
|
- Description = "实现类名",
|
|
|
+ Description = "命名空间",
|
|
|
Show = false,
|
|
|
Use = false,
|
|
|
- Initial = nameSpace,
|
|
|
Default = nameSpace,
|
|
|
- DataCate = ParamStructure.subset.propertie.dataCate.text
|
|
|
+ DataCate = ParamStructure.dataCate.text
|
|
|
});
|
|
|
foreach (var lib in libInstanceParams)
|
|
|
{
|
|
|
- string param = ReflexTool.GetModelValue(lib.Name, beckhoffData);
|
|
|
+ //默认值
|
|
|
+ string Default = ReflexTool.GetModelValue(lib.Name, beckhoffData);
|
|
|
+ //前端展示特性
|
|
|
+ DisplayAttribute? displayAttribute = typeof(BeckhoffData.Basics).GetProperty(lib.Name).GetCustomAttribute<DisplayAttribute>();
|
|
|
+ //验证特性
|
|
|
+ VerifyAttribute? verifyAttribute = typeof(BeckhoffData.Basics).GetProperty(lib.Name).GetCustomAttribute<VerifyAttribute>();
|
|
|
+ //单位特性
|
|
|
+ UnitAttribute? unitAttribute = typeof(BeckhoffData.Basics).GetProperty(lib.Name).GetCustomAttribute<UnitAttribute>();
|
|
|
+
|
|
|
ParamStructure.subset.propertie propertie = new ParamStructure.subset.propertie
|
|
|
{
|
|
|
PropertyName = lib.Name,
|
|
|
Description = lib.Describe,
|
|
|
- IsShow = true,
|
|
|
- Default = param,
|
|
|
- Value = param
|
|
|
+ Show = displayAttribute?.Show,
|
|
|
+ Use = displayAttribute?.Use,
|
|
|
+ DataCate = displayAttribute?.DataCate,
|
|
|
+ Regex = verifyAttribute?.Regex ?? null,
|
|
|
+ FailTips = verifyAttribute?.FailTips ?? null,
|
|
|
+ Default = Default
|
|
|
};
|
|
|
|
|
|
- switch (lib.ParamType)
|
|
|
+ switch (displayAttribute.DataCate)
|
|
|
{
|
|
|
- case "Enum":
|
|
|
- propertie.DataCate = ParamStructure.subset.propertie.dataCate.select;
|
|
|
+ case Core.data.ParamStructure.dataCate.select:
|
|
|
propertie.Options = new List<ParamStructure.subset.propertie.options>();
|
|
|
foreach (var val in lib.EnumArray as List<dynamic>)
|
|
|
{
|
|
|
@@ -790,16 +805,7 @@ namespace YSAI.Beckhoff
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case "Int32":
|
|
|
- propertie.DataCate = ParamStructure.subset.propertie.dataCate.unmber;
|
|
|
- break;
|
|
|
-
|
|
|
- case "String":
|
|
|
- propertie.DataCate = ParamStructure.subset.propertie.dataCate.text;
|
|
|
- break;
|
|
|
-
|
|
|
- case "Boolean":
|
|
|
- propertie.DataCate = ParamStructure.subset.propertie.dataCate.radio;
|
|
|
+ case Core.data.ParamStructure.dataCate.radio:
|
|
|
propertie.Options = new List<ParamStructure.subset.propertie.options>();
|
|
|
propertie.Options.Add(new ParamStructure.subset.propertie.options
|
|
|
{
|