private async void BtnDisconnect_Clicked(object sender, EventArgs e) { if (device != null && device.Name == "HET Wound v2.1-001") { await adapter.DisconnectDeviceAsync(device); string notif = ("You've disconnected from " + device.Name); await DisplayAlert("Notice", notif, "OK"); if (WoundPage.ConnectionDelete != null) { WoundPage.ConnectionDelete(false); } if (MainPage.SetDeviceName != null) { MainPage.SetDeviceName("No Device", "Disconnected"); } device = null; } else { await DisplayAlert("Notice", "You are not connected to a device", "OK"); } }
public void ScaleReadyData() { while (true) { if (data_packets.Count > 0) { var _data = data_packets.Dequeue(); try { //Stopwatch watch = new Stopwatch(); //watch.Start(); if (_data != null) { if (wound == null) { wound = new WoundSensors(); } int channel = _data[0]; float bias = (float)Math.Round((_data[1] - 1) * -0.05, 1); float voltage = ((_data[2] & 0xff) << 8) | (_data[3] & 0xff); float temp = ((_data[6] & 0xff) << 8) | (_data[7] & 0xff); float batteryOut = (float)(((_data[4] & 0xff) << 8) | (_data[5] & 0xff)); float batteryVoltage = (batteryOut) / (float)(435.0); float current = (float)((voltage) / 32767.0 * 2.048); float temperature = (float)Math.Round((temp) / 4096.0 * 3.3, 3); wound.user_id = MainPage.mac; wound.mChannel = channel; wound.mTemperature = temperature; wound.mBattery_voltage = batteryVoltage; wound.mBias = bias; wound.mLmpoutput = current; wound.mTimeStamp = (System.DateTime.Now.ToString(Constants.DATETIMEFORMAT)); //woundData = ConvertWoundSensor(woundData, wound); if (WoundPage.SetWoundData != null) { WoundPage.SetWoundData(wound.GetDoubleArray()); } SyncData(wound); //if (PowerBILive != null) //{ // var dataWound = string.Format(Constants.wounddata, DateTime.Now.ToString(Constants.DATETIMEFORMAT), woundData.Channel.ToString(), woundData.Lmpoutput.ToString(), woundData.Temperature.ToString()); // PowerBILive(dataWound, NetworkCommunicationManager.DATATYPE.WOUND); //} } } catch (Exception ex) { ExceptionErrorLogger.writeFileOnInternalStorage(ex.ToString()); } } } }