Exemplo n.º 1
0
 private static void AmplifierStatusObserver(ref TiInfo info)
 {
     byte[] answer;
     answer = Boards.State(Board.amplifier);
     if (answer == null)
     {
         _amplifBoardErrors++; if (_amplifBoardErrors == 3)
         {
             info.systemMessage = SysMessages.AmplifierrBoardError;
         }
         return;
     }                                                                                                                                         //ошибка платы;
     else //obrabotka otveta
     {
         _amplifBoardErrors = 0;
         info.flow          = answer[5] | answer[6] << 8 | answer[7] << 16 | answer[8] << 24;
     }
 }
Exemplo n.º 2
0
 public void Execution(Commands butt, ref TiInfo inf)
 {
     State.Execution(butt, ref inf);
 }
Exemplo n.º 3
0
 public void Execution(Commands butt, ref TiInfo inf)
 {
 }
Exemplo n.º 4
0
        public void Execution(Commands butt, ref TiInfo inf)
        {
            if (DeviceManager.GlobalState.Vlap == DeviceManager.Status.Off)
            {
                Valves.Switch(Valve.VLap, Act.Close);
            }

            switch (butt)
            {
            case Commands.S:
                break;

            case Commands.V1:
            {
                if (DeviceManager.GlobalState.V1 == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.V1, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.V1, Act.Close);
                }
                break;
            }

            case Commands.V2:
            {
                if (DeviceManager.GlobalState.V2 == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.V2, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.V2, Act.Close);
                }
                break;
            }

            case Commands.V3:
            {
                if (DeviceManager.GlobalState.V3 == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.V3, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.V3, Act.Close);
                }
                break;
            }

            case Commands.V4:
            {
                if (DeviceManager.GlobalState.V4 == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.V4, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.V4, Act.Close);
                }
                break;
            }

            case Commands.V5:
            {
                if (DeviceManager.GlobalState.V5 == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.V5, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.V5, Act.Close);
                }
                break;
            }

            case Commands.V6:
            {
                if (DeviceManager.GlobalState.V6 == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.V6, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.V6, Act.Close);
                }
                break;
            }

            case Commands.VProm:
            {
                if (DeviceManager.GlobalState.VProm == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.VProm, Act.Open);
                }
                else
                {
                    Valves.Switch(Valve.VProm, Act.Close);
                }
                break;
            }

            case Commands.Vlap:
            {
                if (DeviceManager.GlobalState.Vlap == DeviceManager.Status.Off)
                {
                    Valves.Switch(Valve.VLap, Act.Close);
                }
                else
                {
                    Valves.Switch(Valve.VLap, Act.Open);
                }
                break;
            }

            case Commands.N1:
                if (DeviceManager.GlobalState.N1 == DeviceManager.Status.Off)
                {
                    TurbomolecularPump.Switch(Mode.On);
                }
                else
                {
                    TurbomolecularPump.Switch(Mode.Off);
                }
                break;

            case Commands.N2:
                if (DeviceManager.GlobalState.N2 == DeviceManager.Status.Off)
                {
                    Pump.Switch(Mode.On);
                }
                else
                {
                    Pump.Switch(Mode.Off);
                }
                break;

            case Commands.ChangeObj:
                break;

            case Commands.Menu:
                break;

            case Commands.Obnul:
                break;

            case Commands.Start:
                break;
            }
        }
