コード例 #1
0
        private void Monitor_Polled(object sender, MonitorPolledEventArgs args)
        {
            Debug.WriteLine("X10Controller.Monitor_Polled");
            try
            {
                if (!IsInsideLampSwitchingHours)
                {
                    SetRedYellowGreenLamps(false, false, false);
                    return;
                }

                ProjectState      state  = monitor.ProjectState;
                IntegrationStatus status = ((IProjectMonitor)sender).IntegrationStatus;

                if (state.Equals(ProjectState.NotConnected) || status.Equals(IntegrationStatus.Unknown))
                {
                    SetRedYellowGreenLamps(false, false, false);
                }
                else
                {
                    bool red = status.Equals(IntegrationStatus.Exception) ||
                               status.Equals(IntegrationStatus.Failure) ||
                               state.Equals(ProjectState.Broken) ||
                               state.Equals(ProjectState.BrokenAndBuilding);
                    bool yellow = state.Equals(ProjectState.Building) ||
                                  state.Equals(ProjectState.BrokenAndBuilding);
                    bool green = (status.Equals(IntegrationStatus.Success) &&
                                  (state.Equals(ProjectState.Success) || (state.Equals(ProjectState.Building))));

                    SetRedYellowGreenLamps(red, yellow, green);
                }
            }
            catch (ApplicationException ex)
            {
                Trace.WriteLine("Failed to update X10 device status: " + ex);
            }
        }