using HighWayIot.Repository.domain;
using HighWayIot.Repository.service.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.TouchSocket
{
public class BufferAnalysis
{
///
/// 心跳报文分析
///
///
public static void HeartbeatSocket(byte[] bytes)
{
string a = Encoding.ASCII.GetString(bytes, 4, 4);
int deviceno;
if(int.TryParse(a, out deviceno))
{
BaseHeartbeatServiceImpl sql = new BaseHeartbeatServiceImpl();
if(sql.UpdateHeartbeatInfo(deviceno) == 0)
{
RFIDHeartbeat heartbeat = new RFIDHeartbeat()
{
DeviceNo = deviceno,
BeatTime = DateTime.Now,
};
sql.AddHeartbeatInfo(heartbeat);
}
}
}
///
/// RFID发送设备状态
///
///
public static void RFIDStatusSocket(byte[] bytes)
{
}
///
/// RFID发送条码
///
///
public static void RFIDCodeSocket(byte[] bytes)
{
}
///
/// 将一个数组拆成另外一个数组
///
/// 原始数组,被拆分的数组
/// 从原始数组第几个元素开始
/// 目标数组的长度
/// 目标数组开始的元素序号,默认为0
///
public static byte[] SplitByteArray(byte[] originbyte, int oringinstartindex, int destbytelength, int destbytestartindex = 0)
{
byte[] result = new byte[destbytelength];
System.Array.Copy(originbyte, oringinstartindex, result, destbytestartindex, destbytelength);
return result;
}
}
}