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
public string Descrption;
}
public static class PlcErrNos
public class PlcErrNos
{
public static PlcErrNos Instance { get; } = new PlcErrNos();
/// <summary>
/// PLC连接断开
/// </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
bool b = !PLCos.PLCs[i].Client.IsConnected;
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);
string description;
if (PLCos.PLCs.Count() > 1)
......
using FLY.Thick.Base.IService;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
......@@ -33,7 +34,7 @@ namespace FLY.Thick.Base.UI
public void Init(IFlyAdIoDefineService iODefineService, ITDGageService gageService) {
viewModel = new WdIoTipVm();
viewModel.Init(iODefineService, gageService);
viewModel.Init(iODefineService, gageService.DynArea);
this.DataContext = viewModel;
}
......@@ -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;
for (int i = 0; i < 16; i++) {
for (int i = 0; i < 12; i++) {
IStatus.Add(new FlyAdIoStatus()
{
Number = $"i{i+1}"
});
};
for (int i = 0; i < 8; i++)
for (int i = 0; i < 4; i++)
{
OStatus.Add(new FlyAdIoStatus()
{
......@@ -86,23 +87,25 @@ namespace FLY.Thick.Base.UI
update();
}
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), () =>
{
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);
}
});
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++)
{
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)
{
var client = this.iODefineService as FObjBase.FObjServiceClient;
......@@ -119,53 +122,73 @@ namespace FLY.Thick.Base.UI
{
iODefineService.GetIODefine((asyncContext, retData) => {
var reponse = retData as List<IODefine>;
if (reponse == null || reponse.Count() == 0)
var reponse = retData as IODefineCollection;
if (reponse == null) {
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;
}
}
else {
if (ioDefine.Index < ostatus_desps.Count())
{
ostatus_desps[ioDefine.Index] = ioDefine.Description;
}
}
}
var list = reponse.List;
if (list == null || list.Count() == 0)
return;
for (int i = 0; i < istatus_desps.Count(); i++) {
if (string.IsNullOrEmpty(istatus_desps[i]))
{
IStatus[i].Desp = "";
}
else
update(IODefine.IOTYPE.Input, IStatus, reponse.InCount, list);
update(IODefine.IOTYPE.Output, OStatus, reponse.OutCount, list);
updateIsOn_In();
updateIsOn_Out();
}, this);
}
void update(
IODefine.IOTYPE ioType,
ObservableCollection<FlyAdIoStatus> ioStatus,
int ioCnt,
List<IODefine> list)
{
//补够数量
if (ioStatus.Count() != ioCnt && ioCnt > 0)
{
while (ioStatus.Count() > ioCnt)
{
ioStatus.RemoveAt(ioStatus.Count() - 1);
}
while (ioStatus.Count() < ioCnt)
{
int i = ioStatus.Count();
ioStatus.Add(new FlyAdIoStatus()
{
IStatus[i].Desp = istatus_desps[i];
}
Number = $"i{i + 1}"
});
}
}
//获取中文
string[] iostatus_desps = new string[ioCnt];
for (int i = 0; i < ostatus_desps.Count(); i++)
for (int i = 0; i < list.Count(); i++)
{
var ioDefine = list[i];
if (ioDefine.IoType == ioType)
{
if (string.IsNullOrEmpty(ostatus_desps[i]))
if (ioDefine.Index < iostatus_desps.Count())
{
OStatus[i].Desp = "";
}
else
{
OStatus[i].Desp = ostatus_desps[i];
iostatus_desps[ioDefine.Index] = ioDefine.Description;
}
}
}, this);
}
}
//填入
for (int i = 0; i < iostatus_desps.Count(); i++)
{
if (string.IsNullOrEmpty(iostatus_desps[i]))
{
ioStatus[i].Desp = "";
}
else
{
ioStatus[i].Desp = iostatus_desps[i];
}
}
}
}
public class FlyAdIoStatus : INotifyPropertyChanged
{
......@@ -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()
{
for (int i = 0; i < 16; i++)
for (int i = 0; i < 12; i++)
{
IStatus.Add(new FlyAdIoStatus()
{
Number = $"i{i + 1}"
});
};
for (int i = 0; i < 8; i++)
for (int i = 0; i < 4; i++)
{
OStatus.Add(new FlyAdIoStatus()
{
......
......@@ -33,45 +33,9 @@ namespace FLY.Thick.Base.Client
/// </summary>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
[Call(typeof(List<IODefine>))]
public void GetIODefine(AsyncCBHandler asyncDelegate, object 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,8 +12,16 @@ namespace FLY.Thick.Base.Common
/// </summary>
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 输入口
/// <summary>
/// 归零信号
......@@ -114,13 +122,15 @@ namespace FLY.Thick.Base.Common
#endregion
private int version = 2;
/// <summary>
/// 根据AD盒的版本,设置
/// </summary>
/// <param name="version"></param>
public virtual void SerVersion(int version)
{
if (version == 3)
this.version = version;
if (this.version == 3)
{
InNo_Org = 13 - 1;
InNo_Limit_Forw = 14 - 1;
......@@ -181,8 +191,19 @@ namespace FLY.Thick.Base.Common
public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext)
{
//获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX
List<IODefine> reponse = new List<IODefine>();
IODefineCollection reponse = new IODefineCollection();
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 outputPropertyNames = GetOutputPropertyNames();
......@@ -209,7 +230,7 @@ namespace FLY.Thick.Base.Common
Index = index,
Description = desp
};
reponse.Add(iodefine);
list.Add(iodefine);
}
foreach (var propertyName in outputPropertyNames)
......@@ -232,10 +253,10 @@ namespace FLY.Thick.Base.Common
Index = index,
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
/// </summary>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
[Call(typeof(List<IODefine>))]
[Call(typeof(IODefineCollection))]
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>
......
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