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); }
private void btnOK_Click(object sender, EventArgs e) { GeneralSettingMeta meta = GeneralSettings.GetInstance().GetSettingMeta(); //meta.DispenseInterval = (int)numDripInter.Value; meta.MoveSpeed = float.Parse(txtMoveSpd.Text.Trim()); meta.AutoConnect = ckbAutoConnect.Checked; meta.OutputCommandLog = ckbEnableCmdLog.Checked; meta.OutputStsCommandLog = ckbEnableStsCmdLog.Checked; meta.PipettingSpeed = int.Parse(txtPipettingSpeed.Text); bool retVal = GeneralSettings.GetInstance().Save(); if (retVal) { StatusBar.DisplayMessage(MessageType.Info, "设置成功!"); if (VsmdController.GetVsmdController().IsInitialized()) { VsmdController.GetVsmdController().SetOutputCommandLogFlag(meta.OutputCommandLog); } this.Close(); } else { StatusBar.DisplayMessage(MessageType.Error, "设置失败!"); } }
private async void SetTubePositionFrm_KeyDown(object sender, KeyEventArgs e) { if (m_inMoving) { return; } float moveSpd = GeneralSettings.GetInstance().MoveSpeed; if (m_axisType == VsmdAxis.X) { if (e.KeyCode == Keys.Right) { await MoveAxis(moveSpd); } else if (e.KeyCode == Keys.Left) { await MoveAxis(-moveSpd); } } else if (m_axisType == VsmdAxis.Y) { if (e.KeyCode == Keys.Up) { await MoveAxis(moveSpd); } else if (e.KeyCode == Keys.Down) { await MoveAxis(-moveSpd); } } }
private void MainFrm_Load(object sender, EventArgs e) { InitStatusBar(); Preference.GetInstace().Load(); GeneralSettings.GetInstance().LoadGeneralSettings(); BoardSetting.GetInstance().LoadBoardSettings(); InitVsmdConnection(); }
private void InitFormData() { GeneralSettingMeta meta = GeneralSettings.GetInstance().GetSettingMeta(); //numDripInter.Value = (decimal)meta.DispenseInterval; txtPipettingSpeed.Text = meta.PipettingSpeed.ToString(); txtMoveSpd.Text = meta.MoveSpeed.ToString(); ckbAutoConnect.Checked = meta.AutoConnect; ckbEnableCmdLog.Checked = meta.OutputCommandLog; ckbEnableStsCmdLog.Checked = meta.OutputStsCommandLog; }
/// <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(); }
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); } }
public async Task <InitResult> Init(string port, int baudrate) { if (m_initialized && port == m_port && baudrate == m_baudrate) { return(new InitResult() { Message = "设备连接成功!", IsSuccess = true }); } m_port = port; m_baudrate = baudrate; if (m_initialized) { m_vsmd.closeSerialPort(); } m_vsmd = new VsmdSync(); bool ret = m_vsmd.openSerialPort(port, baudrate); if (!ret) { return(new InitResult() { Message = "打开串口失败!", IsSuccess = false }); } m_vsmd.OutputCommandLog = GeneralSettings.GetInstance().OutputCommandLog; m_vsmd.OutputStsCommandLog = GeneralSettings.GetInstance().OutputStsCommandLog; List <string> errAxis = new List <string>(); m_axisX = m_vsmd.createVsmdInfo(1); await m_axisX.CheckAxisIsOnline(); if (m_axisX.isOnline) { await m_axisX.enable(); m_axisX.flgAutoUpdate = true; await m_axisX.cfg(); } else { errAxis.Add("X"); } m_axisY = m_vsmd.createVsmdInfo(2); await m_axisY.CheckAxisIsOnline(); if (m_axisY.isOnline) { await m_axisY.enable(); m_axisY.flgAutoUpdate = true; await m_axisY.cfg(); } else { errAxis.Add("Y"); } m_axisZ = m_vsmd.createVsmdInfo(3); await m_axisZ.CheckAxisIsOnline(); if (m_axisY.isOnline) { await m_axisZ.enable(); m_axisZ.flgAutoUpdate = true; m_axisZ.SetMaxWaitTimeForMove(3); await m_axisZ.cfg(); } else { errAxis.Add("Z"); } if (errAxis.Count <= 0) { m_initialized = true; } string errMsg = ""; if (errAxis.Count > 0) { errMsg = "设备 "; for (int i = 0; i < errAxis.Count; i++) { if (i > 0) { errMsg += ", "; } errMsg += errAxis[i]; } errMsg += "连接失败!"; } if (!m_initialized) { m_vsmd.closeSerialPort(); m_vsmd = null; } return(new InitResult() { IsSuccess = m_initialized, Message = errMsg }); }