Commit 2e998d28 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 FlyADIODefine 使用方式,确保一个环境只有 一个FlyADIODefine

parent c8c14e01
using FLY.Thick.Base.IService; using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
...@@ -33,7 +34,7 @@ namespace FLY.Thick.Base.UI ...@@ -33,7 +34,7 @@ namespace FLY.Thick.Base.UI
public void Init(IFlyAdIoDefineService iODefineService, ITDGageService gageService) { public void Init(IFlyAdIoDefineService iODefineService, ITDGageService gageService) {
viewModel = new WdIoTipVm(); viewModel = new WdIoTipVm();
viewModel.Init(iODefineService, gageService); viewModel.Init(iODefineService, gageService.DynArea);
this.DataContext = viewModel; this.DataContext = viewModel;
} }
...@@ -53,9 +54,9 @@ namespace FLY.Thick.Base.UI ...@@ -53,9 +54,9 @@ namespace FLY.Thick.Base.UI
} }
public void Init(IFlyAdIoDefineService iODefineService, ITDGageService gageService) public void Init(IFlyAdIoDefineService iODefineService, DynArea dynArea)
{ {
this.dynArea = gageService.DynArea; this.dynArea = dynArea;
this.iODefineService = iODefineService; this.iODefineService = iODefineService;
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
...@@ -86,23 +87,25 @@ namespace FLY.Thick.Base.UI ...@@ -86,23 +87,25 @@ namespace FLY.Thick.Base.UI
update(); update();
} }
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), () => Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), updateIsOn_In);
{ Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), updateIsOn_Out);
for (int i = 0; i < IStatus.Count(); i++) {
IStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.IStatus, i);
}
});
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), () =>
{
for (int i = 0; i < OStatus.Count(); i++)
{
OStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.OStatus, i);
}
});
} }
void updateIsOn_In()
{
for (int i = 0; i < IStatus.Count(); i++)
{
IStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.IStatus, i);
}
}
void updateIsOn_Out()
{
for (int i = 0; i < OStatus.Count(); i++)
{
OStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.OStatus, i);
}
}
private void Client_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) private void Client_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
var client = this.iODefineService as FObjBase.FObjServiceClient; var client = this.iODefineService as FObjBase.FObjServiceClient;
...@@ -129,6 +132,9 @@ namespace FLY.Thick.Base.UI ...@@ -129,6 +132,9 @@ namespace FLY.Thick.Base.UI
update(IODefine.IOTYPE.Input, IStatus, reponse.InCount, list); update(IODefine.IOTYPE.Input, IStatus, reponse.InCount, list);
update(IODefine.IOTYPE.Output, OStatus, reponse.OutCount, list); update(IODefine.IOTYPE.Output, OStatus, reponse.OutCount, list);
updateIsOn_In();
updateIsOn_Out();
}, this); }, this);
} }
...@@ -205,25 +211,19 @@ namespace FLY.Thick.Base.UI ...@@ -205,25 +211,19 @@ namespace FLY.Thick.Base.UI
} }
public class WdIoTipVmUt : INotifyPropertyChanged public class WdIoTipVmUt : WdIoTipVm
{ {
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<FlyAdIoStatus> IStatus { get; } = new ObservableCollection<FlyAdIoStatus>();
public ObservableCollection<FlyAdIoStatus> OStatus { get; } = new ObservableCollection<FlyAdIoStatus>();
public WdIoTipVmUt() public WdIoTipVmUt()
{ {
for (int i = 0; i < 16; i++) for (int i = 0; i < 12; i++)
{ {
IStatus.Add(new FlyAdIoStatus() IStatus.Add(new FlyAdIoStatus()
{ {
Number = $"i{i + 1}" Number = $"i{i + 1}"
}); });
}; };
for (int i = 0; i < 8; i++) for (int i = 0; i < 4; i++)
{ {
OStatus.Add(new FlyAdIoStatus() OStatus.Add(new FlyAdIoStatus()
{ {
......
...@@ -33,45 +33,9 @@ namespace FLY.Thick.Base.Client ...@@ -33,45 +33,9 @@ namespace FLY.Thick.Base.Client
/// </summary> /// </summary>
/// <param name="asyncDelegate"></param> /// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param> /// <param name="asyncContext"></param>
[Call(typeof(List<IODefine>))]
public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext) { public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext) {
Call(nameof(GetIODefine), null, asyncDelegate, asyncContext); Call(nameof(GetIODefine), null, asyncDelegate, asyncContext);
} }
} }
/// <summary>
/// 输入输出口描述
/// </summary>
public class IODefine
{
/// <summary>
/// 输入口?输出口?
/// </summary>
public enum IOTYPE {
/// <summary>
/// 输入口
/// </summary>
Input,
/// <summary>
/// 输出口
/// </summary>
Output
};
/// <summary>
/// 输入口?输出口?
/// </summary>
public IOTYPE IoType;
/// <summary>
/// 序号,从0开始排列
/// </summary>
public int Index;
/// <summary>
/// 功能表述
/// </summary>
public string Description;
}
} }
...@@ -12,10 +12,15 @@ namespace FLY.Thick.Base.Common ...@@ -12,10 +12,15 @@ namespace FLY.Thick.Base.Common
/// </summary> /// </summary>
public class FlyADIODefine: IFlyAdIoDefineService public class FlyADIODefine: IFlyAdIoDefineService
{ {
protected static FlyADIODefine instance;
public static void SetInstance(FlyADIODefine flyADIODefine)
{
instance = flyADIODefine;
}
/// <summary> /// <summary>
/// 子类 需要 重新 把子类对象 赋值给 Instance, 确保整个环境只用一个版本的 单例 /// 子类 需要 重新 把子类对象 赋值给 Instance, 确保整个环境只用一个版本的 单例
/// </summary> /// </summary>
public static FlyADIODefine Instance { get; set; } = new FlyADIODefine(); public static FlyADIODefine Instance => instance;
#region 输入口 #region 输入口
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment