public static void servoPort_Change(object sender, serialComms.SerialArgs ca) { byte[] multinumbers = GUI_Forms.Program.servoPort.getCommBuffer(); if (multinumbers.Length == 2) { Data.constants.Pan = (int)multinumbers[0]; Data.constants.Tilt = (int)multinumbers[1]; } }
public static void multiLateration_Change(object sender, serialComms.SerialArgs ca) { Console.WriteLine("Multilat Changed"); byte[] multinumbers = GUI_Forms.Program.multiLateration.getCommBuffer(); /* for (int pl = 0; pl < multinumbers.Length; pl++) { Console.Write("CommBuffer " + pl + " is " + (int)multinumbers[pl] + " "); } Console.Write("\n"); */ if(multinumbers.Length==6) { GUI_Forms.Program.multiLateration.setCommBuffer(new byte[0]); int[] numbers = new int[3]; numbers[0] = ((int)multinumbers[0] << 8) + (int)multinumbers[1]; numbers[1] = ((int)multinumbers[2] << 8) + (int)multinumbers[3]; numbers[2] = ((int)multinumbers[4] << 8) + (int)multinumbers[5]; int multiangle = MultiLatHelper.getPanAngle(numbers[0], numbers[1], numbers[2]); int tempMultiLat = MultiLatHelper.Angle2Bits(multiangle); Console.WriteLine("----------MULTI----------"); Console.WriteLine("\tRecieved numbers: " +numbers[0] + "\t" + numbers[1] + "\t" + numbers[2]); Console.WriteLine("\tAngle: " + multiangle); Console.WriteLine("\tPan Value: " + tempMultiLat); if (tempMultiLat != -1) { Data.constants.Pan = tempMultiLat; InterfaceFunctions.Interface.moveServos(Data.constants.Pan, Data.constants.Tilt); } else { Console.WriteLine("CLAP AGAIN"); } } }
public static void bluetoothDevice_Change(object sender, serialComms.SerialArgs ca) { byte[] bluetoothData = GUI_Forms.Program.bluetoothDevicePort.getCommBuffer(); GUI_Forms.Program.bluetoothDevicePort.setCommBuffer(new byte[0]); if (bluetoothData.Length == 5) { // update server entry ServerFunctions.ServerFuncs.svrSetMedInfo(Data.constants.UserID, bluetoothData[1], bluetoothData[2], bluetoothData[3], bluetoothData[4]); //ServerFunctions.ServerFuncs.svrSetMedInfo(Data.constants.UserID, "Device ID: " + bluetoothData[1] + " Heart Rate (BPM): " + bluetoothData[2] + " Blood Pressure: " + bluetoothData[3] + "/" + bluetoothData[4]); } }
private void redButton_Change(object sender, serialComms.SerialArgs ca) { byte[] redButtonData = GUI_Forms.Program.redButtonPort.getCommBuffer(); if (redButtonData[0] == 0x01) { // Emergency - join doctor conf Data.constants.Emergency = true; } else if (redButtonData[0] == 0) { // No Emergency - do nothing } else { // Error } GUI_Forms.Program.redButtonPort.setCommBuffer(new byte[0]); }