Пример #1
0
        private Property FindProperty(BacnetObjectId object_id, BacnetPropertyIds property_id)
        {
            //liniear search
            Object obj = FindObject(object_id);

            return(FindProperty(obj, property_id));
        }
Пример #2
0
 public BacnetDeviceObjectPropertyReference(BacnetObjectId objectIdentifier, BacnetPropertyIds propertyIdentifier, BacnetObjectId?deviceIndentifier = null, uint arrayIndex = ASN1.BACNET_ARRAY_ALL)
 {
     this.objectIdentifier   = objectIdentifier;
     this.propertyIdentifier = propertyIdentifier;
     this.arrayIndex         = arrayIndex;
     this.deviceIndentifier  = deviceIndentifier ?? new BacnetObjectId(BacnetObjectTypes.MAX_BACNET_OBJECT_TYPE, 0);
 }
Пример #3
0
 // Managed in BacnetActivity.cs, for COV notification to client
 public void ExternalCOVManagement(BacnetPropertyIds propId)
 {
     if (OnExternalCOVNotify != null)
     {
         OnExternalCOVNotify(this, propId);
     }
 }
Пример #4
0
        public Property FindProperty(BacnetObjectId objectId, BacnetPropertyIds propertyId)
        {
            //liniear search
            var obj = FindObject(objectId);

            return(FindProperty(obj, propertyId));
        }
Пример #5
0
        private void Initialize(BACnetObject bno, BacnetPropertyIds property_id)
        {
            this.BacnetObject     = bno;
            this.BacnetPropertyId = property_id;        //this is how these are indexed within the object

            this.Id = (Int32)property_id;
            SetName();
        }
Пример #6
0
        public BACnetProperty(BACnetObject bno, BacnetPropertyIds property_id)
        {
            Initialize(bno, property_id);
            ReadValue();
            ParseValue();

            //if (property_value = null)
            //    ReadProperty();
        }
Пример #7
0
        public static bool Has(this IList <BacnetPropertyValue> propertyValues, BacnetPropertyIds propertyId)
        {
            if (propertyValues.All(v => v.property.GetPropertyId() != propertyId))
            {
                return(false);
            }

            return(propertyValues
                   .Where(v => v.property.GetPropertyId() == propertyId)
                   .Any(v => !v.value.HasError()));
        }
Пример #8
0
        private static void OnWritePropertyRequest(BacnetClient sender, BacnetAddress adr, byte invoke_id, BacnetObjectId object_id, BacnetPropertyValue value, BacnetMaxSegments max_segments)
        {
            BacnetPropertyIds PropId = (BacnetPropertyIds)value.property.propertyIdentifier;

            bool AllowWrite =
                (object_id.Equals("OBJECT_ANALOG_VALUE:0") && (PropId == BacnetPropertyIds.PROP_OUT_OF_SERVICE)) ||
                (object_id.Equals("OBJECT_ANALOG_VALUE:0") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_ANALOG_VALUE:1") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_ANALOG_VALUE:2") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_ANALOG_VALUE:3") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_CHARACTERSTRING_VALUE:1") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_CHARACTERSTRING_VALUE:2") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_CHARACTERSTRING_VALUE:3") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE)) ||
                (object_id.Equals("OBJECT_MULTI_STATE_VALUE:0") && (PropId == BacnetPropertyIds.PROP_PRESENT_VALUE));

            if (AllowWrite == false)
            {
                sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_WRITE_ACCESS_DENIED);
                return;
            }

            lock (m_lockObject)
            {
                try
                {
                    // Modif FC

                    DeviceStorage.ErrorCodes code = m_storage.WriteCommandableProperty(object_id, (BacnetPropertyIds)value.property.propertyIdentifier, value.value[0], value.priority);

                    if (code == DeviceStorage.ErrorCodes.NotForMe)
                    {
                        code = m_storage.WriteProperty(object_id, (BacnetPropertyIds)value.property.propertyIdentifier, value.property.propertyArrayIndex, value.value);
                    }

                    if (code == DeviceStorage.ErrorCodes.Good)
                    {
                        sender.SimpleAckResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id);
                    }
                    else
                    if (code == DeviceStorage.ErrorCodes.WriteAccessDenied)
                    {
                        sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_WRITE_ACCESS_DENIED);
                    }
                    else
                    {
                        sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_OTHER);
                    }
                }
                catch (Exception)
                {
                    sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_OTHER);
                }
            }
        }
Пример #9
0
        public ErrorCodes ReadProperty(BacnetObjectId object_id, BacnetPropertyIds property_id, uint array_index, out IList <BacnetValue> value)
        {
            value = new BacnetValue[0];

            //wildcard device_id
            if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance >= System.IO.BACnet.Serialize.ASN1.BACNET_MAX_INSTANCE)
            {
                object_id.instance = DeviceId;
            }

            //overrides
            bool       handled;
            ErrorCodes status;

            if (ReadOverride != null)
            {
                ReadOverride(object_id, property_id, array_index, out value, out status, out handled);
                if (handled)
                {
                    return(status);
                }
            }

            //By thamersalek : find Object in storage
            Object Obj1 = FindObject(object_id);

            if (Obj1 == null)
            {
                return(ErrorCodes.UnKnownObject);
            }
            //Object found now find property
            Property p = FindProperty(object_id, property_id);

            if (p == null)
            {
                return(ErrorCodes.NotExist);
            }

            //get value ... check for array index
            if (array_index == 0)
            {
                value = new BacnetValue[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT, (uint)p.BacnetValue.Count) };
            }
            else if (array_index != System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL)
            {
                value = new BacnetValue[] { p.BacnetValue[(int)array_index - 1] };
            }
            else
            {
                value = p.BacnetValue;
            }

            return(ErrorCodes.Good);
        }
