using SKMC.Api.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
namespace SKMC.Api.Motion.Model
{
///
/// IO模块设备
///
public class MotionIODev
{
///
/// 设备编号
///
public short DevNo { get; set; }
///
/// 设备类型, DI/DO/AD/DA
///
public string Type { get; set; }
///
/// 当前的分类, 在分类筛选时有用
///
public string Catalog { get; set; }
///
/// 所属(模块)分类, 一个IODev可能包含多个分类
///
public HashSet Catalogs { get; set; } = new HashSet();
public string Desc
{
get
{
if (MotionIOs != null & MotionIOs.Count > 0)
{
HashSet descs = new HashSet();
foreach(var motionIO in MotionIOs)
{
if (!CommonUtil.IsEmptyString(motionIO.Code))
{
descs.Add(motionIO.Desc);
}
}
StringBuilder builder = new StringBuilder();
foreach(var desc in descs)
{
builder.Append(desc).Append(',');
}
return builder.Remove(builder.Length - 1, 1).ToString();
}
return default;
}
}
///
/// 点位数量
///
public int SiteNum { get => MotionIOs.Count; }
public List MotionIOs { get; set; }
public string DevInfo() => $"{Type} [{DevNo}]: {Desc}";
}
}