private static void RunProcess(BluetoothCmd bcmd, Bluetooth oBluetooth) { if (bcmd.CmdBytes != null && bcmd.CmdBytes.Length != 0) { if (!oBluetooth.isTestMode()) { Task.Run(async() => { if (await oBluetooth.SendCommandAsync(bcmd)) { UpdateProcessItem(bcmd); } else { Debug.WriteLine("Process: {0} {1}", bcmd.Name, Bluetooth.GetStatusMessage()); } }); } else { if (oBluetooth.SendCommandAsync_Test(bcmd)) { UpdateProcessItem(bcmd); } else { Debug.WriteLine("Process: {0} {1}", bcmd.Name, Bluetooth.GetStatusMessage()); } } } }
private static async Task RunProcess(BluetoothCmd bcmd, Bluetooth oBluetooth, bool isTest) { if (bcmd.CmdBytes != null && bcmd.CmdBytes.Length != 0) { if (!isTest) { if (await oBluetooth.SendCommandAsync(bcmd)) { UpdateProcessItem(bcmd); } else { Debug.WriteLine("{0} Error: {1}", bcmd.Name, Bluetooth.GetStatusMessage()); } } else { if (oBluetooth.SendCommandAsync_Test(bcmd)) { UpdateProcessItem(bcmd); } else { Debug.WriteLine("{0} Error: {1}", bcmd.Name, Bluetooth.GetStatusMessage()); } } } }
public static void InitUnitType(BluetoothCmd bthcmd, UserSettings.UNIT_TYPE Unit_Type) { if (Unit_Type == UserSettings.UNIT_TYPE.IMPERIAL) { unitsImperial.InitType(bthcmd); } else { unitsMetric.InitType(bthcmd); } }
private static void UpdateProcessItem(BluetoothCmd bcmd) { // ToDo: Add direct ProcessItem reference to BluetoothCmd objects for faster iteration? foreach (ProcessItem pi in ProcessItems.Where(pi => pi.id == bcmd.Id)) { pi.Value = bcmd.value.ToString(); break; } //Debug.WriteLine("Process: {0} Rx: {1} RxValue: {2} Value: {3}", bcmd.Name, // bcmd.Response, (bcmd.isRxBytes) ? bcmd.rxvalue : -1, bcmd.value); }
private static void AddListViewItem(BluetoothCmd bthCmd) { if (!string.IsNullOrEmpty(bthCmd.Name)) { ProcessItems.Add ( new ProcessItem { Name = bthCmd.Name, Value = string.Empty, Units = bthCmd.GetUnits(), id = bthCmd.Id } ); } }
private void SetProcessPickerSelection(int index) { if (index == -1 || pkrProcess.Items.Count == 0) { return; } BluetoothCmd bthCmd = (BluetoothCmd)pkrProcess.SelectedItem; if (bthCmd == null) { throw new Exception("Selection Error Occurred"); } bthCmd.isSelected = isPickerProcessAdd; if (!BlueToothCmds.updateRecord(bthCmd)) { throw new Exception("Failed to update command"); } UpdateListViewItems(); if (!bthCmd.isSelected) { bthCmd.Selection_Type = (bthCmd.Selection_Type == BlueToothCmds.SELECTION_TYPE.USER_PROCESS) ? BlueToothCmds.SELECTION_TYPE.PROCESS : BlueToothCmds.SELECTION_TYPE.NONE; } else { bthCmd.Selection_Type = (bthCmd.Selection_Type == BlueToothCmds.SELECTION_TYPE.PROCESS) ? BlueToothCmds.SELECTION_TYPE.USER_PROCESS : BlueToothCmds.SELECTION_TYPE.USER; } }