Exemple #1
0
 private bool GetModelName(ref BacnetDevice device)
 {
     return(GetStringPropertyValue(ref device, BacnetEnums.BacnetPropertyId.PropModelName,
                                   ref device.ModelName));
 }
Exemple #2
0
        /// <summary>
        ///     Finds the device objects.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <returns></returns>
        public bool FindDeviceObjects(ref BacnetDevice device)
        {
            var successful = true;

            var deviceObjects = new List <string>();

            var recipient = new Device
            {
                ServerEp     = device.IpAddress,
                Instance     = device.InstanceNumber,
                Network      = device.Network,
                SourceLength = device.SourceLength
            };

            var property = new Property {
                Tag = BacnetEnums.BacnetApplicationTag.BacnetApplicationTagEnumerated
            };

            if (!bacStack.SendReadProperty(
                    recipient,
                    0, // Array[0] is Object Count
                    BacnetEnums.BacnetObjectType.ObjectDevice,
                    BacnetEnums.BacnetPropertyId.PropObjectList,
                    property))
            {
                successful = false;
            }

            if (property.Tag != BacnetEnums.BacnetApplicationTag.BacnetApplicationTagUnsignedInt)
            {
                successful = false;
            }

            int i;
            var total = property.ValueUInt;

            if (total > 0)
            {
                for (i = 1; i <= total; i++)
                {
                    // Read through Array[x] up to Object Count
                    // Need to try the read again if it times out
                    var tries = 0;
                    while (tries < 5)
                    {
                        tries++;
                        if (!bacStack.SendReadProperty(
                                recipient,
                                i,
                                // each array index
                                BacnetEnums.BacnetObjectType.ObjectDevice,
                                BacnetEnums.BacnetPropertyId.PropObjectList,
                                property))
                        {
                            continue;
                        }
                        tries = 5; // Next object
                        string s;
                        if (property.Tag != BacnetEnums.BacnetApplicationTag.BacnetApplicationTagObjectId)
                        {
                            tries = 5; // continue;
                        }
                        switch (property.ValueObjectType)
                        {
                        case BacnetEnums.BacnetObjectType.ObjectDevice:
                            s = "Device";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectAnalogInput:
                            s = "Analog Input";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectAnalogOutput:
                            s = "Analog Output";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectAnalogValue:
                            s = "Analog value";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectBinaryInput:
                            s = "Binary Input";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectBinaryOutput:
                            s = "Binary Output";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectBinaryValue:
                            s = "Binary value";
                            break;

                        case BacnetEnums.BacnetObjectType.ObjectFile:
                            s = "File";
                            break;

                        default:
                            s = "Other";
                            break;
                        }
                        s = s + "  " + property.ValueObjectInstance;
                        deviceObjects.Add(s);
                    }
                }
            }
            device.DeviceObjects = deviceObjects;
            return(successful);
        }