Пример #10
0
 private BacnetValue ReadScalarValue(BacnetAddress adr, BacnetObjectId oid,
                                     BacnetPropertyIds pid, byte invokeId = 0, uint arrayIndex = uint.MaxValue)
 {
     try
     {
         BacnetValue NoScalarValue = Bacnet_client.ReadPropertyRequest(adr, oid, pid, arrayIndex);
         return(NoScalarValue);
     }
     catch (Exception ex)
     {
         Log("Err:" + ex.Message);
     }
     return(new BacnetValue());
 }
Пример #11
0
 public BacnetDeviceObjectPropertyReference(BacnetObjectId objectIdentifier, BacnetPropertyIds propertyIdentifier, BacnetObjectId?deviceIndentifier = null, UInt32 arrayIndex = ASN1.BACNET_ARRAY_ALL)
 {
     this.objectIdentifier   = objectIdentifier;
     this.propertyIdentifier = propertyIdentifier;
     this.arrayIndex         = arrayIndex;
     if (deviceIndentifier != null)
     {
         this.deviceIndentifier = deviceIndentifier.Value;
     }
     else
     {
         this.deviceIndentifier = new BacnetObjectId(BacnetObjectTypes.MAX_BACNET_OBJECT_TYPE, 0);
     }
 }
Пример #12
0
 private Property FindProperty(Object obj, BacnetPropertyIds property_id)
 {
     //liniear search
     if (obj != null)
     {
         foreach (Property p in obj.Properties)
         {
             if (p.Id == property_id)
             {
                 return(p);
             }
         }
     }
     return(null);
 }
Пример #13
0
 IList <BacnetValue> ReadScalarValue(BacnetAddress adr, BacnetObjectId oid,
                                     BacnetPropertyIds pid, byte invokeId = 0, uint arrayIndex = uint.MaxValue)
 {
     try
     {
         IList <BacnetValue> NoScalarValue;
         var rst = Bacnet_client.ReadPropertyRequest(adr, oid, pid, out NoScalarValue, invokeId, arrayIndex);
         if (!rst)
         {
             return(null);
         }
         return(NoScalarValue);
     }
     catch { }
     return(null);
 }
Пример #14
0
        //private void AddProperty(BacnetPropertyIds id)
        //{
        //    //var id = BacnetPropertyIds.PROP_OBJECT_IDENTIFIER;
        //    //var val = new BacnetValue(object_id);
        //    var prop = new BACnetProperty(this, id);    //don't know the value, so query device after property instantiation.
        //    var kvp = new KeyValuePair<BacnetPropertyIds, BACnetProperty>(id, prop);


        //    if (BACnetObject.RequiredPropertyIds.Contains(id))
        //        this.RequiredProperties[id] = prop;
        //    else
        //        Properties.Add(kvp);


        //}



        private void AddProperty(BacnetPropertyIds id)
        {
            if (!BACnetObject.SupportedPropertyIds.Contains(id))        //make this better later
            {
                return;
            }

            //var bpv = new BacnetPropertyValue();


            var prop = new BACnetProperty(this, id);

            addProp(id, prop);

            //AddProperty(id, new BacnetValue(null));     //setting this to null means we still need to read the property.
        }
Пример #15
0
        public int ReadPropertyValue(BacnetObjectId objectId, BacnetPropertyIds propertyId)
        {
            IList <BacnetValue> value;

            if (ReadProperty(objectId, propertyId, Serialize.ASN1.BACNET_ARRAY_ALL, out value) != ErrorCodes.Good)
            {
                return(0);
            }

            if (value == null || value.Count < 1)
            {
                return(0);
            }

            return((int)Convert.ChangeType(value[0].Value, typeof(int)));
        }
Пример #16
0
        //public Boolean TryGetBacnetProperty(BacnetObjectId boi, out BACnetProperty bnp)
        //{
        //    bnp = null;
        //    foreach (var kvp in BacnetProperties)
        //    {
        //        if (kvp.Key.Equals(boi))
        //        {
        //            bo = kvp.Value;
        //            return true;
        //        }
        //    }
        //    return false;
        //}



        public BACnetProperty GetBacnetProperty(BacnetPropertyIds bpi, Boolean bypassRefresh = false)
        {
            if (!AllPropertiesFetched && !bypassRefresh)
            {
                FetchProperties();
            }

            foreach (var kvp in BacnetProperties)
            {
                BacnetPropertyIds thisPropId = kvp.Key;
                if (thisPropId == bpi)
                {
                    return(kvp.Value);
                }
            }
            return(null);
        }
Пример #17
0
        private static string GetNiceName(BacnetPropertyIds property)
        {
            string name = property.ToString();

            if (name.StartsWith("PROP_"))
            {
                name = name.Substring(5);
                name = name.Replace('_', ' ');
                name = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(name.ToLower());
            }
            else
            {
                //name = "Proprietary (" + property.ToString() + ")";
                name = property.ToString() + " - Proprietary";
            }
            return(name);
        }
Пример #18
0
        public ErrorCodes ReadProperty(BacnetObjectId objectId, BacnetPropertyIds propertyId, uint arrayIndex, out IList <BacnetValue> value)
        {
            value = new BacnetValue[0];

            //wildcard device_id
            if (objectId.type == BacnetObjectTypes.OBJECT_DEVICE && objectId.instance >= Serialize.ASN1.BACNET_MAX_INSTANCE)
            {
                objectId.instance = DeviceId;
            }

            //overrides
            if (ReadOverride != null)
            {
                ErrorCodes status;
                bool       handled;
                ReadOverride(objectId, propertyId, arrayIndex, out value, out status, out handled);
                if (handled)
                {
                    return(status);
                }
            }

            //find in storage
            var p = FindProperty(objectId, propertyId);

            if (p == null)
            {
                return(ErrorCodes.NotExist);
            }

            //get value ... check for array index
            if (arrayIndex == 0)
            {
                value = new[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT, (uint)p.BacnetValue.Count) };
            }
            else if (arrayIndex != Serialize.ASN1.BACNET_ARRAY_ALL)
            {
                value = new[] { p.BacnetValue[(int)arrayIndex - 1] };
            }
            else
            {
                value = p.BacnetValue;
            }

            return(ErrorCodes.Good);
        }
