Skip to content

Commit

Permalink
Move IsDevicesEnumerationComplete to PortBase (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Oct 24, 2017
1 parent 45313b9 commit d4305dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public string PersistName
/// </summary>
public abstract event EventHandler DeviceEnumerationCompleted;

/// <summary>
/// Flag to signal that devices enumeration is complete.
/// </summary>
public bool IsDevicesEnumerationComplete { get; internal set; } = false;

public ObservableCollection<NanoDeviceBase> NanoFrameworkDevices { get; protected set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public partial class SerialPort : PortBase, IPort
/// </summary>
List<SerialDeviceInformation> SerialDevices;

/// <summary>
/// Flag to signal that devices enumeration is complete.
/// </summary>
public bool DevicesEnumerationComplete { get; internal set; } = false;

/// <summary>
/// Creates an Serial debug client
/// </summary>
Expand Down Expand Up @@ -147,7 +142,7 @@ private void StartDeviceWatchers()
// Start all device watchers
watchersStarted = true;
deviceWatchersCompletedCount = 0;
DevicesEnumerationComplete = false;
IsDevicesEnumerationComplete = false;

foreach (DeviceWatcher deviceWatcher in mapDeviceWatchersToDeviceSelector.Keys)
{
Expand Down Expand Up @@ -249,7 +244,7 @@ private async void AddDeviceToList(DeviceInformation deviceInformation, String d
NanoFrameworkDevices.Add(newNanoFrameworkDevice as NanoDeviceBase);

// perform check for valid nanoFramework device is this is not the initial enumeration
if (DevicesEnumerationComplete)
if (IsDevicesEnumerationComplete)
{
// try opening the device to check for a valid nanoFramework device
if (await ConnectSerialDeviceAsync(newNanoFrameworkDevice.Device.DeviceInformation).ConfigureAwait(false))
Expand Down Expand Up @@ -448,7 +443,7 @@ private void OnDeviceEnumerationComplete(DeviceWatcher sender, object args)
devicesToRemove.Select(d => NanoFrameworkDevices.Remove(d)).Count();

// all watchers have completed enumeration
DevicesEnumerationComplete = true;
IsDevicesEnumerationComplete = true;

Debug.WriteLine($"Serial device enumeration completed. Found {NanoFrameworkDevices.Count} devices");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public class UsbPort : PortBase, IPort
/// </summary>
List<UsbDeviceInformation> UsbDevices;

/// <summary>
/// Flag to signal that devices enumeration is complete.
/// </summary>
public bool DevicesEnumerationComplete { get; internal set; } = false;

/// <summary>
/// Creates an USB debug client
/// </summary>
Expand Down Expand Up @@ -132,7 +127,7 @@ private void StartDeviceWatchers()
// Start all device watchers
watchersStarted = true;
deviceWatchersCompletedCount = 0;
DevicesEnumerationComplete = false;
IsDevicesEnumerationComplete = false;

foreach (DeviceWatcher deviceWatcher in mapDeviceWatchersToDeviceSelector.Keys)
{
Expand Down Expand Up @@ -354,7 +349,7 @@ private void OnDeviceEnumerationComplete(DeviceWatcher sender, object args)
Debug.WriteLine($"USB device enumeration completed. Found { UsbDevices.Count } devices");

// all watchers have completed enumeration
DevicesEnumerationComplete = true;
IsDevicesEnumerationComplete = true;

// fire event that USB enumeration is complete
OnDeviceEnumerationCompleted();
Expand Down

0 comments on commit d4305dc

Please sign in to comment.