Esempio 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");
            }
        }
Esempio n. 2
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");
            }
        }
Esempio n. 3
0
 public DeviceStateHasChangedEventArgs(DeviceOverallState state)
 {
     deviceState = state;
 }