コード例 #1
0
        private void FrMain_Load(object sender, EventArgs e)
        {
            EM_RES ret;

            VAR.msg.ShowMsgCfg(1000, (Msg.EM_MSGTYPE) 0xffff);
            VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, "系统启动...");
            //load sys config
            VAR.gsys_set.LoadSysCfg();
            VAR.gsys_set.status = EM_SYS_STA.UNKOWN;
            VAR.gsys_set.bclose = false;

            VAR.sys_inf.Set(EM_ALM_STA.WAR_YELLOW_FLASH, "正在加载", 2, true);

            //加载产品
            try
            {
                //if (COM.NGDef == null)
                //    COM.NGDef = new NGCodeDef();
                //COM.NGDef.LoadCfg();

                //if (COM.product == null) COM.product = new Product();
                //ret = COM.product.LoadDat(VAR.gsys_set.cur_product_name);
                //if (ret != EM_RES.OK) VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "产品数据加载失败!");
                //else VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "产品数据加载成功!");

                //foreach (WS ws in COM.list_ws)
                //{
                //    ws.LoadCfg();
                //}

                ////加载吸头
                //COM.XtInit(VAR.gsys_set.cur_product_name);
                ////加载仓储
                //COM.TrayBoxInit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //硬件初始化
            Task TaskHWInit = new Task(() =>
            {
                ret = MT.Init(Path.GetFullPath("..") + "\\syscfg\\");
                if (ret != EM_RES.OK)
                {
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "板卡初始化失败!");
                }
                else
                {
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "板卡初始化成功!");
                }
            }
                                       );

            TaskHWInit.Start();

            //相机初始化
            //Task TaskCamInit = new Task(() =>
            //{
            //    ret = MT.Init(Path.GetFullPath("..") + "\\syscfg\\");
            //    if (ret != EM_RES.OK) VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "板卡始化失败!");
            //    else VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "板卡始化成功!");
            //}
            //ret = COM.CamInit();
            //if (ret != EM_RES.OK) VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "相机初始化失败!");
            //else VAR.msg.AddMsg(Msg.EM_MSGTYPE.NOR, "相机初始化成功!");
            //);
            //TaskHWInit.Start();
            //COM.CamInit();

            //create form
            //Task TaskFormInit = new Task(() =>
            //{
            //    if (frsys == null) frsys = new FrSys();
            //    frsys.bupdate = false;
            //    if (frrst == null) frrst = new FrRst();
            //    frrst.bupdate = false;
            //    if (frproduct == null) frproduct = new FrProduct();
            //    frproduct.bupdate = false;
            //    if (frrun == null) frrun = new FrRun();
            //    frrun.bupdate = false;

            //    pnl_sub.Controls.Clear();
            //    frrun.TopLevel = false;
            //    frrun.FormBorderStyle = FormBorderStyle.None;
            //}
            //);
            //TaskFormInit.Start();
            form_sel("rbtn_run");//显示运行界面
            Application.DoEvents();
            Thread.Sleep(10);

            //   timer_reconnect.Enabled = true;
            //    if (frrun != null) frrun.bupdate = true;

            VAR.sys_inf.Set(EM_ALM_STA.WAR_YELLOW_FLASH, "待回零", 10, true);

            if (MT.isReady)
            {
                ////钩子侦测按键
                //k_hook.KeyDownEvent += new KeyEventHandler(hook_KeyDown);//钩住键按下
                //k_hook.KeyUpEvent += new KeyEventHandler(hook_KeyUp);//钩住键按下
                //k_hook.Start();//安装键盘钩子
            }
            MT.SetSafeFunc();
            //MT.GPIO_OUT_TT_REV.ChkSafe = Turntable.ChkSafe;
            //MT.GPIO_OUT_TT_FWD.ChkSafe = Turntable.ChkSafe;
        }