Пример #1
0
        public async Task <InitResult> ResetVsmdController()
        {
            if (m_initialized)
            {
                this.Dispose();
            }
            InitResult result = await Init(m_port, m_baudrate);

            if (!result.IsSuccess)
            {
                //StatusBar.DisplayMessage(MessageType.Error, result.ErrorMsg);
            }
            return(result);
        }
Пример #2
0
 private void InitVsmdConnectionCB(InitResult initRet)
 {
     if (initRet.IsSuccess)
     {
         StatusBar.DisplayMessage(MessageType.Info, "设备连接成功!");
         if (m_dripForm == null)
         {
             m_dripForm           = new DripFrm();
             m_dripForm.MdiParent = this;
             m_dripForm.Show();
             m_connectForm.Close();
             m_connectForm = null;
         }
     }
     else
     {
         StatusBar.DisplayMessage(MessageType.Error, initRet.Message);
     }
 }
Пример #3
0
        private async void btnConnect_Click(object sender, EventArgs e)
        {
            if (VsmdController.GetVsmdController().IsInitialized())
            {
                VsmdController.GetVsmdController().Dispose();
                PumpController.GetPumpController().Dispose();
                UpdateControlState();
                return;
            }

            if (m_isConnecting)
            {
                return;
            }

            if (cmbPort.SelectedItem == null)
            {
                StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "电机端口不能为空!");
                return;
            }
            if (cmbPumpPort.SelectedItem == null)
            {
                StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "蠕动泵端口不能为空!");
                return;
            }
            string vsmdPort = cmbPort.SelectedItem.ToString();
            string pumpPort = cmbPumpPort.SelectedItem.ToString();

            if (vsmdPort == pumpPort)
            {
                StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "电机端口与蠕动泵端口不能相同!");
                return;
            }
            int baudrate = int.Parse(cmbBaudrate.SelectedItem.ToString());

            if (vsmdPort == VsmdController.GetVsmdController().GetPort() &&
                baudrate == VsmdController.GetVsmdController().GetBaudrate() &&
                pumpPort == PumpController.GetPumpController().GetPort())
            {
                if (m_initCB != null)
                {
                    m_initCB(new InitResult()
                    {
                        Message = "设备连接成功!", IsSuccess = true
                    });
                }
                this.Close();
            }

            m_isConnecting = true;
            InitResult vsmdRet = await VsmdController.GetVsmdController().Init(vsmdPort, baudrate);

            InitResult pumpRet = PumpController.GetPumpController().Init(pumpPort);

            if (m_initCB != null)
            {
                InitResult connectRet = new InitResult();
                connectRet.IsSuccess = vsmdRet.IsSuccess && pumpRet.IsSuccess;
                connectRet.Message   = vsmdRet.IsSuccess ? pumpRet.Message : vsmdRet.Message;
                m_initCB(connectRet);
                m_isConnecting = false;
            }
            if (vsmdRet.IsSuccess && pumpRet.IsSuccess)
            {
                this.Close();
            }
        }
Пример #4
0
        private async void btnConnect_Click(object sender, EventArgs e)
        {
            if (VsmdController.GetVsmdController().IsInitialized())
            {
                VsmdController.GetVsmdController().Dispose();
                PumpController.GetPumpController().Dispose();
                UpdateControlState();
                return;
            }

            if (m_isConnecting)
            {
                return;
            }

            if (cmbPort.SelectedItem == null)
            {
                StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "电机端口不能为空!");
                return;
            }
            string vsmdPort = cmbPort.SelectedItem.ToString();

            bool       pumpExist = PumpController.GetPumpController().PumpExist;
            InitResult pumpRet   = new InitResult();

            pumpRet.IsSuccess = true;
            pumpRet.Message   = "";
            if (pumpExist)
            {
                if (cmbPumpPort.SelectedItem == null)
                {
                    StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "蠕动泵端口不能为空!");
                    return;
                }
                string pumpPort = cmbPumpPort.SelectedItem.ToString();
                if (vsmdPort == pumpPort)
                {
                    StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "电机端口与蠕动泵端口不能相同!");
                    return;
                }
                pumpRet = PumpController.GetPumpController().Init(pumpPort);
                if (pumpRet.IsSuccess)
                {
                    Preference.GetInstace().PumpPort = pumpPort;
                }
                Preference.GetInstace().Save();
            }


            int baudrate = int.Parse(cmbBaudrate.SelectedItem.ToString());

            m_isConnecting = true;
            InitResult vsmdRet = await VsmdController.GetVsmdController().Init(vsmdPort, baudrate);

            if (m_initCB != null)
            {
                InitResult connectRet = new InitResult();
                connectRet.IsSuccess = vsmdRet.IsSuccess && pumpRet.IsSuccess;
                connectRet.Message   = vsmdRet.IsSuccess ? pumpRet.Message : vsmdRet.Message;
                m_initCB(connectRet);
                m_isConnecting = false;
                //m_initCB = null;
            }
            if (vsmdRet.IsSuccess && pumpRet.IsSuccess)
            {
                Preference.GetInstace().VsmdPort = vsmdPort;
                GoHome();
                this.Close();
            }
        }