/// <summary> /// 将轴状态更新到界面 /// </summary> public void UpdateStationUI() { int i = 0; if (null != _axisNames) { for (i = 0; i < _axisNames.Length; i++) { JFDevCellInfo dcInfo = JFHubCenter.Instance.MDCellNameMgr.GetAxisCellInfo(_axisNames[i]); if (dcInfo == null) { tbCurrPoses[i].Text = "无效值"; continue; } IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(dcInfo.DeviceID) as IJFDevice_MotionDaq; if (null == dev) { tbCurrPoses[i].Text = "无效值"; continue; } if (dcInfo.ModuleIndex >= dev.McCount) { tbCurrPoses[i].Text = "无效值"; continue; } IJFModule_Motion md = dev.GetMc(dcInfo.ModuleIndex); if (dcInfo.ChannelIndex >= md.AxisCount) { tbCurrPoses[i].Text = "无效值"; continue; } double pos = 0; int errCode = md.GetFbkPos(dcInfo.ChannelIndex, out pos); if (0 != errCode) { tbCurrPoses[i].Text = "获取错误!代码:" + errCode; } else { tbCurrPoses[i].Text = pos.ToString(); } bool isServon = md.IsSVO(i); btServons[i].LampColor = isServon ? LampButton.LColor.Green : LampButton.LColor.Gray; } } for (; i < 4; i++) { tbCurrPoses[i].Text = "无效值"; btServons[i].LampColor = LampButton.LColor.Gray; } }
/// <summary> /// 获取轴反馈坐标 /// </summary> /// <param name="AxisName"></param> /// <param name="pos"></param> /// <param name="errMsg"></param> /// <returns></returns> public int GetAxisFbkPos(string AxisName, out double pos, out string errMsg) { pos = 0; errMsg = ""; IJFInitializable dev; JFDevCellInfo ci; double UV2xy = 0; if (!JFCMFunction.CheckDevCellName(JFCMFunction.Axis, AxisName, out dev, out ci, out errMsg)) { return((int)ErrorDef.InvokeFailed); } IJFModule_Motion md = (dev as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex); int errCode = md.GetFbkPos(ci.ChannelIndex, out UV2xy); if (errCode != (int)ErrorDef.Success) { errMsg = md.GetErrorInfo(errCode); return(errCode); } pos = UV2xy; return((int)ErrorDef.Success); }
void UpdateModuleStatus() { if (InvokeRequired) { Invoke(new Action(UpdateModuleStatus)); return; } if (null == _module) { return; } if (tabCtrl.SelectedIndex == 0) //更新单轴控制界面 { for (int i = 0; i < _module.AxisCount; i++) { _lstStatus[i].UpdateAxisStatus(); _lstTest[i].UpdateAxisUI(); } } else //更新插补测试界面 { if (dgvLinePos.Rows.Count > 0) //更新直线查补控件 { for (int i = 0; i < dgvLinePos.Rows.Count; i++) { DataGridViewRow row = dgvLinePos.Rows[i]; string axisIDTxt = row.Cells[0].Value as string; if (!string.IsNullOrEmpty(axisIDTxt)) { int axisID = Convert.ToInt32(axisIDTxt); if (axisID <= _module.AxisCount) { double currPos = 0; int err = _module.GetFbkPos(axisID, out currPos); if (err != 0) { row.Cells[2].Value = "获取失败"; } else { row.Cells[2].Value = currPos.ToString("F3"); } if (_module.IsMDN(axisID)) { lampLineDone.LampColor = LampButton.LColor.Green; } else { lampLineDone.LampColor = LampButton.LColor.Gray; } } else { row.Cells[2].Value = "轴序号错误"; } } else { row.Cells[2].Value = ""; } } } } }