private async void airflowWatcher_Added(airflowWatcher watcher, AllJoynServiceInfo args) { if (_airflowConsumer == null && args.ObjectPath.Contains(_expectedBusObjectPath)) { var joinSessionResult = await airflowConsumer.JoinSessionAsync(args, watcher); if (joinSessionResult.Status == AllJoynStatus.Ok) { _airflowConsumer = joinSessionResult.Consumer; _airflowConsumer.SessionLost += Consumer_SessionLost; // subscribe to value changes _airflowConsumer.DirectionChanged += this.airflowConsumer_DirectionChanged; _airflowConsumer.RangeChanged += this.airflowConsumer_RangeChanged; _airflowConsumer.SpeedChanged += this.airflowConsumer_SpeedChanged; // populate initial values var directionResult = await _airflowConsumer.GetDirectionAsync(); if (directionResult.Status != AllJoynStatus.Ok) { return; } this.AirflowDirection = directionResult.Direction; var rangeResult = await _airflowConsumer.GetRangeAsync(); if (rangeResult.Status != AllJoynStatus.Ok) { return; } this.AirflowDirection = rangeResult.Range; var speedResult = await _airflowConsumer.GetSpeedAsync(); if (speedResult.Status != AllJoynStatus.Ok) { return; } this.AirflowSpeed = speedResult.Speed; this.IsConnected = true; } } }
protected override void OnStart() { _modeWatcher = new modeWatcher(this.CreateBusAttachment(ref _modeBusAttachment)); _modeWatcher.Added += this.modeWatcher_Added; _modeWatcher.Start(); _airflowWatcher = new airflowWatcher(this.CreateBusAttachment(ref _airflowBusAttachment)); _airflowWatcher.Added += this.airflowWatcher_Added; _airflowWatcher.Start(); _binaryWatcher = new binaryWatcher(this.CreateBusAttachment(ref _binaryBusAttachment)); _binaryWatcher.Added += this.binaryWatcher_Added; _binaryWatcher.Start(); _temperatureWatcher = new temperatureWatcher(this.CreateBusAttachment(ref _temperatureBusAttachment)); _temperatureWatcher.Added += this.temperatureWatcher_Added; _temperatureWatcher.Start(); }