Beispiel #1
0
        private static void InitThread()
        {
            try
            {
                using (new ProcessBarMgt("正在在初始化系统..."))
                {
                    IsInInit = true;
                    //connect to
                    MessageBody message = new MessageBody();
                    //1. light
                    LogHelper.AppLoger.Debug("init light control.");
                    message.type = MsgType.Information;
                    message.msg  = "初始化触发控制卡";
                    ThrowMessage(message);

                    IsInInit = Ilight.InitSys();
                    if (IsInInit)
                    {
                        LogHelper.AppLoger.Debug("init light control successed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化触发控制卡成功";
                        ThrowMessage(message);
                    }
                    else
                    {
                        LogHelper.AppLoger.Debug("init light control failed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化触发控制卡失败";
                        ThrowMessage(message);
                    }


                    //2.connnect motor
                    LogHelper.AppLoger.Debug("init plc control.");
                    message.type = MsgType.Information;
                    message.msg  = "初始化运动控制卡";
                    ThrowMessage(message);

                    IsInInit = IMotorCtrl.Connect(SystemConfig.Instance.Control_IP);

                    if (IsInInit)
                    {
                        LogHelper.AppLoger.Debug("init plc control successed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化运动控制卡成功";
                        ThrowMessage(message);
                    }
                    else
                    {
                        LogHelper.AppLoger.Debug("init plc control failed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化运动控制卡失败";
                        ThrowMessage(message);
                    }

                    //3. home
                    //IMotorCtrl.ExecHomeALL();
                    message.msg = "运动平台开始回原点";
                    ThrowMessage(message);

                    //while (true)
                    //{
                    //    if (IMotorCtrl.IsHome())
                    //    {
                    //        message.msg = "运动平台回原点成功";
                    //        ThrowMessage(message);
                    //        break;
                    //    }
                    //    else
                    //    {
                    //        System.Threading.Thread.Sleep(100);
                    //    }
                    //}
                    if (IsInInit)
                    {
                        //4.move z to start pos
                        //IMotorCtrl.Move(3, -4.45015f);
                        //message.msg = "Z轴运动到初始位置";
                        ThrowMessage(message);
                    }

                    //4.init camera
                    LogHelper.AppLoger.Debug("init camera control.");
                    message.type = MsgType.Information;
                    message.msg  = "初始化相机";
                    ThrowMessage(message);

                    IsInInit = ICamCtrl.Init();
                    if (IsInInit)
                    {
                        LogHelper.AppLoger.Debug("init camera control successed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化相机成功";
                        ThrowMessage(message);
                    }
                    else
                    {
                        LogHelper.AppLoger.Debug("init camera control failed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化相机失败";
                        ThrowMessage(message);
                    }

                    //IsInInit = ICamCtrl_HaiKang.Init();
                    //if (IsInInit)
                    //{
                    //    LogHelper.AppLoger.Debug("Init HaiKang camera control successed.");
                    //    message.type = MsgType.Information;
                    //    message.msg = "初始化海康相机成功";
                    //    ThrowMessage(message);
                    //}
                    //else
                    //{
                    //    LogHelper.AppLoger.Debug("Init HaiKang camera control failed.");
                    //    message.type = MsgType.Information;
                    //    message.msg = "初始化海康相机失败";
                    //    ThrowMessage(message);
                    //}

                    //5. init matlab control
                    //IsInInit = IFocus.Init();

                    if (IsInInit)
                    {
                        LogHelper.AppLoger.Debug("init matlab control successed.");
                    }
                    else
                    {
                        LogHelper.AppLoger.Debug("init matlab control failed.");
                    }

                    //6. set green light on
                    ConstDef.IsSysReady = IsInInit;

                    //7.初始化压电陶瓷控制器,20181213,顾叶俊修改
                    IsInInit = IPiz.Open();
                    if (IsInInit)
                    {
                        LogHelper.AppLoger.Debug("init Pize control successed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化压电陶瓷控制器成功";
                        ThrowMessage(message);
                    }
                    else
                    {
                        LogHelper.AppLoger.Debug("init Pize control failed.");
                        message.type = MsgType.Information;
                        message.msg  = "初始化压电陶瓷控制器失败";
                        ThrowMessage(message);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("初始化系统异常!", "睿仟医疗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogHelper.AppLoger.Error(ex);
            }
            finally
            {
                IsInInit = false;
            }
        }