Пример #19
0
        public void WritePropertyValue(BacnetObjectId object_id, BacnetPropertyIds property_id, int value)
        {
            IList <BacnetValue> read_values;

            //get existing type
            if (ReadProperty(object_id, property_id, System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL, out read_values) != ErrorCodes.Good)
            {
                return;
            }
            if (read_values == null || read_values.Count == 0)
            {
                return;
            }

            //write
            BacnetValue[] write_values = new BacnetValue[] { new BacnetValue(read_values[0].Tag, Convert.ChangeType(value, read_values[0].Value.GetType())) };
            WriteProperty(object_id, property_id, System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL, write_values);
        }
        /*****************************************************************************************************/
        static bool WriteScalarValue(int device_id, BacnetObjectId BacnetObjet, BacnetPropertyIds Propriete, BacnetValue Value)
        {
            BacnetAddress adr;

            // Looking for the device
            adr = DeviceAddr((uint)device_id);
            if (adr == null)
            {
                return(false);              // not found
            }
            // Property Write
            BacnetValue[] NoScalarValue = { Value };
            if (bacnet_client.WritePropertyRequest(adr, BacnetObjet, Propriete, NoScalarValue) == false)
            {
                return(false);
            }

            return(true);
        }
        /*****************************************************************************************************/
        static void handler_OnCOVManagementNotify(BaCSharpObject sender, BacnetPropertyIds propId)
        {
            System.Threading.ThreadPool.QueueUserWorkItem((o) =>
            {
                lock (device)
                {
                    //remove old leftovers
                    SubscriptionManager.RemoveOldSubscriptions();

                    //find subscription
                    List <Subscription> subs = SubscriptionManager.GetSubscriptionsForObject(sender.PROP_OBJECT_IDENTIFIER);

                    if (subs == null)
                    {
                        return;             // nobody
                    }
                    //Read the property
                    IList <BacnetValue> value;
                    BacnetPropertyReference br = new BacnetPropertyReference((uint)propId, (uint)System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL);
                    ErrorCodes error           = sender.ReadPropertyValue(br, out value);

                    List <BacnetPropertyValue> values = new List <BacnetPropertyValue>();
                    BacnetPropertyValue tmp           = new BacnetPropertyValue();
                    tmp.value    = value;
                    tmp.property = br;
                    values.Add(tmp);

                    //send to all
                    foreach (Subscription sub in subs)
                    {
                        if (sub.monitoredProperty.propertyIdentifier == (uint)BacnetPropertyIds.PROP_ALL || sub.monitoredProperty.propertyIdentifier == (uint)propId)
                        {
                            tmp.property = sub.monitoredProperty;
                            if (!sub.reciever.Notify(sub.reciever_address, sub.subscriberProcessIdentifier, deviceId, sub.monitoredObjectIdentifier, (uint)sub.GetTimeRemaining(), sub.issueConfirmedNotifications, values))
                            {
                                SubscriptionManager.RemoveReceiver(sub.reciever_address);
                            }
                        }
                    }
                }
            }, null);
        }
Пример #22
0
        private void addProp(BacnetPropertyIds id, BACnetProperty prop)
        {
            if (!BACnetObject.SupportedPropertyIds.Contains(id))
            {
                return;
            }


            //Console.WriteLine("Read property: " + id.ToString() + " (value: " + prop.ValueString() + ")");

            if (id == BacnetPropertyIds.PROP_PRESENT_VALUE)
            {
                Console.WriteLine(this.BacnetObjectId + ": present value = " + prop.ValueString());
            }


            var kvp = new KeyValuePair <BacnetPropertyIds, BACnetProperty>(id, prop);

            BacnetProperties.Add(kvp);
        }
        /*****************************************************************************************************/
        static bool ReadScalarValue(int device_id, BacnetObjectId BacnetObjet, BacnetPropertyIds Propriete, out BacnetValue Value)
        {
            BacnetAddress       adr;
            IList <BacnetValue> NoScalarValue;

            Value = new BacnetValue(null);

            // Looking for the device
            adr = DeviceAddr((uint)device_id);
            if (adr == null)
            {
                return(false);              // not found
            }
            // Property Read
            if (bacnet_client.ReadPropertyRequest(adr, BacnetObjet, Propriete, out NoScalarValue) == false)
            {
                return(false);
            }

            Value = NoScalarValue[0];
            return(true);
        }
        /*****************************************************************************************************/
        static bool WriteScalarValue(int device_id, BacnetObjectId BacnetObjet, BacnetPropertyIds Propriete, BacnetValue Value)
        {
            BacnetAddress adr;

            // Looking for the device
            adr = DeviceAddr((uint)device_id);
            if (adr == null) return false;  // not found

            // Property Write
            BacnetValue[] NoScalarValue = { Value };
            if (bacnet_client.WritePropertyRequest(adr, BacnetObjet, Propriete, NoScalarValue) == false)
                return false;

            return true;
        }
        /*****************************************************************************************************/
        static bool ReadScalarValue(int device_id, BacnetObjectId BacnetObjet, BacnetPropertyIds Propriete, out BacnetValue Value)
        {
            BacnetAddress adr;
            IList<BacnetValue> NoScalarValue;

            Value = new BacnetValue(null);

            // Looking for the device
            adr = DeviceAddr((uint)device_id);
            if (adr == null) return false;  // not found

            // Property Read
            if (bacnet_client.ReadPropertyRequest(adr, BacnetObjet, Propriete, out NoScalarValue) == false)
                return false;

            Value = NoScalarValue[0];
            return true;
        }
