using FObjBase; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FLY.FeedbackRenZiJia.OBJ_INTERFACE { public class SNAPSHOT_OBJ_INTERFACE { #region pack public class Pack_IntList : IPack { public List<int> list; #region IPack 成员 public byte[] ToBytes() { List<byte> buf = new List<byte>(); if (list != null) { buf.AddRange(BitConverter.GetBytes(list.Count())); for (int i = 0; i < list.Count(); i++) { buf.AddRange(BitConverter.GetBytes(list[i])); } } else { buf.AddRange(BitConverter.GetBytes(0)); } return buf.ToArray(); } /// <summary> /// 返回由字节数组中指定位置的9个字节转换来的数据。 /// </summary> /// <param name="value"></param> /// <returns></returns> public bool TryParse(byte[] value) { int cnt = 4; if (value.Length < cnt) return false; int idx = 0; int len = BitConverter.ToInt32(value, idx); idx += 4; cnt += len * 4; if (value.Length < cnt) return false; if (list == null) list = new List<int>(); list.Clear(); for (int i = 0; i < len; i++) { list.Add(BitConverter.ToInt32(value, idx)); idx += 4; } return true; } #endregion } public class Pack_Int : IPack { public int num; #region IPack 成员 public byte[] ToBytes() { List<byte> buf = new List<byte>(); buf.AddRange(BitConverter.GetBytes(num)); return buf.ToArray(); } public bool TryParse(byte[] value) { if (value.Length < 4) return false; int idx = 0; num = BitConverter.ToInt32(value, idx); idx += 4; return true; } #endregion } #endregion #region Get #endregion #region Set #endregion #region Call /// <summary> /// request:Pack_Int /// reponse:FlyData_SnapShot /// </summary> public const UInt16 CALL_GET_SNAPSHOT = 14; /// <summary> /// request:FlyData_SnapShot /// reponse:null /// </summary> public const UInt16 CALL_SET_SNAPSHOT = 15; /// <summary> /// request:Pack_Int /// reponse:null /// </summary> public const UInt16 CALL_DEL_SNAPSHOT = 16; /// <summary> /// request:null /// reponse:Pack_IntList /// </summary> public const UInt16 CALL_GET_SNAPSHOT_LIST = 17; #endregion #region Push #endregion } }