Beispiel #1
0
        /// <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);
        }