Example #1
0
        /*****************************************************************************************************/
        /* This is the objective of this sample !                                                            */
        /*****************************************************************************************************/
        static void handler_OnEventNotify(BacnetClient sender, BacnetAddress adr, byte invoke_id, BacnetEventNotificationData EventData, bool need_confirm)
        {
            string val;

            // if event enrollment dispaly which datapoint is being watched
            if (EventData.eventObjectIdentifier.type == BacnetObjectTypes.OBJECT_EVENT_ENROLLMENT)
            {
                IList <BacnetValue> values;
                sender.ReadPropertyRequest(adr, EventData.eventObjectIdentifier, BacnetPropertyIds.PROP_OBJECT_PROPERTY_REFERENCE, out values);

                BacnetDeviceObjectPropertyReference obj = (BacnetDeviceObjectPropertyReference)values[0].Value;
                val = adr.ToString() + ":" + EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance + ":" + EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance + " object Type : " + obj.objectIdentifier.type + " object Instance :" + obj.objectIdentifier.instance + " object Property :" + obj.propertyIdentifier;
            }
            else
            {
                val = adr.ToString() + ":" + EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance + ":" + EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance;
            }

            if (need_confirm)
            {
                sender.SimpleAckResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_EVENT_NOTIFICATION, invoke_id);
            }

            // Just to show how Acknowledgement can be programmed. Never Ack an alarm like this without tested the source, the reason, ... and normally with a human action
            if (EventData.ackRequired)
            {
                sender.AlarmAcknowledgement(adr, EventData.eventObjectIdentifier, EventData.toState, "Alarmlistener", EventData.timeStamp, new BacnetGenericTime(DateTime.Now, BacnetTimestampTags.TIME_STAMP_DATETIME));
            }


            Console.WriteLine(val + " " + EventData.fromState + " to " + EventData.toState + " " + EventData.notifyType.ToString());
        }
Example #2
0
        void RunReadAll()
        {
            Application.UseWaitCursor = true;

            // Gets all elements concerning the selected device into the DeviceTree
            // and optionnaly the object into the AddressSpaceTree treeview
            // return false if objId is not OK (but got the value ANALOG:0 !)
            // BacnetClient & BacnetAddress could be null if nothing is selected into the DeviceTree

            // a lot of Error in the Trace due to Read property not existing, remove listerner, then add it back
            TraceListener trace = Trace.Listeners[1];

            Trace.Listeners.Remove(Trace.Listeners[1].Name);

            try
            {
                yabeFrm.GetObjectLink(out client, out adr, out objId, BacnetObjectTypes.MAX_BACNET_OBJECT_TYPE);
                Devicename.Text = adr.ToString();

                CheckAllObjects(yabeFrm.m_AddressSpaceTree.Nodes);
                EmptyList.Visible = IsEmpty;
            }
            catch
            { }

            Trace.Listeners.Add(trace);

            treeView1.ExpandAll();

            Application.UseWaitCursor = false;
        }
Example #3
0
        /*****************************************************************************************************/
        /* This is the objective of this sample !                                                            */
        /*****************************************************************************************************/
        static void handler_OnEventNotify(BacnetClient sender, BacnetAddress adr, byte invoke_id, BacnetEventNotificationData EventData, bool need_confirm)
        {
            string val = adr.ToString() + ":" + EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance + ":" + EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance;

            if (need_confirm)
            {
                sender.SimpleAckResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_EVENT_NOTIFICATION, invoke_id);
            }

            Console.WriteLine(val + " " + EventData.fromState + " to " + EventData.toState + " " + EventData.notifyType.ToString());
        }
        /// <summary>
        /// alarm event handler to perform task basis on event state changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="adr"></param>
        /// <param name="EventData"></param>
        public void handler_OnEventNotify(BacnetClient sender, BacnetAddress adr, BacnetEventNotificationData EventData)
        {
            string val = adr.ToString() + ":" + EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance + ":" + EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance;

            Console.WriteLine(val + " " + EventData.fromState + " to " + EventData.toState + " " + EventData.notifyType.ToString());

            string lsDeviceDetail   = EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance;
            string lsInstanceDetail = EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance;
            string lsEventState     = EventData.fromState + " to " + EventData.toState;

            AlarmEventChangesToUI(lsDeviceDetail, lsInstanceDetail, lsEventState);
        }
        public RecipientUserCtrl(TabPage myTab, DeviceReportingRecipient?recipient = null)
        {
            InitializeComponent();
            this.myTab = myTab;

            if (recipient == null)
            {
                for (byte i = 0; i < 7; i++)
                {
                    WeekOfDay.SetBit(i, true);
                }
                for (byte i = 0; i < 3; i++)
                {
                    EventType.SetBit(i, true);
                }
                return;
            }

            if (recipient.Value.adr != null)
            {
                adr         = recipient.Value.adr;
                Device.Text = adr.ToString();
            }
            else
            {
                deviceid    = recipient.Value.Id.instance;
                Device.Text = deviceid.ToString();
            }

            AckRequired.Checked = recipient.Value.Ack_Required;
            ProcessId.Text      = recipient.Value.processIdentifier.ToString();

            WeekOfDay = recipient.Value.WeekofDay;
            // dispatch the days
            Monday.Checked    = ((WeekOfDay.value[0] & 1) == 1);
            Tuesday.Checked   = ((WeekOfDay.value[0] & 2) == 2);
            Wedesnday.Checked = ((WeekOfDay.value[0] & 4) == 4);
            Thursday.Checked  = ((WeekOfDay.value[0] & 8) == 8);
            Friday.Checked    = ((WeekOfDay.value[0] & 16) == 16);
            Saturday.Checked  = ((WeekOfDay.value[0] & 32) == 32);
            Sunday.Checked    = ((WeekOfDay.value[0] & 64) == 64);

            EventType = recipient.Value.evenType;
            // dispatch the event types
            To_OffNormal.Checked = ((EventType.value[0] & 1) == 1);
            To_Fault.Checked     = ((EventType.value[0] & 2) == 2);
            To_Normal.Checked    = ((EventType.value[0] & 4) == 4);

            // Some problems when date is 0 in the original values (readed for the device)
            // so toTime.Value=toTime cannot be done
            toTime.Value   = new DateTime(2000, 1, 1, recipient.Value.toTime.Hour, recipient.Value.toTime.Minute, recipient.Value.toTime.Second);
            fromTime.Value = new DateTime(2000, 1, 1, recipient.Value.fromTime.Hour, recipient.Value.fromTime.Minute, recipient.Value.fromTime.Second);
        }
