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);
        }
Example #2
0
 private void IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e)
 {
     if (e.IsBrowserInitialized && m_delayToBuildGrid)
     {
         m_externalObj.BuildGrid(BoardSetting.GetInstance().CurrentBoard);
     }
 }
Example #3
0
 private void OnGridPageDomLoaded()
 {
     if (BoardSetting.GetInstance().CurrentBoard != null)
     {
         m_externalObj.BuildGrid(BoardSetting.GetInstance().CurrentBoard);
     }
 }
Example #4
0
        private void InitBoardSettings()
        {
            cmbBoards.Items.Clear();
            BoardSetting.GetInstance().GetAllBoardMetaes().ForEach((meta) =>
            {
                cmbBoards.Items.Add(meta);
            }
                                                                   );
            Preference perfInst = Preference.GetInstace();

            if (cmbBoards.Items.Count > 0)
            {
                if (perfInst.HasPreference)
                {
                    BoardMeta findBoardMeta = BoardSetting.GetInstance().GetAllBoardMetaes().Find((meta) =>
                    {
                        return(meta.ID == perfInst.BoardID);
                    });
                    if (findBoardMeta != null)
                    {
                        cmbBoards.SelectedItem = findBoardMeta;
                    }
                }
                else
                {
                    cmbBoards.SelectedIndex = 0;
                }
            }
        }
        private void btnAdjustOrder_Click(object sender, EventArgs e)
        {
            var         boardMetas  = BoardSetting.GetInstance().GetAllBoardMetaes();
            var         names       = boardMetas.Select(x => x.Name).ToList();
            AdjustOrder adjustOrder = new AdjustOrder(names);

            adjustOrder.ShowDialog();
        }
Example #6
0
 public static BoardSetting GetInstance()
 {
     if (m_curBoardSetting == null)
     {
         m_curBoardSetting = new BoardSetting();
     }
     return(m_curBoardSetting);
 }
 private void tsmNew_Click(object sender, EventArgs e)
 {
     m_curMeta      = new BoardMeta();
     m_curMeta.ID   = BoardSetting.GetInstance().GetNextBoardNo();
     m_curMeta.Type = (int)BoardType.Site;
     FillData();
     m_mode = FORM_MODE.Add;
 }
Example #8
0
 private void MainFrm_Load(object sender, EventArgs e)
 {
     InitStatusBar();
     Preference.GetInstace().Load();
     GeneralSettings.GetInstance().LoadGeneralSettings();
     BoardSetting.GetInstance().LoadBoardSettings();
     InitVsmdConnection();
 }
        /// <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");
        }
Example #10
0
 private void cmbBoards_SelectedIndexChanged(object sender, EventArgs e)
 {
     BoardSetting.GetInstance().CurrentBoard = (BoardMeta)cmbBoards.Items[cmbBoards.SelectedIndex];
     if (m_browser.IsBrowserInitialized)
     {
         m_externalObj.BuildGrid(BoardSetting.GetInstance().CurrentBoard);
     }
     else
     {
         m_delayToBuildGrid = true;
     }
 }
        /// <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();
        }
Example #12
0
        private async void btnMoveToBack_Click(object sender, EventArgs e)
        {
            BoardSetting curBoardSetting = BoardSetting.GetInstance();
            bool         bok             = await VsmdController.GetVsmdController().MoveTo(VsmdAxis.Y, 30500);

            if (bok)
            {
                StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Info, "移动到后端!");
            }
            else
            {
                StatusBar.DisplayMessage(VsmdWorkstation.Controls.MessageType.Error, "未能移动到后端!");
            }
        }
Example #13
0
        private void InitBoardSettings()
        {
            cmbBoards.Items.Clear();
            txtDelaySeconds.Text = Preference.GetInstace().DelaySeconds.ToString();
            var allMetas = BoardSetting.GetInstance().GetAllBoardMetaes();
            List <BoardMeta> sortedMetas = new List <BoardMeta>();

            if (BoardSetting.GetInstance().NamesOrder.Count > 0)
            {
                foreach (var boardName in BoardSetting.GetInstance().NamesOrder)
                {
                    var validNameMetas = allMetas.Where(x => x.Name == boardName);
                    if (validNameMetas.Count() > 0)
                    {
                        sortedMetas.Add(validNameMetas.First());
                        //allMetas.Remove(validNameMetas.First());
                    }
                }
            }

            foreach (var meta in allMetas) //add remaining
            {
                if (!sortedMetas.Contains(meta))
                {
                    sortedMetas.Add(meta);
                }
            }
            sortedMetas.ForEach(x => cmbBoards.Items.Add(x));

            Preference perfInst = Preference.GetInstace();

            if (cmbBoards.Items.Count > 0)
            {
                if (perfInst.HasPreference)
                {
                    BoardMeta findBoardMeta = BoardSetting.GetInstance().GetAllBoardMetaes().Find((meta) =>
                    {
                        return(meta.ID == perfInst.BoardID);
                    });
                    if (findBoardMeta != null)
                    {
                        cmbBoards.SelectedItem = findBoardMeta;
                    }
                }
                else
                {
                    cmbBoards.SelectedIndex = 0;
                }
            }
        }