Пример #26
0
 private static Property FindProperty(Object obj, BacnetPropertyIds propertyId)
 {
     //liniear search
     return(obj?.Properties.FirstOrDefault(p => p.Id == propertyId));
 }
Пример #27
0
 public bool WritePropertyRequest(BacnetAddress adr, BacnetObjectId object_id, BacnetPropertyIds property_id, IEnumerable<BacnetValue> value_list, byte invoke_id = 0)
 {
     using (BacnetAsyncResult result = (BacnetAsyncResult)BeginWritePropertyRequest(adr, object_id, property_id, value_list, true, invoke_id))
     {
         for (int r = 0; r < m_retries; r++)
         {
             if (result.WaitForDone(m_timeout))
             {
                 Exception ex;
                 EndWritePropertyRequest(result, out ex);
                 if (ex != null) throw ex;
                 else return true;
             }
             result.Resend();
         }
     }
     value_list = null;
     return false;
 }
Пример #28
0
        // Fc
        public IAsyncResult BeginRawEncodedDecodedPropertyConfirmedRequest(BacnetAddress adr, BacnetObjectId object_id, BacnetPropertyIds property_id, BacnetConfirmedServices service_id, byte[] InOutBuffer, bool wait_for_transmit, byte invoke_id = 0)
        {
            Trace.WriteLine("Sending RawEncodedRequest ... ", null);
            if (invoke_id == 0) invoke_id = unchecked(m_invoke_id++);

            EncodeBuffer b = GetEncodeBuffer(m_client.HeaderLength);
            NPDU.Encode(b, BacnetNpduControls.PriorityNormalMessage | BacnetNpduControls.ExpectingReply, adr.RoutedSource, null, DEFAULT_HOP_COUNT, BacnetNetworkMessageTypes.NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, 0);
            APDU.EncodeConfirmedServiceRequest(b, BacnetPduTypes.PDU_TYPE_CONFIRMED_SERVICE_REQUEST | (m_max_segments != BacnetMaxSegments.MAX_SEG0 ? BacnetPduTypes.SEGMENTED_RESPONSE_ACCEPTED : 0), service_id , m_max_segments, m_client.MaxAdpuLength, invoke_id, 0, 0);

            ASN1.encode_context_object_id(b, 0, object_id.type, object_id.instance);
            ASN1.encode_context_enumerated(b, 1, (byte)property_id);

            // No content encoding to do
            if (InOutBuffer!=null)
                b.Add(InOutBuffer, InOutBuffer.Length);

            //send
            BacnetAsyncResult ret = new BacnetAsyncResult(this, adr, invoke_id, b.buffer, b.offset - m_client.HeaderLength, wait_for_transmit, m_transmit_timeout);
            ret.Resend();

            return ret;
        }
Пример #29
0
        // Write PROP_PRESENT_VALUE or PROP_RELINQUISH_DEFAULT in an object with a 16 level PROP_PRIORITY_ARRAY (BACNET_APPLICATION_TAG_NULL)
        public ErrorCodes WriteCommandableProperty(BacnetObjectId object_id, BacnetPropertyIds property_id, BacnetValue value, uint priority)
        {
            if (!(property_id == BacnetPropertyIds.PROP_PRESENT_VALUE))
            {
                return(DeviceStorage.ErrorCodes.NotForMe);
            }

            Property p_presentvalue = FindProperty(object_id, BacnetPropertyIds.PROP_PRESENT_VALUE);

            if (p_presentvalue == null)
            {
                return(DeviceStorage.ErrorCodes.NotForMe);
            }

            Property p_relinquish = FindProperty(object_id, BacnetPropertyIds.PROP_RELINQUISH_DEFAULT);

            if (p_relinquish == null)
            {
                return(DeviceStorage.ErrorCodes.NotForMe);
            }

            Property p_outofservice = FindProperty(object_id, BacnetPropertyIds.PROP_OUT_OF_SERVICE);

            if (p_outofservice == null)
            {
                return(DeviceStorage.ErrorCodes.NotForMe);
            }

            Property p_array = FindProperty(object_id, BacnetPropertyIds.PROP_PRIORITY_ARRAY);

            if (p_array == null)
            {
                return(DeviceStorage.ErrorCodes.NotForMe);
            }

            DeviceStorage.ErrorCodes errorcode = DeviceStorage.ErrorCodes.GenericError;

            try
            {
                // If PROP_OUT_OF_SERVICE=True, value is accepted as is : http://www.bacnetwiki.com/wiki/index.php?title=Priority_Array
                if (((bool)p_outofservice.BacnetValue[0].Value == true) && (property_id == BacnetPropertyIds.PROP_PRESENT_VALUE))
                {
                    p_presentvalue.BacnetValue = new BacnetValue[1] {
                        value
                    };
                    return(DeviceStorage.ErrorCodes.Good);
                }

                IList <BacnetValue> valueArray = null;

                // Thank's to Steve Karg
                // The 135-2016 text:
                // 19.2.2 Application Priority Assignments
                // All commandable objects within a device shall be configurable to accept writes to all priorities except priority 6
                if (priority == 6)
                {
                    return(DeviceStorage.ErrorCodes.WriteAccessDenied);
                }

                //
                //http://www.chipkin.com/changing-the-bacnet-present-value-or-why-the-present-value-doesn%E2%80%99t-change/
                //
                // Write Property PROP_PRESENT_VALUE : A value is placed in the PROP_PRIORITY_ARRAY
                if (property_id == BacnetPropertyIds.PROP_PRESENT_VALUE)
                {
                    errorcode = DeviceStorage.ErrorCodes.Good;

                    valueArray = p_array.BacnetValue;
                    if (value.Value == null)
                    {
                        valueArray[(int)priority - 1] = new BacnetValue(null);
                    }
                    else
                    {
                        valueArray[(int)priority - 1] = value;
                    }
                    p_array.BacnetValue = valueArray;
                }

                // Look on the priority Array to find the first value to be set in PROP_PRESENT_VALUE
                if (errorcode == DeviceStorage.ErrorCodes.Good)
                {
                    bool done = false;
                    for (int i = 0; i < 16; i++)
                    {
                        if (valueArray[i].Value != null)    // A value is OK
                        {
                            p_presentvalue.BacnetValue = new BacnetValue[1] {
                                valueArray[i]
                            };

                            done = true;
                            break;
                        }
                    }
                    if (done == false)  // Nothing in the array : PROP_PRESENT_VALUE = PROP_RELINQUISH_DEFAULT
                    {
                        IList <BacnetValue> DefaultValue = p_relinquish.BacnetValue;
                        p_presentvalue.BacnetValue = DefaultValue;
                    }
                }
            }
            catch
            {
                errorcode = DeviceStorage.ErrorCodes.GenericError;
            }

            return(errorcode);
        }
