コード例 #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            double val = 0;

            bool bok = double.TryParse(txtDelaySeconds.Text, out val);

            if (!bok)
            {
                MessageBox.Show("体积必须为数字!");
                return;
            }
            if (val == 0)
            {
                MessageBox.Show("体积必须大于0!");
                return;
            }

            Preference.GetInstace().DelaySeconds = val;

            int cnt = 0;

            bok = int.TryParse(txtSampleCnt.Text, out cnt);
            if (!bok)
            {
                MessageBox.Show("样本数必须为数字!");
                return;
            }
            if (val == 0)
            {
                MessageBox.Show("样本数必须大于0!");
                return;
            }
            if (!m_manuallySelect)
            {
                m_externalObj.ResetBoard();
                m_externalObj.SelectTubes(cnt);
            }
            Preference.GetInstace().Save();
            //Logger.Instance.Write("about to start pipetting");
            m_externalObj.Move();
            m_pipettingStatus = PipettingStatus.Moving;
            runInfoModel.AddRunInfo(cmbProjectName.SelectedItem.ToString(), int.Parse(txtSampleCnt.Text));
            UpdateButtons();
        }
コード例 #2
0
        public bool SavePref()
        {
            bool       ret         = true;
            Preference perfInst    = Preference.GetInstace();
            string     curVsmdPort = cmbPort.SelectedItem.ToString();
            int        curBaudrate = int.Parse(cmbBaudrate.SelectedItem.ToString());
            string     pumpPort    = cmbPumpPort.SelectedItem.ToString();

            if (perfInst.VsmdPort != curVsmdPort ||
                perfInst.Baudrate != curBaudrate ||
                perfInst.PumpPort != pumpPort)
            {
                perfInst.VsmdPort = curVsmdPort;
                perfInst.Baudrate = curBaudrate;
                perfInst.PumpPort = pumpPort;
                ret = perfInst.Save();
            }


            return(ret);
        }
コード例 #3
0
        private void ConnectVsmd_Load(object sender, EventArgs e)
        {
            cmbPort.Items.AddRange(SerialPort.GetPortNames());
            cmbPumpPort.Items.AddRange(SerialPort.GetPortNames());
            if (VsmdController.GetVsmdController().IsInitialized())
            {
                //lblCurInfo.Text = VsmdController.GetVsmdController().GetPort() + ", " + VsmdController.GetVsmdController().GetBaudrate() + ", " + PumpController.GetPumpController().GetPort();
                int idx = cmbPort.Items.IndexOf(VsmdController.GetVsmdController().GetPort());
                if (idx > -1)
                {
                    cmbPort.SelectedIndex = idx;
                }
                idx = cmbBaudrate.Items.IndexOf(VsmdController.GetVsmdController().GetBaudrate().ToString());
                if (idx > -1)
                {
                    cmbBaudrate.SelectedIndex = idx;
                }
                idx = cmbPumpPort.Items.IndexOf(PumpController.GetPumpController().GetPort());
                if (idx > -1)
                {
                    cmbPumpPort.SelectedIndex = idx;
                }
                UpdateControlState();
                return;
            }
            else
            {
                UpdateControlState();
            }

            if (Preference.GetInstace().HasPreference)
            {
                int idx = cmbPort.Items.IndexOf(Preference.GetInstace().VsmdPort);
                if (idx > -1)
                {
                    cmbPort.SelectedIndex = idx;
                }
                idx = cmbBaudrate.Items.IndexOf(Preference.GetInstace().Baudrate.ToString());
                if (idx > -1)
                {
                    cmbBaudrate.SelectedIndex = idx;
                }
                idx = cmbPumpPort.Items.IndexOf(Preference.GetInstace().PumpPort);
                if (idx > -1)
                {
                    cmbPumpPort.SelectedIndex = idx;
                }
            }
            else
            {
                if (cmbPort.Items.Count > 0)
                {
                    cmbPort.SelectedIndex     = 0;
                    cmbPumpPort.SelectedIndex = 0;
                }
                cmbBaudrate.SelectedIndex = 2;
            }
            IsClosed = false;

            if (GeneralSettings.GetInstance().AutoConnect)
            {
                btnConnect_Click(null, null);
            }
        }
コード例 #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();
            }
        }