Ejemplo n.º 1
0
        private void dev_evDeviceStateHasChanged(object sender, DeviceStateHasChangedEventArgs args)
        {
            Logger.Log(this,
                       String.Format(
                           "device {0} state has changed to: {1}",
                           sender.ToString(),
                           args.ToString()),
                       1);

            switch (args.GetDeviceState())
            {
            case DeviceOverallState.Error:
                overallState = DeviceOverallState.Error;
                EmergencyStop();
                break;

            case DeviceOverallState.Warrning:
                if (overallState == DeviceOverallState.OK)
                {
                    PauseEffectors();
                    overallState = DeviceOverallState.Warrning;
                }
                break;

            case DeviceOverallState.OK:
                int devsInWarrningState = 0;
                int devsInErrorState    = 0;
                foreach (Device dev in devicesList)
                {
                    if (dev.overallState == DeviceOverallState.Warrning)
                    {
                        devsInWarrningState++;
                    }
                    else if (dev.overallState == DeviceOverallState.Error)
                    {
                        devsInErrorState++;
                    }

                    if (devsInErrorState > 0)
                    {
                        overallState = DeviceOverallState.Error;
                    }
                    else if (devsInWarrningState > 0)
                    {
                        overallState = DeviceOverallState.Warrning;
                    }
                    else
                    {
                        overallState = DeviceOverallState.OK;
                    }
                }
                break;

            default:
                throw new ApplicationException("Unknown device state");
            }
        }
Ejemplo n.º 2
0
        void deviceManager_evDeviceStateHasChanged(object sender, DeviceStateHasChangedEventArgs args)
        {
            if (args.GetDeviceState() == DeviceOverallState.Error)
            {
                UpdateButtonsStateInCaseOfDeviceError();
            }
            else if (args.GetDeviceState() == DeviceOverallState.OK &&                                            //its work arroud for bug causing wrong button enabling when initialized button was clicked in overall error state
                     deviceManager.devicesList[0].initializationState == DeviceInitializationState.Initialized || //devices are initialized or initializing
                     deviceManager.devicesList[0].initializationState == DeviceInitializationState.Initializing)
            {
                EnableStartSensorsButtonAndDisableInitButton();
            }

            ChangeOverallStateLabel(args.GetDeviceState().ToString());
        }