Example #1
0
        private void button_Connect_Click(object sender, EventArgs e)
        {
            if (connection.isConnected == false)
            {
                //清除显示区
                ClearLine();
                try
                {
                    //连接本地端Prosim
                    connection.Connect("127.0.0.1");
                }
                catch (Exception ex)
                {
                    WriteLine("无法连接ProSim320程序");
                    return;
                }
                WriteLine("已连接ProSim320程序");
                button_Connect.Text = "断开连接";

                //获得硬件选择情况并创建
                GetHardwareStatus();

                Thread.Sleep(200);
                //StartThreads();
            }
            else
            {
                connection.Dispose();
                connection = new ProSimConnect();
                WriteLine("已断开与ProSim320的连接");
                button_Connect.Text = "连接";

                a320_Glare.Disconnect();
                a320_TQ.Disconnect();
                a320_YokeL.Disconnect();
                a320_YokeR.Disconnect();

                //回收内存,Prosim接口没有多次运行的回收机制
                GC.Collect();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("程序名称:InputTest");
            Console.WriteLine("程序版本:V1.0");
            Console.WriteLine("发布时间:2018.7.12");
            Console.WriteLine("开发者:柴宇宸");
            Console.WriteLine("");
            //ProSim连接
            ProSimConnect connection = new ProSimConnect();

            try
            {
                connection.Connect("127.0.0.1");
            }
            catch (Exception ex)
            {
                Console.WriteLine("未连接ProSim320程序");
                Console.Read();
                Environment.Exit(0);
            }
            Console.WriteLine("已连接ProSim320程序");

            DataRefDescription[] descriptions = connection.getDataRefDescriptions().ToArray();
            Eng_L = new DataRef("system.encoders.E_FCU_ALTITUDE", 100, connection);
            //Eng_R = new DataRef("system.analog.A_FC_THROTTLE_RIGHT_INPUT", 100, connection);

            Console.Title = "MyConsoleApp";
            while (true)
            {
                Console.Write("请输入信息:");
                string   eng  = Console.ReadLine();
                string[] engs = eng.Split(new char[] { ' ' });

                int engl = int.Parse(engs[0]);
                //int engr = int.Parse(engs[1]);
                Eng_L.value = engl;
                //Eng_R.value = engr;
            }
        }