public InsertNodeInfoToDBWithoutDeviceInfo ( string buildingName, string chart_respective_nodeID, string id, double xVal, double yVal, string temperature_source, string humidity_source, string name, Color colorValue, int nodeSizeValue, string airFlow ) : void | ||
buildingName | string | |
chart_respective_nodeID | string | |
id | string | node id |
xVal | double | x axis value |
yVal | double | y axis value |
temperature_source | string | Temperature source[Manual/Web/Device] |
humidity_source | string | Humidity source[Manual/Web/Device] |
name | string | Node name |
colorValue | Color | Node color |
nodeSizeValue | int | Node Size |
airFlow | string | |
리턴 | void |
int airFlowValueGlobal = 1000; //This will be updated public void plot_on_graph_values_process_diagram(double xval, double yval) { //chart1.Series.Clear(); try { series1.ChartType = SeriesChartType.Point; //int r, g, b; series1.MarkerSize = 20; series1.MarkerStyle = MarkerStyle.Circle; series1.Points.AddXY(xval, yval); string s = "source :\nTemperature Source " + temperature_sourceGlobal + "\nHumidity Source" + humidity_sourceGlobal + "\n Name : " + tbName; series1.Points[index].Color = colorValue; series1.Points[index].ToolTip = s; string labelStringValue = null; //labeling part //if (comboboxItemText == "Label") //{ // //label is selected // labelStringValue = tbLabel; //} //else if (comboboxItemText == "Name") //{ //Name is selected labelStringValue = tbName; //} //else //{ // //Source is selected // labelStringValue = tbSource; //} series1.Points[index].Label = labelStringValue; // MessageBox.Show("value xval =" + xval + ",yval = " + yval); //series1.Points[index_series++].Color = colorValue;//blue // MessageBox.Show("end re"); //index_series++; //series1.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } //now lets move on to storing those values and futher porcessing it... //we need to get this a unique id string unique_id_for_node = selectedBuildingList[0].BuildingName + GetGUID();//This is the unique id //the value is added... menuStripNodeInfoValues.Add(new TempDataType { id = unique_id_for_node, xVal = xval, yVal = yval, // source = tbSource, temperature_source = temperature_sourceGlobal, humidity_source = humidity_sourceGlobal, name = tbName, // label = tbLabel, colorValue = colorValue, // showItemText = comboboxItemText, marker_Size = markerSize , airFlow = airFlowValueGlobal }); //--Inserting the node values in the database sqlite if (flagForInsertOrUpdateDataToDB == 1) { //do only if the flag is raised. // InsertNodeInfoToDB(unique_id_for_node, xval, yval, tbSource, tbName, tbLabel, colorValue, comboboxItemText, markerSize, deviceInstanceValue, deviceIP, deviceParam1ID, deviceParam2ID, device_param1_info_for_node, device_param2_info_for_node, object_param1_identifier_type, object_param2_identifier_type); //--New code is added to here DatabaseOperations ObjDbOperation = new DatabaseOperations(); // MessageBox.Show("Building Name= " + selectedBuildingList[0].BuildingName); // MessageBox.Show(unique_id_for_node+"xval = "+ xval+" yval"+ yval+"temp "+ temperature_sourceGlobal+"hum="+ humidity_sourceGlobal+",name="+ tbName+",col="+ colorValue+",size=" +markerSize +",air="+airFlowValueGlobal.ToString()); ObjDbOperation.InsertNodeInfoToDBWithoutDeviceInfo(CurrentSelectedBuilding, chartDetailList[indexForWhichChartIsSelected].chart_respective_nodeID, unique_id_for_node, xval, yval, temperature_sourceGlobal, humidity_sourceGlobal, tbName, colorValue, markerSize, airFlowValueGlobal.ToString()); // MessageBox.Show("Operation Complete Test"); //InsertNodeInfoToDBWithoutDeviceInfo(unique_id_for_node,) } //the liine plot part is only done when ther is two points or more if (index > 0) { double startHumidity1 = 0; double startEnthalpy1 = 0; double endHumidity1 = 0;//--this is for the start and end humidity print in the tooltip double endEnthalpy1 = 0; //now lets plot lines between tow points... Series newLineSeries = new Series("LineSeries" + index); //string nameSeries = newLineSeries.Name; //--If the series already present lets remove from the chart ok ol :) if (chart1.Series.IndexOf(newLineSeries.Name) != -1) { //MessageBox.Show("Series exits"); //--This means the series is present.... chart1.Series.RemoveAt(chart1.Series.IndexOf(newLineSeries.Name)); } string unique_id_for_line = selectedBuildingList[0].BuildingName + GetGUID();//This is the unique id //--Lets store the nodeline info as well menuStripNodeLineInfoValues.Add(new lineNodeDataType { //--Id of this .. ID = unique_id_for_line, // prevNodeId = menuStripNodeInfoValues[index - 1].id, //previousNodeIndexForLineInput prevNodeId = menuStripNodeInfoValues[previousNodeIndexForLineInput].id, nextNodeId = menuStripNodeInfoValues[index].id, lineColorValue = menuStripNodeInfoValues[previousNodeIndexForLineInput].colorValue, lineSeriesID = newLineSeries, lineThickness = 3, //default thickness is 3 name = lineName, status = lineStatus_ON_OFF }); //--Adding to db if (flagForInsertOrUpdateDataToDB == 1) { //--Insert the values when the flag is raised. //InsertLineInfoToDB(unique_id_for_line, menuStripNodeInfoValues[index - 1].id, menuStripNodeInfoValues[index].id, menuStripNodeInfoValues[index - 1].colorValue, newLineSeries, menuStripNodeLineInfoValues[index - 1].lineThickness); // InsertLineInfoToDB(unique_id_for_line, menuStripNodeInfoValues[index - 1].id, menuStripNodeInfoValues[index].id, menuStripNodeInfoValues[index - 1].colorValue, newLineSeries,3); InsertLineInfoToDB(unique_id_for_line, menuStripNodeInfoValues[previousNodeIndexForLineInput].id, menuStripNodeInfoValues[index].id, menuStripNodeInfoValues[previousNodeIndexForLineInput].colorValue, newLineSeries, 3); } //newSeries.MarkerStyle = MarkerStyle.Triangle; newLineSeries.ChartType = SeriesChartType.Line; //newLineSeries.MarkerStyle = MarkerStyle.Circle; //newLineSeries.MarkerStyle = MarkerStyle.Star6; newLineSeries.MarkerBorderWidth.Equals(15); newLineSeries.MarkerSize.Equals(35); newLineSeries.BorderWidth.Equals(15); // newLineSeries.SetCustomProperty(newLineSeries.MarkerSize.ToString(),newLineSeries.MarkerSize.Equals(25).ToString()); newLineSeries.Color = menuStripNodeInfoValues[index].colorValue; //--this sets the initial values of humidity and enthalpy //CalculateHumidityEnthalpy((double)menuStripNodeInfoValues[index - 1].xVal, (double)menuStripNodeInfoValues[index - 1].yVal);//previousNodeIndexForLineInput CalculateHumidityEnthalpy((double)menuStripNodeInfoValues[previousNodeIndexForLineInput].xVal, (double)menuStripNodeInfoValues[previousNodeIndexForLineInput].yVal);//previousNodeIndexForLineInput startHumidity1 = Math.Round(humidityCalculated, 2);//--Fro showing only up to 2 dec. eg."34.52" startEnthalpy1 = Math.Round(enthalpyCalculated, 2); double startSpecificVolume1 = SpecificVolumeReturn; //--This calculates the end humidity and the enthalpy values.. CalculateHumidityEnthalpy((double)menuStripNodeInfoValues[index].xVal, (double)menuStripNodeInfoValues[index].yVal); endHumidity1 = Math.Round(humidityCalculated, 2); endEnthalpy1 = Math.Round(enthalpyCalculated, 2); double endSpecificVolume1 = SpecificVolumeReturn; double enthalpyChange = endEnthalpy1 - startEnthalpy1; // string sequenceDetected = menuStripNodeInfoValues[index - 1].name + " to " + menuStripNodeInfoValues[index].name; string sequenceDetected = menuStripNodeInfoValues[previousNodeIndexForLineInput].name + " to " + menuStripNodeInfoValues[index].name; //string tooltipString = "Sequence : " + sequenceDetected + " \n" + " start end \n" + "Temp :" + Math.Round(menuStripNodeInfoValues[index - 1].xVal, 2) + " " + Math.Round(menuStripNodeInfoValues[index].xVal, 2) + "\nHumidity :" + startHumidity1 + " " + endHumidity1 + "\nEnthalpy : " + startEnthalpy1 + " " + endEnthalpy1 + "\nEnthalpy Change:" + enthalpyChange; //=====================================THisi used========================// //--this sets the initial values of humidity and enthalpy //CalculateHumidityEnthalpy(temporaryNodeValueStoreForRedrawLine[0].xVal, temporaryNodeValueStoreForRedrawLine[0].yVal); //startHumidity1 = Math.Round(humidityCalculated, 2); //startEnthalpy1 = Math.Round(enthalpyCalculated, 2); //--This calculates the end humidity and the enthalpy values.. //CalculateHumidityEnthalpy((double)temporaryNodeValueStoreForRedrawLine[1].xVal, (double)temporaryNodeValueStoreForRedrawLine[1].yVal); //endHumidity1 = Math.Round(humidityCalculated, 2); //endEnthalpy1 = Math.Round(enthalpyCalculated, 2); // MessageBox.Show("Start hum" + startHumidity1 + " end enth" + endEnthalpy1); //MessageBox.Show("menustripinfovalues[prevNodeID].xVal=" + menuStripNodeInfoValues[prevNodeID].xVal + "menuStripNodeInfoValues[nextNodeID].yVal=" + menuStripNodeInfoValues[nextNodeID].yVal + "menuStripNodeInfoValues[nextNodeID].xVal = "+ menuStripNodeInfoValues[nextNodeID].xVal + " menuStripNodeInfoValues[nextNodeID].yVal" + menuStripNodeInfoValues[nextNodeID].yVal); // double enthalpyChange = endEnthalpy1 - startEnthalpy1; // string sequenceDetected = temporaryNodeValueStoreForRedrawLine[0].name + " to " + temporaryNodeValueStoreForRedrawLine[1].name; // string tooltipString = ""; string ZeroLine = "Process: " + lineName + " "; string FirstLine = @"Parameters " + "Units " + menuStripNodeInfoValues[previousNodeIndexForLineInput].name + " " + menuStripNodeInfoValues[index].name; string SecondLine = @"DBT " + "\x00B0 C " + Math.Round(menuStripNodeInfoValues[previousNodeIndexForLineInput].xVal, 2) + " " + Math.Round(menuStripNodeInfoValues[index].xVal, 2); string ThirdLine = @"Relative Humidity " + "% " + startHumidity1 + " " + endHumidity1; string FourthLine = @"Humidity Ratio " + "Kg/Kg dryair " + Math.Round(menuStripNodeInfoValues[previousNodeIndexForLineInput].yVal, 2) + " " + Math.Round(menuStripNodeInfoValues[index].yVal, 2); string FifthLine = "Volume Flow Rate " + "m\xB3/s " + Math.Round(menuStripNodeInfoValues[previousNodeIndexForLineInput].airFlow, 2) + " " + Math.Round(menuStripNodeInfoValues[index].airFlow, 2); string SixthLine = "Specific Volume " + "m\xB3/Kg " + startSpecificVolume1 + " " + endSpecificVolume1; double massFlowRate1 = menuStripNodeInfoValues[previousNodeIndexForLineInput].airFlow / startSpecificVolume1; double massFlowRate2 = menuStripNodeInfoValues[index].airFlow / endSpecificVolume1; string SeventhLine = @"Mass flow rate(dry air) " + "Kg(dry air)/s " + Math.Round(massFlowRate1, 2) + " " + Math.Round(massFlowRate2, 2); string EighthLine = @"Enthalpy " + "KJ/Kg " + startEnthalpy1 + " " + endEnthalpy1; double totalEnthalpyFlow1 = massFlowRate1 * startEnthalpy1; double totalEnthalpyFlow2 = massFlowRate2 * endEnthalpy1; string NinthLine = @"Total Enthalpy Flow " + "KJ/s " + Math.Round(totalEnthalpyFlow1, 2) + " " + Math.Round(totalEnthalpyFlow2, 2); double heatChange = totalEnthalpyFlow2 - totalEnthalpyFlow1; string TenthLine = @"Heat Change " + "KW " + Math.Round(heatChange, 2) + " "; string tooltipString = ZeroLine + "\n" + FirstLine + "\n" + SecondLine + "\n" + ThirdLine + "\n" + FourthLine + "\n" + FifthLine + "\n" + SixthLine + "\n" + SeventhLine + "\n" + EighthLine + "\n" + NinthLine + "\n" + TenthLine; newLineSeries.ToolTip = tooltipString; //=============================end of this is used======================// //newSeries.MarkerStyle = MarkerStyle.Circle; //newSeries.Points.AddXY(menuStripNodeInfoValues[index - 1].xVal, menuStripNodeInfoValues[index].xVal, menuStripNodeInfoValues[index - 1].yVal, menuStripNodeInfoValues[index].yVal); //newLineSeries.Points.Add(new DataPoint(menuStripNodeInfoValues[index - 1].xVal, menuStripNodeInfoValues[index - 1].yVal)); newLineSeries.Points.Add(new DataPoint(menuStripNodeInfoValues[previousNodeIndexForLineInput].xVal, menuStripNodeInfoValues[previousNodeIndexForLineInput].yVal)); //double mid_point_XValue = (menuStripNodeInfoValues[index - 1].xVal + menuStripNodeInfoValues[index].xVal)/ 2; //double mid_point_YValue = (menuStripNodeInfoValues[index - 1].yVal + menuStripNodeInfoValues[index].yVal) / 2; double mid_point_XValue = (menuStripNodeInfoValues[previousNodeIndexForLineInput].xVal + menuStripNodeInfoValues[index].xVal) / 2; double mid_point_YValue = (menuStripNodeInfoValues[previousNodeIndexForLineInput].yVal + menuStripNodeInfoValues[index].yVal) / 2; newLineSeries.Points.Add(new DataPoint(mid_point_XValue, mid_point_YValue)); newLineSeries.Points.Add(new DataPoint(menuStripNodeInfoValues[index].xVal, menuStripNodeInfoValues[index].yVal)); if(lineStatus_ON_OFF == 1) { newLineSeries.Points[1].Color = colorValue; newLineSeries.Points[1].Label = lineName; } chart1.Series.Add(newLineSeries); chart1.Series[newLineSeries.Name].BorderWidth = 3; } index++; previousNodeIndexForLineInput = IndexOfPreviousNodeForLineFunction(); }//close of buttons
public void AddMixNodeBetweenTwoNodes() { //Steps: /* 1.Identify node1 and node2, 2. CALCULATE THE mid point using section formula (x1,y1)-------------------------------(x2,y2) <------m-->P(x,y)<------n-----> P(x,y) = [(m*x2+n*x1)/(m+n),(m*y2+n*y1)/(m+n)] */ //============Lets check first======= if(indexOfPrevPointForLineMovement == ""|| indexOfNextNodeForLineMovement == "") { return;//If index seleted is empty return } mixCorrespondingNodeValuesList.Clear(); //--ADDING NODE1 info foreach(var node in menuStripNodeInfoValues) { //--Now lets find which node is being found if(node.id == indexOfPrevPointForLineMovement) { //Previous node is found ie node1 mixCorrespondingNodeValuesList.Add(new TempDataType { id = node.id, name= node.name, xVal = node.xVal, yVal = node.yVal, temperature_source = node.temperature_source , humidity_source = node.humidity_source, colorValue = node.colorValue , airFlow = node.airFlow, marker_Size = node.marker_Size, lastUpdatedDate = node.lastUpdatedDate });//This is the node of previous node found break; } } //Adding node2 info foreach (var node in menuStripNodeInfoValues) { //--Now lets find which node is being found if (node.id == indexOfNextNodeForLineMovement) { //Previous node is found ie node1 mixCorrespondingNodeValuesList.Add(new TempDataType { id = node.id, name = node.name, xVal = node.xVal, yVal = node.yVal, temperature_source = node.temperature_source, humidity_source = node.humidity_source, colorValue = node.colorValue, airFlow = node.airFlow, marker_Size = node.marker_Size, lastUpdatedDate = node.lastUpdatedDate });//This is the node of previous node found break; } }//Close of for each.. //Now let x_mix,y_mix contain the mix value of node double m = mixCorrespondingNodeValuesList[0].airFlow; double n = mixCorrespondingNodeValuesList[1].airFlow; double x1 = mixCorrespondingNodeValuesList[0].xVal; double y1 = mixCorrespondingNodeValuesList[0].yVal; //x2,y2; double x2 = mixCorrespondingNodeValuesList[1].xVal; double y2 = mixCorrespondingNodeValuesList[1].yVal; double x_mix = ((n * x2) + (m * x1)) / (m + n); double y_mix = ((n * y2) + (m * y1)) / (m + n); //Now we know the coordinates we need to plot now.. string idForNode = GetGUID();//This get the id int mixAirFlowContent = (int)(m + n); //Finding appropriate name string mixNodeName = UniqueMixName(); //--Now insert into db first then only plot the values //--Now lets update the values DatabaseOperations ObjDbOperation = new DatabaseOperations(); // MessageBox.Show("Building Name= " + selectedBuildingList[0].BuildingName); // MessageBox.Show(unique_id_for_node+"xval = "+ xval+" yval"+ yval+"temp "+ temperature_sourceGlobal+"hum="+ humidity_sourceGlobal+",name="+ tbName+",col="+ colorValue+",size=" +markerSize +",air="+airFlowValueGlobal.ToString()); ObjDbOperation.InsertNodeInfoToDBWithoutDeviceInfo(CurrentSelectedBuilding, chartDetailList[indexForWhichChartIsSelected].chart_respective_nodeID, idForNode, x_mix, y_mix, "Mix","Mix", mixNodeName, Color.Blue, 20, mixAirFlowContent.ToString()); //--Now inserting the node info ObjDbOperation.InsertMixNodeInfo(CurrentSelectedBuilding,chartDetailList[indexForWhichChartIsSelected].chartID, idForNode, indexOfPrevPointForLineMovement, indexOfNextNodeForLineMovement);//Insertion operation //Now plotting the values //=================Now refreshing the data =======================// //indexOfChartSelected = e.RowIndex; //This value is changed LoadNodeAndLineFromDB(indexOfChartSelected); //Lets make it passing the stirngs //flagForInsertOrUpdateDataToDB = 1; //--This is also completed.. ReDrawingLineAndNode(); //Done checking bbk modif: changing to alex db //====================End of data refresh }