Example #6
0
        public BBMDEditor(BacnetClient comm, BacnetAddress adr)
        {
            InitializeComponent();

            DataGridViewCellStyle dgv = new DataGridViewCellStyle();

            dgv.Alignment = DataGridViewContentAlignment.MiddleCenter;

            BBMDTable.ColumnHeadersDefaultCellStyle = FDRTable.ColumnHeadersDefaultCellStyle = dgv;

            transport = (BacnetIpUdpProtocolTransport)comm.Transport;
            BBMDep    = new IPEndPoint(System.Net.IPAddress.Parse(adr.ToString().Split(':')[0]), Convert.ToInt32(adr.ToString().Split(':')[1]));

            transport.Bvlc.MessageReceived += new System.IO.BACnet.Serialize.BVLC.BVLCMessageReceiveHandler(Bvlc_MessageReceived);
        }
        private void bacnet_client_OnIam(BacnetClient sender, BacnetAddress adr, uint device_id, uint max_apdu, BacnetSegmentations segmentation, ushort vendor_id)
        {
            this.Invoke((MethodInvoker) delegate
            {
                ListViewItem itm = m_list.Items.Add(adr.ToString());
                itm.Tag          = new KeyValuePair <BacnetAddress, uint>(adr, device_id);
                itm.SubItems.Add("");

                //read name
                IList <BacnetValue> values;
                if (bacnet_client.ReadPropertyRequest(adr, new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, device_id), BacnetPropertyIds.PROP_OBJECT_NAME, out values))
                {
                    itm.SubItems[1].Text = (string)values[0].Value;
                }
            }, null);
        }
Example #8
0
 private void handler_OnIam(BacnetClient sender, BacnetAddress adr, uint deviceId, uint maxAPDU, BacnetSegmentations segmentation, ushort vendorId)
 {
     BeginInvoke(new Action(() =>
     {
         lock (devicesList)
         {
             foreach (BacNode bn in devicesList)
             {
                 if (bn.GetAdd(deviceId) != null)
                 {
                     return;                                // Yes
                 }
             }
             devicesList.Add(new BacNode(adr, deviceId));   // add it
             listBox1.Items.Add(adr.ToString() + " " + deviceId);
         }
     }));
 }
Example #9
0
        private void handler_OnReadPropertyRequest(BacnetClient sender, BacnetAddress adr, byte invoke_id, BacnetObjectId object_id, BacnetPropertyReference property, BacnetMaxSegments max_segments)
        {
            lock (m_storage)
            {
                _logger.LogInformation($"Read property request for {property.ToString()} of {object_id.ToString()} from {adr.ToString()}.");

                try
                {
                    IList <BacnetValue>      value;
                    DeviceStorage.ErrorCodes code = m_storage.ReadProperty(object_id, (BacnetPropertyIds)property.propertyIdentifier, property.propertyArrayIndex, out value);
                    if (code == DeviceStorage.ErrorCodes.Good)
                    {
                        sender.ReadPropertyResponse(adr, invoke_id, sender.GetSegmentBuffer(max_segments), object_id, property, value);
                    }
                    else
                    {
                        sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_READ_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_OTHER);
                    }
                }
                catch (Exception)
                {
                    sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_READ_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, BacnetErrorCodes.ERROR_CODE_OTHER);
                }
            }
        }
Example #10
0
        /*****************************************************************************************************/
        /* This is the objective of this sample !                                                            */
        /*****************************************************************************************************/
        static void handler_OnEventNotify(BacnetClient sender, BacnetAddress adr, BacnetEventNotificationData EventData)
        {
            string val = adr.ToString() + ":" + EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance + ":" + EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance;

            Console.WriteLine(val + " " + EventData.fromState + " to " + EventData.toState + " " + EventData.notifyType.ToString());
        }
 void handler_OnIam(BacnetClient sender, BacnetAddress adr, uint device_id, uint max_apdu, BacnetSegmentations segmentation, ushort vendor_id)
 {
     // simple write some information concerning the device
     RunOnUiThread(() => {
         tv.Text = tv.Text + System.Environment.NewLine + "    BacnetAdr : " + adr.ToString() + ",  Device Id : " + device_id.ToString();
     });
 }
Example #12
0
        /*****************************************************************************************************/
        /* This is the objective of this sample !                                                            */
        /*****************************************************************************************************/
        static void handler_OnEventNotify(BacnetClient sender, BacnetAddress adr, byte invokeId, NotificationData EventData, bool needConfirm)
        {
            string val = adr.ToString() + ":" + EventData.InitiatingObjectIdentifier.Type + ":" + EventData.InitiatingObjectIdentifier.Instance + ":" + EventData.EventObjectIdentifier.Type + ":" + EventData.EventObjectIdentifier.Instance;

            Console.WriteLine(val + " to " + EventData.ToState + " " + EventData.NotifyType.ToString());
        }