예제 #1
0
        /// <summary>
        /// 返回  请求错误代码的数据域
        /// </summary>
        /// <returns></returns>
        public static byte[] GetData(ushort errorcode)
        {
            byte[]      tempdata;
            List <byte> _tempdata = new List <byte>();

            WriteUnit.AddUshortToList(_tempdata, errorcode);
            tempdata = _tempdata.ToArray <byte>();
            return(tempdata);
        }
예제 #2
0
파일: GetFileInfo.cs 프로젝트: athree/YSP
        /// <summary>
        /// 组包中获取数据域字节数组
        /// </summary>
        /// <param name="para">发送摘要</param>
        /// <param name="subtype">包子类型,用于区分getdata调用哪些</param>
        /// <returns></returns>
        public static byte[] GetData(GetFileInfo.Parameter para, byte subtype)
        {
            byte[] tempdata;

            List <byte> _tempdata = new List <byte>();

            switch (subtype)
            {
            //按日期范围查询数据文件名及文件大小
            case (byte)MSGEncoding.GetFileInfo.GetFileByRange:
            {
                long start = TimerTick.TimeSpanToSecond(para.starttime);
                long stop  = TimerTick.TimeSpanToSecond(para.endtime);
                WriteUnit.AddTimeToList(_tempdata, start);
                WriteUnit.AddTimeToList(_tempdata, stop);
                break;
            }

            //查询离指定日期最近的x个数据文件名及文件大小
            case (byte)MSGEncoding.GetFileInfo.GetXFileByLately:
            {
                long time = TimerTick.TimeSpanToSecond(para.timepoint);
                WriteUnit.AddTimeToList(_tempdata, time);
                WriteUnit.AddUshortToList(_tempdata, para.filenum);
                break;
            }

            //取得配置文件名称(=更新时间)及文件大小
            case (byte)MSGEncoding.GetFileInfo.GetcfgFile:
            {
                //发送内容为空,通过包类型及子类型截取
                break;
            }

            default:
            {
                //MessageBox.Show("文件信息查询子类消息编号超出范围!");
                break;
            }
            }
            tempdata = _tempdata.ToArray <byte>();
            return(tempdata);
        }