Commit b35abc60 authored by 潘栩锋's avatar 潘栩锋 🚴

Merge remote-tracking branch 'remotes/origin/dev7.0-blowing' into dev7.0-filmCasting

parents 0733b593 2e998d28
...@@ -112,11 +112,13 @@ namespace FLY.OBJComponents.Common ...@@ -112,11 +112,13 @@ namespace FLY.OBJComponents.Common
public string Descrption; public string Descrption;
} }
public static class PlcErrNos public class PlcErrNos
{ {
public static PlcErrNos Instance { get; } = new PlcErrNos();
/// <summary> /// <summary>
/// PLC连接断开 /// PLC连接断开
/// </summary> /// </summary>
public static ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Descrption = "PLC连接断开" }; public ERRNO ERRNO_PLC_DISCONNECTED = new ERRNO() { Code = 65535, Descrption = "PLC连接断开" };
} }
} }
...@@ -107,7 +107,7 @@ namespace FLY.OBJComponents.Server ...@@ -107,7 +107,7 @@ namespace FLY.OBJComponents.Server
bool b = !PLCos.PLCs[i].Client.IsConnected; bool b = !PLCos.PLCs[i].Client.IsConnected;
ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF; ERR_STATE state = b ? ERR_STATE.ON : ERR_STATE.OFF;
ERRNO errno = PlcErrNos.ERRNO_PLC_DISCONNECTED; ERRNO errno = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED;
UInt16 errcode = (UInt16)(errno.Code - i); UInt16 errcode = (UInt16)(errno.Code - i);
string description; string description;
if (PLCos.PLCs.Count() > 1) if (PLCos.PLCs.Count() > 1)
......
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,18 +54,18 @@ namespace FLY.Thick.Base.UI ...@@ -53,18 +54,18 @@ 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 < 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()
{ {
...@@ -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);
}
void updateIsOn_In()
{
for (int i = 0; i < IStatus.Count(); i++)
{ {
for (int i = 0; i < IStatus.Count(); i++) {
IStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.IStatus, i); IStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.IStatus, i);
} }
}); }
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), () => void updateIsOn_Out()
{ {
for (int i = 0; i < OStatus.Count(); i++) for (int i = 0; i < OStatus.Count(); i++)
{ {
OStatus[i].IsOn = !Misc.MyBase.CHECKBIT(dynArea.OStatus, 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;
...@@ -119,53 +122,73 @@ namespace FLY.Thick.Base.UI ...@@ -119,53 +122,73 @@ namespace FLY.Thick.Base.UI
{ {
iODefineService.GetIODefine((asyncContext, retData) => { iODefineService.GetIODefine((asyncContext, retData) => {
var reponse = retData as List<IODefine>; var reponse = retData as IODefineCollection;
if (reponse == null || reponse.Count() == 0) if (reponse == null) {
return; 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;
} }
var list = reponse.List;
if (list == null || list.Count() == 0)
return;
update(IODefine.IOTYPE.Input, IStatus, reponse.InCount, list);
update(IODefine.IOTYPE.Output, OStatus, reponse.OutCount, list);
updateIsOn_In();
updateIsOn_Out();
}, this);
} }
else {
if (ioDefine.Index < ostatus_desps.Count()) void update(
IODefine.IOTYPE ioType,
ObservableCollection<FlyAdIoStatus> ioStatus,
int ioCnt,
List<IODefine> list)
{
//补够数量
if (ioStatus.Count() != ioCnt && ioCnt > 0)
{
while (ioStatus.Count() > ioCnt)
{ {
ostatus_desps[ioDefine.Index] = ioDefine.Description; ioStatus.RemoveAt(ioStatus.Count() - 1);
} }
while (ioStatus.Count() < ioCnt)
{
int i = ioStatus.Count();
ioStatus.Add(new FlyAdIoStatus()
{
Number = $"i{i + 1}"
});
} }
} }
for (int i = 0; i < istatus_desps.Count(); i++) { //获取中文
if (string.IsNullOrEmpty(istatus_desps[i])) string[] iostatus_desps = new string[ioCnt];
for (int i = 0; i < list.Count(); i++)
{ {
IStatus[i].Desp = ""; var ioDefine = list[i];
} if (ioDefine.IoType == ioType)
else
{ {
IStatus[i].Desp = istatus_desps[i]; if (ioDefine.Index < iostatus_desps.Count())
{
iostatus_desps[ioDefine.Index] = ioDefine.Description;
}
} }
} }
for (int i = 0; i < ostatus_desps.Count(); i++) //填入
for (int i = 0; i < iostatus_desps.Count(); i++)
{ {
if (string.IsNullOrEmpty(ostatus_desps[i])) if (string.IsNullOrEmpty(iostatus_desps[i]))
{ {
OStatus[i].Desp = ""; ioStatus[i].Desp = "";
} }
else else
{ {
OStatus[i].Desp = ostatus_desps[i]; ioStatus[i].Desp = iostatus_desps[i];
} }
} }
}, this);
} }
} }
public class FlyAdIoStatus : INotifyPropertyChanged public class FlyAdIoStatus : INotifyPropertyChanged
{ {
...@@ -188,25 +211,19 @@ namespace FLY.Thick.Base.UI ...@@ -188,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,7 +12,15 @@ namespace FLY.Thick.Base.Common ...@@ -12,7 +12,15 @@ namespace FLY.Thick.Base.Common
/// </summary> /// </summary>
public class FlyADIODefine: IFlyAdIoDefineService public class FlyADIODefine: IFlyAdIoDefineService
{ {
public static FlyADIODefine Instance { get; } = new FlyADIODefine(); protected static FlyADIODefine instance;
public static void SetInstance(FlyADIODefine flyADIODefine)
{
instance = flyADIODefine;
}
/// <summary>
/// 子类 需要 重新 把子类对象 赋值给 Instance, 确保整个环境只用一个版本的 单例
/// </summary>
public static FlyADIODefine Instance => instance;
#region 输入口 #region 输入口
/// <summary> /// <summary>
...@@ -114,13 +122,15 @@ namespace FLY.Thick.Base.Common ...@@ -114,13 +122,15 @@ namespace FLY.Thick.Base.Common
#endregion #endregion
private int version = 2;
/// <summary> /// <summary>
/// 根据AD盒的版本,设置 /// 根据AD盒的版本,设置
/// </summary> /// </summary>
/// <param name="version"></param> /// <param name="version"></param>
public virtual void SerVersion(int version) public virtual void SerVersion(int version)
{ {
if (version == 3) this.version = version;
if (this.version == 3)
{ {
InNo_Org = 13 - 1; InNo_Org = 13 - 1;
InNo_Limit_Forw = 14 - 1; InNo_Limit_Forw = 14 - 1;
...@@ -181,8 +191,19 @@ namespace FLY.Thick.Base.Common ...@@ -181,8 +191,19 @@ namespace FLY.Thick.Base.Common
public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext) public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext)
{ {
//获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX //获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX
IODefineCollection reponse = new IODefineCollection();
List<IODefine> reponse = new List<IODefine>(); 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 inputPropertyNames = GetInputPropertyNames();
var outputPropertyNames = GetOutputPropertyNames(); var outputPropertyNames = GetOutputPropertyNames();
...@@ -209,7 +230,7 @@ namespace FLY.Thick.Base.Common ...@@ -209,7 +230,7 @@ namespace FLY.Thick.Base.Common
Index = index, Index = index,
Description = desp Description = desp
}; };
reponse.Add(iodefine); list.Add(iodefine);
} }
foreach (var propertyName in outputPropertyNames) foreach (var propertyName in outputPropertyNames)
...@@ -232,10 +253,10 @@ namespace FLY.Thick.Base.Common ...@@ -232,10 +253,10 @@ namespace FLY.Thick.Base.Common
Index = index, Index = index,
Description = desp Description = desp
}; };
reponse.Add(iodefine); list.Add(iodefine);
} }
asyncDelegate?.Invoke(asyncContext, reponse); asyncDelegate?.Invoke(asyncContext, list);
} }
} }
} }
...@@ -18,10 +18,26 @@ namespace FLY.Thick.Base.IService ...@@ -18,10 +18,26 @@ namespace FLY.Thick.Base.IService
/// </summary> /// </summary>
/// <param name="asyncDelegate"></param> /// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param> /// <param name="asyncContext"></param>
[Call(typeof(List<IODefine>))] [Call(typeof(IODefineCollection))]
void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext); 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>
/// 输入输出口描述 /// 输入输出口描述
/// </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