예제 #1
0
        /// <summary>
        /// function to take input of controller and variable name and id and scan the hardware values
        /// </summary>
        /// <param name="controllerInstanceID"></param>
        /// <param name="variableName"></param>
        /// <param name="variableNumber"></param>
        public double InputDeviceInfoAndValue(int controllerInstanceID, string variableName, int variableNumber)
        {
            /*
             * Task by this function :
             * 1. Filter which object to call.
             * 2. call a function and a value
             * 3.
             */

            string inputNameForYabee = "";

            if (variableName == "VAR")
            {
                // ANALOG_INPUT_VALUE
                inputNameForYabee = "OBJECT_ANALOG_VALUE";
            }
            else if (variableName == "IN")
            {
                // ANALOG_INPUT_INPUT
                inputNameForYabee = "OBJECT_ANALOG_INPUT";
            }
            else if (variableName == "OUT")
            {
                //variableName == OUT so for this we have
                inputNameForYabee = "OBJECT_ANALOG_OUTPUT";
            }
            double           valueFromDevice = 0;
            DeviceConnection db = new DeviceConnection();

            lock (db)
            {
                db.ScanForDevice();
                //==Now calling yabee for this values
                BACnetClass bc = new BACnetClass();
                valueFromDevice = bc.ReadSingleParameterUsigBacnetID(controllerInstanceID, inputNameForYabee, variableNumber);
                db.ScanForDevice();
            }
            //db.ScanForDevice();
            return(valueFromDevice);
        }