Пример #30
0
        public bool ReadScalarValue(int deviceId, BacnetObjectId bacnetObjet, BacnetPropertyIds property,
            out BacnetValue value)
        {
            lock (this)
            {
                IList<BacnetValue> noScalarValue;

                value = new BacnetValue(null);

                // Looking for the device
                var adr = DeviceAddr((uint) deviceId);
                if (adr == null) return false; // not found

                // Property Read
                if (_bacnetClient.ReadPropertyRequest(adr, bacnetObjet, property, out noScalarValue) == false)
                    return false;

                value = noScalarValue[0];
                return true;
            }
        }
Пример #31
0
 // Fc
 // Read or Write without APDU Data encoding nor Decoding (just Request type, Object id and Property id)
 // Data is given by the caller starting with the Tag 3 (or maybe another one), and ending with it
 // return buffer start also with the Tag 3
 public bool RawEncodedDecodedPropertyConfirmedRequest(BacnetAddress adr, BacnetObjectId object_id, BacnetPropertyIds property_id, BacnetConfirmedServices service_id, ref byte[] InOutBuffer, byte invoke_id = 0)
 {
     using (BacnetAsyncResult result = (BacnetAsyncResult)BeginRawEncodedDecodedPropertyConfirmedRequest(adr, object_id, property_id, service_id, InOutBuffer, true, invoke_id))
     {
         for (int r = 0; r < m_retries; r++)
         {
             if (result.WaitForDone(m_timeout))
             {
                 Exception ex;
                 EndRawEncodedDecodedPropertyConfirmedRequest(result, service_id, out InOutBuffer, out ex);
                 if (ex != null) throw ex;
                 else return true;
             }
             result.Resend();
         }
     }
     InOutBuffer = null;
     return false;
 }
Пример #32
0
 public bool ReadPropertyRequest(BacnetAddress adr, BacnetObjectId object_id, BacnetPropertyIds property_id, out IList<BacnetValue> value_list, byte invoke_id = 0, uint array_index = ASN1.BACNET_ARRAY_ALL)
 {
     using (BacnetAsyncResult result = (BacnetAsyncResult)BeginReadPropertyRequest(adr, object_id, property_id, true, invoke_id, array_index))
     {
         for (int r = 0; r < m_retries; r++)
         {
             if (result.WaitForDone(m_timeout))
             {
                 Exception ex;
                 EndReadPropertyRequest(result, out value_list, out ex);
                 if (ex != null) throw ex;
                 else return true;
             }
             result.Resend();
         }
     }
     value_list = null;
     return false;
 }
Пример #33
0
        public ErrorCodes WriteProperty(BacnetObjectId objectId, BacnetPropertyIds propertyId, uint arrayIndex, IList <BacnetValue> value, bool addIfNotExits = false)
        {
            //wildcard device_id
            if (objectId.type == BacnetObjectTypes.OBJECT_DEVICE && objectId.instance >= Serialize.ASN1.BACNET_MAX_INSTANCE)
            {
                objectId.instance = DeviceId;
            }

            //overrides
            if (WriteOverride != null)
            {
                bool       handled;
                ErrorCodes status;
                WriteOverride(objectId, propertyId, arrayIndex, value, out status, out handled);
                if (handled)
                {
                    return(status);
                }
            }

            //find
            var p = FindProperty(objectId, propertyId);

            if (p == null)
            {
                if (!addIfNotExits)
                {
                    return(ErrorCodes.NotExist);
                }

                //add obj
                var obj = FindObject(objectId);
                if (obj == null)
                {
                    obj = new Object
                    {
                        Type     = objectId.type,
                        Instance = objectId.instance
                    };
                    var arr = Objects;
                    Array.Resize(ref arr, arr.Length + 1);
                    arr[arr.Length - 1] = obj;
                    Objects             = arr;
                }

                //add property
                p = new Property {
                    Id = propertyId
                };
                var props = obj.Properties;
                Array.Resize(ref props, props.Length + 1);
                props[props.Length - 1] = p;
                obj.Properties          = props;
            }

            //set type if needed
            if (p.Tag == BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL && value != null)
            {
                foreach (var v in value)
                {
                    if (v.Tag == BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL)
                    {
                        continue;
                    }

                    p.Tag = v.Tag;
                    break;
                }
            }

            //write
            p.BacnetValue = value;

            //send event ... for subscriptions
            ChangeOfValue?.Invoke(this, objectId, propertyId, arrayIndex, value);

            return(ErrorCodes.Good);
        }
