public Radio() { _state = RadioState.None; _pause = false; _speed = 1; _progress = 0; }
private void buildPriorityOutput(TaskKeeper currentTaskKeeper) { RadioState classPriority = currentTaskKeeper.TaskPriority; var classString = "Class: " + currentTaskKeeper.ClassName; if (classPriority == RadioState.Low) { this.lowPriorityStringBuilder.AppendLine(classString); foreach (var currentString in currentTaskKeeper.TaskCollection) { this.lowPriorityStringBuilder.AppendLine(currentString); } } if (classPriority == RadioState.Medium) { this.mediumPriorityStringBuilder.AppendLine(classString); foreach (var currentString in currentTaskKeeper.TaskCollection) { this.mediumPriorityStringBuilder.AppendLine(currentString); } } if (classPriority == RadioState.High) { this.highPriorityStringBuilder.AppendLine(classString); foreach (var currentString in currentTaskKeeper.TaskCollection) { this.highPriorityStringBuilder.AppendLine(currentString); } } }
internal BaseRadio(RadioDevice device, Radios parent) { DeviceName = device.DeviceName; DisplayName = device.DisplayName; m_state = device.ActualState ? RadioState.On : RadioState.Off; m_parent = parent; }
private void HandleGettingRadioDevicesTransition(RadioState nextState) { if (nextState != RadioState.GettingRadioDevices) { return; } }
private Task <RadioAccessStatus> DoSetStateAsync(RadioState state) { bool success = false; bool enable = state == RadioState.On; string path = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\BTHPORT\\Parameters\\Radio Support", "SupportDLL", string.Empty).ToString(); if (!string.IsNullOrEmpty(path)) { //load dll IntPtr hmodule = NativeMethods.LoadLibrary(path); if (hmodule != IntPtr.Zero) { //call function IntPtr addr = NativeMethods.GetProcAddress(hmodule, "BluetoothEnableRadio"); if (addr != IntPtr.Zero) { NativeMethods.BluetoothEnableRadio deleg = Marshal.GetDelegateForFunctionPointer <NativeMethods.BluetoothEnableRadio>(addr); int result = deleg.Invoke(enable); success = result == 0; } //free dll NativeMethods.FreeLibrary(hmodule); } } return(Task.FromResult <RadioAccessStatus>(success ? RadioAccessStatus.Allowed : RadioAccessStatus.Unspecified)); }
private RadioState GetState() { RadioState state = RadioState.Unknown; var t = Task.Run(async() => { PeerFinder.AlternateIdentities["Bluetooth:Paired"] = ""; try { var peers = await PeerFinder.FindAllPeersAsync(); state = RadioState.On; } catch (Exception ex) { if ((uint)ex.HResult == 0x8007048F) { state = RadioState.Off; } } }); t.Wait(); return(state); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left && e.Clicks == 1) { ControlState = RadioState.Pressed; } }
public void MoveTo(RadioState radioState) { var oldState = this.currentRadioState; this.currentRadioState = radioState; this.StateTransition?.Invoke(this, new StateTransitionEventHandlerArgs(oldState, this.currentRadioState)); }
/// <summary> /// An asynchronous operation that attempts to set the state of the radio represented by this object. /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks> /// <para/><list type="table"> /// <listheader><term>Platform</term><description>Version supported</description></listheader> /// <item><term>Android</term><description>Android 4.4 and later</description></item> /// <item><term>Windows UWP</term><description>Windows 10</description></item> /// <item><term>Windows (Desktop Apps)</term><description>Windows 7 or later</description></item></list> /// </remarks> public Task <RadioAccessStatus> SetStateAsync(RadioState value) { #if WINDOWS_UWP || __ANDROID__ || WIN32 return(DoSetStateAsync(value)); #else return(Task.FromResult(RadioAccessStatus.Unspecified)); #endif }
private async Task HandlePlayingTransition(RadioState nextState) { if (nextState != RadioState.Playing) { return; } await this.StartSignalMeasure(); }
private void ValidateRadioState(params RadioState[] required) { RadioState curState = State; if (required.Contains(curState) == false) { throw new InvalidOperationException($"{curState} is not valid state."); } }
private void determineTabStates() { var firstTabTagValue = int.Parse(this.firstTabHomeworkTracker.Tag.ToString()); var secondTabTagValue = int.Parse(this.secondTabHomeworkTracker.Tag.ToString()); var thirdTabTagValue = int.Parse(this.thirdTabHomeworkTracker.Tag.ToString()); this.firstTabState = (RadioState)firstTabTagValue; this.secondTabState = (RadioState)secondTabTagValue; this.thirdTabState = (RadioState)thirdTabTagValue; }
private void HandleDeviceOnTransition(RadioState nextState) { if (nextState != RadioState.DeviceOn) { return; } this.OnOffButton.BackColor = Color.Red; this.OnOffButton.Text = "Off"; }
/// <summary> /// An asynchronous operation that attempts to set the state of the radio represented by this object. /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks> /// <para/><list type="table"> /// <listheader><term>Platform</term><description>Version supported</description></listheader> /// <item><term>Android</term><description>Android 4.4 and later</description></item> /// <item><term>Windows UWP</term><description>Windows 10</description></item> /// <item><term>Windows (Desktop Apps)</term><description>Windows 7 or later</description></item></list> /// </remarks> public async Task <RadioAccessStatus> SetStateAsync(RadioState value) { #if WINDOWS_UWP return((RadioAccessStatus)((int)await _radio.SetStateAsync((Windows.Devices.Radios.RadioState)((int)value)))); #elif __ANDROID__ || WIN32 return(await DoSetStateAsync(value)); #else return(RadioAccessStatus.Unspecified); #endif }
private void HandleDeviceSelectedTransition(RadioState nextState) { if (nextState != RadioState.DeviceSelected) { return; } this.OnOffButton.Enabled = true; this.OnOffButton.BackColor = Color.GreenYellow; this.OnOffButton.Text = "On"; }
public bool CanMoveTo(RadioState goToRadioState) { var canMoveTo = this .stateMovementDictionary[this.currentRadioState] .Contains(goToRadioState); var canMoveText = canMoveTo ? "Yes" : "No"; Debug.WriteLine($"From {this.currentRadioState}, To {goToRadioState}, {canMoveText}"); return(canMoveTo); }
private void HandleDeviceOffTransition(RadioState nextState) { if (nextState != RadioState.DeviceOff) { return; } this.OnOffButton.BackColor = Color.GreenYellow; this.OnOffButton.Text = "On"; this.ProgramListBox.Items.Clear(); }
private static void ProcessRadioInfo(N1mmRadioInfo ri) { //Log($"{ri.StationName} {ri.Freq} {ri.TXFreq}"); RadioState rs = new RadioState { LastUpdated = DateTime.Now, Frequency = Math.Round(ri.TXFreq / 100000.0, 4), ID = ri.StationName, }; PostObject(new[] { rs }, "radios"); }
/// <summary> /// An asynchronous operation that attempts to set the state of the radio represented by this object. /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks> /// <para/><list type="table"> /// <listheader><term>Platform</term><description>Version supported</description></listheader> /// <item><term>Android</term><description>Android 4.4 and later</description></item> /// <item><term>Windows UWP</term><description>Windows 10</description></item> /// <item><term>Windows (Desktop Apps)</term><description>Windows 7 or later</description></item></list> /// </remarks> public Task <RadioAccessStatus> SetStateAsync(RadioState value) { #if WINDOWS_UWP return(Task <RadioAccessStatus> .Run(async() => { return (RadioAccessStatus)((int)await _radio.SetStateAsync((Windows.Devices.Radios.RadioState)((int)value))); })); #elif __ANDROID__ || WIN32 return(DoSetStateAsync(value)); #else return(Task.FromResult(RadioAccessStatus.Unspecified)); #endif }
void Awake() { _state = RadioState.None; _pause = false; _speed = 1; _progress = 0; _frame = 0; _particles = GetComponentsInChildren <ParticleSystem>(); _animators = GetComponentsInChildren <Animator>(); _trails = GetComponentsInChildren <TrailRenderer>(); UpdateSpeed(); UpdateScale(); state = RadioState.Stop; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (e.Button == MouseButtons.Left && e.Clicks == 1) { if (ClientRectangle.Contains(e.Location)) { ControlState = RadioState.Hover; } else { ControlState = RadioState.Normal; } } }
public bool InteractionValid() { switch (m_radioState) { case RadioState.OFF: m_radioState = RadioState.ON; m_radioStarted.Invoke(); break; case RadioState.ON: m_radioState = RadioState.OFF; m_radioStopped.Invoke(); break; } return(true); }
private Color determineTabColor(RadioState currentState) { var returnColor = Color.Gray; if (currentState == RadioState.Medium) { returnColor = Color.Yellow; } if (currentState == RadioState.High) { returnColor = Color.Red; } return(returnColor); }
public static string RadioStateToString(RadioState band) { switch (band) { case RadioState.Rx: return("RX"); case RadioState.Tx: return("TX"); case RadioState.Inhibit: return("TX INHIBIT"); } return("UNKNOWN"); }
private Task <RadioAccessStatus> DoSetStateAsync(RadioState state) { bool success = false; switch (state) { case RadioState.On: success = _manager.Adapter.Enable(); break; default: success = _manager.Adapter.Disable(); break; } return(Task <RadioAccessStatus> .FromResult(success?RadioAccessStatus.Allowed : RadioAccessStatus.DeniedBySystem)); }
private BluetoothState RadioStateTo(RadioState State) { switch (State) { case RadioState.Off: return(BluetoothState.Off); case RadioState.On: return(BluetoothState.On); case RadioState.Disabled: return(BluetoothState.Unavailable); default: return(BluetoothState.Unknown); } }
private RadioState GetState() { RadioState state = RadioState.Unknown; /*if (s_type10 != null) * { * return (RadioState)((int)s_type10.GetProperty("State").GetValue(_object10)); * } * else * {*/ try { string path = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\BTHPORT\\Parameters\\Radio Support", "SupportDLL", string.Empty).ToString(); if (!string.IsNullOrEmpty(path)) { //load dll IntPtr hmodule = NativeMethods.LoadLibrary(path); if (hmodule != IntPtr.Zero) { //call function IntPtr addr = NativeMethods.GetProcAddress(hmodule, "IsBluetoothRadioEnabled"); if (addr != IntPtr.Zero) { bool enabled = false; NativeMethods.IsBluetoothRadioEnabled deleg = Marshal.GetDelegateForFunctionPointer <NativeMethods.IsBluetoothRadioEnabled>(addr); int result = deleg.Invoke(ref enabled); if (result == 0) { state = enabled ? RadioState.On : RadioState.Off; } } //free dll NativeMethods.FreeLibrary(hmodule); } } } catch { } //} return(state); }
public static RadioStatus ToRadioStatus(this RadioState status) { switch (status) { case RadioState.On: return(RadioStatus.On); case RadioState.Off: return(RadioStatus.Off); case RadioState.Disabled: return(RadioStatus.Disabled); default: case RadioState.Unknown: return(RadioStatus.Unknown); } }
internal void SetState(IRadio radio, RadioState newState) { lock (m_radios) { IntPtr pDeviceList = IntPtr.Zero; if (GetDeviceList(ref pDeviceList, 0) == -1) { throw new Exception("Failed to get device list"); } if (pDeviceList != IntPtr.Zero) { try { RadioDevice device; IntPtr next = pDeviceList; do { device = new RadioDevice(next, 0); if (device.RadioType == radio.RadioType) { ChangeRadioState(device.Pointer, newState, SaveAction.PreSave); // don't exit the loop - we need to free all name strings } next = device.Next; } while (next != IntPtr.Zero); } finally { FreeDeviceList(pDeviceList); } } } }
public Radio(ushort address) { state = RadioState.IDLE; port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); port.ReadTimeout = 2; port.Open(); data = new InterfacePacket(0xFE, (int)PACKET.ANALOG_BYTES, (int)PACKET.DIGITAL_BYTES); buffer = new byte[128]; receiver = new XBeeReceiver(); frame = 0; radioThread = new Thread(new ThreadStart(this.Poll)); radioThread.Start(); }
internal RadioStateChangedEventArgs(RadioState oldState, RadioState newState) { OldState = oldState; NewState = newState; }
public Radio(Robot robo, string portName) { robot = robo; UIAnalogVals = new int[(int)INTERFACEPACKET.ANALOG_BYTES]; UIDigitalVals = new bool[(int)INTERFACEPACKET.DIGITAL_BYTES]; FieldAnalogVals = new int[(int)FIELDPACKET.ANALOG_BYTES]; FieldDigitalVals = new bool[(int)FIELDPACKET.DIGITAL_BYTES]; state = RadioState.IDLE; port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One); port.ReadTimeout = 2; port.Open(); data = new InterfacePacket((byte)INTERFACEPACKET.IDENT, (int)INTERFACEPACKET.ANALOG_BYTES, (int)INTERFACEPACKET.DIGITAL_BYTES); telemetry = new TelemetryPacket((byte)TELEMETRYPACKET.IDENT, (int)TELEMETRYPACKET.ANALOG_BYTES, (int)TELEMETRYPACKET.DIGITAL_BYTES); buffer = new byte[128]; telemetryThread = new Thread(new ThreadStart(this.Telemetry)); receiver = new XBeeReceiver(this); frame = 0; Debug.Print(" **** Radio constructor ****"); radioThread = new Thread(new ThreadStart(this.Poll)); radioThread.Start(); }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); ControlState = RadioState.Normal; }
protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); ControlState = RadioState.Hover; }
public Radio_Series1(Robot robo, string portName) { robot = robo; UIAnalogVals = new int[(int)INTERFACEPACKET.ANALOG_BYTES]; UIDigitalVals = new bool[(int)INTERFACEPACKET.DIGITAL_BYTES * 8]; state = RadioState.IDLE; port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One); port.ReadTimeout = 2; port.Open(); data = new InterfacePacket((byte)INTERFACEPACKET.IDENT, (int)INTERFACEPACKET.ANALOG_BYTES, (int)INTERFACEPACKET.DIGITAL_BYTES); telemetry = new TelemetryPacket((byte)TELEMETRYPACKET.IDENT, (int)TELEMETRYPACKET.ANALOG_BYTES, (int)TELEMETRYPACKET.DIGITAL_BYTES); buffer = new byte[512]; receiver = new XBeeInterfaceReceiver(this); frame = 0; }