Пример #1
0
        public void Acknowledge_Alarm_Handler(ref Byte[] request, UInt16 request_len, ref BACNET_ADDRESS src, ref BACNET_CONFIRMED_SERVICE_DATA request_data)
        {
            ACKNOWLEDGE_ALARM_DATA Ack_data = new ACKNOWLEDGE_ALARM_DATA();

            Byte[]           buffer     = new Byte[1024];
            BACNET_ADDRESS   my_address = new BACNET_ADDRESS();
            NpduProcessor    n_pro      = new NpduProcessor();
            BACNET_NPDU_DATA npdu_data  = new BACNET_NPDU_DATA();
            ApduProcessor    a_pro      = new ApduProcessor();
            BvlcProcessor    b_pro      = new BvlcProcessor();
            int pdu_len  = 0;
            int byte_len = 0;
            int apdu_len = -1;
            int npdu_len = -1;
            int len      = 0;

            len = Decode_Service_Request(ref request, request_len, ref Ack_data);


            n_pro.Encode_NpduData(ref npdu_data, false, BACNET_MESSAGE_PRIORITY.MESSAGE_PRIORITY_NORMAL);
            npdu_len = n_pro.Encode(ref buffer, ref src, ref my_address, ref npdu_data);
            apdu_len = a_pro.Encode_Simple_Ack(ref buffer, request_data.invoke_id, (Byte)BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_SUBSCRIBE_COV, npdu_len);
            pdu_len  = npdu_len + apdu_len;
            byte_len = b_pro.Encode(ref buffer, ref src, ref npdu_data, pdu_len);
        }
        /********************************************************************************************************************************************************************************/
        public void Cov_Subscribe_Handler(ref Byte[] request, UInt16 request_len, ref BACNET_ADDRESS src, ref BACNET_CONFIRMED_SERVICE_DATA request_data)
        {
            int pdu_len  = 0;
            int byte_len = 0;

            Byte[] buffer = new Byte[1024];
            BACNET_SUBSCRIBE_COV_DATA cov_data   = new BACNET_SUBSCRIBE_COV_DATA();
            BACNET_ADDRESS            my_address = new BACNET_ADDRESS();
            NpduProcessor             n_pro      = new NpduProcessor();
            BACNET_NPDU_DATA          npdu_data  = new BACNET_NPDU_DATA();
            ApduProcessor             a_pro      = new ApduProcessor();
            BvlcProcessor             b_pro      = new BvlcProcessor();
            int apdu_len = -1;
            int npdu_len = -1;
            int len      = 0;

            //cov_data.error_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED;
            //datalink_get_my_address(&my_address);
            n_pro.Encode_NpduData(ref npdu_data, false, BACNET_MESSAGE_PRIORITY.MESSAGE_PRIORITY_NORMAL);
            npdu_len = n_pro.Encode(ref buffer, ref src, ref my_address, ref npdu_data);
            //  if (service_data.segmented_message)
            /* we don't support segmentation - send an abort */
            len = Decode_Service_Request(ref request, request_len, ref cov_data);

            //
            for (int i = 0; i < Form_main.lift_count; i++)
            {
                if (cov_data.monitoredObjectIdentifier.instance == Form_main.lift_list[i].Object_Identifier.instance)
                {
                    Form_main.lift_list[i].cov_subscribe(src, cov_data);
                }
            }



            //
            apdu_len = a_pro.Encode_Simple_Ack(ref buffer, request_data.invoke_id, (Byte)BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_SUBSCRIBE_COV, npdu_len);
            pdu_len  = npdu_len + apdu_len;
            byte_len = b_pro.Encode(ref buffer, ref src, ref npdu_data, pdu_len);
        }