Example #14
0
        private void InitListView()
        {
            List <BoardMeta> list = BoardSetting.GetInstance().GetAllBoardMetaes();
            int no = 1;

            list.ForEach((meta) =>
            {
                ListViewItem lvm = new ListViewItem(no.ToString());
                lvm.SubItems.Add(meta.Name);
                lvm.Tag = meta;
                listView.Items.Add(lvm);
                no++;
            });
        }
        private void tsmiDelete_Click(object sender, EventArgs e)
        {
            bool ret = BoardSetting.GetInstance().DeleteBoard(m_curMeta);

            if (ret)
            {
                ShowMessage(MessageType.Info, "删除成功!");
                ResetData();
            }
            else
            {
                ShowMessage(MessageType.Error, "删除失败!");
            }
        }
        public async void MoveToHere(string args)
        {
            JObject targetTube = (JObject)JsonConvert.DeserializeObject(args);
            int     blockNum, row, col;

            GetPositionInfo(targetTube, out blockNum, out row, out col);
            VsmdController vsmdController  = VsmdController.GetVsmdController();
            BoardSetting   curBoardSetting = BoardSetting.GetInstance();
            //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);
        }
        private void FormDatToMetaImpl(BoardMeta meta)
        {
            if (m_mode == FORM_MODE.Add)
            {
                meta.ID = BoardSetting.GetInstance().GetNextBoardNum();
            }
            meta.Name             = txtName.Text.Trim();
            meta.WashTimes        = int.Parse(txtWashTimes.Text);
            meta.WashDelaySeconds = int.Parse(txtWashDelaySeconds.Text);
            meta.WashX            = int.Parse(txtWashX.Text);
            meta.WashY            = int.Parse(txtWashY.Text);
            meta.WashZ            = int.Parse(txtWashZ.Text);
            meta.Type             = rbtSite.Checked ? 1 : 2;
            if (rbtSite.Checked)
            {
                meta.SiteCount   = int.Parse(txtSiteCnt.Text);
                meta.RowCount    = int.Parse(txtSiteRowCnt.Text);
                meta.ColumnCount = int.Parse(txtSiteColCnt.Text);

                meta.Site1FirstTubeX = int.Parse(txtSite1FTX.Text);
                meta.Site1FirstTubeY = int.Parse(txtSite1FTY.Text);
                meta.Site1LastTubeX  = int.Parse(txtSite1LTX.Text);
                meta.Site1LastTubeY  = int.Parse(txtSite1LTY.Text);
                meta.Site2FirstTubeX = int.Parse(txtSite2FTX.Text);
                meta.Site2FirstTubeY = int.Parse(txtSite2FTY.Text);

                meta.TouchEdgeOffset = int.Parse(txtTouchPosition.Text) - meta.Site1FirstTubeX;
            }
            else
            {
                meta.GridCount = int.Parse(txtGridCnt.Text);
                meta.RowCount  = int.Parse(txtGridRowCnt.Text);

                meta.GridFirstTubeX = int.Parse(txtGridFTX.Text);
                meta.GridFirstTubeY = int.Parse(txtGridFTY.Text);
                meta.GridLastTubeX  = int.Parse(txtGridLTX.Text);
                meta.GridLastTubeY  = int.Parse(txtGridLTY.Text);

                meta.TouchEdgeOffset = int.Parse(txtTouchPosition.Text) - meta.GridFirstTubeX;
            }

            meta.ZTravel      = int.Parse(txtZTravel.Text);
            meta.ZDispense    = int.Parse(txtZDispense.Text);
            meta.DelaySeconds = float.Parse(txtTouchDelaySeconds.Text);
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!ValidFormData())
            {
                return;
            }
            //BoardMeta meta = GetTempBoardSetting();
            FormDatToMeta();
            bool ret = true;

            if (m_mode == FORM_MODE.Add)
            {
                ret = BoardSetting.GetInstance().AddNewBoard(m_curMeta);
                if (ret)
                {
                    ShowMessage(MessageType.Info, "添加成功!");
                    ResetData();
                }
                else
                {
                    ShowMessage(MessageType.Error, "添加失败!");
                }
            }
            else if (m_mode == FORM_MODE.Update)
            {
                //BoardSetting.GetInstance().AddNewBoard(m_curMeta);
                ret = BoardSetting.GetInstance().Save();
                if (ret)
                {
                    ShowMessage(MessageType.Info, "更新成功!");
                    ResetData();
                }
                else
                {
                    ShowMessage(MessageType.Error, "更新失败!");
                }
            }
        }
        private void FormDatToMetaImpl(BoardMeta meta)
        {
            if (m_mode == FORM_MODE.Add)
            {
                meta.ID = BoardSetting.GetInstance().GetNextBoardNum();
            }
            meta.Name = txtName.Text.Trim();
            meta.Type = rbtSite.Checked ? 1 : 2;
            if (rbtSite.Checked)
            {
                meta.SiteCount   = int.Parse(txtSiteCnt.Text);
                meta.RowCount    = int.Parse(txtSiteRowCnt.Text);
                meta.ColumnCount = int.Parse(txtSiteColCnt.Text);

                meta.Site1FirstTubeX = int.Parse(txtSite1FTX.Text);
                meta.Site1FirstTubeY = int.Parse(txtSite1FTY.Text);
                meta.Site1LastTubeX  = int.Parse(txtSite1LTX.Text);
                meta.Site1LastTubeY  = int.Parse(txtSite1LTY.Text);
                meta.Site2FirstTubeX = int.Parse(txtSite2FTX.Text);
                meta.Site2FirstTubeY = int.Parse(txtSite2FTY.Text);
                meta.ZTravel         = int.Parse(txtSiteZTravel.Text);
                meta.ZDispense       = int.Parse(txtSiteZDispense.Text);
            }
            else
            {
                meta.GridCount = int.Parse(txtGridCnt.Text);
                meta.RowCount  = int.Parse(txtGridRowCnt.Text);

                meta.GridFirstTubeX = int.Parse(txtGridFTX.Text);
                meta.GridFirstTubeY = int.Parse(txtGridFTY.Text);
                meta.GridLastTubeX  = int.Parse(txtGridLTX.Text);
                meta.GridLastTubeY  = int.Parse(txtGridLTY.Text);
                meta.ZTravel        = int.Parse(txtGridZTravel.Text);
                meta.ZDispense      = int.Parse(txtGridZDispense.Text);
            }
        }
