初始化CRICS
This commit is contained in:
201
RCUHost/Protocols/AirConditionSettingPacket.cs
Normal file
201
RCUHost/Protocols/AirConditionSettingPacket.cs
Normal file
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 空调设置 Packet 服务器 -> RCU
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct AirConditionSettingPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 空调编号
|
||||
/// </summary>
|
||||
public byte AirNo;
|
||||
|
||||
/// <summary>
|
||||
/// 开关机:0/关,1/开
|
||||
/// </summary>
|
||||
public byte OnOff;
|
||||
|
||||
/// <summary>
|
||||
/// 设定温度
|
||||
/// </summary>
|
||||
public byte SettingTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 补偿温度:范围 -6.0~6.0,存放格式 值*10
|
||||
/// </summary>
|
||||
public byte CompensatoryTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 风速:0/停止, 1/低速, 2/中速, 3/高速, 4/自动
|
||||
/// </summary>
|
||||
public byte Speed;
|
||||
|
||||
/// <summary>
|
||||
/// 模式: 0/制冷,1/制热,2/送风,3/除湿
|
||||
/// </summary>
|
||||
public byte Mode;
|
||||
|
||||
/// <summary>
|
||||
/// 是否锁定温度:0/否,1/是
|
||||
/// </summary>
|
||||
public byte IsLockTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 锁定温度
|
||||
/// </summary>
|
||||
public byte LockTemp;
|
||||
|
||||
/*************温控器设置*************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// 保温温度
|
||||
/// </summary>
|
||||
public byte KeepTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 初始温度
|
||||
/// </summary>
|
||||
public byte InitTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 最高温度
|
||||
/// </summary>
|
||||
public byte HighTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 最低温度
|
||||
/// </summary>
|
||||
public byte LowerTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 冷热转换延时,单位:秒
|
||||
/// </summary>
|
||||
public byte ColdHotSwitchDelayTime;
|
||||
|
||||
/// <summary>
|
||||
/// 手自模式:0/手动,1/自动
|
||||
/// </summary>
|
||||
public byte ColdHotMode;
|
||||
|
||||
/// <summary>
|
||||
/// 死区温度
|
||||
/// </summary>
|
||||
public byte DeadTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 热偏差
|
||||
/// </summary>
|
||||
public byte HotDevition;
|
||||
|
||||
/// <summary>
|
||||
/// 冷偏差
|
||||
/// </summary>
|
||||
public byte ColdDevition;
|
||||
|
||||
/// <summary>
|
||||
/// 欢迎模式时间(分钟)
|
||||
/// </summary>
|
||||
public byte WelcomeTime;
|
||||
|
||||
/// <summary>
|
||||
/// 是否关联房态:0/否,1/是
|
||||
/// </summary>
|
||||
public byte RelateRoomStatus;
|
||||
|
||||
/// <summary>
|
||||
/// 是否关联门磁:0/否,1/是
|
||||
/// </summary>
|
||||
public byte RelateDoorContact;
|
||||
|
||||
/// <summary>
|
||||
/// 温度到达停止风机运行:0/否,1/是
|
||||
/// </summary>
|
||||
public byte FanStop;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止风机高速运行:0/否,1/是
|
||||
/// </summary>
|
||||
public byte DisableFanHighSpeed;
|
||||
|
||||
/*************睡眠温度设置*************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// 睡眠启用标志
|
||||
/// </summary>
|
||||
public byte SleepFlag;
|
||||
|
||||
/// <summary>
|
||||
/// 睡眠开始时间 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] SleepStartTime;
|
||||
|
||||
/// <summary>
|
||||
/// 睡眠结束时间 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] SleepEndTime;
|
||||
|
||||
/// <summary>
|
||||
/// 睡眠模式偏差
|
||||
/// </summary>
|
||||
public byte SleepDevition;
|
||||
|
||||
/*************空调定时设置*************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// 定时启用标志
|
||||
/// </summary>
|
||||
public byte TimeFlag;
|
||||
|
||||
/// <summary>
|
||||
/// 定时开始时间1 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] TimeStartTime1;
|
||||
|
||||
/// <summary>
|
||||
/// 定时结束时间1 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] TimeEndTime1;
|
||||
|
||||
/// <summary>
|
||||
/// 定时开始时间2 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] TimeStartTime2;
|
||||
|
||||
/// <summary>
|
||||
/// 定时结束时间2 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] TimeEndTime2;
|
||||
|
||||
/// <summary>
|
||||
/// 定时开始时间3 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] TimeStartTime3;
|
||||
|
||||
/// <summary>
|
||||
/// 定时结束时间3 byte0:小时, byte1:分钟
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
public byte[] TimeEndTime3;
|
||||
|
||||
/*************其它*************************************************************/
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
60
RCUHost/Protocols/AirConditionStatusPacket.cs
Normal file
60
RCUHost/Protocols/AirConditionStatusPacket.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 空调状态 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct AirConditionStatusPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 空调标识符,从0开始编号
|
||||
/// </summary>
|
||||
public byte AirConditionID;
|
||||
|
||||
/// <summary>
|
||||
/// 风机状态:0/停止, 1/运行
|
||||
/// </summary>
|
||||
public byte Running;
|
||||
|
||||
/// <summary>
|
||||
/// 当前实际温度
|
||||
/// </summary>
|
||||
public byte CurrentTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 设定温度
|
||||
/// </summary>
|
||||
public byte SettingTemp;
|
||||
|
||||
/// <summary>
|
||||
/// 风速:0/停止, 1/低速, 2/中速, 3/高速, 4/自动
|
||||
/// </summary>
|
||||
public byte Speed;
|
||||
|
||||
/// <summary>
|
||||
/// 季节:0/冷风,1/暖风
|
||||
/// </summary>
|
||||
public byte Season;
|
||||
|
||||
/// <summary>
|
||||
/// 冷阀门:0/关,1/开
|
||||
/// </summary>
|
||||
public byte ColdValve;
|
||||
|
||||
/// <summary>
|
||||
/// 热阀门:0/关,1/开
|
||||
/// </summary>
|
||||
public byte ThermalValve;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
40
RCUHost/Protocols/AlarmPacket.cs
Normal file
40
RCUHost/Protocols/AlarmPacket.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警状态 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct AlarmPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// SOS
|
||||
/// </summary>
|
||||
public byte SOS;
|
||||
|
||||
/// <summary>
|
||||
/// 门磁
|
||||
/// </summary>
|
||||
public byte Door;
|
||||
|
||||
/// <summary>
|
||||
/// 取电卡类型
|
||||
/// 1: 无卡
|
||||
/// 2:经理卡
|
||||
/// 3:客人卡
|
||||
/// 4:服务卡
|
||||
/// </summary>
|
||||
public byte Card;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
|
||||
}
|
||||
}
|
||||
26
RCUHost/Protocols/AuthorizationReply.cs
Normal file
26
RCUHost/Protocols/AuthorizationReply.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 授权时间回复 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct AuthorizationReply
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.U4)]
|
||||
public byte[] Time;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
33
RCUHost/Protocols/CommandData.cs
Normal file
33
RCUHost/Protocols/CommandData.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
public class CommandData
|
||||
{
|
||||
public IPEndPoint RemoteEndPoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 帧序号
|
||||
/// </summary>
|
||||
public ushort FrameNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 命令数据
|
||||
/// </summary>
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生存时间
|
||||
/// </summary>
|
||||
public int TTL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 重发次数
|
||||
/// </summary>
|
||||
public int ResendTime { get; set; }
|
||||
}
|
||||
}
|
||||
197
RCUHost/Protocols/CommandType.cs
Normal file
197
RCUHost/Protocols/CommandType.cs
Normal file
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// RCU与服务器交互命令
|
||||
/// </summary>
|
||||
public enum CommandType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时上报
|
||||
/// </summary>
|
||||
TimerReport=0x34,
|
||||
|
||||
/// <summary>
|
||||
/// 搜索主机
|
||||
/// </summary>
|
||||
SearchHost = 0x01,
|
||||
/// <summary>
|
||||
/// 心跳包
|
||||
/// </summary>
|
||||
Heart = 0x02,
|
||||
/// <summary>
|
||||
/// 插卡取电
|
||||
/// </summary>
|
||||
InsertCard = 0x03,
|
||||
/// <summary>
|
||||
/// 服务请求
|
||||
/// </summary>
|
||||
ServiceRequest = 0x04,
|
||||
/// <summary>
|
||||
/// 报警状态
|
||||
/// </summary>
|
||||
AlarmStatus = 0x05,
|
||||
/// <summary>
|
||||
/// 空调状态
|
||||
/// </summary>
|
||||
AirConditionStatus = 0x06,
|
||||
/// <summary>
|
||||
/// 节能模式下发
|
||||
/// </summary>
|
||||
EnergySavingMode = 0x07,
|
||||
/// <summary>
|
||||
/// 同步时间
|
||||
/// </summary>
|
||||
SyncTime = 0x08,
|
||||
/// <summary>
|
||||
/// 设置命令,客房控制
|
||||
/// </summary>
|
||||
RoomControl = 0x10,
|
||||
/// <summary>
|
||||
/// 升级主机固件(局域网使用)
|
||||
/// </summary>
|
||||
UpdateHost = 0x0A,
|
||||
/// <summary>
|
||||
/// 升级配置文件(局域网使用)
|
||||
/// </summary>
|
||||
UpdateConfig = 0xA2,
|
||||
|
||||
/// <summary>
|
||||
/// 升级进度
|
||||
/// </summary>
|
||||
UpdateProgressBar = 0xB6,
|
||||
/// <summary>
|
||||
/// 上传RCU软件当前版本号 RCU -> 服务器
|
||||
/// </summary>
|
||||
UploadCurrentVersion = 0x0B,
|
||||
/// <summary>
|
||||
/// 房态变化 服务器 -> RCU
|
||||
/// </summary>
|
||||
RoomStatusChanged = 0x0C,
|
||||
/// <summary>
|
||||
/// 灯光模式 服务器 -> RCU
|
||||
/// </summary>
|
||||
LightScene = 0x0D,
|
||||
/// <summary>
|
||||
/// 客房状态同步 RCU->服务器
|
||||
/// </summary>
|
||||
RoomStatus = 0x0E,
|
||||
|
||||
/// <summary>
|
||||
/// 新版本的 设备状态
|
||||
/// </summary>
|
||||
NewRoomStatus=0x36,
|
||||
/// <summary>
|
||||
/// 设备控制 服务器 -> RCU
|
||||
/// </summary>
|
||||
DeviceControl = 0xF,
|
||||
/// <summary>
|
||||
/// 设置/取消连通房 服务器 -> RCU
|
||||
/// </summary>
|
||||
ConnectingRoom = 0x10,
|
||||
/// <summary>
|
||||
/// 设置主机网络参数 服务器 -> RCU
|
||||
/// </summary>
|
||||
NetworkSetting = 0x11,
|
||||
/// <summary>
|
||||
/// 服务状态上报及控制
|
||||
/// </summary>
|
||||
Service = 0x12,
|
||||
/// <summary>
|
||||
/// 空调单属性控制
|
||||
/// </summary>
|
||||
AirProperty = 0x13,
|
||||
/// <summary>
|
||||
/// 文字上报:RCU -> 服务器
|
||||
/// </summary>
|
||||
WordsReport = 0x14,
|
||||
/// <summary>
|
||||
/// 电视控制 服务器 -> RCU
|
||||
/// </summary>
|
||||
TvControl = 0x21,
|
||||
/// <summary>
|
||||
/// 主机授权 服务器 -> RCU
|
||||
/// </summary>
|
||||
HostAuthorization = 0x22,
|
||||
/// <summary>
|
||||
/// 窗帘控制 服务器 -> RCU
|
||||
/// </summary>
|
||||
CurtainControl = 0x23,
|
||||
/// <summary>
|
||||
/// 电源控制 服务器 -> RCU
|
||||
/// </summary>
|
||||
PowerSupplyControl = 0x24,
|
||||
/// <summary>
|
||||
/// 开锁 服务器 -> RCU
|
||||
/// </summary>
|
||||
UnlockControl = 0x25,
|
||||
/// <summary>
|
||||
/// 音乐控制 服务器 -> RCU
|
||||
/// </summary>
|
||||
MusicControl = 0x26,
|
||||
/// <summary>
|
||||
/// 设置MAC地址 服务器 -> RCU
|
||||
/// </summary>
|
||||
SetMAC = 0x27,
|
||||
/// <summary>
|
||||
/// 设置设备密钥 服务器 -> RCU
|
||||
/// </summary>
|
||||
SetDeviceSecret = 0x28,
|
||||
/// <summary>
|
||||
/// 获取主机密钥 服务器 <-> RCU
|
||||
/// </summary>
|
||||
GetHostSecret = 0x29,
|
||||
/// <summary>
|
||||
/// tftp升级
|
||||
/// </summary>
|
||||
TFTPUpdate = 0x68,
|
||||
/// <summary>
|
||||
/// ftp升级
|
||||
/// </summary>
|
||||
FTPUpdate = 0x69,
|
||||
/// <summary>
|
||||
/// 读取寄存器信息
|
||||
/// </summary>
|
||||
GetRegister = 0x30,
|
||||
/// <summary>
|
||||
/// 设置寄存器信息
|
||||
/// </summary>
|
||||
SetRegister = 0x31,
|
||||
|
||||
/// <summary>
|
||||
/// 询问房态
|
||||
/// </summary>
|
||||
AskRoomStatus = 0x32,
|
||||
/// <summary>
|
||||
/// 读取主机信息
|
||||
/// </summary>
|
||||
RCUInfo = 0xB1,
|
||||
/// <summary>
|
||||
/// 主机获取指定域名解释的IP
|
||||
/// </summary>
|
||||
ExplainDomainIP = 0xD6,
|
||||
/// <summary>
|
||||
/// 日志服务器域名设置
|
||||
/// </summary>
|
||||
SetRCULog = 0xD9,
|
||||
/// <summary>
|
||||
/// 日志服务信息查询
|
||||
/// </summary>
|
||||
ReceiveRCULog = 0xDA,
|
||||
/// <summary>
|
||||
/// 白天起止时间同步
|
||||
/// </summary>
|
||||
HotelTime = 0xDB,
|
||||
|
||||
/// <summary>
|
||||
/// TFTP_Log
|
||||
/// </summary>
|
||||
TFTPLog = 0xDA,
|
||||
TFTPLog_Setting = 0xD9
|
||||
|
||||
}
|
||||
}
|
||||
23
RCUHost/Protocols/DeviceHeader.cs
Normal file
23
RCUHost/Protocols/DeviceHeader.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct DeviceHeader
|
||||
{
|
||||
/// 目标模块设备, 0是主控器,其它的模块按地址拨码开关
|
||||
public byte NodeAddr;
|
||||
|
||||
/// 命令类型
|
||||
public ushort CmdType;
|
||||
|
||||
/// unsigned char
|
||||
public byte AskAck;
|
||||
|
||||
public HostNumber RoomNumber;
|
||||
}
|
||||
}
|
||||
82
RCUHost/Protocols/DeviceStatus.cs
Normal file
82
RCUHost/Protocols/DeviceStatus.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备
|
||||
/// </summary>
|
||||
public class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
/// <summary>
|
||||
/// 地址类型
|
||||
/// </summary>
|
||||
public AddressType AddressType { get; set; }
|
||||
/// <summary>
|
||||
/// 设备开关状态:1开,2关,6停(窗帘),下发1个字节
|
||||
/// </summary>
|
||||
public byte Status { get; set; }
|
||||
/// <summary>
|
||||
/// 设备开关状态:1开,2关,6停(窗帘),接收2个字节
|
||||
/// </summary>
|
||||
public ushort StatusReceiver { get; set; }
|
||||
/// <summary>
|
||||
/// 亮度值
|
||||
/// </summary>
|
||||
public byte Brightness { get; set; }
|
||||
/// <summary>
|
||||
/// 回路类型
|
||||
/// </summary>
|
||||
public Domain.DeviceType Type { get; set; }
|
||||
/// <summary>
|
||||
/// 温度
|
||||
/// </summary>
|
||||
public byte Temperature { get; set; }
|
||||
/// <summary>
|
||||
/// 风速
|
||||
/// </summary>
|
||||
public byte FanSpeed { get; set; }
|
||||
/// <summary>
|
||||
/// 模式
|
||||
/// </summary>
|
||||
public byte Mode { get; set; }
|
||||
/// <summary>
|
||||
/// 阀门开关
|
||||
/// </summary>
|
||||
public byte Valve { get; set; }
|
||||
/// <summary>
|
||||
/// 空调执行方式和内容
|
||||
/// </summary>
|
||||
public Int32 AirExecMode { get; set; }
|
||||
/// <summary>
|
||||
/// 地暖执行方式和内容
|
||||
/// </summary>
|
||||
public Int32 FloorHotExecMode { get; set; }
|
||||
/// <summary>
|
||||
/// 背景音乐执行方式和内容
|
||||
/// </summary>
|
||||
public Int32 MusicExecMode { get; set; }
|
||||
/// <summary>
|
||||
/// 色温执行方式和内容
|
||||
/// </summary>
|
||||
//public Int32 ColorTempExecMode { get; set; }
|
||||
}
|
||||
|
||||
public enum AddressType
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备地址
|
||||
/// </summary>
|
||||
DeviceAddress = 0,
|
||||
/// <summary>
|
||||
/// 组地址
|
||||
/// </summary>
|
||||
GroupAddress = 1
|
||||
}
|
||||
}
|
||||
84
RCUHost/Protocols/EnergySavingModePacket.cs
Normal file
84
RCUHost/Protocols/EnergySavingModePacket.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 节能模式下发 Packet 服务器 -> RCU
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct EnergySavingModePacket
|
||||
{
|
||||
/// 温度修正值
|
||||
public byte CorrectedTemp;
|
||||
|
||||
/// 到达温度后风机是否保持低速运行
|
||||
public byte FanRunStatus;
|
||||
|
||||
//排风扇状态
|
||||
|
||||
/// 0:关,1:开,2:定时
|
||||
public byte ExhaustFanStatus;
|
||||
|
||||
/// 定时时长(分钟/每小时)
|
||||
public byte ExhaustFanTime;
|
||||
|
||||
|
||||
/// 红外延时断电时间(分)
|
||||
public byte InfraredDelayPO;
|
||||
|
||||
/// 门磁延时断电时间(秒)
|
||||
public ushort DoorDelayPO;
|
||||
|
||||
/// 拔卡延时断电时间(秒)
|
||||
public ushort PullCardDelayPO;
|
||||
|
||||
/// 风机状态
|
||||
/// fengji_status[0]; 插卡时状态
|
||||
/// fengji_status[1]; 拔卡时状态
|
||||
/// fengji_status[2]; 待租时状态
|
||||
/// fengji_status[3]; 停租时状态
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.Struct)]
|
||||
public FengJiStatus[] FengJiStatus;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 风机状态
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential)]
|
||||
public struct FengJiStatus
|
||||
{
|
||||
/// 0:关,1:开
|
||||
public byte OnOff;
|
||||
|
||||
/// 0:手动,1:自动
|
||||
public byte Type;
|
||||
|
||||
/// 0:停止,1:低速,2:中速,3:高速
|
||||
public byte Speed;
|
||||
|
||||
/// 夏季温度
|
||||
public byte SummerTemp;
|
||||
|
||||
/// 冬季温度
|
||||
public byte WinterTemp;
|
||||
|
||||
/// 定时控制,0:否,1:是
|
||||
public byte TimingControl;
|
||||
|
||||
/// 定时时长(分钟/每小时)
|
||||
public byte Timer;
|
||||
|
||||
/// 允许用电,0:否,1:是
|
||||
public byte AllowElectric;
|
||||
}
|
||||
|
||||
}
|
||||
150
RCUHost/Protocols/GroupAddress.cs
Normal file
150
RCUHost/Protocols/GroupAddress.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct GroupAddress
|
||||
{
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public readonly byte[] groupAddress;
|
||||
|
||||
public GroupAddress(byte[] groupAddress)
|
||||
{
|
||||
if (groupAddress != null && groupAddress.Length == 3)
|
||||
{
|
||||
this.groupAddress = groupAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ApplicationException("无效的组地址。");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建一个组地址
|
||||
/// </summary>
|
||||
/// <param name="groupAddress">字符串格式的组地址,如:1.2.3</param>
|
||||
public GroupAddress(string groupAddress)
|
||||
{
|
||||
this.groupAddress = Parse(groupAddress).GetBytes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组地址的字节表示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.groupAddress;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Join(".", groupAddress);
|
||||
}
|
||||
|
||||
public static GroupAddress Parse(string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
{
|
||||
throw new ArgumentNullException("s");
|
||||
}
|
||||
|
||||
byte[] arrGroupAddr = new byte[3] { 0, 0, 0 };
|
||||
|
||||
try
|
||||
{
|
||||
if (s.Count(r => r == '.') != 2)
|
||||
{
|
||||
throw new ApplicationException("组地址必须是以三段点分十进制组成。");
|
||||
}
|
||||
|
||||
arrGroupAddr = s.Split('.').Select(r => Convert.ToByte(r)).ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("无效的组地址(" + s + ")。", ex);
|
||||
}
|
||||
|
||||
return new GroupAddress(arrGroupAddr);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct DeviceAddress
|
||||
{
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public readonly byte[] deviceAddress;
|
||||
|
||||
public DeviceAddress(byte[] deviceAddress)
|
||||
{
|
||||
if (deviceAddress != null && deviceAddress.Length == 4)
|
||||
{
|
||||
this.deviceAddress = deviceAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ApplicationException("无效的设备地址:" + System.Text.Encoding.UTF8.GetString(deviceAddress));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建一个设备地址
|
||||
/// </summary>
|
||||
/// <param name="deviceAddress">字符串格式的设备地址</param>
|
||||
public DeviceAddress(string deviceAddress)
|
||||
{
|
||||
this.deviceAddress = Parse(deviceAddress).GetBytes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备地址的字节表示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.deviceAddress;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
//ushort type = BitConverter.ToUInt16(deviceAddress, 1);
|
||||
//return String.Format("{0:000}{1:000}{2:000}", deviceAddress[0], type, deviceAddress[3]);
|
||||
if (deviceAddress[0] == 0x00)//指令场景地址
|
||||
{
|
||||
return String.Format("{0}.{1}.{2}", deviceAddress[1], deviceAddress[2], deviceAddress[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ushort type = BitConverter.ToUInt16(deviceAddress, 2);
|
||||
return String.Format("{0:000}{1:000}{2:000}", deviceAddress[0], deviceAddress[1], type);
|
||||
}
|
||||
}
|
||||
|
||||
public static DeviceAddress Parse(string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
{
|
||||
throw new ArgumentNullException("s");
|
||||
}
|
||||
byte[] arrDeviceAddr = new byte[4] { 0, 0, 0, 0 };
|
||||
try
|
||||
{
|
||||
arrDeviceAddr[0] = Convert.ToByte(s.Substring(0, 3));
|
||||
arrDeviceAddr[1] = Convert.ToByte(s.Substring(3, 3));
|
||||
byte[] modalType = BitConverter.GetBytes(Convert.ToUInt16(s.Substring(6, 3)));
|
||||
arrDeviceAddr[2] = modalType[0];
|
||||
arrDeviceAddr[3] = modalType[1];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("无效的设备地址。", ex);
|
||||
}
|
||||
|
||||
return new DeviceAddress(arrDeviceAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
RCUHost/Protocols/HeartPacket.cs
Normal file
26
RCUHost/Protocols/HeartPacket.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 心跳 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
|
||||
public struct HeartPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// MAC地址
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6)]
|
||||
public byte[] MAC;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
60
RCUHost/Protocols/HostNumber.cs
Normal file
60
RCUHost/Protocols/HostNumber.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 主机编号(房号)
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct HostNumber
|
||||
{
|
||||
/// <summary>
|
||||
/// 栋
|
||||
/// </summary>
|
||||
public byte NBuild;
|
||||
|
||||
/// <summary>
|
||||
/// 单元
|
||||
/// </summary>
|
||||
public byte NUnit;
|
||||
|
||||
/// <summary>
|
||||
/// 层
|
||||
/// </summary>
|
||||
public byte NFloor;
|
||||
|
||||
/// <summary>
|
||||
/// 房
|
||||
/// </summary>
|
||||
public byte NRoom;
|
||||
|
||||
/// <summary>
|
||||
/// 主机编码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return NBuild.ToString("000") + NUnit.ToString("000") + NFloor.ToString("000") + NRoom.ToString("000");
|
||||
}
|
||||
/// <summary>
|
||||
/// 对应房号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ToRoomNumber()
|
||||
{
|
||||
return NFloor.ToString("000") + NRoom.ToString("000");
|
||||
}
|
||||
/// <summary>
|
||||
/// 酒店编码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Int64 ToHotelCode()
|
||||
{
|
||||
return Convert.ToInt64(Convert.ToInt16(NBuild.ToString("000")) + Convert.ToInt16(NUnit.ToString("000")) * 256);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
RCUHost/Protocols/InsertCardPacket.cs
Normal file
35
RCUHost/Protocols/InsertCardPacket.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 插卡取电 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct InsertCardPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否插卡
|
||||
/// </summary>
|
||||
public byte InsertCard;
|
||||
|
||||
/// <summary>
|
||||
/// 取电卡类型:0无人,1有人,2客人,3服务员,4管理员,5总管,6工程维修
|
||||
/// </summary>
|
||||
public byte CardType;
|
||||
|
||||
/// <summary>
|
||||
/// 取电卡编号
|
||||
/// </summary>
|
||||
public uint CardNumber;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
26
RCUHost/Protocols/LightStatusPacket.cs
Normal file
26
RCUHost/Protocols/LightStatusPacket.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 灯光状态 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct LightStatusPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 灯光状态
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] Status;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
40
RCUHost/Protocols/PowerSupplyPacketReply.cs
Normal file
40
RCUHost/Protocols/PowerSupplyPacketReply.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 控制电源回复 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct PowerSupplyPacketReply
|
||||
{
|
||||
#region Status Const
|
||||
|
||||
/// <summary>
|
||||
/// 电源开启
|
||||
/// </summary>
|
||||
public const byte Open = 0x00;
|
||||
|
||||
/// <summary>
|
||||
/// 电源关闭
|
||||
/// </summary>
|
||||
public const byte Close = 0x01;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public byte Status;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
29
RCUHost/Protocols/RoomStatusChangedPacket.cs
Normal file
29
RCUHost/Protocols/RoomStatusChangedPacket.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 房态变化 Packet服务器 -> RCU
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct RoomStatusChangedPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 房态:
|
||||
/// 待租 => 0x00,
|
||||
/// 已租 => 0x01,
|
||||
/// 已预定 => 0x02,
|
||||
/// 维修 => 0x03
|
||||
/// </summary>
|
||||
public byte Status;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16校验
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
43
RCUHost/Protocols/SearchHostPacket.cs
Normal file
43
RCUHost/Protocols/SearchHostPacket.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 搜索主机 Packet 服务器 -> RCU
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct SearchHostPacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户码
|
||||
/// 用于多用户搜索时区别搜索指令是由哪个用户发出的
|
||||
/// </summary>
|
||||
public int UserCode;
|
||||
|
||||
/// <summary>
|
||||
/// RCU是否保存服务器IP和端口,0/不保存,1/保存
|
||||
/// </summary>
|
||||
public byte IsSave;
|
||||
|
||||
/// <summary>
|
||||
/// 服务器IP
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] IP;
|
||||
|
||||
/// <summary>
|
||||
/// 服务器端口号
|
||||
/// </summary>
|
||||
public ushort Port;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
|
||||
}
|
||||
}
|
||||
60
RCUHost/Protocols/SearchHostPacketReply.cs
Normal file
60
RCUHost/Protocols/SearchHostPacketReply.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 搜索主机 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
|
||||
public struct SearchHostPacketReply
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户码
|
||||
/// </summary>
|
||||
public uint UserCode;
|
||||
|
||||
/// <summary>
|
||||
/// 子网掩码
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] SubnetMask;
|
||||
|
||||
/// <summary>
|
||||
/// 网关
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] Gateway;
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public UInt16 Port;
|
||||
|
||||
/// <summary>
|
||||
/// MAC地址
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 6)]
|
||||
public byte[] MAC;
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 20)]
|
||||
public string Version;
|
||||
|
||||
/// <summary>
|
||||
/// 配置版本号
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
public byte[] ConfigVersion;
|
||||
|
||||
///// <summary>
|
||||
///// CRC16
|
||||
///// </summary>
|
||||
//public ushort CRC;
|
||||
}
|
||||
}
|
||||
48
RCUHost/Protocols/SearchHostPacketReplyV2.cs
Normal file
48
RCUHost/Protocols/SearchHostPacketReplyV2.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 搜索主机 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
|
||||
public struct SearchHostPacketReplyV2
|
||||
{
|
||||
/// <summary>
|
||||
/// DNS:新主机才有
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] DNS;
|
||||
|
||||
/// <summary>
|
||||
/// 房型编号:新主机才有
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string RoomTypeCode;
|
||||
|
||||
/// <summary>
|
||||
/// 房号:新主机才有
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 16)]
|
||||
public string RoomNumber;
|
||||
|
||||
/// <summary>
|
||||
/// 房型ID:新主机才有
|
||||
/// </summary>
|
||||
public int RoomTypeID;
|
||||
|
||||
/// <summary>
|
||||
/// 主机ID:新主机才有
|
||||
/// </summary>
|
||||
public int HostID;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
64
RCUHost/Protocols/SyncTimePacket.cs
Normal file
64
RCUHost/Protocols/SyncTimePacket.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步时间 Packet 服务器 -> RCU
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct SyncTimePacket
|
||||
{
|
||||
/// <summary>
|
||||
/// 年
|
||||
/// </summary>
|
||||
public ushort Year;
|
||||
|
||||
/// <summary>
|
||||
/// 月
|
||||
/// </summary>
|
||||
public byte Month;
|
||||
|
||||
/// <summary>
|
||||
/// 日
|
||||
/// </summary>
|
||||
public byte Day;
|
||||
|
||||
/// <summary>
|
||||
/// 星期(1~7),7代表星期日
|
||||
/// </summary>
|
||||
public byte Week;
|
||||
|
||||
/// <summary>
|
||||
/// 时
|
||||
/// </summary>
|
||||
public byte Hour;
|
||||
|
||||
/// <summary>
|
||||
/// 分
|
||||
/// </summary>
|
||||
public byte Minute;
|
||||
/// <summary>
|
||||
/// 秒
|
||||
/// </summary>
|
||||
public byte Second;
|
||||
|
||||
/// <summary>
|
||||
/// 白天开始时间
|
||||
/// </summary>
|
||||
public byte StartDayTime;
|
||||
|
||||
/// <summary>
|
||||
/// 白天截止时间
|
||||
/// </summary>
|
||||
public byte EndDayTime;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
51
RCUHost/Protocols/SystemHeader.cs
Normal file
51
RCUHost/Protocols/SystemHeader.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
|
||||
public struct SystemHeader
|
||||
{
|
||||
#if SIMON
|
||||
public const string SYSTEM_ID = "T3SA";
|
||||
#else
|
||||
public const string SYSTEM_ID = "TSA1";
|
||||
#endif
|
||||
|
||||
public const ushort SIGNATURE = 0x55AA;
|
||||
|
||||
/// <summary>
|
||||
/// Magic
|
||||
/// </summary>
|
||||
public ushort Signature;
|
||||
|
||||
/// <summary>
|
||||
/// 帧总字节数,包括头部和数据
|
||||
/// </summary>
|
||||
public ushort FrameLength;
|
||||
|
||||
/// <summary>
|
||||
/// 系统标识
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public char[] SystemID;
|
||||
|
||||
/// <summary>
|
||||
/// 指令代码
|
||||
/// </summary>
|
||||
public byte CmdType;
|
||||
|
||||
/// <summary>
|
||||
/// 帧序号
|
||||
/// </summary>
|
||||
public ushort FrameNo;
|
||||
|
||||
/// <summary>
|
||||
/// 主机编号(房号)
|
||||
/// </summary>
|
||||
public HostNumber HostNumber;
|
||||
}
|
||||
}
|
||||
59
RCUHost/Protocols/UpdateConfigPacketReply.cs
Normal file
59
RCUHost/Protocols/UpdateConfigPacketReply.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 升级主机 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct UpdateConfigPacketReply
|
||||
{
|
||||
#region Status Const
|
||||
|
||||
/// <summary>
|
||||
/// 升级就绪
|
||||
/// </summary>
|
||||
public const byte Ready = 0x00;
|
||||
|
||||
/// <summary>
|
||||
/// 升级完成
|
||||
/// </summary>
|
||||
public const byte Completed = 0x01;
|
||||
|
||||
/// <summary>
|
||||
/// 升级出错
|
||||
/// </summary>
|
||||
public const byte Error = 0x02;
|
||||
|
||||
/// <summary>
|
||||
/// 文件块数错误
|
||||
/// </summary>
|
||||
public const byte BlockNumError = 0x03;
|
||||
|
||||
/// <summary>
|
||||
/// 文件类型错误
|
||||
/// </summary>
|
||||
public const byte FileTypeError = 0x04;
|
||||
|
||||
/// <summary>
|
||||
/// 文件MD5错误
|
||||
/// </summary>
|
||||
public const byte FileMD5Error = 0x05;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public byte Status;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
68
RCUHost/Protocols/UpdateHostPacketProgress.cs
Normal file
68
RCUHost/Protocols/UpdateHostPacketProgress.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct UpdateHostPacketProgress
|
||||
{
|
||||
#region Status Const
|
||||
|
||||
/// <summary>
|
||||
/// 升级就绪
|
||||
/// </summary>
|
||||
public const byte Ready = 0x00;
|
||||
|
||||
/// <summary>
|
||||
/// 升级完成
|
||||
/// </summary>
|
||||
public const byte Completed = 0x01;
|
||||
|
||||
/// <summary>
|
||||
/// 升级出错
|
||||
/// </summary>
|
||||
public const byte Error = 0x02;
|
||||
|
||||
/// <summary>
|
||||
/// 文件块数错误
|
||||
/// </summary>
|
||||
public const byte BlockNumError = 0x03;
|
||||
|
||||
/// <summary>
|
||||
/// 文件类型错误
|
||||
/// </summary>
|
||||
public const byte FileTypeError = 0x04;
|
||||
|
||||
/// <summary>
|
||||
/// 文件MD5错误
|
||||
/// </summary>
|
||||
public const byte FileMD5Error = 0x05;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public byte fileType;
|
||||
|
||||
public ushort fileBlockCount;
|
||||
|
||||
public ushort fileCurrentNumber;
|
||||
|
||||
public byte fileNameLen;
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 2)]
|
||||
public string Version;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
70
RCUHost/Protocols/UpdateHostPacketReply.cs
Normal file
70
RCUHost/Protocols/UpdateHostPacketReply.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 升级主机 Packet RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct UpdateHostPacketReply
|
||||
{
|
||||
#region Status Const
|
||||
|
||||
/// <summary>
|
||||
/// 升级就绪
|
||||
/// </summary>
|
||||
public const byte Ready = 0x00;
|
||||
|
||||
/// <summary>
|
||||
/// 升级完成
|
||||
/// </summary>
|
||||
public const byte Completed = 0x01;
|
||||
|
||||
/// <summary>
|
||||
/// 升级出错
|
||||
/// </summary>
|
||||
public const byte Error = 0x02;
|
||||
|
||||
/// <summary>
|
||||
/// 文件块数错误
|
||||
/// </summary>
|
||||
public const byte BlockNumError = 0x03;
|
||||
|
||||
/// <summary>
|
||||
/// 文件类型错误
|
||||
/// </summary>
|
||||
public const byte FileTypeError = 0x04;
|
||||
|
||||
/// <summary>
|
||||
/// 文件MD5错误
|
||||
/// </summary>
|
||||
public const byte FileMD5Error = 0x05;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public byte Status;
|
||||
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 20)]
|
||||
public string Version;
|
||||
|
||||
/// <summary>
|
||||
/// 文件类型
|
||||
/// </summary>
|
||||
public byte FileType;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
26
RCUHost/Protocols/UploadCurrentVersionPacketReply.cs
Normal file
26
RCUHost/Protocols/UploadCurrentVersionPacketReply.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace RCUHost.Protocols
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传RCU软件当前版本号 RCU -> 服务器
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct UploadCurrentVersionPacketReply
|
||||
{
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
[MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 17)]
|
||||
public string Version;
|
||||
|
||||
/// <summary>
|
||||
/// CRC16
|
||||
/// </summary>
|
||||
public ushort CRC;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user