コード例 #1
0
ファイル: Client.cs プロジェクト: fanzcsoft/bacstack
        /// <summary>
        /// Extracts an array of read results from a read property multiple ack
        /// </summary>
        /// <param name="ack">The read propety multiple ack</param>
        /// <returns>The array of read results</returns>
        private ReadAccessResult.ReadResultType[] _extractReadResults(ReadPropertyMultipleAck ack)
        {
            List <ReadAccessResult.ReadResultType> values = new List <ReadAccessResult.ReadResultType>();

            foreach (var results in ack.ListOfReadAccessResults)
            {
                if (!results.ListOfResults.HasValue)
                {
                    continue;
                }

                foreach (var result in results.ListOfResults.Value)
                {
                    if (result.ReadResult.IsPropertyAccessError &&
                        result.ReadResult.AsPropertyAccessError.ErrorCode == Error.ErrorCodeType.UnknownProperty)
                    {
                        // for optional properties, we handle a non-existing properties
                        // with a Option<T> instance with no value, rather than an error
                        // code
                        values.Add(ReadAccessResult.ReadResultType.NewPropertyValue(
                                       TaggedGenericValue.Empty));
                    }
                    else
                    {
                        values.Add(result.ReadResult);
                    }
                }
            }

            return(values.ToArray());
        }
コード例 #2
0
        public void ReceivedReadPropertyMultipleAck(BacNetRawMessage msg)
        {
            ReadPropertyMultipleAck apdu;

            try
            {
                apdu = new ReadPropertyMultipleAck(msg.Apdu);
            }
            catch (Exception ex)
            {
                _logger.WarnException("Malformed ReadPropertyMultipleAck: ", ex);
                BacNetDevice.Instance.Waiter = new List <BacNetObject>();
                return;
            }
            if (BacNetDevice.Instance.Waiter is int && Convert.ToInt32(BacNetDevice.Instance.Waiter) == apdu.InvokeId)
            {
                if (apdu.ObjectList == null)
                {
                    _logger.Warn("Received empty object list");
                }
                BacNetDevice.Instance.Waiter = apdu.ObjectList;
            }

            //RpmE
            BacNetDevice.Instance.Services.Confirmed.RpmCallBack(apdu.InvokeId, apdu.ObjectList);
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: fanzcsoft/bacstack
        /// <summary>
        /// Extracts the array of generic values from a read property multiple ack
        /// </summary>
        /// <param name="ack">The read property multiple ack</param>
        /// <returns>The array of generic values</returns>
        private GenericValue[] _extractValues(ReadPropertyMultipleAck ack)
        {
            List <GenericValue> values = new List <GenericValue>();

            foreach (var results in ack.ListOfReadAccessResults)
            {
                if (!results.ListOfResults.HasValue)
                {
                    continue;
                }

                foreach (var result in results.ListOfResults.Value)
                {
                    var readResult = result.ReadResult;
                    if (readResult.IsPropertyValue)
                    {
                        values.Add(readResult.AsPropertyValue);
                    }
                }
            }
            return(values.ToArray());
        }