/// <summary> /// Raises the <see cref="E:VirtualPortRemoved"/> event. /// </summary> /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.VirtualComPortEventArgs"/> instance containing the event data.</param> internal virtual void OnVirtualPortRemoved(VirtualComPortEventArgs e) { EventHandler <VirtualComPortEventArgs> handler = VirtualPortRemoved; try { handler(this, e); } catch (Exception ex) { Trace.TraceError("{0}.OnVirtualPortRemoved: {1}", CLASSNAME, ex.GetBaseException()); } }
/// <summary> /// Raises the <see cref="E:VirtualPortCreated"/> event. /// </summary> /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Hardware.VirtualComPortEventArgs"/> instance containing the event data.</param> protected virtual void OnVirtualPortCreated(VirtualComPortEventArgs e) { EventHandler <VirtualComPortEventArgs> handler = this.VirtualPortCreated; try { handler(this, e); } catch (Exception ex) { Trace.TraceError("{0}.OnVirtualPortCreated: {1}", CLASSNAME, ex.GetBaseException()); throw; } }
/// <summary> /// Handles the VirtualPortRemoved event of the _virtualComPortsFinder control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.VirtualComPortEventArgs"/> instance containing the event data.</param> private void VirtualComPortsFinder_VirtualPortRemoved(object sender, VirtualComPortEventArgs e) { Trace.TraceInformation("{0}.VirtualPortRemoved: PNPDeviceID={1}", CLASSNAME, e.PNPDeviceID); Trace.Indent(); IReceiver receiver = null; int count; lock (_recievers) { if (_recievers.ContainsKey(e.PNPDeviceID)) { receiver = _recievers[e.PNPDeviceID]; _recievers.Remove(e.PNPDeviceID); } count = _recievers.Count; } if (receiver != null) { // Clear out game registrations receiver.ClearGameRegistrations(); // UnHook event handlers receiver.StrikeDetected -= OnStrikeDetected; receiver.PanelButtonPressed -= OnPanelButtonPressed; receiver.DeviceStatusUpdate -= OnDeviceStatusUpdate; receiver.DeviceRegistered -= OnDeviceRegistered; receiver.Dispose(); } OnReceiverCountChanged(this, new ReceiverCountEventArgs() { Count = count }); Trace.Unindent(); }
/// <summary> /// Handles the VirtualPortCreated event of the _virtualComPortsFinder control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.VirtualComPortEventArgs"/> instance containing the event data.</param> private void VirtualComPortsFinder_VirtualPortCreated(object sender, VirtualComPortEventArgs e) { Trace.TraceInformation("{0}.VirtualPortCreated: PNPDeviceID={1} DeviceId={2} Caption={3}", CLASSNAME, e.PNPDeviceID, e.DeviceID, e.Caption); Trace.Indent(); IReceiver receiver = new Receiver(e.PNPDeviceID, e.DeviceID, _courtNumber++); int count; // Hook up event handlers receiver.StrikeDetected += OnStrikeDetected; receiver.PanelButtonPressed += OnPanelButtonPressed; receiver.DeviceStatusUpdate += OnDeviceStatusUpdate; receiver.DeviceRegistered += OnDeviceRegistered; // Clear any existing registrations from receiver receiver.ClearGameRegistrations(); lock (_recievers) { _recievers.Add(e.PNPDeviceID, receiver); count = _recievers.Count; } OnReceiverCountChanged(this, new ReceiverCountEventArgs() { Count = count }); Trace.Unindent(); }
/// <summary> /// Raises the <see cref="E:VirtualPortRemoved"/> event. /// </summary> /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Hardware.VirtualComPortEventArgs"/> instance containing the event data.</param> protected virtual void OnVirtualPortRemoved(VirtualComPortEventArgs e) { EventHandler<VirtualComPortEventArgs> handler = this.VirtualPortRemoved; try { handler(this, e); } catch (Exception ex) { Trace.TraceError("{0}.OnVirtualPortRemoved: {1}", CLASSNAME, ex.GetBaseException()); throw; } }
/// <summary> /// Raises the <see cref="E:VirtualPortCreated"/> event. /// </summary> /// <param name="e">The <see cref="LaJust.PowerMeter.Communications.VirtualComPortEventArgs"/> instance containing the event data.</param> internal virtual void OnVirtualPortCreated(VirtualComPortEventArgs e) { EventHandler<VirtualComPortEventArgs> handler = VirtualPortCreated; try { handler(this, e); } catch (Exception ex) { Trace.TraceError("{0}.OnVirtualPortCreated: {1}", CLASSNAME, ex.GetBaseException()); } }