123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- using SourceGen;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using WCS.Protocol.SX.BCR;
- using WCS.Protocol.SX.Protocol.DataStructure;
- using WCS.Protocol.SX.Robot;
- using WCS.Protocol.SX.SRM;
- using WCS.Protocol.SX.Station;
- namespace WCS.Protocol.SX.DataStructure
- {
- /// <summary>
- /// 设备数据包
- /// </summary>
- [DataContract]
- public class DeviceDataPack
- {
- /// <summary>
- /// 堆垛机数据集
- /// </summary>
- [DataMember(Order = 0)]
- public DeviceDataCollection<SRMData> SRMDatas { get; set; }
- /// <summary>
- /// 穿梭车数据集
- /// </summary>
- [DataMember(Order = 1)]
- public DeviceDataCollection<RGVData> RGVDatas { get; set; }
- /// <summary>
- /// 站台数据集
- /// </summary>
- [DataMember(Order = 2)]
- public DeviceDataCollection<StationData> StationDatas { get; set; }
- ///// <summary>
- ///// 扫码器数据
- ///// </summary>
- //[DataMember(Order = 3)]
- //public DeviceDataCollection<BCRData> BcrDatas { get; set; }
- /// <summary>
- /// 机器人数据集
- /// </summary>
- [DataMember(Order = 3)]
- public DeviceDataCollection<RobotData> RobotData { get; set; }
- /// <summary>
- /// 机器人数据集
- /// </summary>
- [DataMember(Order = 4)]
- public DeviceDataCollection<TrussData> TrussData { get; set; }
- ///// <summary>
- ///// 产线数据集
- ///// </summary>
- //[DataMember(Order = 5)]
- //public DeviceDataCollection<ProdLineData> ProdLineData { get; set; }
- /// <summary>
- /// 时间
- /// </summary>
- [DataMember(Order = 5)]
- public DateTime Frame { get; set; }
- /// <summary>
- /// 回放最早时间
- /// </summary>
- [DataMember(Order = 6)]
- public int PlaybackSeconds { get; set; }
- }
- [DataContract]
- public class DataPack
- {
- [DataMember(Order = 0)]
- public DateTime Frame { get; set; }
- [DataMember(Order = 1)]
- public ProtocolData<IStation520Data>[] Station520 { get; set; }
- [DataMember(Order = 2)]
- public ProtocolData<IStation521Data>[] Station521 { get; set; }
- [DataMember(Order = 3)]
- public ProtocolData<IStation23Data>[] Station23 { get; set; }
- [DataMember(Order = 4)]
- public ProtocolData<IStation523Data>[] Station523 { get; set; }
- [DataMember(Order = 5)]
- public ProtocolData<IBCR81Data>[] BCR81 { get; set; }
- [DataMember(Order = 6)]
- public ProtocolData<ISRM520Data>[] SRM520 { get; set; }
- [DataMember(Order = 7)]
- public ProtocolData<ISRM521Data>[] SRM521 { get; set; }
- [DataMember(Order = 8)]
- public ProtocolData<ISRM537Data>[] SRM537 { get; set; }
- [DataMember(Order = 9)]
- public ProtocolData<IRobot520Data>[] Robot520 { get; set; }
- [DataMember(Order = 10)]
- public ProtocolData<IRobot521Data>[] Robot521 { get; set; }
- [DataMember(Order = 11)]
- public ProtocolData<IRobot522Data>[] Robot522 { get; set; }
- [DataMember(Order = 12)]
- public ProtocolData<IRobot530Data>[] Robot530 { get; set; }
- [DataMember(Order = 13)]
- public ProtocolData<IRobot531Data>[] Robot531 { get; set; }
- [DataMember(Order = 14)]
- public ProtocolData<IQT51Data>[] QT51 { get; set; }
- [DataMember(Order = 15)]
- public ProtocolData<LogContent>[] LogContent { get; set; }
- [DataMember(Order = 16)]
- public ProtocolData<ISRM542Data>[] SRM542 { get; set; }
- public Dictionary<string, ProtocolData[]> GetDeviceData()
- {
- List<Tuple<string, ProtocolData>> list = new List<Tuple<string, ProtocolData>>();
- foreach (var p in this.GetType().GetProperties())
- {
- if (p.PropertyType.IsArray)
- {
- var arr = p.GetValue(this) as Array;
- foreach (var a in arr)
- {
- var code = a.GetType().GetProperty("Code").GetValue(a).ToString();
- //var data = a.GetType().GetProperty("Data").GetValue(a);
- list.Add(new Tuple<string, ProtocolData>(code, a as ProtocolData));
- }
- }
- }
- var res = list.GroupBy(v => v.Item1).ToDictionary(v => v.Key, v => v.Select(d => d.Item2).ToArray());
- return res;
- }
- }
- }
|