Ejemplo n.º 1
0
        private void AmovPlanner_Load(object sender, EventArgs e)
        {
            AmovPlanner amov = new AmovPlanner();

            amov.WindowState = FormWindowState.Maximized;
            //************************************MAVLink对象* ****************************************
            //dv1 = new Device(ConnectType.Tcp);//打开了设备,创建了数据读取类和用于更新UI的事件和委托函数
            // dv1.linkEvent += Dv1_linkEvent;//绑定一个委托事件,用于读写线程( SerialReader)来触发这个UI显示事件
            //this.Commandspanel.Visible = false
            flightdata1.SuspendLayout();
            devicecheck1.SuspendLayout();
            flightdata1.Visible  = false;
            devicecheck1.Visible = false;
            //System.Threading.Thread.Sleep(100000);占用较长时间
            //数据加载完成通过实践通知

            // SendMsg(sender, e);
        }
Ejemplo n.º 2
0
        Tool Tool = new Tool();                                            //自动读取设备的一个类,可以实现软件打开自动扫描设备类。
        public AmovPlanner()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            gbl_flag            = new GBL_FLAG();
            gbl_flag.flight     = false; //地面站打开,系统默认为飞控不处于飞行状态
            gbl_flag.bRoutePlan = false; //地面站打开,系统默认飞控不处于航线规划状态
            massag_error        = "";

            //show_waypoint.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
            //show_waypoint.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
            //show_waypoint.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
            FlightPlanner = new flightplanner(); //实例化路径规划类
            devicecheck1.SuspendLayout();        // 进入时挂起控件
            flightdata1.SuspendLayout();

            instance = this;

            //for (int i = 1; i <= 5; i++)//Tool类里面做了自动连接的配置,在Set文件中配置了连接类型,程序上电自动连接设备
            //{
            bool _have = false;
            int  n     = 0;

            for (n = 0; n < Tool.ConfSet.Count; n++)
            {
                //if (Tool.ConfSet[n].DeviceId == 1)
                //{
                _have = true;
                break;
                //}
            }
            if (_have)
            {
                Device dev = new Device();
                if (Tool.ConfSet[n].IsComm)
                {
                    dev.ConnectType = ConnectType.Com;
                }
                else
                {
                    dev.ConnectType = ConnectType.Tcp;
                }
                dev.linkEvent   += Dv1_linkEvent;
                dev.Index        = 1;
                dev.ConnectState = Tool.ConfSet[n].IsConnect;
                dev.ComPort      = Tool.ConfSet[n].ComPort;

                dev.IP   = Tool.ConfSet[n].IP;
                dev.Port = Tool.ConfSet[n].Port;
                dev.Baud = 115200;
                //if (dev.ConnectState)
                //{
                //    dev.Start();
                //    dev.isOccupy = false;
                //}
                SorlistDevice.Add(1, dev);
                //if (i == 1)
                //{
                dv1 = dev;
                //}
            }
            else
            {
                Device dev = new Device(ConnectType.Tcp);
                dev.ConnectState = false;
                dev.Index        = 1;
                dev.linkEvent   += Dv1_linkEvent;
                dev.Baud         = 115200;
                SorlistDevice.Add(1, dev);
                Set se = new Set();
                se.DeviceId  = 1;
                se.IsConnect = false;
                //if (i == 1)
                //{
                dv1 = dev;
                //}

                Tool.ConfSet.Add(se);
            }
            //}

            //try
            //{
            //     = ActiveChildForm(dllFormNameWithNameSpace);
            //    if (child != null)
            //        return child;
            //    loading ld = new loading();
            //    Action handler = new Action();
            //    handler.BeginInvoke(null, null);  //在另外一个线程打开,否则会阻塞
            //    Form form = OpenPluginFormInMainDomain(dllFileSimpleName, dllFormNameWithNameSpace, initParam);

            //    if (form != null && form is Form)
            //    {
            //        child = form as Form;
            //        ((Fm11Base)child).RightsList = rightsList.ToLower();
            //        ((Fm11Base)child).OnLoadParams = onLoadParams;
            //        child.Text = tagTitle;
            //        child.MdiParent = (Form)this;
            //        child.FormClosed += Child_FormClosed;
            //        child.Show();
            //        child.WindowState = FormWindowState.Maximized;
            //        this.ActivateMdiChild(child);
            //        if (child.HasChildren)
            //        {
            //            child.Controls[0].Focus();
            //        }
            //        CloseLoadingForm();
            //        return child;
            //    }
            //    else
            //    {
            //        CloseLoadingForm();
            //        return null;
            //        throw new Exception("未找到窗体文件或加载了未知的窗体类型!");
            //    }
            //}
            //catch (Exception ex)
            //{
            //    CloseLoadingForm();
            //    MyMsg.Information("窗体实例化出错,请重试.", ex.Message);
            //    return null;
            //}
        }