示例#1
0
        static void Main(string[] args)
        {
            var termodat = new Termodat("COM4", 2, 1, 1, 1);

            ShowTitle();
            InitProgram(termodat);
        }
示例#2
0
        static void InitProgram(Termodat termodat)
        {
            while (true && termodat.IsConnect)
            {
                Console.Write("$ ");
                string input = Console.ReadLine();
                switch (input)
                {
                case "set-program":
                    SetStartProgram(termodat);
                    break;

                case "temp":
                    Show(termodat.Temp);
                    break;

                case "setpoint":
                    Show(termodat.SetPoint);
                    break;

                case "channel":
                    Show(termodat.Channels);
                    break;

                case "process":
                    Show(termodat.StateProcess.ToString());
                    break;

                case "program":
                    Show(termodat.StateProgram.ToString());
                    break;

                case "start":
                    if (termodat.StateProcess != StateProcess.Run)
                    {
                        termodat.StartProcess();
                        Show("Start OK");
                    }
                    else
                    {
                        Show("Process already running");
                    }
                    break;

                case "stop":
                    if (termodat.StateProcess != StateProcess.Stop)
                    {
                        termodat.StopProcess();
                        Show("Stop OK");
                    }
                    else
                    {
                        Show("Process already stopped");
                    }
                    break;

                case "pause":
                    if (termodat.StateProcess != StateProcess.Pause)
                    {
                        termodat.PauseProcess();
                        Show("Pause OK");
                    }
                    else
                    {
                        Show("Process already paused");
                    }
                    break;

                case "clear":
                    Console.Clear();
                    ShowTitle();
                    break;

                case "q":
                case "quit":
                    Show("Bye...");
                    return;


                default:
                    Console.WriteLine("Incorrect input, try again");
                    break;
                }
            }
        }
示例#3
0
        static void SetStartProgram(Termodat termodat)
        {
            bool cicle = true;

            Console.WriteLine("Editable program number: ");
            int programNumber = int.Parse(Console.ReadLine());

            Console.WriteLine("Editable step number: ");
            int stepNumber = int.Parse(Console.ReadLine());

            Console.WriteLine("What doing in this step, \"HeatingOrCooling\", \"Exposure\", \"Goto\", \"Stop\"?: ");
            string       step  = Console.ReadLine();
            StateProgram state = StateProgram.HeatingOrCooling;

            while (cicle)
            {
                switch (step)
                {
                case "HeatingOrCooling":
                    state = StateProgram.HeatingOrCooling;
                    cicle = false;
                    break;

                case "Exposure":
                    state = StateProgram.Exposure;
                    cicle = false;
                    break;

                case "Goto":
                    state = StateProgram.Goto;
                    cicle = false;
                    break;

                case "Stop":
                    state = StateProgram.Stop;
                    cicle = false;
                    break;

                default:
                    Console.WriteLine("Incorrect input, try again");
                    break;
                }
            }
            cicle = true;

            Console.WriteLine("Параметр 1 (время выдержки, либо скорость (0,1ºC/ч), либо номер программы (если Goto)) Integer (100 = 10,0): ");
            int param1 = int.Parse(Console.ReadLine());

            Console.WriteLine("Параметр 2 (целевая уставка в 0,1ºC)] Integer: ");
            int param2 = int.Parse(Console.ReadLine());

            Console.WriteLine("Условие перехода на следующий шаг \"Tcalc\", \"ManualAccept\", \"Tmeasure\"");
            TransitionCondition condition = TransitionCondition.Tmeasure;
            string cond = Console.ReadLine();

            while (cicle)
            {
                switch (cond)
                {
                case "Tcalc":
                    condition = TransitionCondition.Tcalc;
                    cicle     = false;
                    break;

                case "ManualAccept":
                    condition = TransitionCondition.ManualAccept;
                    cicle     = false;
                    break;

                case "Tmeasure":
                    condition = TransitionCondition.Tmeasure;
                    cicle     = false;
                    break;

                default:
                    Console.WriteLine("Incorrect input, try again");
                    break;
                }
            }
            termodat.SetupProgram(programNumber, stepNumber, state, param1, param2, condition);
        }