public void calculateFunctionTest2() { SleepFunction function = new SleepFunction(SimpleId.NewGuid(), new Address(100, 1), new TimeSpan(1, 0, 0), new TimeSpan(0, 0, 0), new TimeSpan(23, 59, 59)); ZoneServerMock zoneServer = new ZoneServerMock(); Dictionary <int, IAudioDriver> audioDrivers = null; ConcreteSleepFunction_Accessor target = new ConcreteSleepFunction_Accessor(function, zoneServer, audioDrivers); // notify the first time, the update time is set to the current update time ZoneStateEventArgs e1 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 20, NuvoControl.Common.ZoneQuality.Online)); target.notifyOnZoneUpdate(e1); Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON); DateTime aktTime = DateTime.Now; target.calculateFunction(aktTime); DateTime nextTime = DateTime.Now + new TimeSpan(1, 0, 0); target.calculateFunction(nextTime); Assert.AreEqual(1, zoneServer._monitoredZones.Count); // 1 zone monitored Assert.AreEqual(1, zoneServer.ZoneStates.Count); // 1 command issued Assert.AreEqual(false, zoneServer.ZoneStates[new Address(100, 1)].PowerStatus); // switch off }
public void notifyOnZoneUpdateTest() { SleepFunction function = new SleepFunction(); IZoneServer zoneServer = null; Dictionary <int, IAudioDriver> audioDrivers = null; ConcreteSleepFunction_Accessor target = new ConcreteSleepFunction_Accessor(function, zoneServer, audioDrivers); // notify the first time, the update time is set to the current update time ZoneStateEventArgs e1 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 20, NuvoControl.Common.ZoneQuality.Online)); target.notifyOnZoneUpdate(e1); Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON); // notify volume change, the last zone change to On time stays the same ZoneStateEventArgs e2 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 30, NuvoControl.Common.ZoneQuality.Online)); target.notifyOnZoneUpdate(e2); Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON); // notify switch off, the last zone change to On time stays the same ZoneStateEventArgs e3 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), false, 30, NuvoControl.Common.ZoneQuality.Online)); target.notifyOnZoneUpdate(e3); Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON); // notify switch on, the last zone change to On time updates ZoneStateEventArgs e4 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 30, NuvoControl.Common.ZoneQuality.Online)); target.notifyOnZoneUpdate(e4); Assert.AreEqual(e4.ZoneState.LastUpdate, target._lastZoneChangeToON); }
/// <summary> /// Notifcation handler, called from the zone server, which delivers zone state changes /// </summary> /// <param name="sender">The zone controller, for which the state change appened.</param> /// <param name="e">State change event arguments.</param> private void OnZoneNotification(object sender, ZoneStateEventArgs e) { ZoneController zoneController = sender as ZoneController; if (zoneController != null) { NotifySubscribers(zoneController.UniqueZoneId, e.ZoneState); } }
public void notifyOnZoneUpdateTest1() { ZoneChangeFunction function = new ZoneChangeFunction(); IZoneServer zoneServer = null; Dictionary <int, IAudioDriver> audioDrivers = null; ConcreteZoneChangeFunction target = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers); ZoneStateEventArgs e = new ZoneStateEventArgs(new ZoneState()); // not supported anymore; quick-fix, uncomment unit test -> target.notifyOnZoneUpdate(e); //ok, pass without exception }
public void notifyOnZoneUpdateTest1() { ZoneChangeFunction function = new ZoneChangeFunction(); IZoneServer zoneServer = null; Dictionary <int, IAudioDriver> audioDrivers = null; ConcreteZoneChangeFunction_Accessor target = new ConcreteZoneChangeFunction_Accessor(function, zoneServer, audioDrivers); ZoneStateEventArgs e = new ZoneStateEventArgs(new ZoneState()); target.notifyOnZoneUpdate(e); //ok, pass without exception }
public void ZoneUpdateNotification(object sender, ZoneStateEventArgs e) { SendOrPostCallback callback = delegate { _ignoreViewSelectionChange = true; _zoneState = new ZoneState(e.ZoneState); NotifyPropertyChanged(new PropertyChangedEventArgs("")); _ignoreViewSelectionChange = false; }; _synchronizationContext.Post(callback, null); }
public void notifyOnZoneUpdateTest2() { List <Command> commands = new List <Command>(); commands.Add(new SendNuvoCommand(new SimpleId(), true, true, true, true, true, true, true, new Address("100.1"), "OFF", "100.6", 10)); ZoneChangeFunction function = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, true, true, true, true, null, new TimeSpan(), new TimeSpan(), commands); IZoneServer zoneServer = null; Dictionary <int, IAudioDriver> audioDrivers = null; ConcreteZoneChangeFunction target = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers); ZoneStateEventArgs e = new ZoneStateEventArgs(new ZoneState()); // not supported anymore; quick-fix, uncomment unit test -> target.notifyOnZoneUpdate(e); // init zone state // not supported anymore; quick-fix, uncomment unit test -> target.notifyOnZoneUpdate(e); }
protected override void notifyOnZoneUpdate(ZoneStateEventArgs e) { // Store zone change, will be processed in calculate method _newZoneState.Add(e.ZoneState); }
/// <summary> /// Abstract method called by base class ConcreteFunction, to notify super class in case of a zone update. /// </summary> /// <param name="e">State change event argument.</param> protected abstract void notifyOnZoneUpdate(ZoneStateEventArgs e);
/// <summary> /// Notifcation handler, called from the zone server, which delivers zone state changes /// </summary> /// <param name="sender">The zone controller, for which the state change appened.</param> /// <param name="e">State change event argument.</param> private void OnZoneNotification(object sender, ZoneStateEventArgs e) { //_log.Trace(m => m("ConcreteFunction: OnZoneNotification() EventArgs={0} ...", e.ToString())); notifyOnZoneUpdate(e); }
/// <summary> /// Method invoked to notify the function about zone state changes. /// The new zone state is stored in the member variable _zoneState /// </summary> /// <param name="e">Event argument, passed by the notification event.</param> protected override void notifyOnZoneUpdate(ZoneStateEventArgs e) { //_log.Trace(m => m("ConcreteSleepFunction: notifyOnZoneUpdate() EventArgs={0} ...", e.ToString())); _lastZoneChangeToON = calculateZoneChangeToON(_lastZoneChangeToON, _zoneState, e.ZoneState); _zoneState = new ZoneState(e.ZoneState); }