Commit 6f4472f1 authored by 潘栩锋's avatar 潘栩锋 🚴

删除 dynarea 内的 ToBytes

parent b272c7aa
...@@ -11,64 +11,17 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -11,64 +11,17 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
{ {
#region Pack #region Pack
public class Pack_GetADPos : IPack public class Pack_GetADPos
{ {
public int thick; public int thick;
public int position; public int position;
public int boltIndex; public int boltIndex;
public int ad; public int ad;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(thick));
buf.AddRange(BitConverter.GetBytes(position));
buf.AddRange(BitConverter.GetBytes(boltIndex));
buf.AddRange(BitConverter.GetBytes(ad));
return buf.ToArray();
} }
public class Pack_Position2
public bool TryParse(byte[] value)
{
int idx = 0;
thick = BitConverter.ToInt32(value,idx);
idx += 4;
position = BitConverter.ToInt32(value, idx);
idx += 4;
boltIndex = BitConverter.ToInt32(value, idx);
idx += 4;
ad = BitConverter.ToInt32(value, idx);
idx += 4;
return true;
}
#endregion
}
public class Pack_Position2 : IPack
{ {
public int position; public int position;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(position));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
position = BitConverter.ToInt32(value, 0);
return true;
}
#endregion
} }
public class Pack_GetScanInfo public class Pack_GetScanInfo
{ {
...@@ -105,7 +58,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -105,7 +58,7 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
/// </summary> /// </summary>
public double velocity; public double velocity;
} }
public class Pack_GetControllerState : IPack public class Pack_GetControllerState
{ {
/// <summary> /// <summary>
/// 运行状态 /// 运行状态
...@@ -115,210 +68,84 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -115,210 +68,84 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
/// 自动扫描时间累积 /// 自动扫描时间累积
/// </summary> /// </summary>
public int autoscan_counter; public int autoscan_counter;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes((Int32)controller_state));
buf.AddRange(BitConverter.GetBytes(autoscan_counter));
return buf.ToArray();
} }
public class Pack_GetIO
public bool TryParse(byte[] value)
{
if (value.Length < 8)
return false;
int idx = 0;
controller_state = (CTRL_STATE)BitConverter.ToInt32(value, idx);
idx += 4;
autoscan_counter = BitConverter.ToInt32(value, idx);
idx += 4;
return true;
}
#endregion
}
public class Pack_GetIO : IPack
{ {
public UInt16 iStatus; public UInt16 iStatus;
public UInt16 oStatus; public UInt16 oStatus;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(iStatus));
buf.AddRange(BitConverter.GetBytes(oStatus));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
iStatus = BitConverter.ToUInt16(value, 0);
oStatus = BitConverter.ToUInt16(value, 2);
return true;
} }
public class Pack_GetSystem
#endregion
}
public class Pack_GetSystem : IPack
{
public bool isConnect;//FLYAD 连接状态
public bool secuteLock;//锁
public int hrs;//系统剩余小时
public string version;//版本
public GAGE_TYPE gagetype;//设备类型
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(isConnect));
buf.AddRange(BitConverter.GetBytes(secuteLock));
buf.AddRange(BitConverter.GetBytes(hrs));
byte[] version_buf = Converter.StringToBytes(version);
buf.AddRange(BitConverter.GetBytes(version_buf.Length));
buf.AddRange(version_buf);
buf.AddRange(BitConverter.GetBytes((int)gagetype));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{ {
int cnt = 1 + 1 + 4 + 4 + 4; /// <summary>
if (value.Length < cnt) /// FLYAD 连接状态
return false; /// </summary>
public bool isConnect;
int index = 0; /// <summary>
isConnect = BitConverter.ToBoolean(value, index); /// 锁
index++; /// </summary>
secuteLock = BitConverter.ToBoolean(value, index); public bool secuteLock;
index++; /// <summary>
hrs = BitConverter.ToInt32(value, index); /// 系统剩余小时
index += 4; /// </summary>
public int hrs;
int len = BitConverter.ToInt32(value, index); /// <summary>
index += 4; /// 版本
cnt += len; /// </summary>
if (value.Length < cnt) public string version;
return false; /// <summary>
/// 设备类型
byte[] version_buf = new byte[len]; /// </summary>
Array.Copy(value, index, version_buf, 0, len); public GAGE_TYPE gagetype;
index += len;
version = Converter.BytesToString(version_buf);
gagetype = (GAGE_TYPE)BitConverter.ToInt32(value, index);
index += 4;
return true;
}
#endregion
} }
public class Pack_GetProfile : IPack public class Pack_GetProfile
{ {
public string ProductName;//产品名称 /// <summary>
public int Target;//目标值 /// 产品名称
public int Alarm;//报警值 /// </summary>
public int DataBoltNoBegin;//数据开始分区号 public string ProductName;
public int DataBoltNoEnd;//数据结束分区号 /// <summary>
/// 目标值
/// </summary>
public int Target;
/// <summary>
/// 报警值
/// </summary>
public int Alarm;
/// <summary>
/// 数据开始分区号
/// </summary>
public int DataBoltNoBegin;
/// <summary>
/// 数据结束分区号
/// </summary>
public int DataBoltNoEnd;
/// <summary>
/// 扫描范围开始分区号
/// </summary>
public int ScanBoltNoBegin; public int ScanBoltNoBegin;
/// <summary>
/// 扫描范围结束分区号
/// </summary>
public int ScanBoltNoEnd; public int ScanBoltNoEnd;
/// <summary>
/// 斜率补差
/// </summary>
public double Comp; public double Comp;
/// <summary>
/// 平移补差
/// </summary>
public int Shift; public int Shift;
#region IPack 成员
public byte[] ToBytes()
{
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(Target));
buf.AddRange(BitConverter.GetBytes(Alarm));
buf.AddRange(BitConverter.GetBytes(DataBoltNoBegin));
buf.AddRange(BitConverter.GetBytes(DataBoltNoEnd));
buf.AddRange(BitConverter.GetBytes(ScanBoltNoBegin));
buf.AddRange(BitConverter.GetBytes(ScanBoltNoEnd));
buf.AddRange(BitConverter.GetBytes(Comp));
buf.AddRange(BitConverter.GetBytes(Shift));
byte[] name_bytes = Converter.StringToBytes(ProductName);
buf.AddRange(BitConverter.GetBytes((int)name_bytes.Length));
buf.AddRange(name_bytes);
return buf.ToArray();
} }
public class Pack_GetBoltmap
public bool TryParse(byte[] value)
{
int index = 0;
Target = BitConverter.ToInt32(value, index);
index += 4;
Alarm = BitConverter.ToInt32(value, index);
index += 4;
DataBoltNoBegin = BitConverter.ToInt32(value, index);//数据开始分区号
index += 4;
DataBoltNoEnd = BitConverter.ToInt32(value, index);//数据结束分区号
index += 4;
ScanBoltNoBegin = BitConverter.ToInt32(value, index);//数据开始分区号
index += 4;
ScanBoltNoEnd = BitConverter.ToInt32(value, index);//数据结束分区号
index += 4;
Comp = BitConverter.ToDouble(value, index);
index += 8;
Shift = BitConverter.ToInt32(value, index);
index += 4;
int name_bytes_length = BitConverter.ToInt32(value, index);
index += 4;
byte[] name_bytes = new byte[name_bytes_length];
Array.Copy(value, index, name_bytes, 0, name_bytes_length);
index += name_bytes_length;
ProductName = Converter.BytesToString(name_bytes);
return true;
}
#endregion
}
public class Pack_GetBoltmap : IPack
{ {
public int NBolts;//总分区数 /// <summary>
public int FirstBoltNo;//开始分区号 /// 总分区数
/// </summary>
public int NBolts;
#region IPack 成员 /// <summary>
/// 开始分区号
public byte[] ToBytes() /// </summary>
{ public int FirstBoltNo;
List<byte> buf = new List<byte>();
buf.AddRange(BitConverter.GetBytes(NBolts));
buf.AddRange(BitConverter.GetBytes(FirstBoltNo));
return buf.ToArray();
}
public bool TryParse(byte[] value)
{
NBolts = BitConverter.ToInt32(value, 0);
FirstBoltNo = BitConverter.ToInt32(value, 4);
return true;
}
#endregion
} }
#endregion #endregion
......
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