/// <summary> /// Receives stream request from UI. /// Check UART characteristics are properly registered, then send request stream command out to remote device. /// </summary> public async Task Stream() { // Flush out data DATA_IN.Clear(); SystemUpdatedEventArgs args = new SystemUpdatedEventArgs { Status = SYS_STREAM_START, Message = "Starting data stream..." }; EVENT(args); // Request stream from menu await RUN_BLE_WRITE(uartRx, "S"); }
private void RELEASE_DATA(byte[] bytes, bool save = true) { // Reset packet index packetIndex = 0; // Save data try { // Send signal to Interface? if (STATUS == SYS_STREAM_START) { double[] z = new double[16]; // Perform calibration var calibrated = NeuralNetCalib.CalibratePacket(bytes); // Place calibrated z axis data in array and send with event for (int i = 0; i < 16; i++) { z[i] = calibrated[i, Z_AXIS]; } PressureUpdatedEventArgs args = new PressureUpdatedEventArgs { Values = z }; PressureUpdated(this, args); } // Save to array of input data if (save) { DATA_IN.Add(bytes); } } catch (Exception ex) { Debug.WriteLine($"Failed to write {BitConverter.ToString(bytes)} to app with exception: {ex.Message}"); } // Return empty array of same size buffer = new byte[bytes.Length]; }
public void WRITE_FILE(List <byte[]> data, string name, byte[] header = null, byte[] footer = null) { FileManager.WriteFile(data, name, header, footer); DATA_IN.Clear(); }