private void btn_beginSession_Click(object sender, RoutedEventArgs e) { if (Session.SessionStatus == Session.Status.Uninitialized) { if (txtBox_patientName.Text != "") { txtBox_patientName.IsEnabled = false; //Disable and enable boxes now that the name has been set. btn_beginSession.Content = "End Session"; groupBox_Sensors.IsEnabled = true; groupBox_Motion.IsEnabled = true; updateSensors(); //Display all connected sensors. DataLogging.InitiateStreams(txtBox_patientName.Text); //Sets up the file for recording the patient's data. Session.Initialize(); } else { System.Windows.MessageBox.Show("Please enter a patient name.", "EMAT - Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else if (Session.SessionStatus == Session.Status.Initialized || Session.SessionStatus == Session.Status.Free) { txtBox_patientName.IsEnabled = true; btn_beginSession.Content = "Begin Session"; groupBox_Sensors.IsEnabled = false; groupBox_Motion.IsEnabled = false; txtBox_patientName.Text = ""; Session.Quit(); } else if (Session.SessionStatus == Session.Status.Busy) { } }
/// <summary> /// /// </summary> /// <param name="frequency"></param> /// <param name="amplitude"></param> private void TremorProcessing_CalculatedTremor(float frequency, float amplitude) { // Log clinician data DataLogging.LogClinicianData(amplitude, frequency, DateTime.Now); // Display and plot no tremor if the freq or magnitude are below threshold // Otherwise, plot frequency and magnitude, and display rounded values if (amplitude < TremorProcessing.Threshold_Amplitude) { _syncContext.Send(o => { lbl_tremor.Content = "Frequency: No Tremor Detected"; lbl_tremorAmp.Content = "Amplitude: No Tremor Detected"; updateGraph(); }, null); } else { _syncContext.Send(o => { lbl_tremor.Content = "Frequency: " + Math.Round(frequency, 1) + " Hz"; lbl_tremorAmp.Content = "Amplitude: " + Math.Round(amplitude, 2) + " mm"; updateGraph(TremorProcessing.Frequency, TremorProcessing.Amplitude); }, null); } _syncContext.Send(o => { lbl_averageThreshold.Content = "Average x Threshold: " + TremorProcessing.Average_Frequency * TremorProcessing.Threshold_Frequency; lbl_average.Content = "Average: " + TremorProcessing.Average_Frequency; lbl_maxBin.Content = "Largest Value: " + TremorProcessing.Largest_Bin; }, null); }
private void Awake() { // get the controller Engine = GetComponent <EngineModel>(); // DataLogger dataLogger = GetComponent <DataLogging>(); }
private void Start() { player = GameObject.FindGameObjectWithTag("Player").transform; canvas = GameObject.FindGameObjectWithTag("mainCanvas"); dataScript = canvas.GetComponent <DataLogging>(); signCounter = GameObject.FindGameObjectWithTag("sign count").transform; hospitalLightScript = player.GetComponent <HospitalLight>(); }
private void btn_exit_Click(object sender, EventArgs e) { if (running) { // Stop the collection and calculation events Nodes.NodesList[0].CapturedData -= Fusion_CapturedData; TremorProcessing.CalculatedTremor -= TremorProcessing_CalculatedTremor; // Stop the collection and calculation events Nodes.NodesList[0].Dispose(); Nodes.NodesList.Clear(); } DataLogging.Dispose(); this.Close(); }
public Form1() { InitializeComponent(); initCbbPorts(); initModeSelection(); mountEventHandlers(); /* initialise modbus client here.. */ mountModbusMaster(); /* Initialise the log file */ DataLogging.setCurrentLogFile(); Debug.WriteLine("Created a new log file at: " + DataLogging.CURRENT_LOG_FILE); //printYourName("David"); Debug.WriteLine(MathLibraryWrapper.add(1, 2).ToString()); Debug.WriteLine(MathLibraryWrapper.subtract(100, 1).ToString()); Debug.WriteLine(WimodHCIWrapper.printFromHCIDLL()); Debug.WriteLine(WimodHCIWrapper.wrap_WiMOD_HCI_Init()); Debug.WriteLine(WimodHCIWrapper.getWiMODPayloadSize()); /*fibonacci_init(1,1); * * do * { * Debug.WriteLine(fibonacci_index() + ": " + fibonacci_current()); * fibonacci_next(); * } while (fibonacci_index() <= 20);*/ }
private void btn_break_Click(object sender, RoutedEventArgs e) { DataLogging.InsertBreak(); }
/// <summary> /// This is where the sensor data goes when it has been captured. /// </summary> /// <param name="data">Data from he sensor. Remember, the structure of data is [accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z,mag_x,mag_y,mag_z]</param> /// <param name="deltaT">Time since previous data was given.</param> private static void Fusion_CapturedData(float[] data, float deltaT) { TremorProcessing.LogPoint(data[0], data[1], data[2], deltaT); DataLogging.LogRawData(deltaT, data[0], data[1], data[2], data[3], data[4], data[5], 0, 0, 0); }
void inputRegToGUI() { if (textBox1.InvokeRequired) { inputRegToGUIDelegate d = new inputRegToGUIDelegate(inputRegToGUI); this.Invoke(d, new object[] { }); } else { try { /* --- Fetch server response --- */ int[] serverResponse = modbusClient.ReadInputRegisters(INPUT_REG_START - 1, INPUT_REG_NUM_REGS); /* --- Voltages battery 0 to 3 --- */ string[] log_data = new string[10]; log_data[0] = ConversionUtils.trueBatVoltsFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[0])).ToString(); textBox1.Text = log_data[0]; log_data[1] = ConversionUtils.trueBatVoltsFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[1])).ToString(); textBox2.Text = log_data[1]; log_data[2] = ConversionUtils.trueBatVoltsFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[2])).ToString(); textBox3.Text = log_data[2]; log_data[3] = ConversionUtils.trueBatVoltsFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[3])).ToString(); textBox4.Text = log_data[3]; /* --- Voltage solar --- */ log_data[4] = ConversionUtils.trueSolarVoltsFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[4])).ToString(); textBox5.Text = log_data[4]; /* --- Current solar --- */ log_data[5] = ConversionUtils.trueCurrentFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[5]), ConversionUtils.RS_PV_CHARGE, ConversionUtils.RL_PV_CHARGE).ToString(); textBox6.Text = log_data[5]; /* --- Current charging --- */ log_data[6] = ConversionUtils.trueCurrentFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[6]), ConversionUtils.RS_PV_CHARGE, ConversionUtils.RL_PV_CHARGE).ToString(); textBox7.Text = log_data[6]; /* --- Current load --- */ log_data[7] = ConversionUtils.trueCurrentFromADC(ConversionUtils.adcValueFromScaled((ushort)serverResponse[7]), ConversionUtils.RS_LOAD, ConversionUtils.RL_LOAD).ToString(); textBox8.Text = log_data[7]; /* --- Active and charging states --- */ setActiveChkbx((int)serverResponse[8]); log_data[8] = ((int)serverResponse[8]).ToString(); Debug.WriteLine("Active battery: " + ((int)serverResponse[8]).ToString()); setChargeChkbx((int)serverResponse[9]); Debug.WriteLine("Charging battery: " + ((int)serverResponse[9]).ToString()); log_data[9] = ((int)serverResponse[9]).ToString(); /* Maybe also calculate the power consume of the system. */ /* Write to system log */ DataLogging.WriteDataToLog(log_data); Debug.Write("Wrote data to log file\n"); int[] holdingServerRsp = modbusClient.ReadHoldingRegisters(HOLDING_REG_START - 1, HOLDING_REG_NUM_REGS); updateCurrentSettings(holdingServerRsp); if ((ushort)holdingServerRsp[8] == 1) { throw new EmergencyStopException(); } } catch (EmergencyStopException esexc) { if (CYCLIC_READ) { CYCLIC_READ = false; btnCyclicRead.Text = "Start Cyclic Read"; btnCyclicRead.BackColor = Color.Plum; btnRead1.Enabled = true; } alertEmergencyStop(); } catch (Exception exc) { Debug.WriteLine("Exception Reading values from Server."); // Print error message txtComErrors.Text = "No response from server. Sure you're connected?"; txtConnectState.Text = "MODBUS not connected"; txtConnectState.BackColor = Color.Red; if (CYCLIC_READ) { CYCLIC_READ = false; btnCyclicRead.Text = "Start Cyclic Read"; btnCyclicRead.BackColor = Color.Plum; btnRead1.Enabled = true; } } } }