Example #20
0
 /// <summary>
 /// called from JS
 /// </summary>
 /// <param name="args"></param>
 public void StartDrip(string args)
 {
     m_selectedTubes  = (JArray)JsonConvert.DeserializeObject(args.ToString());
     m_sortedTubesArr = new JToken[m_selectedTubes.Count];
     m_selectedTubes.CopyTo(m_sortedTubesArr, 0);
     Array.Sort(m_sortedTubesArr, (token1, token2) =>
     {
         int ret      = 1;
         JObject obj1 = (JObject)token1;
         JObject obj2 = (JObject)token2;
         int type     = int.Parse(obj1["type"].ToString());
         if (type == (int)BoardType.Site)
         {
             int site1, site2, row1, row2, col1, col2;
             site1 = int.Parse(obj1["site"].ToString());
             site2 = int.Parse(obj2["site"].ToString());
             row1  = int.Parse(obj1["row"].ToString());
             row2  = int.Parse(obj2["row"].ToString());
             col1  = int.Parse(obj1["col"].ToString());
             col2  = int.Parse(obj2["col"].ToString());
             if (col1 < col2)
             {
                 ret = -1;
             }
             else if (col1 == col2)
             {
                 ret = ((site1 - 1) * BoardSetting.GetInstance().CurrentBoard.RowCount + row1) < ((site2 - 1) * BoardSetting.GetInstance().CurrentBoard.RowCount + row2) ? -1 : 1;
             }
             else
             {
                 ret = 1;
             }
         }
         else
         {
             int grid1, grid2, row1, row2;
             grid1 = int.Parse(obj1["grid"].ToString());
             grid2 = int.Parse(obj2["grid"].ToString());
             row1  = int.Parse(obj1["row"].ToString());
             row2  = int.Parse(obj2["row"].ToString());
             if (grid1 < grid2)
             {
                 ret = -1;
             }
             else if (grid1 == grid2)
             {
                 ret = row1 < row2 ? -1 : 1;
             }
             else
             {
                 ret = 1;
             }
         }
         return(ret);
     });
     m_pipettingIndex = -1;
     DoPipetting();
     m_selectedTubes.Clear();
     //m_moveThread = new Thread(new ThreadStart(PipettingThread));
     //m_moveThread.Start();
 }
Example #21
0
 public static void SetCurrentBoardSetting(BoardSetting setting)
 {
     m_curBoardSetting = setting;
 }