예제 #2
0
        int deviceInstanceValuTemp = 0;//This for particular device
        private void CB_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            groupBox3.Enabled = true;
            //Lets clear the combobox first
            CB_param_temp.Items.Clear();
            CB_param_hum.Items.Clear();
            parameterValFromBacnet.Clear();//Clearing the list value

            if (CB_Device.SelectedIndex > -1)
            {
                //On this index change the we need to get the values from the
                indexSelectedDevice = CB_Device.SelectedIndex;
                int instanceId = (int)copyOfMainControllerList[indexSelectedDevice].controllerInstanceId;//Device instance selected.

                deviceInstanceValuTemp = instanceId;

                // MessageBox.Show("instance id = " + instanceId);
                // MessageBox.Show("Device checkonline offline = " + CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0));
                if (CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0) == true)
                {
                    //This uint has to be converted to int because that is what is required...
                    DeviceConnection db = new DeviceConnection();
                    db.ScanForDevice();
                    db.ScanForParameters(instanceId);//This will return the parameters
                    //resert first
                    device_info.Clear();
                    foreach (var bn in BACnetClass.DevicesList)
                    {
                        device_info.Add(new DeviceClass
                        {
                            deviceInstance = bn.device_id,
                            deviceIP       = bn.device_id + "." + bn.adr.adr[0] + "." + bn.adr.adr[1] + "." + bn.adr.adr[2] + "." + bn.adr.adr[3]
                        });
                    }

                    //Now we can use the value strored int  the db.parameterList1
                    string s = "";
                    foreach (var bac in db.parameterListValue)
                    {
                        parameterValFromBacnet.Add(new parameter_class1
                        {
                            device_object_name = bac.device_object_name,
                            indexID            = bac.indexID,
                            presentValue       = bac.presentValue
                        });
                        //    s += bac.device_object_name + "," + bac.presentValue;
                    }

                    //  MessageBox.Show("value = " + s);

                    //Now that we have the parameter list lets display the list in the combobox...
                    // string s = "";
                    foreach (var item in parameterValFromBacnet)
                    {
                        CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID);
                        CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                        CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                        //     s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";
                    }
                }//close of the device is online or offline
                else
                {
                    MessageBox.Show("Device is offline");
                }
                //TEST
                // MessageBox.Show("s = " + s);
            }//Close of if
        }
        private void CB_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            //--This is when the controller is selected and value is added to it
            //--This load the data form the device rather then access db
            /*
            Steps :
            1. Get the data and then pull the value
            */

            groupBox3.Enabled = true;
            //Lets clear the combobox first
            CB_param_temp.Items.Clear();
               // CB_param_hum.Items.Clear();
            parameterValFromBacnet.Clear();//Clearing the list value

            if (CB_Device.SelectedIndex > -1)
            {
                //On this index change the we need to get the values from the
                indexSelectedDevice = CB_Device.SelectedIndex;
                int instanceId = (int)copyOfMainControllerList[indexSelectedDevice].controllerInstanceId;//Device instance selected.

                deviceInstanceValuTemp = instanceId;

                // MessageBox.Show("instance id = " + instanceId);
                // MessageBox.Show("Device checkonline offline = " + CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0));
                if (CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0) == true)
                {

                    //This uint has to be converted to int because that is what is required...
                    DeviceConnection db = new DeviceConnection();
                    db.ScanForDevice();
                    db.ScanForParameters(instanceId);//This will return the parameters
                                                     //resert first
                    device_info.Clear();
                    foreach (var bn in BACnetClass.DevicesList)
                    {
                        device_info.Add(new DeviceClass
                        {
                            deviceInstance = bn.device_id,
                            deviceIP = bn.device_id + "." + bn.adr.adr[0] + "." + bn.adr.adr[1] + "." + bn.adr.adr[2] + "." + bn.adr.adr[3]

                        });
                    }

                   // MessageBox.Show("parameterListValue count option  = " + db.parameterListValue.Count);
                    //Now we can use the value strored int  the db.parameterList1
                    string s = "";
                    foreach (var bac in db.parameterListValue)
                    {
                        parameterValFromBacnet.Add(new parameter_class1
                        {
                            device_object_name = bac.device_object_name,
                            indexID = bac.indexID,
                            presentValue = bac.presentValue,
                            object_identifier_type = bac.object_identifier_type

                        });
                      //  s += "\n"+bac.device_object_name + ",["+ bac.indexID + "]"+ bac.presentValue+",TYPE = "+bac.object_identifier_type;
                    }

                     //MessageBox.Show("Data returned from backnet  value =\n " + s);
                    //--Here we need to scan form th    e  T3000 database and then publish the list which is there
                    /*
                    Task :
                    1.Read the data from the alex db
                    2.Find only TEMPERATURE VALUE
                    3.Filter and display only temperature values
                    */
                    Form1_main f = new Form1_main();
                    string path_to_alexdb = f.PathToT3000BuildingDB;// PathToT3000BuildingDB;
                    ReadDataFromAlexDatabase( "INPUTable");

                    //--This only filteres temperature inside alex db
                    FilterOnlyTemperatureAndHumidityFromAlexDBValue();//Returns FilteredTemperatureValueList as a result

                    //--Returns AfterFilteringFromAlexValueListOfValues
                    FilterDataForDisplayInList();//Filteres value form alex db and give new value to insert to list teurns:AfterFilteringFromAlexValueListOfValues

                    foreach (var item in AfterFilteringFromAlexValueListOfValues)
                    {
                        CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID+ "[Value = " + item.presentValue + "]");
                        // CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                        //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                        // s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                    }

                    CB_param_temp.Enabled = true;
                    //Now that we have the parameter list lets display the list in the combobox...
                    // string s = "";
                    //foreach (var item in parameterValFromBacnet)
                    //{
                    //   CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID);
                    //   // CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                    //   //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                    //   // s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                    //}
                }//close of the device is online or offline
                else
                {
                    MessageBox.Show("Device is offline");
                }
                //TEST
                // MessageBox.Show("s = " + s);
            }//Close of if
        }
        int deviceInstanceValuTemp = 0;     //This for particular device

        private void CB_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            //--This is when the controller is selected and value is added to it
            //--This load the data form the device rather then access db

            /*
             * Steps :
             * 1. Get the data and then pull the value
             */

            groupBox3.Enabled = true;
            //Lets clear the combobox first
            CB_param_temp.Items.Clear();
            // CB_param_hum.Items.Clear();
            parameterValFromBacnet.Clear();//Clearing the list value

            if (CB_Device.SelectedIndex > -1)
            {
                //On this index change the we need to get the values from the
                indexSelectedDevice = CB_Device.SelectedIndex;
                int instanceId = (int)copyOfMainControllerList[indexSelectedDevice].controllerInstanceId;//Device instance selected.

                deviceInstanceValuTemp = instanceId;

                // MessageBox.Show("instance id = " + instanceId);
                // MessageBox.Show("Device checkonline offline = " + CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0));
                if (CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0) == true)
                {
                    //This uint has to be converted to int because that is what is required...
                    DeviceConnection db = new DeviceConnection();
                    db.ScanForDevice();
                    db.ScanForParameters(instanceId); //This will return the parameters
                                                      //resert first
                    device_info.Clear();
                    foreach (var bn in BACnetClass.DevicesList)
                    {
                        device_info.Add(new DeviceClass
                        {
                            deviceInstance = bn.device_id,
                            deviceIP       = bn.device_id + "." + bn.adr.adr[0] + "." + bn.adr.adr[1] + "." + bn.adr.adr[2] + "." + bn.adr.adr[3]
                        });
                    }

                    // MessageBox.Show("parameterListValue count option  = " + db.parameterListValue.Count);
                    //Now we can use the value strored int  the db.parameterList1
                    string s = "";
                    foreach (var bac in db.parameterListValue)
                    {
                        parameterValFromBacnet.Add(new parameter_class1
                        {
                            device_object_name     = bac.device_object_name,
                            indexID                = bac.indexID,
                            presentValue           = bac.presentValue,
                            object_identifier_type = bac.object_identifier_type
                        });
                        //  s += "\n"+bac.device_object_name + ",["+ bac.indexID + "]"+ bac.presentValue+",TYPE = "+bac.object_identifier_type;
                    }

                    //MessageBox.Show("Data returned from backnet  value =\n " + s);
                    //--Here we need to scan form th    e  T3000 database and then publish the list which is there

                    /*
                     * Task :
                     * 1.Read the data from the alex db
                     * 2.Find only TEMPERATURE VALUE
                     * 3.Filter and display only temperature values
                     */
                    Form1_main f = new Form1_main();
                    string     path_to_alexdb = f.PathToT3000BuildingDB;// PathToT3000BuildingDB;
                    ReadDataFromAlexDatabase("INPUTable");

                    //--This only filteres temperature inside alex db
                    FilterOnlyTemperatureAndHumidityFromAlexDBValue();//Returns FilteredTemperatureValueList as a result

                    //--Returns AfterFilteringFromAlexValueListOfValues
                    FilterDataForDisplayInList();//Filteres value form alex db and give new value to insert to list teurns:AfterFilteringFromAlexValueListOfValues


                    foreach (var item in AfterFilteringFromAlexValueListOfValues)
                    {
                        CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID + "[Value = " + item.presentValue + "]");
                        // CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                        //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                        // s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";
                    }

                    CB_param_temp.Enabled = true;
                    //Now that we have the parameter list lets display the list in the combobox...
                    // string s = "";
                    //foreach (var item in parameterValFromBacnet)
                    //{
                    //   CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID);
                    //   // CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                    //   //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                    //   // s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                    //}
                }//close of the device is online or offline
                else
                {
                    MessageBox.Show("Device is offline");
                }
                //TEST
                // MessageBox.Show("s = " + s);
            }//Close of if
        }
        private void CB_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            groupBox3.Enabled = true;
            //Lets clear the combobox first
            CB_param_temp.Items.Clear();
            CB_param_hum.Items.Clear();
            parameterValFromBacnet.Clear();//Clearing the list value

            if (CB_Device.SelectedIndex > -1) {
                //On this index change the we need to get the values from the
             indexSelectedDevice = CB_Device.SelectedIndex;
            int instanceId = (int)copyOfMainControllerList[indexSelectedDevice].controllerInstanceId;//Device instance selected.

                deviceInstanceValuTemp = instanceId;

               // MessageBox.Show("instance id = " + instanceId);
               // MessageBox.Show("Device checkonline offline = " + CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0));
                if (CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0) == true)
                {

                    //This uint has to be converted to int because that is what is required...
                    DeviceConnection db = new DeviceConnection();
                    db.ScanForDevice();
                    db.ScanForParameters(instanceId);//This will return the parameters
                        //resert first
                    device_info.Clear();
                    foreach (var bn in BACnetClass.DevicesList)
                    {
                        device_info.Add(new DeviceClass
                        {
                            deviceInstance = bn.device_id,
                            deviceIP = bn.device_id + "." + bn.adr.adr[0] + "." + bn.adr.adr[1] + "." + bn.adr.adr[2] + "." + bn.adr.adr[3]

                        });
                    }

                    //Now we can use the value strored int  the db.parameterList1
                    string s = "";
                    foreach (var bac in db.parameterListValue)
                    {
                        parameterValFromBacnet.Add(new parameter_class1
                        {
                            device_object_name = bac.device_object_name,
                            indexID = bac.indexID,
                            presentValue = bac.presentValue,
                            object_identifier_type = bac.object_identifier_type

                        });
                    //    s += bac.device_object_name + "," + bac.presentValue;
                    }

                  //  MessageBox.Show("value = " + s);

                    //Now that we have the parameter list lets display the list in the combobox...
                    // string s = "";
                    foreach (var item in parameterValFromBacnet)
                    {
                        CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID);
                        CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                 //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                        //     s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                    }
                }//close of the device is online or offline
                else
                {
                    MessageBox.Show("Device is offline");
                }
            //TEST
               // MessageBox.Show("s = " + s);
            }//Close of if
        }
        /// <summary>
        /// This function bull the all the available values for particualar device id
        /// </summary>
        /// <param name="device_instance_id"></param>
        /// <returns></returns>
        public void getDataFromParameter(int device_instance_id)
        {

            if (CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0) == true)
            {


               

                DeviceConnection db = new DeviceConnection();
              //  db.parameterListValue.Clear();//This will scan the paramter list first
               // db.ScanForParameters(device_instance_id);//This will return the parameters
                                                         //Now we can use the value strored int  the db.parameterList1

                if (db.parameterListValue.Count > 0)
                {

                    ///WE NEED TO REENABLE BOTH DORPDOWN IE FOR TEMP AND HUM IF THE SYSTEM IS ONLINE
                    //temp
                    //  string s = "";
                    //parameterValFromBacnet.Clear();
                    //foreach (var bac in db.parameterListValue)
                    //{
                    //    parameterValFromBacnet.Add(new parameter_class1
                    //    {
                    //        device_object_name = bac.device_object_name,
                    //        indexID = bac.indexID,
                    //        presentValue = bac.presentValue ,
                    //        object_identifier_type = bac.object_identifier_type

                    //    });
                    //    // s += bac.device_object_name + "," + bac.presentValue;
                    //}



                    //Reading values for temperature and humidity 
                    double temperatureValue = 0;
                    double humidityValue = 0;

                    //==For Temperature 
                    try { 

                    ReadDataFromDeviceForTemperature(device_instance_id, AfterFilteringFromAlexValueListOfValues[parameterID_ForTemp].indexID, AfterFilteringFromAlexValueListOfValues[parameterID_ForTemp].object_identifier_type);
                    //we have recent value in hardwareValue1 and hardwareValue2 so lets calc corresponding x and y value
                    //now temp itself is x value we need to calculate y value

                    // if ((hardwareValue1.ToString() == null || hardwareValue1 == 0.00) || (hardwareValue2.ToString() == null || hardwareValue2 == 0.00))
                    if ((hardwareValue1.ToString() == null || hardwareValue1 == 0.00))
                    {
                        return;
                    }
                    temperatureValue = hardwareValue1;

                   //==For humidity====

                    //tb_hum_panel_value.Text = AfterFilteringFromAlexValueListOfValuesForHumidityOnly[CB_param_hum.SelectedIndex].presentValue.ToString();
                    //parameterID_ForHum = CB_param_hum.SelectedIndex;//Setting the index value for constant update


                    ReadDataFromDeviceForHumidity(device_instance_id, AfterFilteringFromAlexValueListOfValuesForHumidityOnly[parameterID_ForHum].indexID, AfterFilteringFromAlexValueListOfValuesForHumidityOnly[parameterID_ForHum].object_identifier_type);
                    //we have recent value in hardwareValue1 and hardwareValue2 so lets calc corresponding x and y value
                    //now temp itself is x value we need to calculate y value

                    // if ((hardwareValue1.ToString() == null || hardwareValue1 == 0.00) || (hardwareValue2.ToString() == null || hardwareValue2 == 0.00))
                    if ((hardwareValue2.ToString() == null || hardwareValue2 == 0.00))
                    {
                        return;
                    }


                    humidityValue = hardwareValue2;
                    }catch(Exception ex)
                    {
                        MessageBox.Show("Exception :\n" + ex.Message);
                    }

                    //MessageBox.Show()
                    // MessageBox.Show("count everytime " + parameterValFromBacnet.Count);
                    if (parameterValFromBacnet.Count < 1)
                    {

                    }
                    else
                    {
                        //This is connected section
                        //===============================Ren enabling both dropdown===============//
                        if (CB_param_temp.InvokeRequired)
                        {
                            CB_param_temp.Invoke(new MethodInvoker(() =>
                            {
                                CB_param_temp.Enabled = true;

                            }));
                        }
                        else
                        {
                            CB_param_temp.Enabled = true;
                        }

                        //hum
                        if (CB_param_hum.InvokeRequired)
                        {
                            CB_param_hum.Invoke(new MethodInvoker(() =>
                            {
                                CB_param_hum.Enabled = true;

                            }));
                        }
                        else
                        {
                            CB_param_hum.Enabled = true;
                        }

                        //============================== End=Ren enabling both dropdown===============//




                        //Device is connected and pulling is success
                        //This means we have values 
                        //Temp is set 
                        //shwo status 
                        //lb_device_status.Text = "connected";
                        if (lb_device_status.InvokeRequired)
                        {
                            lb_device_status.Invoke(new Action(() => lb_device_status.Text = "connected"));

                        }
                        else
                        {     //if invoke is not requred the do normal way

                            lb_device_status.Text = "connected";
                        }


                        if (parameterID_ForTemp >= 0)
                        {
                            //This is done to elimate the cross-thread exception which was occured while simple call
                            if (tb_temp_panel_value.InvokeRequired)
                            {
                                tb_temp_panel_value.Invoke(new MethodInvoker(() =>
                                {
                                    //RefreshDataFromDeviceAndWeb();
                                    //MessageBox.Show("Temp value methodinvoker bhitra");     
                                    try {
                                        tb_temp_panel_value.Text = temperatureValue.ToString(); //parameterValFromBacnet[parameterID_ForTemp].presentValue.ToString();
                                    }
                                    catch { }
                                }));
                            }
                            else
                            {
                                // RefreshDataFromDeviceAndWeb();
                                //tb_temp_panel_value.Text = parameterValFromBacnet[parameterID_ForTemp].presentValue.ToString();
                                try
                                {
                                    tb_temp_panel_value.Text = temperatureValue.ToString(); //parameterValFromBacnet[parameterID_ForTemp].presentValue.ToString();
                                }
                                catch { }
                            }
                        }

                        //If hum value is set then do below
                        if (parameterID_ForHum >= 0)
                        {
                            //index is set so
                            //tb_hum_panel_value.Text = parameterValFromBacnet[parameterID_ForHum].presentValue.ToString();
                            //This is done to elimate the cross-thread exception which was occured while simple call
                            if (tb_hum_panel_value.InvokeRequired)
                            {
                                tb_hum_panel_value.Invoke(new MethodInvoker(() =>
                                {
                                    //RefreshDataFromDeviceAndWeb();
                                    try {
                                        tb_hum_panel_value.Text = humidityValue.ToString();//parameterValFromBacnet[parameterID_ForHum].presentValue.ToString();
                                    }
                                    catch { }
                                }));
                            }
                            else
                            {
                                // RefreshDataFromDeviceAndWeb();
                                // tb_hum_panel_value.Text = parameterValFromBacnet[parameterID_ForHum].presentValue.ToString();
                                try
                                {
                                    tb_hum_panel_value.Text = humidityValue.ToString();//parameterValFromBacnet[parameterID_ForHum].presentValue.ToString();
                                }
                                catch { }

                            }
                        }

                    }

                }//This is the close of  parameter valueList >0 this done so that when the device return nothing after 
                //It has been online in status change nothing for eg say if device is gone online in access db but now 
                //Device is turned OFF when the scanner just started to scan then device will return nothing thought 
                //Db shows online so in such case in order to preserve previous setting this is used


            }  //this is the closing of checkOnlineOfline fxn
            else
            {
                //Device is offline 
               // lb_device_status.Text = "Disconnected";


                if (lb_device_status.InvokeRequired)
                {
                    lb_device_status.Invoke(new MethodInvoker(() =>
                    {
                        //RefreshDataFromDeviceAndWeb();
                        //lb_device_status.Text = parameterValFromBacnet[parameterID_ForHum].presentValue.ToString();
                        lb_device_status.Text = "Disconnected";

                    }));
                }
                else
                {
                    // RefreshDataFromDeviceAndWeb();
                    // tb_hum_panel_value.Text = parameterValFromBacnet[parameterID_ForHum].presentValue.ToString();
                    lb_device_status.Text = "Disconnected";
                }

                //===============================disabling both dropdown===============//
                //temp
                if (CB_param_temp.InvokeRequired)
                {
                    CB_param_temp.Invoke(new MethodInvoker(() =>
                    {
                        CB_param_temp.Enabled = false;

                    }));
                }
                else
                {
                    CB_param_temp.Enabled = false;
                }

                //hum
                if (CB_param_hum.InvokeRequired)
                {
                    CB_param_hum.Invoke(new MethodInvoker(() =>
                    {
                        CB_param_hum.Enabled = false;

                    }));
                }
                else
                {
                    CB_param_hum.Enabled = false;
                }
                //===============================Ende disabling both dropdown===============//
                //reSETTING BOTH TEXT BOXES
                //tb_temp_panel_value
                if (tb_temp_panel_value.InvokeRequired)
                {
                    tb_temp_panel_value.Invoke(new MethodInvoker(() =>
                    {
                        tb_temp_panel_value.Text = "";

                    }));
                }
                else
                {
                    tb_temp_panel_value.Text = "";
                }

                //tb_hum_panel_value
                if (tb_hum_panel_value.InvokeRequired)
                {
                    tb_hum_panel_value.Invoke(new MethodInvoker(() =>
                    {
                        tb_hum_panel_value.Text = "";

                    }));
                }
                else
                {
                    tb_hum_panel_value.Text = "";
                }




            }

            // return true;
        }//Close maine fxn getdatafromparameter
        private void CB_Device_SelectedIndexChanged(object sender, EventArgs e)
        {
            try { 
            //now on index change
           // groupBox3.Enabled = true;
            //Lets clear the combobox first
            CB_param_temp.Items.Clear();
            CB_param_hum.Items.Clear();
            parameterValFromBacnet.Clear();//Clearing the list value

            if (CB_Device.SelectedIndex > -1)
            {
                //This one is if the timer is running then stop the timer second time 
                if (flagForTimer == 1)
                {
                    //Timer is already set so dissable it first and then reenable...
                    _Timer.Enabled = false;
                    _Timer.Elapsed -= HandleTick; //new System.EventHandler(HandleTick);
                    _Timer.Dispose();

                    flagForTimer = 0;//Timer dissabled
                }

                //On this index change the we need to get the values from the 
              int  indexSelectedDevice = CB_Device.SelectedIndex;
                    int instanceId = copyOfMainControllerList[indexSelectedDevice].controllerInstanceId;  //(int)device_info[indexSelectedDevice].deviceInstance;//Device instance selected.

                 //   MessageBox.Show("Instaneid = " + instanceId);
                //===============For regulare update=============//
                deviceInstanceValuTemp = instanceId;//This one is for regular update
                                                    //================end of for regular update=====//
                                                    //This uint has to be converted to int because that is what is required...

                    //Checking if the device is online or offline
                    if (CheckDeviceOnlineOffline(deviceInstanceValuTemp, 0) == true)
                    {
                      //  MessageBox.Show("Checking online status become true");

                        //return;


                        DeviceConnection db = new DeviceConnection();
                        //We need to scan for the device first and then parameter
                        db.ScanForDevice();
                        //db.ScanForParameters(24649);
                        db.ScanForParameters(instanceId);//This will return the parameters
                       // MessageBox.Show("Count = " + db.parameterListValue.Count);       //Now we can use the value strored int  the db.parameterList1
                        string s = "";
                        foreach (var bac in db.parameterListValue)
                        {
                            parameterValFromBacnet.Add(new parameter_class1
                            {
                                device_object_name = bac.device_object_name,
                                indexID = bac.indexID,
                                presentValue = bac.presentValue ,
                                object_identifier_type = bac.object_identifier_type


                            });
                          //  s += bac.device_object_name + "," + bac.presentValue + "\n";
                        }


                        //  MessageBox.Show("value = " + s);

                        //Now that we have the parameter list lets display the list in the combobox...
                        // string s = "";
                        //foreach (var item in parameterValFromBacnet)
                        //{
                        //    CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID);
                        //    CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                        //    // CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                        //    //     s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                        //}

                        //======================Temperature and humidity filtering here========================//
                        //**************************First Temperature filtering*******************************//


                        //--Here we need to scan form th    e  T3000 database and then publish the list which is there 
                        /*
                        Task :
                        1.Read the data from the alex db 
                        2.Find only TEMPERATURE VALUE
                        3.Filter and display only temperature values
                        */
                        Form1_main f = new Form1_main();
                        string path_to_alexdb = f.PathToT3000BuildingDB;// PathToT3000BuildingDB;
                        ReadDataFromAlexDatabase("INPUTable");


                        //--Now the actual temperature filtering Starts here========================//
                        //--This only filteres temperature inside alex db 
                        FilterOnlyTemperatureAndHumidityFromAlexDBValue();//Returns FilteredTemperatureValueList as a result

                        //--Returns AfterFilteringFromAlexValueListOfValues
                        FilterDataForDisplayInList();//Filteres value form alex db and give new value to insert to list teurns:AfterFilteringFromAlexValueListOfValues


                        foreach (var item in AfterFilteringFromAlexValueListOfValues)
                        {
                            CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID + "[Value = " + item.presentValue + "]");
                            // CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                            //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                            // s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                        }




                        //*************************End of temperature filtering****************************//
                        //************************Humidity Filtering***************************************//



                        //--This only filteres temperature inside alex db 
                        FilterOnlyHumidityFromAlexDBValue();//Returns FilteredTemperatureValueList as a result

                        //--Returns AfterFilteringFromAlexValueListOfValues
                        FilterDataForDisplayInListForHumidity();//Filteres value form alex db and give new value to insert to list teurns:AfterFilteringFromAlexValueListOfValues


                        foreach (var item in AfterFilteringFromAlexValueListOfValuesForHumidityOnly)
                        {
                            //CB_param_temp.Items.Add(item.device_object_name + ":" + item.indexID + "[" + item.presentValue + "]");
                            CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID + "[Value = " + item.presentValue + "]");


                            // CB_param_hum.Items.Add(item.device_object_name + ":" + item.indexID);
                            //  CB_param_enthalpy.Items.Add(item.device_object_name + ":" + item.indexID);
                            // s += item.device_object_name + ":" + item.indexID + " value = " + item.presentValue+"\n";

                        }





                        //************************End of humidity filtering****************************//



                        CB_param_temp.Enabled = true;
                    CB_param_hum.Enabled = true;
                      //MessageBox.Show("ENd of the true");
                    //TEST
                }
                else
                {
                        //Show device is offline
                        lb_device_status.Text = "disconnected";
                }
                
            }//Close of if


            }catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }