Ejemplo n.º 1
0
        private void CreateSubscription(uint l_objectInstance, BacnetObjectTypes objectType, uint l_device)
        {
            var l_objectId = new BacnetObjectId(objectType, l_objectInstance);

            var l_address = this.GetBacnetAddress(l_device);

            if (l_address == null)
            {
                Debug.WriteLine($"Failed. Client {l_device} not found");
                return;
            }

            this.m_next_subscription_id++;

            m_bacnetClient.SubscribeCOVRequest(l_address, l_objectId, this.m_next_subscription_id, false, false, 160);

            var l_subscriptionKey = l_address + ":" + l_device + ":" + this.m_next_subscription_id;

            var l_subscription = new Subscription(
                m_bacnetClient,
                l_address,
                new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, l_device),
                l_objectId,
                l_subscriptionKey,
                this.m_next_subscription_id);

            this.m_subscription_list.Add(l_subscriptionKey, l_subscription);
        }
Ejemplo n.º 2
0
        private void InitSubscription_Click(object sender, RoutedEventArgs e)
        {
            uint l_device_id = 127001;

            // uint l_device_id = 20205;

            UiLogItem("Start subscription");

            BacnetAddress adr;

            adr = DeviceAddr(l_device_id);
            if (adr == null)
            {
                UiLogItem("Failed. Client not found");
                return;
            }

            // advise to OBJECT_ANALOG_INPUT:1 provided by the device 1026
            var l_objectId = new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_VALUE, 10240);

            //var l_objectId = new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_VALUE, 3);

            bacnet_client.SubscribeCOVRequest(adr, l_objectId, 0, false, false, 160);

            m_next_subscription_id++;
            string sub_key = adr.ToString() + ":" + l_device_id + ":" + m_next_subscription_id;

            var subScriptionObj = new Subscription(bacnet_client, adr, new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, l_device_id), l_objectId, sub_key, m_next_subscription_id);

            m_subscription_list.Add(sub_key, subScriptionObj);
        }
        /// <summary>
        /// Register COV event which we want to get, Here AV is registered for COV notification
        /// </summary>
        /// <param name="fiDeviceID"></param>
        private void RegisterCOVForObjectsOfDevice(Int32 fiDeviceID)
        {
            using (var loESDLutronEntities = new ESDLutronEntities())
            {
                var loBACnetDeviceDetail = loESDLutronEntities.BACnetDevices
                                           .Where(x => x.device_id == fiDeviceID &&
                                                  x.object_instance == (int?)LutronObjectType.Lighting_Level)
                                           .Select(x => x).FirstOrDefault();


                BacnetAddress loBacnetAddress;
                loBacnetAddress = new BacnetAddress(BacnetAddressTypes.IP, loBACnetDeviceDetail.network_id);
                loBacnetAddress.RoutedSource = new BacnetAddress(BacnetAddressTypes.IP, loBACnetDeviceDetail.routed_source, (ushort)loBACnetDeviceDetail.routed_net);

                moBacnetClient.SubscribeCOVRequest(loBacnetAddress, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_VALUE, (uint)loBACnetDeviceDetail.object_instance), 0, false, false, 60);
            }
        }
Ejemplo n.º 4
0
        /*****************************************************************************************************/
        static bool BasicAdviseCOV(uint duration)
        {
            BacnetAddress adr;

            // Looking for the device 1026
            adr = DeviceAddr((uint)1026);
            if (adr == null)
            {
                return(false);              // not found
            }
            bool cancel = false;

            if (duration == 0)
            {
                cancel = true;
            }

            // advise to OBJECT_ANALOG_INPUT:1 provided by the device 1026
            bacnet_client.SubscribeCOVRequest(adr, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_INPUT, 1), 0, cancel, false, duration);

            return(true);
        }