/// <summary> /// Called when [sensor registered]. /// </summary> /// <param name="sensorRegistrationData">The sensor registration data.</param> private void OnDeviceRegistered(ReceiverEvents.DeviceRegistered e) { lock (_sensorIds) { if (!_sensorIds.Contains(e.SensorId) && _sensorIds.Count < MAX_METERS) { _sensorIds.Add(e.SensorId); // NOTE: Use RegisterViewWithRegion not Add to region to fix issue with Telerik Control hanging _regionManager.RegisterViewWithRegion(RegionNames.MeterRegion, () => { using (new ShowBusyIndicator()) { IView view = _container.Resolve<MeterView>(); MeterPresenter presenter = _container.Resolve<MeterPresenter>(); presenter.Id = e.SensorId; presenter.SetMeterType(e.SensorType); presenter.RequestRemoval += (sender, args) => { lock (_sensorIds) { IRegion region = _regionManager.Regions[RegionNames.MeterRegion]; region.Remove(view); _sensorIds.Remove(presenter.Id); } }; view.ApplyPresenter(presenter); return view; } }); } } }
/// <summary> /// Called when [sensor impact]. /// </summary> /// <param name="sensorImpactData">The sensor impact data.</param> private void OnSensorHit(ReceiverEvents.SensorHit e) { if (_config.SpeakImpactLevelEnabled) lock (_speechSynthesizer) { _speechSynthesizer.SpeakAsyncCancelAll(); _speechSynthesizer.SpeakAsync(e.ImpactLevel.ToString()); } }
public NetworkModule( IAppConfigService appConfigService, IScoreKeeperService scoreKeeperService, IStopWatchService stopWatchService, ReceiverEvents.ButtonPressed receiverButtonPressed) { this.appConfigService = appConfigService; this.scoreKeeperService = scoreKeeperService; this.stopWatchService = stopWatchService; this.receiverButtonPressed = receiverButtonPressed; }
public KickAndPunch( ReceiverEvents.DeviceRegistered deviceRegisteredEvent, ReceiverEvents.ButtonPressed buttonPressedEvent, ReceiverEvents.RegisterDevice registerDeviceRequest, ReceiverEvents.SensorHit deviceSensorHit, ReceiverEvents.DeviceStatusUpdate deviceStatusNotify, ApplicationEvents.ApplicationClosing appClosingEvent) { this.deviceRegisteredEvent = deviceRegisteredEvent; this.buttonPressedEvent = buttonPressedEvent; this.registerDeviceRequest = registerDeviceRequest; this.deviceSensorHit = deviceSensorHit; this.deviceStatusNotify = deviceStatusNotify; this.appClosingEvent = appClosingEvent; }
/// <summary> /// Called when [sensor impact]. /// </summary> /// <param name="sensorImpactData">The sensor impact data.</param> private void OnSensorHit(ReceiverEvents.SensorHit e) { if (_clockRunning) { using (ReaderWriterLockMgr lockMgr = new ReaderWriterLockMgr(_dataLog.Impacts.Lock)) { lockMgr.EnterWriteLock(); _dataLog.Impacts.AddImpactsRow( DateTime.Now, // Current datetime stamp e.SensorId, // Sensor ID _game.GameNumber, // Game number _game.RoundNumber, // Round number DateTime.Now - _countdownStartedTime, // Elapsed time (_meterNames.ContainsKey(e.SensorId) ? _meterNames[e.SensorId] : string.Empty), // Meter Name e.OpCode, // Data Source Type _config.RequiredImpactLevel, // required impact level e.ImpactLevel, // Actual impact level e.Panel.ToString() // Sensor panel ); } } }
/// <summary> /// Called when [sensor registration]. /// </summary> /// <param name="sensorRegistrationData">The sensor registration data.</param> private void OnDeviceRegistered(ReceiverEvents.DeviceRegistered e) { if (_config.MeterSoundsEnabled) PlaySoundResource(SENSOR_CONNECTED_WAV); }
public ReceiverEventSink(ReceiverEvents.RegisterDevice registerDeviceRequest) { this.registerDeviceRequest = registerDeviceRequest; }
/// <summary> /// Called when [receiver button press]. /// </summary> /// <param name="receiverButtonPressData">The receiver button press data.</param> private void OnReceiverButtonPress(ReceiverEvents.PanelButtons e) { switch (e) { case ReceiverEvents.PanelButtons.Start: GameRoundStart(); break; case ReceiverEvents.PanelButtons.Clocking: if (_clockState == CountDownClockEvents.StateChangedArgs.Running) GameRoundPause(); else GameRoundReset(); break; } //TODO: Move code for registrations here from the receiver module }
/// <summary> /// Called when [sensor impact]. /// </summary> /// <param name="sensorImpactData">The sensor impact data.</param> private void OnSensorHit(ReceiverEvents.SensorHit e) { if (_clockState == CountDownClockEvents.StateChangedArgs.Running) { if (e.ImpactLevel >= _config.RequiredImpactLevel) { ScoreModel scoreModel = _container.Resolve<ScoreModel>(e.SensorId); uint oldScore = scoreModel.Value; scoreModel.Value++; _logger.Log(string.Format("Meter Id {0} score now {1}", e.SensorId, scoreModel.Value), Category.Info, Priority.None); _eventAggregator.GetEvent<GameEngineEvents.ScoreChanged>().Publish( new GameEngineEvents.ScoreChanged() { SensorId = e.SensorId, ImpactLevel = e.ImpactLevel, OldScore = oldScore, NewScore = scoreModel.Value }); } } }
/// <summary> /// Called when [sensor status update]. /// </summary> /// <param name="sensorStatusData">The sensor status data.</param> private void OnDeviceStatusUpdate(ReceiverEvents.DeviceStatusUpdate e) { if (e.SensorId == this.Id) { switch (e.Status) { case ReceiverEvents.SensorDeviceStatus.LowBattery: if (BatteryLow == false) BatteryLow = true; break; case ReceiverEvents.SensorDeviceStatus.NotResponding: MeterColor = Brushes.Gray; IsActive = false; break; case ReceiverEvents.SensorDeviceStatus.HoguOk: case ReceiverEvents.SensorDeviceStatus.TargetOk: if (MeterColor == Brushes.Gray) { MeterColor = GetBrushColorForMeter(MeterType); IsActive = true; } break; } } }
/// <summary> /// Called when sensor impact is received. /// </summary> /// <param name="sensorImpactData">The sensor impact data.</param> private void OnSensorHit(ReceiverEvents.SensorHit e) { if (e.SensorId == this.Id) { this.ImpactLevel = e.ImpactLevel; this.HitPanelNum = (int)e.Panel; if (e.ImpactLevel > this.HighestImpactLevel) this.HighestImpactLevel = e.ImpactLevel; // Update history while (_graphDataItems.Count >= 10) _graphDataItems.RemoveAt(0); _graphDataItems.Add(e.ImpactLevel); } }
/// <summary> /// Called when [sensor registered]. /// </summary> /// <param name="sensorRegistrationData">The sensor registration data.</param> private void OnDeviceRegistered(ReceiverEvents.DeviceRegistered e) { if (e.SensorId == this.Id) { SetMeterType(e.SensorType); IsActive = true; } }
/// <summary> /// Gets the brush color for meter. /// TODO: This should be done in XAML not here! /// </summary> /// <param name="meterType">Type of the meter.</param> /// <returns></returns> private Brush GetBrushColorForMeter(ReceiverEvents.SensorDeviceType meterType) { // Various colors to be used for targets Color[] targetColors = new Color[] { Color.FromRgb(0xFF, 0xBA, 0x00), Color.FromRgb(0xE3, 0x19, 0x39), Color.FromRgb(0xFF, 0x8B, 0x00), Color.FromRgb(0x64, 0x1C, 0xA2), Color.FromRgb(0x00, 0xCF, 0x60), Color.FromRgb(0x1E, 0x54, 0x9E), Color.FromRgb(0xC6, 0xD8, 0x00), Color.FromRgb(0xFF, 0x5F, 0x00) }; switch (meterType) { case ReceiverEvents.SensorDeviceType.Chung: return new SolidColorBrush(Color.FromRgb(0x00, 0x7D, 0x0C3)); case ReceiverEvents.SensorDeviceType.Hong: return new SolidColorBrush(Color.FromRgb(0xE3, 0x19, 0x37)); case ReceiverEvents.SensorDeviceType.Target: Color color = targetColors[(_targetNumber % targetColors.Length)]; return new SolidColorBrush(color); } return Brushes.Gray; }
/// <summary> /// Sets the type of the meter. /// </summary> /// <param name="meterType">Type of the meter.</param> public void SetMeterType(ReceiverEvents.SensorDeviceType meterType) { MeterType = meterType; DisplayName = meterType.ToString(); HasPanels = (meterType == ReceiverEvents.SensorDeviceType.Target); if (meterType == ReceiverEvents.SensorDeviceType.Target) { if (_targetNumber == 0) _targetNumber = ++_targetCount; DisplayName += " " + _targetNumber; } MeterColor = GetBrushColorForMeter(meterType); }