初始化CRICS
This commit is contained in:
51
RCUHost/Implement/UnlockControlReceiver.cs
Normal file
51
RCUHost/Implement/UnlockControlReceiver.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Common;
|
||||
using Domain;
|
||||
using RCUHost.Protocols;
|
||||
|
||||
namespace RCUHost.Implement
|
||||
{
|
||||
/// <summary>
|
||||
/// 开锁
|
||||
/// </summary>
|
||||
public class UnlockControlReceiver : GenericReceiverBase, IUnlockControlReceiver
|
||||
{
|
||||
public void Send(Host host)
|
||||
{
|
||||
var data = CreateDataPacket(1);
|
||||
|
||||
SendAndPushCommandQueue(data, host.HostNumber, host.MAC);
|
||||
}
|
||||
|
||||
private byte[] CreateDataPacket(int status)
|
||||
{
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
int headerLen = StructConverter.SizeOf(typeof(SystemHeader));
|
||||
|
||||
stream.Seek(headerLen, SeekOrigin.Begin);
|
||||
|
||||
stream.WriteByte((byte)status);
|
||||
stream.Write(new byte[] { 0, 0 }, 0, 2);
|
||||
|
||||
SystemHeader systemHeader = CreateSystemHeader((int)stream.Length - headerLen);
|
||||
|
||||
var systemHeaderData = StructConverter.StructToBytes(systemHeader);
|
||||
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.Write(systemHeaderData, 0, systemHeaderData.Length);
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public override CommandType CommandType
|
||||
{
|
||||
get { return CommandType.UnlockControl; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user