コード例 #1
0
ファイル: Cathodes.cs プロジェクト: Physicsfaker/Ti1_50Pi
        public static byte[] SwitchCathodes(Cathode cathode, Mode mode) //dodelat'
        {
            byte[] command = new byte[6];

            command[0] = 0xAB; //маска сети
            command[1] = (byte)Board.analyzer;
            command[2] = 0x02; //команды
            command[3] = 0x02; //для режима управление

            switch (cathode)
            {
            case Cathode.S1: { command[4] = 0x01; break; }

            case Cathode.S2: { command[4] = 0x02; break; }
            }

            if (mode == Mode.On)
            {
                command[5] = 0xFF;                  //выбор состояния устройства
            }
            if (mode == Mode.Off)
            {
                command[5] = 0x00;
            }

            byte[] answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                return(answer);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: Pump.cs プロジェクト: Physicsfaker/Ti1_50Pi
        public static bool Switch(Mode mode)
        {
            byte[] command = new byte[6];

            command[0] = 0xAB; //маска сети
            command[1] = 0x3A;
            command[2] = 0x02; //команды
            command[3] = 0x02; //для режима управление
            command[4] = 0x00;

            if (mode == Mode.On) //выбор состояния устройства
            {
                command[5] = 0xFF;
            }
            if (mode == Mode.Off)
            {
                command[5] = 0x00;
            }

            byte[] answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: Cathodes.cs プロジェクト: Physicsfaker/Ti1_50Pi
        public static byte[] SwitchAnalyzer(Mode mode)
        {
            byte[] command = new byte[6];

            command[0] = 0xAB; //маска сети
            command[1] = (byte)Board.analyzer;
            command[2] = 0x02; //команды
            command[3] = 0x02; //для режима управление
            command[4] = 0x00;

            if (mode == Mode.On)
            {
                command[5] = 0xFF;                  //выбор состояния устройства
            }
            if (mode == Mode.Off)
            {
                command[5] = 0x00;
            }

            byte[] answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                return(answer);
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: Boards.cs プロジェクト: Physicsfaker/Ti1_50Pi
        public static byte[] State(Board device)
        {
            int respLenght = 8;

            byte[] command = new byte[4];
            command[0] = 0xAB;         //маска сети
            command[1] = (byte)device; //адрес платы
            command[2] = 0x00;         //команды
            command[3] = 0x00;         //для запроса состояния

            switch (device)
            {
            case Board.amplifier: { respLenght = 10; break; }

            case Board.analyzer: { respLenght = 17; break; }

            case Board.forsKlapBoard: { respLenght = 8; break; }

            case Board.dvKlapBoard: { respLenght = 11; break; }
            }

            byte[] answer = DevicesSerial.TryToUse(command, respLenght);

            if (answer != null)
            {
                return(answer);
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
ファイル: Cathodes.cs プロジェクト: Physicsfaker/Ti1_50Pi
        public static bool AnalyzerInit() //первоначальная настройка Анализатора, запустить в самом начале при включении
        {
            bool iemOk = false;
            bool uaOk  = false;
            bool usOk  = false;

            byte[] answer = new byte[_respLenght];

            byte[] command = new byte[7];
            command[0] = 0xAB;                                                                                           //маска сети
            command[1] = (byte)Board.analyzer;
            command[2] = 1;                                                                                              //команды
            command[3] = 3;                                                                                              //длинна команды

            command[4] = 0; command[5] = (byte)(analyzaer_Iem & 0xFF); command[6] = (byte)((analyzaer_Iem >> 8) & 0xFF); //IEM

            answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                iemOk = true;
            }
            else
            {
                iemOk = false;
            }

            command[4] = 1; command[5] = (byte)(analyzaer_Ua & 0xFF); command[6] = (byte)((analyzaer_Ua >> 8) & 0xFF); //UA
            answer     = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                uaOk = true;
            }
            else
            {
                uaOk = false;
            }

            command[4] = 2; command[5] = (byte)(analyzaer_Us & 0xFF); command[6] = (byte)((analyzaer_Us >> 8) & 0xFF); //US
            answer     = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                usOk = true;
            }
            else
            {
                usOk = false;
            }

            if (iemOk && uaOk && usOk)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        public static double State(PressureMeter device)
        {
            byte[] command = new byte[4];

            command[0] = 0xAB; //маска сети

            switch (device)    //выбор устройства
            {
            case PressureMeter.P1:
            { command[1] = 0x12; break; }

            case PressureMeter.P3:
            { command[1] = 0x11; break; }
            }

            command[2] = 0x00;   //команды
            command[3] = 0x00;   //для запроса состояния

            byte[] answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer == null)
            {
                return(-999.9);
            }

            _pressValue = (answer[5] | answer[6] << 8);

            if (_pressValue < 100)
            {
                _pressValue = 100;
            }
            if (_pressValue > 65471)
            {
                _pressValue = 65471;
            }

            double pressure = 0;

            for (int i = 1; i < 26; i++)
            {
                if (_pressValue < _pressure_hex[i])
                {
                    pressure = (((_pressure_pascal[i] - _pressure_pascal[i - 1]) /
                                 (_pressure_hex[i] - _pressure_hex[i - 1])) * _pressValue + (_pressure_pascal[i - 1] -
                                                                                             ((_pressure_pascal[i] - _pressure_pascal[i - 1]) / (_pressure_hex[i] - _pressure_hex[i - 1])) *
                                                                                             _pressure_hex[i - 1]));
                    break;
                }
            }
            if (pressure > 99851.0)
            {
                pressure = 100000;
            }

            return(pressure);
        }
コード例 #7
0
        public static bool Switch(Valve device, Act action)
        {
            byte[] command = new byte[6];

            command[0] = 0xAB; //маска сети

            switch (device)    //выбор устройства
            {
            case Valve.V1:
            case Valve.V5:
            case Valve.V6:
            case Valve.VProm:
            case Valve.VLap:
            { command[1] = 0x3A; break; }

            case Valve.V2:
            case Valve.V3:
            case Valve.V4:
            { command[1] = 0x26; break; }
            }

            command[2] = 2;   //команды
            command[3] = 2;   //для режима управление
            command[4] = (byte)device;

            if (action == Act.Open) //выбор состояния устройства
            {
                command[5] = 0xFF;
                if (device == Valve.VLap)
                {
                    command[5] = 0x00;
                }
            }
            if (action == Act.Close)
            {
                command[5] = 0x00;
                if (device == Valve.VLap)
                {
                    command[5] = 0xFF;
                }
            }

            byte[] answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
0
        public static int State()
        {
            byte[] command = new byte[4];

            command[0] = 0xAB; //маска сети
            command[1] = 0x21;
            command[2] = 0x00; //команды
            command[3] = 0x00; //для запроса состояния

            byte[] answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer == null)
            {
                return(-999);
            }
            return((int)answer[5]);
        }
コード例 #9
0
ファイル: Cathodes.cs プロジェクト: Physicsfaker/Ti1_50Pi
        public static byte[] AnalyzerInit(AnalyzerParam param, ushort value) //ручная установка токов и напряжений
        {
            byte[] answer  = new byte[_respLenght];
            byte[] command = new byte[7];
            command[0] = 0xAB; //маска сети
            command[1] = (byte)Board.analyzer;
            command[2] = 1;    //команды
            command[3] = 3;    //длинна команды
            command[4] = (byte)param;
            command[5] = (byte)(value & 0xFF);
            command[6] = (byte)((value >> 8) & 0xFF); //US

            answer = DevicesSerial.TryToUse(command, _respLenght);
            if (answer != null)
            {
                return(answer);
            }
            else
            {
                return(null);
            }
        }