Ejemplo n.º 1
0
        private void button6_Click(object sender, EventArgs e)
        {
            BACNET_EVENT_NOTIFICATION_DATA      data   = new BACNET_EVENT_NOTIFICATION_DATA();
            UnconfirmedEventNotificationService unconf = new UnconfirmedEventNotificationService();

            data.processIdentifier = 123;
            data.ackRequired       = true;
            BACNET_OBJECT_ID obj_id = new BACNET_OBJECT_ID();

            obj_id.type                = (UInt16)BACNET_OBJECT_TYPE.BACNET_LIFT;
            obj_id.instance            = Form_main.lift_list[0].Object_Identifier.instance;
            data.eventObjectIdentifier = obj_id;
            data.eventType             = BACNET_EVENT_TYPE.EVENT_CHANGE_OF_LIFE_SAFETY;
            data.fromState             = BACNET_EVENT_STATE.EVENT_STATE_NORMAL;
            data.timeStamp             = Form_main.lift_list[0].Time_Stamps;
            data.notifyType            = BACNET_NOTIFY_TYPE.NOTIFY_ALARM;
            data.toState               = BACNET_EVENT_STATE.EVENT_STATE_FAULT;
            data.priority              = 3;


            BACNET_OBJECT_ID obj_temp = new BACNET_OBJECT_ID();

            obj_temp.type     = (UInt16)BACNET_OBJECT_TYPE.OBJECT_DEVICE;
            obj_temp.instance = 9527;
            data.notificationParams.change_of_lifesafety.statusFlags.set_bits_used(1, 5);
            data.notificationParams.change_of_lifesafety.statusFlags.set_octet(0, 4);
            data.notificationParams.change_of_lifesafety.newState          = BACNET_LIFE_SAFETY_STATE.LIFE_SAFETY_STATE_ALARM;
            data.notificationParams.change_of_lifesafety.newMode           = BACNET_LIFE_SAFETY_MODE.LIFE_SAFETY_MODE_DISABLED;
            data.notificationParams.change_of_lifesafety.operationExpected = BACNET_LIFE_SAFETY_OPERATION.LIFE_SAFETY_OP_RESET_ALARM;

            //  data.notificationParams.newState.tag = BACNET_PROPERTY_STATE_TYPE.UNSIGNED_VALUE;
            //    data.notificationParams.newState.value = 100;
            //    data.notificationParams.statusFlags.set_bits_used(1, 5);
            //    data.notificationParams.statusFlags.set_octet(0,4);



            data.initiatingObjectIdentifier = obj_temp;
            data.notificationClass          = 123;



            Byte[] buff = new Byte[1024];


            int Send_len = unconf.Unconfirmed_Event_Notification_Pack(ref buff, ref data);

            IPEndPoint dest    = new IPEndPoint(IPAddress.Parse("10.10.161.153"), 60);//假设60测试?
            UdpSender  sendder = new UdpSender(ref buff, dest);

            sendder.Send(Send_len);
        }