Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="device"></param>
        /// <param name="received"></param>
        /// <returns></returns>
        public override IParseResult OnParseReceivedBytes(IDevice device, byte[] received)
        {
            IParseResult pr = this.ReceiveParts.ToValues(received);

            if (pr.IsSuccess)
            {
                // has address data field
                //
                KeyValue addressKV  = pr.Results.Find(ADDRESS);
                bool     hasAddress = addressKV != null;
                if (hasAddress)
                {
                    // match address
                    //
                    object addressObject = pr.Results[ADDRESS];
                    if (addressObject != null)
                    {
                        UInt64 address = Convert.ToUInt64(addressObject);
                        if (address != device.Address)
                        {
                            pr = new AddressErrorResult(device.Address, address);
                        }
                    }
                }
            }

            return(pr);
        }
Example #2
0
File: Opera.cs Project: hkiaipc/C3
        /// <summary>
        /// 
        /// </summary>
        /// <param name="device"></param>
        /// <param name="received"></param>
        /// <returns></returns>
        public override IParseResult OnParseReceivedBytes(IDevice device, byte[] received)
        {
            IParseResult pr = this.ReceiveParts.ToValues(received);

            if (pr.IsSuccess)
            {
                // has address data field
                //
                KeyValue addressKV = pr.Results.Find(ADDRESS);
                bool hasAddress = addressKV != null;
                if (hasAddress)
                {
                    // match address
                    //
                    object addressObject = pr.Results[ADDRESS];
                    if (addressObject != null)
                    {
                        UInt64 address = Convert.ToUInt64(addressObject);
                        if (address != device.Address)
                        {
                            pr = new AddressErrorResult(device.Address, address);
                        }
                    }
                }
            }

            return pr;
        }