Exemplo n.º 5
0
        private static void DeviceStatusObserver(ref TiInfo info)
        {
            byte[] answer;
            switch (_BaseBoardsStateCycl)
            {
            case 1:     //плата ФорсКлап
            {
                answer = Boards.State(Board.forsKlapBoard);
                if (answer == null)
                {
                    _forsKlapBoardErrors++; if (_forsKlapBoardErrors == 3)
                    {
                        info.systemMessage = SysMessages.ForceKlapBoardError;
                    }
                    break;
                }            //ошибка платы;
                else         //obrabotka otveta
                {
                    _forsKlapBoardErrors = 0;

                    GlobalState.V3 = (answer[4] & 0x01 << 2) > 0 ? Status.On : Status.Off;
                    GlobalState.V4 = (answer[4] & 0x01 << 1) > 0 ? Status.On : Status.Off;
                    GlobalState.V2 = (answer[4] & 0x01) > 0 ? Status.On : Status.Off;

                    if (GlobalState.V3 == Status.Off)
                    {
                        Leds.Switch(Led.V3, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.V3, Mode.On);
                    }

                    if (GlobalState.V4 == Status.Off)
                    {
                        Leds.Switch(Led.V4, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.V4, Mode.On);
                    }

                    if (GlobalState.V2 == Status.Off)
                    {
                        Leds.Switch(Led.V2, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.V2, Mode.On);
                    }
                }
                break;
            }

            case 2:     //палата ДвКлап
            {
                answer = Boards.State(Board.dvKlapBoard);
                if (answer == null)
                {
                    _dvKlapBoardErrors++; if (_dvKlapBoardErrors == 3)
                    {
                        info.systemMessage = SysMessages.DvKlapBoardError;
                    }
                    break;
                }            //ошибка платы;
                else         //obrabotka otveta
                {
                    _dvKlapBoardErrors = 0;

                    GlobalState.VProm = (answer[4] & 0x01 << 7) > 0 ? Status.On : Status.Off;

                    if ((answer[4] & 0x01 << 5) == 0 && (answer[4] & 0x01 << 6) > 0)
                    {
                        GlobalState.V6 = Status.Error;
                    }
                    if ((answer[4] & 0x01 << 5) > 0 && (answer[4] & 0x01 << 6) > 0)
                    {
                        GlobalState.V6 = Status.On;
                    }
                    if ((answer[4] & 0x01 << 5) == 0 && (answer[4] & 0x01 << 6) == 0)
                    {
                        GlobalState.V6 = Status.Off;
                    }


                    if (GlobalState.V6 == Status.StartWork)
                    {
                        GlobalState.V6 = (answer[4] & 0x01 << 5) > 0 ? Status.On : Status.Off;
                    }

                    GlobalState.Vlap = (answer[4] & 0x01 << 4) > 0 ? Status.On : Status.Off;
                    GlobalState.V1   = (answer[4] & 0x01 << 3) > 0 ? Status.On : Status.Off;
                    GlobalState.V5   = (answer[4] & 0x01 << 2) > 0 ? Status.On : Status.Off;

                    GlobalState.N2 = (answer[4] & 0x01) > 0 ? Status.On : Status.Off;

                    GlobalState.N1 = (answer[4] & 0x01 << 1) > 0 ? Status.StartWork : Status.Off;
                    GlobalState.N1 = (answer[5] & 0x01 << 1) > 0 ? Status.On : GlobalState.N1;
                    GlobalState.N1 = (answer[5] & 0x01 << 2) > 0 ? Status.Error : GlobalState.N1;

                    if (GlobalState.V1 == Status.Off)
                    {
                        Leds.Switch(Led.V1, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.V1, Mode.On);
                    }

                    if (GlobalState.V5 == Status.Off)
                    {
                        Leds.Switch(Led.V5, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.V5, Mode.On);
                    }

                    if (GlobalState.N2 == Status.Off)
                    {
                        Leds.Switch(Led.N2, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.N2, Mode.On);
                    }

                    if (GlobalState.V6 != Status.On)
                    {
                        Leds.Switch(Led.V6, Mode.Off);
                    }
                    else
                    {
                        Leds.Switch(Led.V6, Mode.On);
                    }

                    if (GlobalState.N1 == Status.Off)
                    {
                        Leds.Switch(Led.N1Green, Mode.Off);
                    }
                    else if (GlobalState.N1 == Status.Error)
                    {
                        Leds.Switch(Led.N1Red, Mode.On);
                    }
                    else if (GlobalState.N1 == Status.On)
                    {
                        Leds.Switch(Led.N1Green, Mode.On);
                    }
                    else if (GlobalState.N1 == Status.StartWork)
                    {
                        if (_n1Flash)
                        {
                            Leds.Switch(Led.N1Orange, Mode.On);
                        }
                        else
                        {
                            Leds.Switch(Led.N1Orange, Mode.Off);
                        }
                        _n1Flash = !_n1Flash;
                    }

                    info.systemMessage = $"N1 =" + GlobalState.N1.ToString();
                }
                break;
            }

            case 3:     //Плата питания анализатора
            {
                answer = Boards.State(Board.analyzer);
                if (answer == null)
                {
                    _analyzerBoardErrors++; if (_analyzerBoardErrors == 3)
                    {
                        info.systemMessage = SysMessages.AnalyzerBoardError;
                    }
                    break;
                }            //ошибка платы;
                else         //obrabotka otveta
                {
                    _analyzerBoardErrors = 0;


                    GlobalState.S1 = (answer[5] & 0x01 << 1) > 0 ? Status.On : Status.Off;             //катод 1 вкл
                    GlobalState.S1 = (answer[5] & 0x01 << 2) > 0 ? Status.On : Status.Off;             //катод 2 вкл
                    if (GlobalState.CurrentS1)
                    {
                        GlobalState.S1 = (answer[5] & 0x01 << 4) > 0 ? Status.StartWork : GlobalState.S1;
                        GlobalState.S1 = (answer[4] & 0x01 << 5) > 0 ? Status.Error : GlobalState.S1;             //обрыв катода 1
                    }
                    else
                    {
                        GlobalState.S2 = (answer[5] & 0x01 << 4) > 0 ? Status.StartWork : GlobalState.S2;
                        GlobalState.S2 = (answer[4] & 0x01 << 5) > 0 ? Status.Error : GlobalState.S2;             //обрыв катода 2
                    }

                    GlobalState.Amplifier = (answer[5] & 0x01) > 0 ? Status.On : Status.Off;                  //высковолт. источ. вкл.
                    if ((answer[4] & 0x01 << 3) > 0)
                    {
                        _analyzerBoardErrors++;                                          //нет напряжения питания катодов (типа ошибка самой платы)
                    }
                    if (_analyzerBoardErrors == 3)
                    {
                        GlobalState.Amplifier = Status.Error;
                    }

                    GlobalState.CurrentAmpMka = answer[6] | answer[7] << 8;           //заданный ток эмиссии мкА
                    GlobalState.CurrentAmpUa  = answer[8] | answer[9] << 8;           //напряжение Ua
                    GlobalState.CurrentAmpUs  = answer[10] | answer[11] << 8;         //напряжение Us

                    //info.systemMessage = $"mkA = {GlobalState.CurrentAmpMka}; Ua = {GlobalState.CurrentAmpUa}; Us = {GlobalState.CurrentAmpUs}";
                }
                break;
            }

            default: break;
            }
            if ((_forsKlapBoardErrors + _analyzerBoardErrors + _amplifBoardErrors + _dvKlapBoardErrors) > 11)
            {
                info.systemMessage = SysMessages.InternalRS485Error;
            }
            _BaseBoardsStateCycl++;
        }