WFA_psychometric_chart.BACnetClass.ReadParameterUsigBacnetID C# (CSharp) Method

ReadParameterUsigBacnetID() public static method

public static ReadParameterUsigBacnetID ( int bacnetid ) : List
bacnetid int
return List
        public static List<parameter_class> ReadParameterUsigBacnetID(int bacnetid)
        {
            List<parameter_class> parameterList = new List<parameter_class>();
                BacnetValue Value;
                BacnetValue Value_Object_Name;
                bool ret;
            // Read Present_Value property on the object ANALOG_INPUT:0 provided by the device 12345
            // Scalar value only
            //   Console.WriteLine("Read ID = %d input0 value = %d");

            //---This one is for OBJECT_ANALOG_VALUE

            for (uint x = 0; x < 10; x++) {
                    //ret = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_INPUT, 0), BacnetPropertyIds.PROP_PRESENT_VALUE, out Value);
                    ret = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_VALUE, x), BacnetPropertyIds.PROP_PRESENT_VALUE, out Value);
                    bool rect2 = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_VALUE, x), BacnetPropertyIds.PROP_OBJECT_NAME, out Value_Object_Name);
                    if (ret == true)
                    {
                        //  Console.WriteLine("Read id = {0},input1 value : {1}", bacnetid, Value.Value.ToString());

                        if (rect2 == true)
                        {
                        //ADD VALUES ONLY IF THE VALUE SI not empty
                        if(Value_Object_Name.ToString() != "") {
                            //ADD to the list and return the value...
                            parameterList.Add(new parameter_class
                            {
                                device_object_name = Value_Object_Name.ToString(),
                                indexID = x,
                                presentValue = double.Parse(Value.ToString())  ,
                                object_identifier_type = "OBJECT_ANALOG_VALUE"

                            });
                        }//Close of if value _object_name
                    }

                    }//close of if
                     // else
                     //   Console.WriteLine("Error somewhere !");
                }//Close of for

            //************************************************added code***************************************************************//

            //---This one is for OBJECT_ANALOG_INPUT
            for (uint x = 0; x < 10; x++)
            {

                ret = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_INPUT, x), BacnetPropertyIds.PROP_PRESENT_VALUE, out Value);
                bool rect2 = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_INPUT, x), BacnetPropertyIds.PROP_OBJECT_NAME, out Value_Object_Name);
                if (ret == true)
                {
                    //  Console.WriteLine("Read id = {0},input1 value : {1}", bacnetid, Value.Value.ToString());

                    if (rect2 == true)
                    {
                        //ADD VALUES ONLY IF THE VALUE SI not empty
                        if (Value_Object_Name.ToString() != "")
                        {
                            //ADD to the list and return the value...
                            parameterList.Add(new parameter_class
                            {
                                device_object_name = Value_Object_Name.ToString(),
                                indexID = x,   //THIS ONE IS THE INSTANCE ID
                                presentValue = double.Parse(Value.ToString()),
                                object_identifier_type = "OBJECT_ANALOG_INPUT"

                            });
                        }//Close of if value _object_name
                    }

                }//close of if

            }//Close of for

            //---This one is for OBJECT_ANALOG_OUTPUT
            for (uint x = 0; x < 10; x++)
            {

                ret = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_OUTPUT, x), BacnetPropertyIds.PROP_PRESENT_VALUE, out Value);
                bool rect2 = ReadScalarValue(bacnetid, new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_OUTPUT, x), BacnetPropertyIds.PROP_OBJECT_NAME, out Value_Object_Name);
                if (ret == true)
                {
                    //  Console.WriteLine("Read id = {0},input1 value : {1}", bacnetid, Value.Value.ToString());

                    if (rect2 == true)
                    {
                        //ADD VALUES ONLY IF THE VALUE SI not empty
                        if (Value_Object_Name.ToString() != "")
                        {
                            //ADD to the list and return the value...
                            parameterList.Add(new parameter_class
                            {
                                device_object_name = Value_Object_Name.ToString(),
                                indexID = x,   //THIS ONE IS THE INSTANCE ID
                                presentValue = double.Parse(Value.ToString()),
                                object_identifier_type = "OBJECT_ANALOG_OUTPUT"

                            });
                        }//Close of if value _object_name
                    }

                }//close of if

            }//Close of for

            //********************************************added code end*************************************************************//
            return parameterList;
        }

Usage Example

 /// <summary>
 /// This used to get the values form the device id
 /// </summary>
 /// <param name="deviceID"></param>
 public List <BACnetClass.parameter_class> ScanForParameters(int deviceID)
 {
     parameterListValue.Clear();//Resetting the values
     parameterListValue = BACnetClass.ReadParameterUsigBacnetID(deviceID);
     // parameterListValue = BACnetClass.ReadParameterUsingBacnetIDForTemperatureAndHumidityBoth(deviceID);
     return(parameterListValue);
 }