Пример #34
0
        public bool WriteScalarValue(int deviceId, BacnetObjectId bacnetObjet, BacnetPropertyIds property,
            BacnetValue value)
        {
            lock (this)
            {
                if (!WriteProtectionEnabled || CurrentNumberOfWrites < Settings.Default.MaxNumberOfWritesPer24h)
                {

                    // Looking for the device
                    var adr = DeviceAddr((uint) deviceId);
                    if (adr == null) return false; // not found

                    Logger.Debug($"WriteScalarValue(): {bacnetObjet.Instance} = {value}");

                    bool retValue = _bacnetClient.WritePropertyRequest(adr, bacnetObjet, property, new[] {value});
                    CurrentNumberOfWrites++;
                    ValuesChanged?.Invoke();
                    return retValue;
                }
                Logger.Error(
                    $"WriteScalarValue(): Number of Writes per 24h exceeded. Change the number MaxNumberOfWritesPer24h if requried.");
                return false;
            }
        }
Пример #35
0
        // Ici les remplacement de la lecture de quelques élements
        private static void m_storage_ReadOverride(BacnetObjectId object_id, BacnetPropertyIds property_id, uint array_index, out IList <BacnetValue> value, out DeviceStorage.ErrorCodes status, out bool handled)
        {
            handled = true;
            value   = new BacnetValue[0];
            status  = DeviceStorage.ErrorCodes.Good;


            if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && property_id == BacnetPropertyIds.PROP_OBJECT_LIST)
            {
                if (array_index == 0)
                {
                    //object list count
                    value = new BacnetValue[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT, (uint)m_storage.Objects.Length) };
                }
                else if (array_index != System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL)
                {
                    //object list index
                    value = new BacnetValue[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_OBJECT_ID, new BacnetObjectId(m_storage.Objects[array_index - 1].Type, m_storage.Objects[array_index - 1].Instance)) };
                }
                else
                {
                    //object list whole
                    BacnetValue[] list = new BacnetValue[m_storage.Objects.Length];
                    for (int i = 0; i < list.Length; i++)
                    {
                        list[i].Tag   = BacnetApplicationTags.BACNET_APPLICATION_TAG_OBJECT_ID;
                        list[i].Value = new BacnetObjectId(m_storage.Objects[i].Type, m_storage.Objects[i].Instance);
                    }
                    value = list;
                }
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance == m_storage.DeviceId && property_id == BacnetPropertyIds.PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED)
            {
                BacnetValue v = new BacnetValue();
                v.Tag = BacnetApplicationTags.BACNET_APPLICATION_TAG_BIT_STRING;
                BacnetBitString b = new BacnetBitString();
                b.SetBit((byte)BacnetObjectTypes.MAX_ASHRAE_OBJECT_TYPE, false); //set all false
                b.SetBit((byte)BacnetObjectTypes.OBJECT_ANALOG_INPUT, true);
                b.SetBit((byte)BacnetObjectTypes.OBJECT_DEVICE, true);
                b.SetBit((byte)BacnetObjectTypes.OBJECT_ANALOG_VALUE, true);
                b.SetBit((byte)BacnetObjectTypes.OBJECT_CHARACTERSTRING_VALUE, true);
                b.SetBit((byte)BacnetObjectTypes.OBJECT_MULTI_STATE_VALUE, true);
                b.SetBit((byte)BacnetObjectTypes.OBJECT_BINARY_VALUE, true);
                v.Value = b;
                value   = new BacnetValue[] { v };
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance == m_storage.DeviceId && property_id == BacnetPropertyIds.PROP_PROTOCOL_SERVICES_SUPPORTED)
            {
                BacnetValue v = new BacnetValue();
                v.Tag = BacnetApplicationTags.BACNET_APPLICATION_TAG_BIT_STRING;
                BacnetBitString b = new BacnetBitString();
                b.SetBit((byte)BacnetServicesSupported.MAX_BACNET_SERVICES_SUPPORTED, false); //set all false
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_SUBSCRIBE_COV, true);

                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_I_AM, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_WHO_IS, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_READ_PROP_MULTIPLE, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_READ_PROPERTY, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_WRITE_PROPERTY, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_CONFIRMED_COV_NOTIFICATION, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_UNCONFIRMED_COV_NOTIFICATION, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_SUBSCRIBE_COV_PROPERTY, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_REINITIALIZE_DEVICE, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_DEVICE_COMMUNICATION_CONTROL, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_TIME_SYNCHRONIZATION, true);
                b.SetBit((byte)BacnetServicesSupported.SERVICE_SUPPORTED_UTC_TIME_SYNCHRONIZATION, true);
                v.Value = b;
                value   = new BacnetValue[] { v };
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance == m_storage.DeviceId && property_id == BacnetPropertyIds.PROP_SEGMENTATION_SUPPORTED)
            {
                BacnetValue v = new BacnetValue();
                v.Tag   = BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED;
                v.Value = (uint)BacnetSegmentations.SEGMENTATION_BOTH;
                value   = new BacnetValue[] { v };
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance == m_storage.DeviceId && property_id == BacnetPropertyIds.PROP_SYSTEM_STATUS)
            {
                BacnetValue v = new BacnetValue();
                v.Tag   = BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED;
                v.Value = (uint)BacnetDeviceStatus.OPERATIONAL;      //can we be in any other mode I wonder?
                value   = new BacnetValue[] { v };
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance == m_storage.DeviceId && property_id == BacnetPropertyIds.PROP_ACTIVE_COV_SUBSCRIPTIONS)
            {
                List <BacnetValue> list = new List <BacnetValue>();
                foreach (KeyValuePair <BacnetObjectId, List <Subscription> > entry in m_subscriptions)
                {
                    foreach (Subscription sub in entry.Value)
                    {
                        //encode
                        System.IO.BACnet.Serialize.EncodeBuffer buffer = new System.IO.BACnet.Serialize.EncodeBuffer();
                        BacnetCOVSubscription cov = new BacnetCOVSubscription();
                        cov.Recipient = sub.reciever_address;
                        cov.subscriptionProcessIdentifier = sub.subscriberProcessIdentifier;
                        cov.monitoredObjectIdentifier     = sub.monitoredObjectIdentifier;
                        cov.monitoredProperty             = sub.monitoredProperty;
                        cov.IssueConfirmedNotifications   = sub.issueConfirmedNotifications;
                        cov.TimeRemaining = (uint)sub.lifetime - (uint)(DateTime.Now - sub.start).TotalMinutes;
                        cov.COVIncrement  = sub.covIncrement;
                        System.IO.BACnet.Serialize.ASN1.encode_cov_subscription(buffer, cov);

                        //add
                        BacnetValue v = new BacnetValue();
                        v.Tag   = BacnetApplicationTags.BACNET_APPLICATION_TAG_COV_SUBSCRIPTION;
                        v.Value = buffer.ToArray();
                        list.Add(v);
                    }
                }
                value = list;
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_OCTETSTRING_VALUE && object_id.instance == 0 && property_id == BacnetPropertyIds.PROP_PRESENT_VALUE)
            {
                //this is our huge blob
                BacnetValue v = new BacnetValue();
                v.Tag = BacnetApplicationTags.BACNET_APPLICATION_TAG_OCTET_STRING;
                byte[] blob = new byte[2000];
                for (int i = 0; i < blob.Length; i++)
                {
                    blob[i] = (i % 2 == 0) ? (byte)'A' : (byte)'B';
                }
                v.Value = blob;
                value   = new BacnetValue[] { v };
            }
            else if (object_id.type == BacnetObjectTypes.OBJECT_GROUP && property_id == BacnetPropertyIds.PROP_PRESENT_VALUE)
            {
                //get property list
                IList <BacnetValue> properties;
                if (m_storage.ReadProperty(object_id, BacnetPropertyIds.PROP_LIST_OF_GROUP_MEMBERS, System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL, out properties) != DeviceStorage.ErrorCodes.Good)
                {
                    value = new BacnetValue[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ERROR, new BacnetError(BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_INTERNAL_ERROR)) };
                }
                else
                {
                    List <BacnetValue> _value = new List <BacnetValue>();
                    foreach (BacnetValue p in properties)
                    {
                        if (p.Value is BacnetReadAccessSpecification)
                        {
                            BacnetReadAccessSpecification prop   = (BacnetReadAccessSpecification)p.Value;
                            BacnetReadAccessResult        result = new BacnetReadAccessResult();
                            result.objectIdentifier = prop.objectIdentifier;
                            List <BacnetPropertyValue> result_values = new List <BacnetPropertyValue>();
                            foreach (BacnetPropertyReference r in prop.propertyReferences)
                            {
                                BacnetPropertyValue prop_value = new BacnetPropertyValue();
                                prop_value.property = r;
                                if (m_storage.ReadProperty(prop.objectIdentifier, (BacnetPropertyIds)r.propertyIdentifier, r.propertyArrayIndex, out prop_value.value) != DeviceStorage.ErrorCodes.Good)
                                {
                                    prop_value.value = new BacnetValue[] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ERROR, new BacnetError(BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_INTERNAL_ERROR)) };
                                }
                                result_values.Add(prop_value);
                            }
                            result.values = result_values;
                            _value.Add(new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_READ_ACCESS_RESULT, result));
                        }
                    }
                    value = _value;
                }
            }
            else
            {
                handled = false;
            }
        }
