|
|
@@ -11,138 +11,138 @@ using YSAI.Mqtt.client;
|
|
|
using YSAI.S7.client;
|
|
|
using YSAI.Unility;
|
|
|
|
|
|
-//采集
|
|
|
-using (类 operate = new 类(new 类数据.Basics
|
|
|
-{
|
|
|
-
|
|
|
- //采集对象参数
|
|
|
-
|
|
|
-}))
|
|
|
-{
|
|
|
- //打开
|
|
|
- OperateResult result = operate.On();
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //点位地址
|
|
|
- Address address = new Address();
|
|
|
- address.SN = Guid.NewGuid().ToString();
|
|
|
- address.CreationTime = DateTime.Now.ToLocalTime();
|
|
|
- address.AddressArray = new List<AddressDetails>
|
|
|
- {
|
|
|
- new AddressDetails()//S7点位地址
|
|
|
- {
|
|
|
- SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
- AddressName = "DB71.DBD4",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
- },
|
|
|
- new AddressDetails()//OpcUa点位地址
|
|
|
- {
|
|
|
- SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
- AddressName = "ns=2;s=Scalar_Simulation_Float",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
- },
|
|
|
- new AddressDetails()//OpcDa点位地址
|
|
|
- {
|
|
|
- SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
- AddressName = "a.a.a",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
- },
|
|
|
- new AddressDetails()//Modbus点位地址
|
|
|
- {
|
|
|
- SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
- AddressName = "0,2",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
- },
|
|
|
- new AddressDetails() //DB点位地址
|
|
|
- {
|
|
|
- SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
- AddressName = "数据库采集",
|
|
|
- AddressDataType = YSAI.Core.@enum.DataType.String,
|
|
|
- AddressExtendParam=new DBData.ExtendParam.Read()
|
|
|
- {
|
|
|
- Sql = @"SELECT A,B,C,D FORM TABLE ORDER BY YPBH DESC LIMIT 0,1",
|
|
|
- ColumnName = new List<string>() { "A", "B", "C", "D"}
|
|
|
- }
|
|
|
- },
|
|
|
- new AddressDetails() //地址详情参数介绍
|
|
|
- {
|
|
|
- SN=$"A88", //可以理解成唯一标识符(可以存机台号、组名、车间、厂)
|
|
|
- AddressAnotherName="A_Name", //地址别名
|
|
|
- AddressDataType=YSAI.Core.@enum.DataType.Float, //数据类型
|
|
|
- AddressDescribe="NameDescribe", //地址描述
|
|
|
- AddressExtendParam=new object(), //扩展数据
|
|
|
- AddressName="Name", //地址名称
|
|
|
- //AddressParseParam=new AddressParse //地址解析参数
|
|
|
- //{
|
|
|
- // ParseType=ParseType.ScriptAnalysis, //解析类型
|
|
|
- // Script=new YSAI.Core.script.ScriptData.Basics //脚本解析数据
|
|
|
- // {
|
|
|
- // }
|
|
|
- //},
|
|
|
- AddressParseParam=new AddressParse //地址解析参数
|
|
|
- {
|
|
|
- ParseType=ParseType.MethodAnalysis, //解析类型
|
|
|
- ReflectionSN="反射SN"
|
|
|
- },
|
|
|
- AddressPropertyName="Name1", //地址别名
|
|
|
- AddressType=AddressType.Reality, //地址类型
|
|
|
- IsEnable=true //是否启用
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- //读取
|
|
|
- result = operate.Read(address);
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //订阅
|
|
|
- operate.OnEvent += delegate (object? sender, EventResult e)
|
|
|
- {
|
|
|
- LogHelper.Info(e.ToJson().JsonFormatting());
|
|
|
- };
|
|
|
- result = operate.Subscribe(address);
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //写入
|
|
|
- ConcurrentDictionary<string, string> value = new ConcurrentDictionary<string, string>
|
|
|
- {
|
|
|
- ["地址"] = "值"
|
|
|
- };
|
|
|
- result = operate.Write(value);
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //关闭
|
|
|
- result = operate.Off();
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-}
|
|
|
-
|
|
|
-//转发
|
|
|
-using (类 operate = new 类(new 类数据.Basics
|
|
|
-{
|
|
|
-
|
|
|
- //转发对象参数
|
|
|
-
|
|
|
-}))
|
|
|
-{
|
|
|
- //打开
|
|
|
- OperateResult result = operate.On();
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //生产
|
|
|
- result = operate.Produce("主题", "内容");
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //消费
|
|
|
- operate.OnEvent += delegate (object? sender, EventResult e)
|
|
|
- {
|
|
|
- LogHelper.Info(e.ToJson().JsonFormatting());
|
|
|
- };
|
|
|
- result = operate.Subscribe("主题");
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-
|
|
|
- //关闭
|
|
|
- result = operate.Off();
|
|
|
- LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
-}
|
|
|
+////采集
|
|
|
+//using (类 operate = new 类(new 类数据.Basics
|
|
|
+//{
|
|
|
+
|
|
|
+// //采集对象参数
|
|
|
+
|
|
|
+//}))
|
|
|
+//{
|
|
|
+// //打开
|
|
|
+// OperateResult result = operate.On();
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //点位地址
|
|
|
+// Address address = new Address();
|
|
|
+// address.SN = Guid.NewGuid().ToString();
|
|
|
+// address.CreationTime = DateTime.Now.ToLocalTime();
|
|
|
+// address.AddressArray = new List<AddressDetails>
|
|
|
+// {
|
|
|
+// new AddressDetails()//S7点位地址
|
|
|
+// {
|
|
|
+// SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
+// AddressName = "DB71.DBD4",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
+// },
|
|
|
+// new AddressDetails()//OpcUa点位地址
|
|
|
+// {
|
|
|
+// SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
+// AddressName = "ns=2;s=Scalar_Simulation_Float",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
+// },
|
|
|
+// new AddressDetails()//OpcDa点位地址
|
|
|
+// {
|
|
|
+// SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
+// AddressName = "a.a.a",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
+// },
|
|
|
+// new AddressDetails()//Modbus点位地址
|
|
|
+// {
|
|
|
+// SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
+// AddressName = "0,2",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.Float
|
|
|
+// },
|
|
|
+// new AddressDetails() //DB点位地址
|
|
|
+// {
|
|
|
+// SN=$"{Guid.NewGuid().ToNString()} - Factory",
|
|
|
+// AddressName = "数据库采集",
|
|
|
+// AddressDataType = YSAI.Core.@enum.DataType.String,
|
|
|
+// AddressExtendParam=new DBData.ExtendParam.Read()
|
|
|
+// {
|
|
|
+// Sql = @"SELECT A,B,C,D FORM TABLE ORDER BY YPBH DESC LIMIT 0,1",
|
|
|
+// ColumnName = new List<string>() { "A", "B", "C", "D"}
|
|
|
+// }
|
|
|
+// },
|
|
|
+// new AddressDetails() //地址详情参数介绍
|
|
|
+// {
|
|
|
+// SN=$"A88", //可以理解成唯一标识符(可以存机台号、组名、车间、厂)
|
|
|
+// AddressAnotherName="A_Name", //地址别名
|
|
|
+// AddressDataType=YSAI.Core.@enum.DataType.Float, //数据类型
|
|
|
+// AddressDescribe="NameDescribe", //地址描述
|
|
|
+// AddressExtendParam=new object(), //扩展数据
|
|
|
+// AddressName="Name", //地址名称
|
|
|
+// //AddressParseParam=new AddressParse //地址解析参数
|
|
|
+// //{
|
|
|
+// // ParseType=ParseType.ScriptAnalysis, //解析类型
|
|
|
+// // Script=new YSAI.Core.script.ScriptData.Basics //脚本解析数据
|
|
|
+// // {
|
|
|
+// // }
|
|
|
+// //},
|
|
|
+// AddressParseParam=new AddressParse //地址解析参数
|
|
|
+// {
|
|
|
+// ParseType=ParseType.MethodAnalysis, //解析类型
|
|
|
+// ReflectionSN="反射SN"
|
|
|
+// },
|
|
|
+// AddressPropertyName="Name1", //地址别名
|
|
|
+// AddressType=AddressType.Reality, //地址类型
|
|
|
+// IsEnable=true //是否启用
|
|
|
+// }
|
|
|
+// };
|
|
|
+
|
|
|
+// //读取
|
|
|
+// result = operate.Read(address);
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //订阅
|
|
|
+// operate.OnEvent += delegate (object? sender, EventResult e)
|
|
|
+// {
|
|
|
+// LogHelper.Info(e.ToJson().JsonFormatting());
|
|
|
+// };
|
|
|
+// result = operate.Subscribe(address);
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //写入
|
|
|
+// ConcurrentDictionary<string, string> value = new ConcurrentDictionary<string, string>
|
|
|
+// {
|
|
|
+// ["地址"] = "值"
|
|
|
+// };
|
|
|
+// result = operate.Write(value);
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //关闭
|
|
|
+// result = operate.Off();
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+//}
|
|
|
+
|
|
|
+////转发
|
|
|
+//using (类 operate = new 类(new 类数据.Basics
|
|
|
+//{
|
|
|
+
|
|
|
+// //转发对象参数
|
|
|
+
|
|
|
+//}))
|
|
|
+//{
|
|
|
+// //打开
|
|
|
+// OperateResult result = operate.On();
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //生产
|
|
|
+// result = operate.Produce("主题", "内容");
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //消费
|
|
|
+// operate.OnEvent += delegate (object? sender, EventResult e)
|
|
|
+// {
|
|
|
+// LogHelper.Info(e.ToJson().JsonFormatting());
|
|
|
+// };
|
|
|
+// result = operate.Subscribe("主题");
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+
|
|
|
+// //关闭
|
|
|
+// result = operate.Off();
|
|
|
+// LogHelper.Info(result.ToJson().JsonFormatting());
|
|
|
+//}
|
|
|
|
|
|
|
|
|
|