/// <summary> /// Change the volume of a specified zone. /// </summary> /// <param name="zoneId">Zone id</param> /// <param name="adjVolume">Delta Volume</param> /// <returns>Zone state, after the command has been performed.</returns> private ZoneState AdjustVolume(Address zoneId, int adjVolume) { MonitorAndControlClient mcProxy = getMCProxy(); mcProxy.Connect(); ZoneState zoneState = mcProxy.GetZoneState(zoneId); zoneState.Volume = zoneState.Volume + adjVolume; mcProxy.SetZoneState(zoneId, zoneState); zoneState = mcProxy.GetZoneState(zoneId); mcProxy.Disconnect(); return(zoneState); }
/// <summary> /// Changes the source of a specified zone. /// </summary> /// <param name="zoneId">Zone id, to specify zone</param> /// <param name="sourceId">Source id, tp specify source</param> /// <returns>Zone state, after the command has been performed.</returns> public ZoneState SwitchSource(Address zoneId, Address sourceId) { MonitorAndControlClient mcProxy = getMCProxy(); mcProxy.Connect(); ZoneState zoneState = mcProxy.GetZoneState(zoneId); zoneState.Source = sourceId; mcProxy.SetZoneState(zoneId, zoneState); zoneState = mcProxy.GetZoneState(zoneId); mcProxy.Disconnect(); return(zoneState); }
/// <summary> /// Switches a zone, specified by its zone id, either on or off (depending on its current state). /// </summary> /// <param name="zoneId">Zone Id</param> /// <returns>Zone state, after the switch command has been performed.</returns> public ZoneState SwitchZone(Address zoneId) { MonitorAndControlClient mcProxy = getMCProxy(); mcProxy.Connect(); ZoneState zoneState = mcProxy.GetZoneState(zoneId); zoneState.PowerStatus = !zoneState.PowerStatus; mcProxy.SetZoneState(zoneId, zoneState); zoneState = mcProxy.GetZoneState(zoneId); mcProxy.Disconnect(); return(zoneState); }
private void InitializeZones() { try { foreach (ZoneControl zoneCtrl in _zoneControlByAddress.Values) { ZoneState zoneState = _monitorAndControlProxy.GetZoneState(zoneCtrl.Zone.Id); zoneCtrl.ZoneState = zoneState; } } catch (Exception) { _monitorAndControlProxy.Abort(); } }
/// <summary> /// Returns the current zone state for a zone, specified by Zone Id. /// </summary> /// <param name="zoneId">Zone Id</param> /// <returns>Zone State.</returns> public ZoneState GetZoneState(Address zoneId) { MonitorAndControlClient mcProxy = getMCProxy(); mcProxy.Connect(); ZoneState zoneState = mcProxy.GetZoneState(zoneId); _log.Trace(m => m("Read zone status for zone with id {0}. Zone State = [{1}]", zoneId.ToString(), zoneState.ToString())); mcProxy.Disconnect(); // Tweak: If a source is not configured, it needs to be added programmatically to the list, because it is still possible to select this source on the keypad. // If such an unconfigured source has been selected an error occurs, becuase the source is unkown! // ToDo: Implement this tweak on server side SourceGraphic source = GetSource(zoneState.Source); if (source.isEmpty()) { _sources.Add(new SourceGraphic(zoneState.Source, String.Format("[{0}]", zoneState.Source), "n/a", "n/a")); _log.Trace(m => m("SOURCE added with id {0}.", zoneState.Source)); } return(zoneState); }