Exemplo n.º 1
0
        public bool ReadPropertyAll(BacnetObjectId objectId, out IList <BacnetPropertyValue> values)
        {
            //find
            var obj = FindObject(objectId);

            if (obj == null)
            {
                values = null;
                return(false);
            }

            //build
            var propertyValues = new BacnetPropertyValue[obj.Properties.Length];

            for (var i = 0; i < obj.Properties.Length; i++)
            {
                var newEntry = new BacnetPropertyValue
                {
                    property = new BacnetPropertyReference((uint)obj.Properties[i].Id, Serialize.ASN1.BACNET_ARRAY_ALL)
                };

                if (ReadProperty(objectId, obj.Properties[i].Id, Serialize.ASN1.BACNET_ARRAY_ALL, out newEntry.value) != ErrorCodes.Good)
                {
                    var bacnetError = new BacnetError(BacnetErrorClasses.ERROR_CLASS_OBJECT, BacnetErrorCodes.ERROR_CODE_UNKNOWN_PROPERTY);
                    newEntry.value = new[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ERROR, bacnetError) };
                }

                propertyValues[i] = newEntry;
            }

            values = propertyValues;
            return(true);
        }
Exemplo n.º 2
0
        public void ReadPropertyMultiple(BacnetObjectId object_id, ICollection <BacnetPropertyReference> properties, out IList <BacnetPropertyValue> values)
        {
            var valuesRet = new List <BacnetPropertyValue>();

            foreach (var entry in properties)
            {
                var newEntry = new BacnetPropertyValue {
                    property = entry
                };
                if (ReadProperty(object_id, (BacnetPropertyIds)entry.propertyIdentifier, entry.propertyArrayIndex, out newEntry.value) != ErrorCodes.Good)
                {
                    var bacnetError = new BacnetError(BacnetErrorClasses.ERROR_CLASS_OBJECT, BacnetErrorCodes.ERROR_CODE_UNKNOWN_PROPERTY);
                    newEntry.value = new[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ERROR, bacnetError) };
                }

                valuesRet.Add(newEntry);
            }

            values = valuesRet;
        }