You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.7 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service.Impl;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.AxHost;
namespace HighWayIot.TouchSocket
{
public class BufferAnalysis
{
private static LogHelper logHelper = LogHelper.Instance;
/// <summary>
/// 心跳报文分析
/// </summary>
/// <param name="bytes"></param>
public static void HeartbeatSocket(JObject obj, string ip)
{
BaseHeartbeatServiceImpl sql = new BaseHeartbeatServiceImpl();
if (sql.UpdateHeartbeatInfo(ip) == 0)
{
RFIDHeartbeat heartbeat = new RFIDHeartbeat()
{
IP = ip,
BeatTime = DateTime.Now,
};
sql.AddHeartbeatInfo(heartbeat);
}
}
/// <summary>
/// RFID发送设备状态
/// </summary>
/// <param name="bytes"></param>
public static void RFIDStatusSocket(JObject obj, string ip)
{
BaseStateServiceImpl sql = new BaseStateServiceImpl();
RFIDState rFIDState = new RFIDState()
{
IP = ip,
DeviceState = state == 1 ? true : false,
LogTime = DateTime.Now,
};
sql.AddStateInfo(rFIDState);
}
/// <summary>
/// RFID发送条码
/// </summary>
/// <param name="bytes"></param>
public static void RFIDCodeSocket(JObject obj, string ip)
{
if ()
{
BaseContentServiceImpl sql = new BaseContentServiceImpl();
}
else
{
logHelper.Error("条码发送报文编号数值转换出现错误!");
}
}
/// <summary>
/// 将一个数组拆成另外一个数组
/// </summary>
/// <param name="originbyte">原始数组,被拆分的数组</param>
/// <param name="oringinstartindex">从原始数组第几个元素开始</param>
/// <param name="destbytelength">目标数组的长度</param>
/// <param name="destbytestartindex">目标数组开始的元素序号默认为0</param>
/// <returns></returns>
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;
}
}
}