|
|
@@ -4,6 +4,7 @@ using YSAI.Core.data;
|
|
|
using YSAI.Core.@enum;
|
|
|
using YSAI.Core.@interface.only;
|
|
|
using YSAI.Core.@interface.unify;
|
|
|
+using YSAI.Manage.Core.@base;
|
|
|
using YSAI.Opc.ua.client;
|
|
|
using YSAI.Unility;
|
|
|
|
|
|
@@ -16,7 +17,6 @@ namespace YSAI.Manage.Core
|
|
|
{
|
|
|
protected override string LogHead => "[ ManageOperate 操作 ]";
|
|
|
protected override string ClassName => "ManageOperate";
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 配置路径
|
|
|
/// </summary>
|
|
|
@@ -25,6 +25,30 @@ namespace YSAI.Manage.Core
|
|
|
/// 实例文件路径
|
|
|
/// </summary>
|
|
|
private readonly string samplePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config//Sample.json");
|
|
|
+ /// <summary>
|
|
|
+ /// 配置数据
|
|
|
+ /// </summary>
|
|
|
+ private List<AddressManage>? AManages = null;
|
|
|
+ /// <summary>
|
|
|
+ /// 底层统一管理
|
|
|
+ /// </summary>
|
|
|
+ private ManageBaseOperate? baseOperate = null;
|
|
|
+ /// <summary>
|
|
|
+ /// 类型解析
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="Name"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public DaqType? TypeParse(string Name)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return (DaqType)Enum.Parse(typeof(DaqType), Name);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public IActionResult Sample()
|
|
|
{
|
|
|
@@ -35,7 +59,7 @@ namespace YSAI.Manage.Core
|
|
|
addressManage.SN = address.SN;
|
|
|
addressManage.AddressArray = address.AddressArray;
|
|
|
addressManage.CreationTime = DateTime.Now.ToLocalTime();
|
|
|
- addressManage.DaqType = DaqType.OpcUa;
|
|
|
+ addressManage.DType = DaqType.OpcUa;
|
|
|
addressManage.InstanceParam = new OpcUaClientData.Basics() { Name = $"OpcUa", UserName = "123", Password = "123", ServerUrl = "opc.tcp://127.0.0.1:4840", SamplingInterval = 100 };
|
|
|
return new FileContentResult(System.Text.Encoding.Default.GetBytes(new List<AddressManage> { addressManage, addressManage, addressManage, addressManage, addressManage, addressManage }.ToJson().JsonFormatting()), "application/octet-stream");
|
|
|
}
|
|
|
@@ -101,6 +125,16 @@ namespace YSAI.Manage.Core
|
|
|
{
|
|
|
ConfigFile.CopyToAsync(stream).Wait();
|
|
|
}
|
|
|
+
|
|
|
+ //配置赋值
|
|
|
+ AManages = JsonTool.StringToListJsonEntity<AddressManage>(FileTool.FileToString(configPath));
|
|
|
+ if (baseOperate != null)
|
|
|
+ {
|
|
|
+ baseOperate.Dispose();
|
|
|
+ }
|
|
|
+ //实例底层统一管理
|
|
|
+ baseOperate = ManageBaseOperate.Instance(new ManageBaseData.Basics { AManages = AManages });
|
|
|
+
|
|
|
return Break("Update", true);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
@@ -116,52 +150,82 @@ namespace YSAI.Manage.Core
|
|
|
|
|
|
public OperateResult Init()
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ if (baseOperate == null)
|
|
|
+ {
|
|
|
+ Depart("Init");
|
|
|
+ return Break("Init",false,"请先设置配置");
|
|
|
+ }
|
|
|
+ return baseOperate.Init();
|
|
|
}
|
|
|
|
|
|
public Task<OperateResult> InitAsync()
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ return Task.Run(() => Init());
|
|
|
}
|
|
|
|
|
|
- public OperateResult Off(string Name, string SN)
|
|
|
+ public OperateResult Off(DaqType? Name, string SN)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ if (baseOperate == null)
|
|
|
+ {
|
|
|
+ Depart("Off");
|
|
|
+ return Break("Off", false, "请先设置配置");
|
|
|
+ }
|
|
|
+ return baseOperate.Off(Name, SN);
|
|
|
}
|
|
|
|
|
|
- public Task<OperateResult> OffAsync(string Name, string SN)
|
|
|
+ public Task<OperateResult> OffAsync(DaqType? Name, string SN)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ return Task.Run(() => Off(Name, SN));
|
|
|
}
|
|
|
|
|
|
- public OperateResult On(string Name, string SN)
|
|
|
+ public OperateResult On(DaqType? Name, string SN)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ if (baseOperate == null)
|
|
|
+ {
|
|
|
+ Depart("On");
|
|
|
+ return Break("On", false, "请先设置配置");
|
|
|
+ }
|
|
|
+ return baseOperate.On(Name, SN);
|
|
|
}
|
|
|
|
|
|
- public Task<OperateResult> OnAsync(string Name, string SN)
|
|
|
+ public Task<OperateResult> OnAsync(DaqType? Name, string SN)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ return Task.Run(() => On(Name, SN));
|
|
|
}
|
|
|
|
|
|
- public OperateResult Read(string Name, string SN, string AddressName)
|
|
|
+ public OperateResult Read(DaqType? Name, string SN, string AddressName)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ if (baseOperate == null)
|
|
|
+ {
|
|
|
+ Depart("Read");
|
|
|
+ return Break("Read", false, "请先设置配置");
|
|
|
+ }
|
|
|
+ return baseOperate.Read(Name, SN, AddressName);
|
|
|
}
|
|
|
|
|
|
- public Task<OperateResult> ReadAsync(string Name, string SN, string AddressName)
|
|
|
+ public Task<OperateResult> ReadAsync(DaqType? Name, string SN, string AddressName)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ return Task.Run(() => Read(Name, SN, AddressName));
|
|
|
}
|
|
|
|
|
|
- public OperateResult Write(string Name, string SN, string AddressName, string Value,DataType DType)
|
|
|
+ public OperateResult Write(DaqType? Name, string SN, string AddressName, string Value,DataType DType)
|
|
|
{
|
|
|
- throw new NotImplementedException();
|
|
|
+ if (baseOperate == null)
|
|
|
+ {
|
|
|
+ Depart("Write");
|
|
|
+ return Break("Write", false, "请先设置配置");
|
|
|
+ }
|
|
|
+ return baseOperate.Write(Name, SN, AddressName, Value, DType);
|
|
|
}
|
|
|
|
|
|
- public Task<OperateResult> WriteAsync(string Name, string SN, string AddressName, string Value, DataType DType)
|
|
|
+ public Task<OperateResult> WriteAsync(DaqType? Name, string SN, string AddressName, string Value, DataType DType)
|
|
|
{
|
|
|
return Task.Run(() => Write(Name, SN, AddressName, Value, DType));
|
|
|
}
|
|
|
+
|
|
|
+ public void Dispose()
|
|
|
+ {
|
|
|
+ baseOperate?.Dispose();
|
|
|
+ }
|
|
|
}
|
|
|
}
|