コード例 #1
0
        public async void DripTube(string args)
        {
            JObject targetTube = (JObject)JsonConvert.DeserializeObject(args);
            int     type = int.Parse(targetTube["type"].ToString());
            int     blockNum, row, col = 1;

            if (type == (int)BoardType.Site)
            {
                blockNum = int.Parse(targetTube["site"].ToString());
                col      = int.Parse(targetTube["col"].ToString());
            }
            else
            {
                blockNum = int.Parse(targetTube["grid"].ToString());
            }
            row = int.Parse(targetTube["row"].ToString());
            SetDrippingTube(blockNum, row, col);
            VsmdController vsmdController  = VsmdController.GetVsmdController();
            PumpController pumpController  = PumpController.GetPumpController();
            BoardSetting   curBoardSetting = BoardSetting.GetInstance();
            await vsmdController.MoveTo(VsmdAxis.Z, curBoardSetting.CurrentBoard.ZDispense);

            await pumpController.Drip();

            Thread.Sleep(GeneralSettings.GetInstance().DripInterval);

            await pumpController.Drip();

            await vsmdController.MoveTo(VsmdAxis.Z, curBoardSetting.CurrentBoard.ZTravel);

            MoveCallBack(blockNum, row, col);
        }
コード例 #2
0
 public static PumpController GetPumpController()
 {
     if (m_instance == null)
     {
         m_instance = new PumpController();
     }
     return(m_instance);
 }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        private async void DoPipetting()
        {
            //Logger.Instance.Write("DoPipetting");
            log.Info("Do Pipetting");
            VsmdController vsmdController  = VsmdController.GetVsmdController();
            PumpController pumpController  = PumpController.GetPumpController();
            BoardSetting   curBoardSetting = BoardSetting.GetInstance();

            await BeforeMove(m_selectedTubes.Count);

            int touchDelaySeconds = (int)(1000 * curBoardSetting.CurrentBoard.DelaySeconds);
            int delayMicroSecondsBetweenSamples = (int)(Preference.GetInstace().DelaySeconds * 1000);
            int blockNum, row, col = 1;

            //await vsmdController.SetS3Mode(VsmdAxis.Z, 1);
            for (int i = m_pipettingIndex + 1; i < m_sortedTubesArr.Length; i++)
            {
                if (m_dripStatus != PipettingStatus.Moving)
                {
                    break;
                }
                JObject obj = (JObject)m_sortedTubesArr[i];
                GetPositionInfo(obj, out blockNum, out row, out col);
                SetPipettingWell(blockNum, row, col);
                int xPos   = curBoardSetting.Convert2PhysicalPos(VsmdAxis.X, blockNum, col);
                int offset = curBoardSetting.CurrentBoard.TouchEdgeOffset;
                await vsmdController.MoveTo(VsmdAxis.X, xPos);

                await vsmdController.MoveTo(VsmdAxis.Y, curBoardSetting.Convert2PhysicalPos(VsmdAxis.Y, blockNum, row));

                // TODO
                await vsmdController.MoveTo(VsmdAxis.Z, curBoardSetting.CurrentBoard.ZDispense);

                // start pipetting
                await pumpController.SwitchOnOff(i);

                // wait several seconds, this time should be changed according to the volume dispensed
                Thread.Sleep(delayMicroSecondsBetweenSamples);
                await vsmdController.MoveTo(VsmdAxis.X, xPos + offset);

                Thread.Sleep(touchDelaySeconds);
                await vsmdController.MoveTo(VsmdAxis.Z, curBoardSetting.CurrentBoard.ZTravel);

                // change the UI to start
                Thread.Sleep(100);

                MoveCallBack(blockNum, row, col);
                m_pipettingIndex = i;
            }

            bool bok = await AfterMove();

            log.InfoFormat("finished pipetting, result is: {0}", bok);
            //Logger.Instance.Write("error happened in afterMove");
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        private async void DripThread()
        {
            VsmdController vsmdController  = VsmdController.GetVsmdController();
            PumpController pumpController  = PumpController.GetPumpController();
            BoardSetting   curBoardSetting = BoardSetting.GetInstance();
            JArray         jsArr           = m_selectedTubes;

            await BeforeMove();

            int dripInterval = GeneralSettings.GetInstance().DripInterval;
            int blockNum, row, col = 1;

            //await vsmdController.SetS3Mode(VsmdAxis.Z, 1);
            for (int i = m_dripIndex + 1; i < jsArr.Count; i++)
            {
                if (m_dripStatus != DripStatus.Moving)
                {
                    break;
                }
                JObject obj = (JObject)jsArr[i];
                GetPositionInfo(obj, out blockNum, out row, out col);
                SetDrippingTube(blockNum, row, col);
                //await vsmdController.MoveTo(VsmdAxis.X, curBoardSetting.Convert2PhysicalPos(VsmdAxis.X, blockNum, col));
                //await vsmdController.MoveTo(VsmdAxis.Y, curBoardSetting.Convert2PhysicalPos(VsmdAxis.Y, blockNum, row));

                var moveXTask = vsmdController.MoveTo(VsmdAxis.X, curBoardSetting.Convert2PhysicalPos(VsmdAxis.X, blockNum, col));
                var moveYTask = vsmdController.MoveTo(VsmdAxis.Y, curBoardSetting.Convert2PhysicalPos(VsmdAxis.Y, blockNum, row));
                await Task.WhenAll(moveXTask, moveYTask);

                // TODO
                await vsmdController.MoveTo(VsmdAxis.Z, curBoardSetting.CurrentBoard.ZDispense);

                // start drip
                //await vsmdController.ClickPump();
                await pumpController.Drip();

                // wait 5 seconds, this time should be changed according to the volume dripped
                Thread.Sleep(dripInterval);
                await vsmdController.MoveTo(VsmdAxis.Z, curBoardSetting.CurrentBoard.ZTravel);

                // change the screen to start
                await pumpController.Drip();

                //await Task.Delay(1000);

                MoveCallBack(blockNum, row, col);
                m_dripIndex = i;
            }

            AfterMove();
        }
コード例 #5
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();
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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();
            }
        }