Пример #36
0
        public ErrorCodes WriteProperty(BacnetObjectId object_id, BacnetPropertyIds property_id, uint array_index, IList <BacnetValue> value, bool add_if_not_exits = false)
        {
            //wildcard device_id
            if (object_id.type == BacnetObjectTypes.OBJECT_DEVICE && object_id.instance >= System.IO.BACnet.Serialize.ASN1.BACNET_MAX_INSTANCE)
            {
                object_id.instance = DeviceId;
            }

            //overrides
            bool       handled;
            ErrorCodes status;

            if (WriteOverride != null)
            {
                WriteOverride(object_id, property_id, array_index, value, out status, out handled);
                if (handled)
                {
                    return(status);
                }
            }

            //find
            Property p = FindProperty(object_id, property_id);

            if (p == null)
            {
                if (!add_if_not_exits)
                {
                    return(ErrorCodes.NotExist);
                }

                //add obj
                Object obj = FindObject(object_id);
                if (obj == null)
                {
                    obj          = new Object();
                    obj.Type     = object_id.type;
                    obj.Instance = object_id.instance;
                    Object[] arr = Objects;
                    Array.Resize <Object>(ref arr, arr.Length + 1);
                    arr[arr.Length - 1] = obj;
                    Objects             = arr;
                }

                //add property
                p    = new Property();
                p.Id = property_id;
                Property[] props = obj.Properties;
                Array.Resize <Property>(ref props, props.Length + 1);
                props[props.Length - 1] = p;
                obj.Properties          = props;
            }

            //set type if needed
            if (p.Tag == BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL && value != null)
            {
                foreach (BacnetValue v in value)
                {
                    if (v.Tag != BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL)
                    {
                        p.Tag = v.Tag;
                        break;
                    }
                }
            }

            //write
            p.BacnetValue = value;

            //send event ... for subscriptions
            if (ChangeOfValue != null)
            {
                ChangeOfValue(this, object_id, property_id, array_index, value);
            }

            return(ErrorCodes.Good);
        }
        /// <summary>
        /// Temporary method
        /// </summary>
        /// <param name="fiDeviceID"></param>
        /// <param name="foBacnetObjectId"></param>
        /// <param name="foBacnetPropertyIds"></param>
        /// <param name="foBacnetValue"></param>
        /// <returns></returns>
        static bool WriteScalarValue(int fiDeviceID, BacnetObjectId foBacnetObjectId, BacnetPropertyIds foBacnetPropertyIds, BacnetValue foBacnetValue)
        {
            using (var loESDLutronEntities = new ESDLutronEntities())
            {
                var loBACnetDeviceDetail = loESDLutronEntities.BACnetDevices
                                           .Where(x => x.device_id == fiDeviceID &&
                                                  x.object_instance == (int?)LutronObjectType.Lighting_State)
                                           .Select(x => x).FirstOrDefault();


                BacnetAddress adr;

                //// Looking for the device
                adr = new BacnetAddress(BacnetAddressTypes.IP, loBACnetDeviceDetail.network_id);
                if (adr == null)
                {
                    return(false);              // not found
                }
                adr.RoutedSource = new BacnetAddress(BacnetAddressTypes.IP, loBACnetDeviceDetail.routed_source, (ushort)loBACnetDeviceDetail.routed_net);

                //// Property Write


                IList <BacnetValue> NoScalarValue;
                moBacnetClient.ReadPropertyRequest(adr, foBacnetObjectId, foBacnetPropertyIds, out NoScalarValue);

                //var loWirteList = NoScalarValue.ToList();
                //loWirteList[0].Value = 5;

                //NoScalarValue[0].Value = 5;
                //List<BacnetValue> loWriteValue = new List<BacnetValue>();
                //loWriteValue.Add(new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_REAL, 5));

                BacnetValue   loBacnetNewValue = new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_REAL, Convert.ToSingle(foBacnetValue.Value));
                BacnetValue[] loWriteValue     = { loBacnetNewValue };

                moBacnetClient.WritePropertyRequest(adr, foBacnetObjectId, foBacnetPropertyIds, loWriteValue);

                return(true);
            }
        }
