/// <summary> /// 上传升级文件到设备 /// </summary> /// <param name="destid"></param> /// <param name="data"></param> /// <returns></returns> public static byte[] UpGradeFile(byte destid, WriteFile.Parameter para) { byte[] donedata; byte[] tempdata = GetData(para, (int)FileType.UpGradeFile); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.WriteFile; _frame.msgSubType = (byte)MSGEncoding.WriteFile.UpGradeFile; _frame.dataLen = (ushort)tempdata.Length; donedata = PrepareData.MergeMsg(ref _frame, tempdata); return(donedata); }
/// <summary> /// LoopBack测试一般只会用在文件传输上,指定的文件的内容通过CRC校验可以确保是否一样 /// 无须按字节对比,或者equal 还是字节对比快 /// </summary> /// <param name="destid"></param> /// <param name="testlen"></param> /// <returns></returns> public static byte[] LoopTest(byte destid, ushort testlen) { byte[] donedata; byte[] data = GetData(testlen); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.ReadBuffer; _frame.msgSubType = (byte)MSGEncoding.ReadBuffer.ReadCO2Cache; _frame.dataLen = (ushort)data.Length; donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
/// <summary> /// 向设备查询Error Code的详细解释 /// 通过该功能,主机可向设备查询每个Error Code的详细英文解释。 /// !!!注意:一次请求只能查询一个error code的解释。 /// </summary> /// <param name="destid"></param> /// <param name="data"></param> /// <returns></returns> public static byte[] ExplainError(byte destid, ushort error) { byte [] donedata; byte[] data = GetData(error); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.GetErrorInfo; _frame.msgSubType = (byte)MSGEncoding.Other.GetErrorInfo; _frame.dataLen = (ushort)data.Length; donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
/// <summary> /// 读取指定配置文件,从x位置开始的n个字节数据 /// </summary> /// <param name="destid"></param> /// <param name="data"></param> /// <returns></returns> public static byte[] ReadDataFile(byte destid, ReadFile.Parameter para) { byte[] donedata; byte[] data = GetData(para); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.ReadFile; _frame.msgSubType = (byte)MSGEncoding.ReadFile.ReadDataFile; _frame.dataLen = (ushort)data.Length; donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
/// <summary> /// 查询设备状态 /// </summary> /// <param name="destid"></param> /// <param name="data"></param> /// <returns></returns> public static byte[] GetDevStatus(byte destid, ushort[] unit) { byte[] donedata; byte[] data = GetData(unit); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.ReadUnit; _frame.msgSubType = (byte)MSGEncoding.ReadUint.GetDevStatus; _frame.dataLen = (ushort)data.Length; donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
//写数据 public static byte[] WriteData(byte destid, Dictionary <string, string> datadict) { byte[] donedata; byte[] data = GetData(datadict); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.WriteUnit; _frame.msgSubType = (byte)MSGEncoding.WriteUint.WriteData; _frame.dataLen = (ushort)data.Length; donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
//重载 public static byte[] ControlDev(byte destid, Dictionary <ushort, object> datadict) { byte[] donedata; byte[] data = GetData(datadict); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.WriteUnit; _frame.msgSubType = (byte)MSGEncoding.WriteUint.ControlDev; _frame.dataLen = (ushort)data.Length; //长短包的区分和数据组合在MergeMsg()方法中完成 donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
/// <summary> /// 取得配置文件名称(=最新更新时间)及文件大小 /// </summary> /// <param name="destid"></param> /// <param name="data"></param> /// <returns></returns> public static byte[] GetXFileByLately(byte destid, GetFileInfo.Parameter para) { byte[] donedata; byte subtype = (byte)MSGEncoding.GetFileInfo.GetXFileByLately; byte[] data = GetFileInfo.GetData(para, subtype); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.GetFileInfo; _frame.msgSubType = (byte)MSGEncoding.GetFileInfo.GetXFileByLately; _frame.dataLen = (ushort)data.Length; donedata = PrepareData.MergeMsg(ref _frame, data); return(donedata); }
/// <summary> /// 上传数据文件到设备 /// </summary> /// <param name="destid"></param> /// <param name="data"></param> /// <returns></returns> public static byte[] UpcfgToDev(byte destid, WriteFile.Parameter para) { byte[] donedata; //由于结构体中普通文件和升级文件的名字都会给出,通过getdata的第二参数标定,为0为普通文件(数据和配置) //不再讨论文件类别,只给出编号,相应的文件以包装进类中 //恢复文件类型标准,由于para和fileitem死循环产生 byte[] tempdata = GetData(para, (int)FileType.CfgOrDataFile); PrepareData.Msg_Bus _frame = new PrepareData.Msg_Bus(); _frame.flag = PrepareData.BUS_FRAME_FLAG; _frame.srcID = MSGEncoding.srcID; _frame.destID = destid; _frame.msgDir = (byte)MSGEncoding.MsgDir.Request; _frame.msgVer = MSGEncoding.msgVer; _frame.msgType = (byte)MSGEncoding.MsgType.WriteFile; _frame.msgSubType = (byte)MSGEncoding.WriteFile.UpcfgToDev; _frame.dataLen = (ushort)tempdata.Length; donedata = PrepareData.MergeMsg(ref _frame, tempdata); return(donedata); }