Esempio n. 1
0
        public override void handle(LocalDevice localDevice, Address from, OctetString linkService)
        {
            BACnetObject local = localDevice.Configuration;

            // Check if we're in the device id range.
            if (DeviceInstanceRangeLowLimit != null && local.InstanceId < DeviceInstanceRangeLowLimit.Value)
            {
                return;
            }

            if (DeviceInstanceRangeHighLimit != null && local.InstanceId > DeviceInstanceRangeHighLimit.Value)
            {
                return;
            }

            // Return the result in a i am message.
            //DCC - AdK
            //if(!localDevice.getDCCEnableDisable().equals(EnableDisable.disable)) {
            IAmRequest iam = localDevice.MakeIAmRequest();

            localDevice.sendGlobalBroadcast(iam, true);
            //}
        }
Esempio n. 2
0
        // Event listeners
        //private readonly DeviceEventHandler eventHandler = new DeviceEventHandler();
        //private readonly DeviceEventHandler eventHandler = new DeviceEventAsyncHandler();

        public LocalDevice(uint deviceId, ApplicationLayer applicationLayer, string deviceName, string modelName)
        {
            this.applicationLayer   = applicationLayer;
            applicationLayer.Device = this;

            initEventHandlers();

            try
            {
                ObjectIdentifier deviceIdentifier = new ObjectIdentifier(ObjectType.Device, deviceId);

                configuration = new BACnetObject(this, deviceIdentifier);
                configuration.setProperty(PropertyIdentifier.MaxApduLengthAccepted, new UnsignedInteger(1476));
                configuration.setProperty(PropertyIdentifier.VendorIdentifier, new Unsigned16(VENDOR_ID));
                configuration.setProperty(PropertyIdentifier.VendorName, new CharacterString(VENDOR_STRING));
                configuration.setProperty(PropertyIdentifier.SegmentationSupported, Segmentation.SegmentedBoth);

                /*TODO SequenceOf<ObjectIdentifier> objectList = new SequenceOf<ObjectIdentifier>();
                 * objectList.add(deviceIdentifier);
                 * configuration.setProperty(PropertyIdentifier.objectList, objectList);*/

                // Set up the supported services indicators. Remove lines as services get implemented.
                ServicesSupported servicesSupported = new ServicesSupported();
                servicesSupported.SetAll(false);
                servicesSupported.AcknowledgeAlarm           = true;
                servicesSupported.ConfirmedCovNotification   = true;
                servicesSupported.ConfirmedEventNotification = true;
                servicesSupported.GetAlarmSummary            = true;
                servicesSupported.GetEnrollmentSummary       = true;
                servicesSupported.setGetEventInformation(true);
                servicesSupported.setIAm(true);
                servicesSupported.setIHave(true);
                servicesSupported.setReadProperty(true);
                servicesSupported.setReadPropertyMultiple(true);
                servicesSupported.setReinitializeDevice(true);
                servicesSupported.SubscribeCov = true;
                servicesSupported.setTimeSynchronization(true);
                servicesSupported.setUnconfirmedCovNotification(true);
                servicesSupported.setUnconfirmedEventNotification(true);
                servicesSupported.setWhoHas(true);
                servicesSupported.setWhoIs(true);
                servicesSupported.setWriteProperty(true);
                servicesSupported.setWritePropertyMultiple(true);
                servicesSupported.setDeviceCommunicationControl(true);

                //servicesSupported.setAll(true);
                //AdK
                //servicesSupported.setAcknowledgeAlarm(false);

                /*
                 * servicesSupported.setGetAlarmSummary(true);
                 * servicesSupported.setGetEnrollmentSummary(true);
                 * servicesSupported.setAtomicReadFile(false);
                 * servicesSupported.setAtomicWriteFile(false);
                 * servicesSupported.setAddListElement(false);
                 * servicesSupported.setRemoveListElement(false);
                 * servicesSupported.setReadPropertyConditional(false);
                 * servicesSupported.setDeviceCommunicationControl(false);
                 * servicesSupported.setReinitializeDevice(false);
                 * servicesSupported.setVtOpen(false);
                 * servicesSupported.setVtClose(false);
                 * servicesSupported.setVtData(false);
                 * servicesSupported.setAuthenticate(false);
                 * servicesSupported.setRequestKey(false);
                 * servicesSupported.setTimeSynchronization(true);
                 * servicesSupported.setReadRange(false);
                 * servicesSupported.setUtcTimeSynchronization(true);
                 * servicesSupported.setLifeSafetyOperation(false);
                 * //servicesSupported.setSubscribeCovProperty(true);
                 * //servicesSupported.setGetEventInformation(true);
                 */

                configuration.setProperty(PropertyIdentifier.ProtocolServicesSupported, servicesSupported);

                // Set up the object types supported.

                /* TODO ObjectTypesSupported objectTypesSupported = new ObjectTypesSupported();
                 * objectTypesSupported.setAll(false);
                 *
                 * objectTypesSupported.setDevice(true);
                 *
                 * objectTypesSupported.setAnalogInput(true);
                 * objectTypesSupported.setAnalogOutput(true);
                 * objectTypesSupported.setAnalogValue(true);
                 *
                 * objectTypesSupported.setBinaryInput(true);
                 * objectTypesSupported.setBinaryOutput(true);
                 * objectTypesSupported.setBinaryValue(true);
                 *
                 * objectTypesSupported.setMultiStateInput(true);
                 * objectTypesSupported.setMultiStateOutput(true);
                 * objectTypesSupported.setMultiStateValue(true);
                 *
                 * objectTypesSupported.setNotificationClass(true);
                 *
                 * configuration.setProperty(PropertyIdentifier.protocolObjectTypesSupported, objectTypesSupported);*/

                // Set some other required values to defaults
                configuration.setProperty(PropertyIdentifier.ObjectName, new CharacterString(deviceName));
                configuration.setProperty(PropertyIdentifier.SystemStatus, DeviceStatus.Operational);
                configuration.setProperty(PropertyIdentifier.ModelName, new CharacterString(modelName));
                configuration.setProperty(PropertyIdentifier.FirmwareRevision, new CharacterString(FIRMWARE_REVISION));
                configuration.setProperty(PropertyIdentifier.ApplicationSoftwareVersion, new CharacterString(APPLICATION_SOFTWARE_VERSION));
                configuration.setProperty(PropertyIdentifier.ProtocolVersion, new UnsignedInteger(1));
                configuration.setProperty(PropertyIdentifier.ProtocolRevision, new UnsignedInteger(0));
                configuration.setProperty(PropertyIdentifier.DatabaseRevision, new UnsignedInteger(0));
            }
            catch (BACnetServiceException e)
            {
                // Should never happen, but wrap in an unchecked just in case.
                throw new BACnetRuntimeException(e);
            }
        }