示例#1
0
        /// <summary>发送数据</summary>
        /// <param name="pv">通讯协议对象</param>
        /// <param name="ispush">是否推送</param>
        public void SendData(ProtocolVo pv, bool ispush)
        {
            var protocol  = new Protocol(pv);
            var send_data = protocol.AFMData();

            Send(send_data, 0, send_data.Length); //发送数据
            if (ispush)
            {
                PushData();          //推送数据
            }
            // CommandEnd(pv.moduleNumber, pv.commandNumber);
        }
示例#2
0
        /// <summary>组建发送协议</summary>
        /// <param name="aso">协议数据</param>
        protected byte[] Build(ASObject aso)
        {
            //组装发送数据
            var pv = new ProtocolVo
            {
                status           = 0,
                sendTime         = 30000,
                serialNumber     = 1,
                verificationCode = 1,
                serverTime       = DateTime.Now.Ticks,
                moduleNumber     = MN,          //模块号
                commandNumber    = (Int32)CN,   //指令号
                data             = aso,
            };

            var protocol = new Protocol(pv);

            return(protocol.AFMData());
        }