Exemplo n.º 1
0
        public void ReceiveAction(DataPackage pkgData)
        {
            //收到启动应答【采集器→主机】
            Struct_TempHumi tempHumi = new Struct_TempHumi();

            byte[] dataBuffer = pkgData.PureData;
            using (MemoryStream ms = new MemoryStream(dataBuffer))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    curDataLen = br.ReadInt32();            //图像数据总长度,为 0 表示图像采集失败
                    tempHumi.Buffer = br.ReadBytes(4);      //温湿度数据
                    curStatus_ctl = br.ReadByte();          //输出开关量状态
                    curRecNo = br.ReadByte();               //图像记录号,用于读取记录。
                    br.ReadInt16();                         //保留字节

                }
            }

            if (curDataLen > 0)
            {
                //读取文件数据, 发送读取数据的命令

                //创建数据存储文件
                curFileName = string.Format("Image_{0}.jpg", DateTime.Now.ToString("yyyyMMdd_HHmmss"));
                curStream = new FileStream(curFileName, FileMode.Create, FileAccess.Write);
                curBinaryWriter = new BinaryWriter(curStream);
                curReadbytes = 0;

                ResetProgress();

                SendDataRead(curRecNo, 0);
            }
        }
Exemplo n.º 2
0
 public DeviceStatusItem()
 {
     Time = new Struct_Clock();
     TH = new Struct_TempHumi();
     detailList = null;
     detailInfoDict = null;
 }
Exemplo n.º 3
0
        void Test()
        {
            //Struct_Clock clock = new Struct_Clock();
            //clock.Year = 2014;
            //clock.Month = 9;
            //clock.Date = 24;
            //clock.Hour = 10;
            //clock.Minute = 30;
            //clock.Second = 05;
            //byte[] buffer = clock.Buffer;

            //byte[] tmpBuffer = new byte[buffer.Length];
            //Array.Copy(buffer, tmpBuffer, tmpBuffer.Length);
            //Struct_Clock c1 = new Struct_Clock();
            //c1.Buffer = tmpBuffer;

            //--------------------------------------------

            DataPackage pkgData = new DataPackage();
            pkgData.CtrlHead.CE_ID = 0;
            pkgData.CtrlHead.CMD_ID = HCCommand.IMAGE_START;

            using (MemoryStream ms = new MemoryStream())
            {
                using (BinaryWriter bw = new BinaryWriter(ms))
                {
                    Struct_TempHumi tempHumi = new Struct_TempHumi();
                    tempHumi.Humi_V = 1;
                    tempHumi.Temp_S = 2;
                    tempHumi.Temp_V = 3;
                    tempHumi.R = 4;

                    int imageLen = 1024;
                    byte status_ctl = 0x3B;
                    byte recNo = 0x01;
                    bw.Write(imageLen);
                    bw.Write(tempHumi.Buffer);
                    bw.Write(status_ctl);
                    bw.Write(recNo);
                    bw.Write((short)0);

                }
                pkgData.PureData = ms.ToArray();
            }

            pkgData.Pack();
            SendData(pkgData);

            //--------------------------------------------

            //StartCapture();
        }