Пример #38
0
        private static void m_storage_ChangeOfValue(DeviceStorage sender, BacnetObjectId object_id, BacnetPropertyIds property_id, uint array_index, IList <BacnetValue> value)
        {
            System.Threading.ThreadPool.QueueUserWorkItem((o) =>
            {
                lock (m_lockObject)
                {
                    //remove old leftovers
                    RemoveOldSubscriptions();

                    //find subscription
                    if (!m_subscriptions.ContainsKey(object_id))
                    {
                        return;
                    }
                    List <Subscription> subs = m_subscriptions[object_id];

                    //convert
                    List <BacnetPropertyValue> values = new List <BacnetPropertyValue>();
                    BacnetPropertyValue tmp           = new BacnetPropertyValue();
                    tmp.property = new BacnetPropertyReference((uint)property_id, array_index);
                    tmp.value    = value;
                    values.Add(tmp);

                    //send to all
                    foreach (Subscription sub in subs)
                    {
                        if (sub.monitoredProperty.propertyIdentifier == (uint)BacnetPropertyIds.PROP_ALL || sub.monitoredProperty.propertyIdentifier == (uint)property_id)
                        {
                            //send notify
                            if (!sub.reciever.Notify(sub.reciever_address, sub.subscriberProcessIdentifier, m_storage.DeviceId, sub.monitoredObjectIdentifier, (uint)sub.GetTimeRemaining(), sub.issueConfirmedNotifications, values))
                            {
                                Trace.TraceError("Couldn't send notify");
                            }
                        }
                    }
                }
            }, null);
        }
Пример #39
0
        public IAsyncResult BeginWritePropertyRequest(BacnetAddress adr, BacnetObjectId object_id, BacnetPropertyIds property_id, IEnumerable<BacnetValue> value_list, bool wait_for_transmit, byte invoke_id = 0)
        {
            Trace.WriteLine("Sending WritePropertyRequest ... ", null);
            if (invoke_id == 0) invoke_id = unchecked(m_invoke_id++);

            EncodeBuffer b = GetEncodeBuffer(m_client.HeaderLength);
            NPDU.Encode(b, BacnetNpduControls.PriorityNormalMessage, adr.RoutedSource, null, DEFAULT_HOP_COUNT, BacnetNetworkMessageTypes.NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, 0);
            APDU.EncodeConfirmedServiceRequest(b, BacnetPduTypes.PDU_TYPE_CONFIRMED_SERVICE_REQUEST | (m_max_segments != BacnetMaxSegments.MAX_SEG0 ? BacnetPduTypes.SEGMENTED_RESPONSE_ACCEPTED : 0), BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, m_max_segments, m_client.MaxAdpuLength, invoke_id, 0, 0);
            Services.EncodeWriteProperty(b, object_id, (uint)property_id, ASN1.BACNET_ARRAY_ALL, m_writepriority, value_list);

            //send
            BacnetAsyncResult ret = new BacnetAsyncResult(this, adr, invoke_id, b.buffer, b.offset - m_client.HeaderLength, wait_for_transmit, m_transmit_timeout);
            ret.Resend();

            return ret;
        }