/// <summary> /// Creates a PI point on the PI server with a given value /// </summary> /// <param name="value"></param> private void createPIPoint(float value) { try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { string usertag = textBox_tag.Text;//set new value to a certain point //Creating a point myPI.createPiPoint(usertag, 2); // Setting the value of the point // Also have the power to only update the value on an existing // tag instead of creating a new tag. myPI.setPiPointValue(usertag, myTruncate(value, 6)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { } }
public void parseVal(string letter, string value) { string connection = "S14_VICE_Connection"; string rpm = "S14VICE_RPM"; string flow = "S14VICE_Flow"; string pressure = "S14VICE_Pressure"; string voltage = "F13APA_Voltage"; string currenttop = "F13APA_CurrentTOP"; string currentbot = "F13APA_CurrentBOTTOM"; string powertop = "F13APA_Power_Top"; string powerbot = "F13APA_Power_Bot"; switch (letter) //checks first value in string for command { case "C": //if Pressure // string pressureVal = pressure + PIout.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(connection, (float.Parse(value))); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "PR": //if Pressure // string pressureVal = pressure + PIout.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(pressure, (float.Parse(value))); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "RPM": //if RPM // string rpmVal = rpm + PIout.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(rpm, (float.Parse(value))); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "F": //if Flow //string flowVal = flow + PIout.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(flow, (float.Parse(value))); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "V": //if voltage string vtemp = voltage + outlet.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(vtemp, ((((float.Parse(value)) * 120) / Math.Pow(2, 23)) / .6)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "IT": //if current TOP outlet string currenttoptemp = currenttop + outlet.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(currenttoptemp, ((((float.Parse(value)) * 15) / (Math.Pow(2, 24) - 1)) / .6)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "IB": //if current BOT outlet string currentbottemp = currentbot + outlet.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(currentbottemp, ((((float.Parse(value)) * 15) / (Math.Pow(2, 24) - 1)) / .6)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "PT": //POWER TOP string powertoptemp = powertop + outlet.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(powertoptemp, 1 - ((float.Parse(value)) / (Math.Pow(2, 23) - 1))); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "PB": //POWER BOT string powerbottemp = powerbot + outlet.ToString(); try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue(powerbottemp, 1 - ((float.Parse(value)) / (Math.Pow(2, 23) - 1))); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "S": //set outlet Status outlet = int.Parse(value); break; case "STM": //set outlet Status stream = int.Parse(value); break; case "OO": //command from Web Service try { myPI.connect_Server("ESMARTSERVER-PC"); if (myPI.check_connection()) { //Setting the value of the point myPI.setPiPointValue("F13APA_STATUS", int.Parse(value)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } switch (value) //case for outlet switching from web service { case "00": { if (outlet == 1) { PythonComm.sendTCP(EWO1, 9750, "<,RT=0,RB=0,TM=" + stream.ToString() + ",>"); } else if (outlet == 2) { PythonComm.sendTCP(EWO2, 9750, "<,RT=0,RB=0,TM=" + stream.ToString() + ",>"); } } break; case "11": { if (outlet == 1) { PythonComm.sendTCP(EWO1, 9750, "<,RT=1,RB=1,TM=" + stream.ToString() + ",>"); } else if (outlet == 2) { PythonComm.sendTCP(EWO2, 9750, "<,RT=1,RB=1,TM=" + stream.ToString() + ",>"); } } break; case "10": { if (outlet == 1) { PythonComm.sendTCP(EWO1, 9750, "<,RT=1,RB=0,TM=" + stream.ToString() + ",>"); } else if (outlet == 2) { PythonComm.sendTCP(EWO2, 9750, "<,RT=1,RB=0,TM=" + stream.ToString() + ",>"); } } break; case "01": { if (outlet == 1) { PythonComm.sendTCP(EWO1, 9750, "<,RT=0,RB=1,TM=" + stream.ToString() + ",>"); } else if (outlet == 2) { PythonComm.sendTCP(EWO2, 9750, "<,RT=0,RB=1,TM=" + stream.ToString() + ",>"); } } break; } break; default: break; } }