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 }
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 }
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) { 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); } }