Пример #1
0
        /// <summary>
        /// 检查通道信息是否有效
        /// 建议在打开设备成功后调用
        /// </summary>
        public bool CheckAvalid(out string invalidInfo)
        {
            IJFDevice     dev = null;
            JFDevCellInfo ci  = null;

            return(CheckChannel(CellType, Name, out dev, out ci, out invalidInfo));
        }
Пример #2
0
        public int CaputreOneImage(string cmrName, string imageType, out HObject hObject, out string errMsg, int timeoutMilSwconds = -1)
        {
            IJFInitializable dev   = null;
            JFDevCellInfo    ci    = null;
            IJFImage         image = null;

            hObject = null;
            errMsg  = "";

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.Cmr, cmrName, out dev, out ci, out errMsg))
            {
                return((int)ErrorDef.InvokeFailed);
            }

            IJFDevice_Camera cmr = (dev as IJFDevice_Camera);

            cmr.ClearBuff();
            int errCode = cmr.GrabOne(out image, timeoutMilSwconds);

            if (errCode != (int)ErrorDef.Success)
            {
                errMsg = cmr.GetErrorInfo(errCode);
                return(errCode);
            }

            if (GenImgObject(imageType, image, out hObject, out errMsg) != 0)
            {
                return((int)ErrorDef.InvokeFailed);
            }
            return((int)ErrorDef.Success);
        }
Пример #3
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            string doName  = GetMethodInputValue("DO通道名称") as string;
            bool   enabled = (bool)GetMethodInputValue("DO状态");

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainDoName(doName))
            {
                errorInfo = "参数项:\"DO通道名称\"的值:\"" + doName + "\"在设备名称表中不存在";
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            IJFInitializable dev = null;
            JFDevCellInfo    ci  = null;

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.DO, doName, out dev, out ci, out errorInfo))
            {
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            int errCode = (dev as IJFDevice_MotionDaq).GetDio(ci.ModuleIndex).SetDO(ci.ChannelIndex, enabled);

            if (errCode != 0)
            {
                errorInfo = (enabled ? "打开" : "关闭") + "DO = " + doName + " 失败," + (dev as IJFDevice_MotionDaq).GetDio(ci.ModuleIndex).GetErrorInfo(errCode);
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }
            errorInfo = "Success";
            SetOutputParamValue("执行结果", JFWorkCmdResult.Success);
            return(true);
        }
Пример #4
0
        private void btNR_Click(object sender, EventArgs e)
        {
            if (cbMoveMode.SelectedIndex != 0) //未选中寸动模式
            {
                return;
            }
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(_axisNames[3], out errInfo);

            if (null == ci)
            {
                MessageBox.Show("R轴负向寸动失败!配置中没有通道信息,Name = \"" + _axisNames[3] + "\" ErrorInfo:" + errInfo);
                return;
            }

            IJFModule_Motion md = (JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
            int errCode         = md.RelMove(ci.ChannelIndex, -_dStepParam);

            if (errCode != 0)
            {
                MessageBox.Show("R轴负向寸动失败!,AxisName = \"" + _axisNames[3] + "\" ErrorInfo:" + md.GetErrorInfo(errCode));
                return;
            }
            ShowTips("R轴负向寸动OK");
        }
Пример #5
0
        /// <summary>
        /// 停止XYZR轴的移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btStop_Click(object sender, EventArgs e)
        {
            bool isOK = true;

            foreach (string axisName in _axisNames)
            {
                string        errInfo;
                JFDevCellInfo ci = CheckAxisDevInfo(axisName, out errInfo);
                if (null != ci)
                {
                    IJFModule_Motion md = (JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
                    int errCode         = md.StopAxis(ci.ChannelIndex);
                    if (errCode != 0)
                    {
                        isOK = false;
                        ShowTips("停止轴:\"" + axisName + "\" 失败,Errornfo: " + md.GetErrorInfo(errCode));
                    }
                }
                else
                {
                    isOK = false;
                    ShowTips("停止轴:\"" + axisName + "\" 失败,未找到通道信息 ");
                }
                if (isOK)
                {
                    ShowTips("所有轴已停止");
                }
            }
        }
Пример #6
0
        /// <summary>
        /// 软触发
        /// </summary>
        /// <param name="TrigChnName"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public int SWPosTrig(string[] TrigChnName, out string errMsg)
        {
            IJFInitializable dev = null;
            JFDevCellInfo    ci  = null;

            errMsg = "";

            if (TrigChnName.Length == 0)
            {
                errMsg = "触发通道名称为空";
                return((int)ErrorDef.InvokeFailed);
            }

            int[] trigChns = new int[TrigChnName.Length];
            for (int i = 0; i < TrigChnName.Length; i++)
            {
                if (!JFCMFunction.CheckDevCellName(JFCMFunction.CmpTrig, TrigChnName[i], out dev, out ci, out errMsg))
                {
                    return((int)ErrorDef.InvokeFailed);
                }
                trigChns[i] = ci.ChannelIndex;
            }

            IJFModule_CmprTrigger md = (dev as IJFDevice_MotionDaq).GetCompareTrigger(ci.ModuleIndex);
            int errCode = md.SoftTrigge(trigChns);

            if (errCode != (int)ErrorDef.Success)
            {
                errMsg = md.GetErrorInfo(errCode);
                return(errCode);
            }
            return((int)ErrorDef.Success);
        }
Пример #7
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            IJFInitializable dev    = null;
            JFDevCellInfo    ci     = null;
            string           axisID = GetInitParamValue("轴ID") as string;

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainAxisName(axisID))
            {
                errorInfo = "参数项:\"轴ID\" = " + axisID + " 在设备名称表中不存在";
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.Axis, axisID, out dev, out ci, out errorInfo))
            {
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            bool             isPositive = (bool)GetInitParamValue("正向移动");
            IJFModule_Motion md         = (dev as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
            int errCode = md.Jog(ci.ChannelIndex, isPositive);

            if (errCode < 0)
            {
                errorInfo = "SDK调用出错:" + md.GetErrorInfo(errCode);
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }
            errorInfo = "Success";
            SetOutputParamValue("执行结果", JFWorkCmdResult.Success);
            return(true);
        }
Пример #8
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            string diName = GetInitParamValue("DI通道名称") as string;

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainDiName(diName))
            {
                errorInfo = "DI通道名称:" + diName + " 在设备命名表中不存在";
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            IJFInitializable dev = null;
            JFDevCellInfo    ci  = null;

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.DI, diName, out dev, out ci, out errorInfo))
            {
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            bool isTurnOn = false;
            int  errCode  = (dev as IJFDevice_MotionDaq).GetDio(ci.ModuleIndex).GetDI(ci.ChannelIndex, out isTurnOn);

            if (errCode != 0)
            {
                errorInfo = (dev as IJFDevice_MotionDaq).GetDio(ci.ModuleIndex).GetErrorInfo(errCode);
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            errorInfo = "Success";
            SetOutputParamValue("执行结果", JFWorkCmdResult.Success);
            SetOutputParamValue("DI状态", isTurnOn);
            return(true);
        }
Пример #9
0
        public void SetAxisName(string axisName)
        {
            _axisName       = axisName;
            gbAxisName.Text = axisName;
            JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetAxisCellInfo(axisName);

            if (null == ci)
            {
                gbAxisName.Text += " 无通道信息";
                ucAxisTest.SetAxis(null, 0);
                cbMode.Enabled = false;
                btCfg.Enabled  = false;
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;

            if (null == dev)
            {
                gbAxisName.Text += " 无设备:" + ci.DeviceID;
                ucAxisTest.SetAxis(null, 0);
                cbMode.Enabled = false;
                btCfg.Enabled  = false;
                return;
            }
            if (!dev.IsDeviceOpen)
            {
                gbAxisName.Text += " 设备未打开";
                ucAxisTest.SetAxis(null, 0);
                cbMode.Enabled = false;
                btCfg.Enabled  = false;
                return;
            }

            if (dev.McCount <= ci.ModuleIndex)
            {
                gbAxisName.Text += " 模块Idx = :" + ci.ModuleIndex + " 超限";
                ucAxisTest.SetAxis(null, 0);
                cbMode.Enabled = false;
                btCfg.Enabled  = false;
                return;
            }
            IJFModule_Motion md = dev.GetMc(ci.ModuleIndex);

            if (ci.ChannelIndex >= md.AxisCount)
            {
                gbAxisName.Text += " 轴Idx = :" + ci.ChannelIndex + " 超限";
                ucAxisTest.SetAxis(null, 0);
                cbMode.Enabled = false;
                btCfg.Enabled  = false;
                return;
            }
            ucAxisTest.SetAxis(md, ci.ChannelIndex);
            cbMode.Enabled = true;
            btCfg.Enabled  = true;
            return;
        }
Пример #10
0
        void _UpdateTrig()
        {
            string[] allTrigDevs = JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_TrigController));
            if (null == allTrigDevs || 0 == allTrigDevs.Length) //系统中不存在已命名的AI通道
            {
                ShowTips("设备列表中不存在触发设备!");
                btAdd.Enabled = false;
            }
            else
            {
                btAdd.Enabled = true;
            }

            string[] chnNames = _station.TrigChannelNames;
            if (null == chnNames || 0 == chnNames.Length)
            {
                btDel.Enabled = false;
                return;
            }
            else//if(null != chnNames)
            {
                btDel.Enabled = true;
                foreach (string chnName in chnNames)
                {
                    DataGridViewRow         row      = new DataGridViewRow();
                    DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                    cellName.Value = chnName;
                    DataGridViewTextBoxCell cellInfo    = new DataGridViewTextBoxCell();
                    JFDevCellInfo           chnCellInfo = JFHubCenter.Instance.MDCellNameMgr.GetTrigCtrlChannelInfo(chnName);
                    if (null == chnCellInfo)
                    {
                        cellName.Style.ForeColor = Color.Red;
                        cellInfo.Value           = "无效的通道名称,在名称配置表中不存在!";
                        cellInfo.Style.ForeColor = Color.Red;
                    }
                    else
                    {
                        IJFDevice_TrigController trigDev = JFHubCenter.Instance.InitorManager.GetInitor(chnCellInfo.DeviceID) as IJFDevice_TrigController;
                        if (null == trigDev)
                        {
                            cellName.Style.ForeColor = Color.Red;
                            cellInfo.Value           = "控制器在设备列表中不存在!";
                            cellInfo.Style.ForeColor = Color.Red;
                        }
                        else
                        {
                            cellInfo.Value = string.Format("控制器:{0} - 通道:{1}", chnCellInfo.DeviceID, chnCellInfo.ChannelIndex);
                        }
                        //cellInfo.Value = string.Format("控制器:{0} - 模块:{1} - 通道:{2}", devInfo.DeviceID, devInfo.ModuleIndex, devInfo.ChannelIndex);
                    }
                    row.Cells.Add(cellName);
                    row.Cells.Add(cellInfo);
                    dgvNameInfos.Rows.Add(row);
                }
            }
        }
        /// <summary>
        /// 更新界面
        /// </summary>
        void AdjustView()
        {
            Controls.Clear();
            _lstCmpTrigInfos.Clear();
            _lstCmpTrigUcs.Clear();
            if (null == _trigNames || 0 == _trigNames.Length)
            {
                return;
            }
            Point loc = new Point(5, 5);

            for (int i = 0; i < _trigNames.Length; i++)
            {
                Label lbInfo = new Label();
                lbInfo.AutoSize = true;
                lbInfo.Text     = _trigNames[i];
                string        errInfo;
                JFDevCellInfo ci = CheckTrigDevInfo(_trigNames[i], out errInfo);
                if (null == ci)
                {
                    lbInfo.Text += " ,ErrorInfo:" + errInfo;
                }
                lbInfo.Location = loc;           //lbInfo.Top = bottom;
                loc.Y           = lbInfo.Bottom; //bottom = lbInfo.Bottom +5;
                Controls.Add(lbInfo);
                _lstCmpTrigInfos.Add(lbInfo);

                UcCmprTrgChn ucTrig = new UcCmprTrgChn();
                if (null == ci)
                {
                    ci = JFHubCenter.Instance.MDCellNameMgr.GetCmpTrigCellInfo(_trigNames[i]); //尝试使用命名表中的名称
                    if (ci == null)
                    {
                        ucTrig.SetModuleChn(null, 0, _trigNames[i] + ":无效通道名", null);
                    }
                    else
                    {
                        ucTrig.SetModuleChn(null, ci.ChannelIndex, _trigNames[i], null);
                    }
                }
                else
                {
                    IJFModule_CmprTrigger md = (JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq).GetCompareTrigger(ci.ModuleIndex);
                    ucTrig.SetModuleChn(md, ci.ChannelIndex, _trigNames[i], null);
                }
                ucTrig.Location  = loc;
                ucTrig.BackColor = SystemColors.ActiveBorder;
                Controls.Add(ucTrig);
                _lstCmpTrigUcs.Add(ucTrig);
                loc.Y = ucTrig.Bottom + 20;//bottom = ucTrig.Bottom + 10;
            }
        }
Пример #12
0
        /// <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;
            }
        }
        void DOButtonClicked(object sender, EventArgs eventArgs)
        {
            LampButton doBt   = sender as LampButton;
            string     doName = doBt.Text;

            JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetDoCellInfo(doName);

            if (ci == null) //名称在配置中不存在
            {
                ShowTips("DO操作失败:名称 \"" + doName + "\" 不存在");
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;

            if (null == dev)
            {
                ShowTips(string.Format("DO: \"{0}\" 操作失败:所属设备 \"{1}\" 在系统中不存在", doName, ci.DeviceID));
                return;
            }
            if (!dev.IsDeviceOpen)
            {
                ShowTips(string.Format("DO \"{0}\" 操作失败:所属设备 \"{1}\" 未打开(关闭状态)", doName, ci.DeviceID));
                return;
            }
            if (dev.DioCount <= ci.ModuleIndex)
            {
                ShowTips(string.Format("DO \"{0}\" 操作失败:所属设备 \"{1}\" 所属模块Index = {2} 超出范围0~{3}", doName, ci.DeviceID, ci.ModuleIndex, dev.DioCount == 0 ? 0 : dev.DioCount - 1));
                return;
            }
            IJFModule_DIO md = dev.GetDio(ci.ModuleIndex);

            if (md.DOCount <= ci.ChannelIndex)
            {
                ShowTips(string.Format("DO \"{0}\" 操作失败:通道序号:{1} 超出范围0~{2}", doName, ci.ChannelIndex, md.DOCount == 0 ? 0 : md.DOCount - 1));
                return;
            }
            bool isON    = false;
            int  errCode = md.GetDO(ci.ChannelIndex, out isON);

            if (0 != errCode)
            {
                ShowTips(string.Format("DO \"{0}\" 操作失败:未能获取当前状态,信息:{1}", doName, md.GetErrorInfo(errCode)));
                return;
            }

            errCode = md.SetDO(ci.ChannelIndex, !isON);
            if (0 != errCode)
            {
                ShowTips(string.Format("DO \"{0}\" {1}操作失败:未能,信息:{2}", doName, isON?"关闭":"打开", md.GetErrorInfo(errCode)));
                return;
            }
        }
Пример #14
0
        void _UpdateCmpTrig()
        {
            JFDevCellNameManeger nameMgr = JFHubCenter.Instance.MDCellNameMgr;

            if (null == nameMgr.AllCmpTrigNames() || 0 == nameMgr.AllCmpTrigNames().Length) //系统中不存在已命名的AI通道
            {
                ShowTips("系统配置中不存在已命名的CmpTrig通道!");
                btAdd.Enabled = false;
            }
            else
            {
                btAdd.Enabled = true;
            }

            string[] cmpTrigNames = _station.CmpTrigNames;
            if (null == cmpTrigNames || 0 == cmpTrigNames.Length)
            {
                btDel.Enabled = false;
                return;
            }
            else//if(null != chnNames)
            {
                btDel.Enabled = true;
                foreach (string cmpTrigName in cmpTrigNames)
                {
                    DataGridViewRow         row      = new DataGridViewRow();
                    DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                    cellName.Value = cmpTrigName;
                    DataGridViewTextBoxCell cellInfo = new DataGridViewTextBoxCell();
                    JFDevCellInfo           devInfo  = nameMgr.GetCmpTrigCellInfo(cmpTrigName);
                    if (null == devInfo)
                    {
                        cellName.Style.ForeColor = Color.Red;
                        cellInfo.Value           = "无效的通道名称,在配置中不存在!";
                        cellInfo.Style.ForeColor = Color.Red;
                    }
                    else
                    {
                        cellInfo.Value = string.Format("控制器:{0} - 模块:{1} - 通道:{2}", devInfo.DeviceID, devInfo.ModuleIndex, devInfo.ChannelIndex);
                    }


                    row.Cells.Add(cellName);
                    row.Cells.Add(cellInfo);
                    dgvNameInfos.Rows.Add(row);
                }
            }
        }
        /// <summary>
        /// 打开所有轴设备
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btOpenAllDev_Click(object sender, EventArgs e)
        {
            if (null == _station)
            {
                return;
            }
            string[] axisNames = _station.AxisNames;
            if (null == axisNames || 0 == axisNames.Length)
            {
                ShowTips("工站 未提供轴/电机!");
                return;
            }
            bool isOK = true;

            foreach (string axisName in axisNames)
            {
                JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetAxisCellInfo(axisName);
                if (null == ci)
                {
                    isOK = false;
                    ShowTips("未发现轴 = \"" + axisName + "\"所属 通道信息!");
                    continue;
                }
                IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;
                if (null == dev)
                {
                    isOK = false;
                    ShowTips("未发现轴 = \"" + axisName + "\"所属 设备ID = \"" + ci.DeviceID + "\"!");
                    continue;
                }
                if (!dev.IsDeviceOpen)
                {
                    int errCode = dev.OpenDevice();
                    if (0 != errCode)
                    {
                        isOK = false;
                        ShowTips(string.Format("打开轴 = \"{0}\"所属设备=\"{1}\"失败,错误信息:{2}", axisName, ci.DeviceID, dev.GetErrorInfo(errCode)));
                        continue;
                    }
                    ShowTips(string.Format("轴 = \"{0}\"所属设备=\"{1}\"已打开 ", axisName, ci.DeviceID));
                }
            }
            if (isOK)
            {
                ShowTips("所有轴设备已打开");
            }
            LayoutStation();
        }
Пример #16
0
        /// <summary>
        /// 向UI更新工站的AI命名通道
        /// </summary>
        void _UpdateAI()
        {
            JFDevCellNameManeger nameMgr = JFHubCenter.Instance.MDCellNameMgr;

            string[] allAIs  = nameMgr.AllAiNames(); //系统中所有可用的AI命名通道
            string[] aiNames = _station.AINames;     //工站中已配置的AI通道
            if (null == allAIs || 0 == allAIs.Length)
            {
                ShowTips("系统配置中不存在已命名的AI通道!");
                btAdd.Enabled = false;
            }
            else
            {
                btAdd.Enabled = true;
            }

            if (null == aiNames || 0 == aiNames.Length)
            {
                btDel.Enabled = false;
                return;
            }
            else//if(null != chnNames)
            {
                btDel.Enabled = true;
                foreach (string aiName in aiNames)
                {
                    DataGridViewRow         row      = new DataGridViewRow();
                    DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                    cellName.Value = aiName;
                    DataGridViewTextBoxCell cellInfo = new DataGridViewTextBoxCell();
                    JFDevCellInfo           devInfo  = nameMgr.GetAiCellInfo(aiName);
                    if (null == devInfo)
                    {
                        cellName.Style.ForeColor = Color.Red;
                        cellInfo.Value           = "无效的通道名称,在配置中不存在!";
                        cellInfo.Style.ForeColor = Color.Red;
                    }
                    else
                    {
                        cellInfo.Value = string.Format("控制器:{0} - 模块:{1} - 通道:{2}", devInfo.DeviceID, devInfo.ModuleIndex, devInfo.ChannelIndex);
                    }
                    row.Cells.Add(cellName);
                    row.Cells.Add(cellInfo);
                    dgvNameInfos.Rows.Add(row);
                }
            }
        }
Пример #17
0
        public void SetAxisName(string axisName)
        {
            //_isAxisEnabled = false;
            _axisName       = axisName;
            gbAxisName.Text = _axisName;
            JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetAxisCellInfo(_axisName);

            if (ci == null)
            {
                gbAxisName.Text      += "  轴名无效";
                ucAxisStatus1.Enabled = false;
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;

            if (null == dev)
            {
                gbAxisName.Text      += "  设备无效";
                ucAxisStatus1.Enabled = false;
                return;
            }
            if (!dev.IsDeviceOpen)
            {
                gbAxisName.Text      += "  设备未打开";
                ucAxisStatus1.Enabled = false;
                return;
            }
            if (ci.ModuleIndex >= dev.McCount)
            {
                gbAxisName.Text      += "  模块号无效";
                ucAxisStatus1.Enabled = false;
                return;
            }

            IJFModule_Motion mm = dev.GetMc(ci.ModuleIndex);

            if (ci.ChannelIndex >= mm.AxisCount)
            {
                gbAxisName.Text      += "  轴序号无效";
                ucAxisStatus1.Enabled = false;
                return;
            }
            ucAxisStatus1.Enabled = true;
            ucAxisStatus1.SetAxis(mm, ci.ChannelIndex);
            //_isAxisEnabled = true;
        }
Пример #18
0
        private void btCfgR_Click(object sender, EventArgs e)
        {
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(_axisNames[3], out errInfo);

            if (null == ci)
            {
                MessageBox.Show("R轴:\"" + _axisNames[3] + "\" 未能显示参数配置窗口,ErrorInfo:" + errInfo);
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;
            IJFModule_Motion    md  = dev.GetMc(ci.ModuleIndex);
            FormAxisTest        fm  = new FormAxisTest();

            fm.SetAxisInfo(md, ci.ChannelIndex, _axisNames[3]);
            fm.ShowDialog();
        }
Пример #19
0
        void CheckAxis(int index)
        {
            if (string.IsNullOrEmpty(_axisNames[index]))
            {
                ShowTips(_AxisAlias[index] + " 未设置/已禁用");
                AxisEnabled(index, false);
                return;
            }
            JFDevCellInfo dcInfo = JFHubCenter.Instance.MDCellNameMgr.GetAxisCellInfo(_axisNames[index]);

            if (null == dcInfo)
            {
                ShowTips(_AxisAlias[index] + "对应轴名称:\"" + _axisNames[index] + "\"在设备命名表中不存在!");
                AxisEnabled(index, false);
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(dcInfo.DeviceID) as IJFDevice_MotionDaq;

            if (null == dev)
            {
                ShowTips(string.Format("{0}对应轴:\"{1}\"所属设备\"{2}\"不存在!", _AxisAlias[index], _axisNames[index], dcInfo.DeviceID));
                AxisEnabled(index, false);
                return;
            }
            if (!dev.IsDeviceOpen)
            {
                ShowTips(string.Format("{0}对应轴:\"{1}\"所属设备\"{2}\"未打开!", _AxisAlias[index], _axisNames[index], dcInfo.DeviceID));
                AxisEnabled(index, false);
                return;
            }
            if (dcInfo.ModuleIndex >= dev.McCount)
            {
                ShowTips(string.Format("{0} 对应轴名称:\"{1}\"所属模块序号{2}超限 (0~{3}) !", _AxisAlias[index], _axisNames[index], dcInfo.ModuleIndex, dev.McCount - 1));
                AxisEnabled(index, false);
                return;
            }
            IJFModule_Motion md = dev.GetMc(dcInfo.ModuleIndex);

            if (dcInfo.ChannelIndex >= md.AxisCount)
            {
                ShowTips(string.Format("{0} 对应轴名称:\"{1}\"所属轴序号{2}超限 (0~{3}) !", _AxisAlias[index], _axisNames[index], dcInfo.ChannelIndex, md.AxisCount - 1));
                AxisEnabled(index, false);
                return;
            }
            AxisEnabled(index, true);
        }
Пример #20
0
        /// <summary>
        /// 显示轴配置/调试窗口
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btCfg_Click(object sender, EventArgs e)
        {
            FormAxisTest  fm = new FormAxisTest();
            JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetAxisCellInfo(_axisName);

            if (null == ci)
            {
                gbAxisName.Text += " 无通道信息";
                ucAxisTest.SetAxis(null, 0);
                cbMode.Enabled = false;
                btCfg.Enabled  = false;
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;
            //if(null == dev)
            //{
            //    gbAxisName.Text += " 无设备:" + ci.DeviceID;
            //    ucAxisTest.SetAxis(null, 0);
            //    cbMode.Enabled = false;
            //    btCfg.Enabled = false;
            //    return;
            //}
            //if(!dev.IsDeviceOpen)
            //{
            //    gbAxisName.Text += " 设备未打开" ;
            //    ucAxisTest.SetAxis(null, 0);
            //    cbMode.Enabled = false;
            //    btCfg.Enabled = false;
            //    return;
            //}

            //if(dev.McCount <= ci.ModuleIndex)
            //{
            //    gbAxisName.Text += " 模块Idx = :" + ci.ModuleIndex + " 超限";
            //    ucAxisTest.SetAxis(null, 0);
            //    cbMode.Enabled = false;
            //    btCfg.Enabled = false;
            //    return;
            //}
            IJFModule_Motion md = dev.GetMc(ci.ModuleIndex);

            fm.SetAxisInfo(md, ci.ChannelIndex, _axisName);
            fm.ShowDialog();
        }
Пример #21
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            IJFInitializable dev    = null;
            JFDevCellInfo    ci     = null;
            string           axisID = GetInitParamValue("轴ID") as string;

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainAxisName(axisID))
            {
                errorInfo = "参数:\"轴ID\" = " + axisID + " 在设备名称表中不存在";
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.Axis, axisID, out dev, out ci, out errorInfo))
            {
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            IJFModule_Motion md = (dev as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
            int  err            = 0;
            bool IsServoOn      = (bool)GetInitParamValue("轴是否励磁");

            if (IsServoOn)
            {
                err = md.ServoOn(ci.ChannelIndex);
            }
            else
            {
                err = md.ServoOff(ci.ChannelIndex);
            }
            if (err != 0)
            {
                errorInfo = (IsServoOn ? "励磁使能ON" : "励磁使能OFF") + "失败:" + md.GetErrorInfo(err);
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            errorInfo = "Success";
            SetOutputParamValue("执行结果", JFWorkCmdResult.Success);
            return(true);
        }
Пример #22
0
        /// <summary>
        /// 只是获取通道对应的设备,不做安全性检查(如通道序号是否合法/设备是否已经打开...)
        /// </summary>
        /// <returns></returns>
        public IJFDevice Device()
        {
            JFDevCellInfo ci = CellInfo();

            if (null == ci)
            {
                return(null);
            }
            IJFInitializable initor = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID);

            switch (CellType)
            {
            case JFDevCellType.DI:
                return(initor as IJFDevice_MotionDaq);

            case JFDevCellType.DO:
                return(initor as IJFDevice_MotionDaq);

            case JFDevCellType.Axis:
                return(initor as IJFDevice_MotionDaq);

            case JFDevCellType.AI:
                return(initor as IJFDevice_MotionDaq);

            case JFDevCellType.AO:
                return(initor as IJFDevice_MotionDaq);

            case JFDevCellType.CmpTrig:
                return(initor as IJFDevice_MotionDaq);

            case JFDevCellType.Light:
                return(initor as IJFDevice_LightController);

            case JFDevCellType.Trig:
                return(initor as IJFDevice_TrigController);

            default:
                break;
            }
            return(null);
        }
Пример #23
0
        private void btHomeR_Click(object sender, EventArgs e)
        {
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(_axisNames[3], out errInfo);

            if (null == ci)
            {
                MessageBox.Show("R轴:\"" + _axisNames[3] + "\" Home操作失败,ErrorInfo:" + errInfo);
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;
            IJFModule_Motion    md  = dev.GetMc(ci.ModuleIndex);
            int errCode             = md.Home(ci.ChannelIndex);

            if (0 != errCode)
            {
                MessageBox.Show("R轴:\"" + _axisNames[3] + "\" Home操作失败,ErrorInfo:" + md.GetErrorInfo(errCode));
                return;
            }
            ShowTips("R轴:\"" + _axisNames[3] + "\" Home运动开始");
        }
Пример #24
0
        void OnServonButtonClicked(object sender, EventArgs e)
        {
            int i = 0;

            for (i = 0; i < btServons.Length; i++)
            {
                if (sender == btServons[i])
                {
                    break;
                }
            }
            string        axisName = _axisNames[i];
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(axisName, out errInfo);

            if (null == ci)
            {
                MessageBox.Show("轴" + _axisNames[i] + "伺服操作失败,ErrorInfo:" + errInfo);
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;
            IJFModule_Motion    md  = dev.GetMc(ci.ModuleIndex);
            bool isCurrSerOn        = md.IsSVO(ci.ChannelIndex);
            int  errCode            = 0;

            if (isCurrSerOn)
            {
                errCode = md.ServoOff(ci.ChannelIndex);
            }
            else
            {
                errCode = md.ServoOn(ci.ChannelIndex);
            }
            if (errCode != 0)
            {
                MessageBox.Show("轴" + _axisNames[i] + "伺服操作失败,ErrorInfo:" + md.GetErrorInfo(errCode));
                return;
            }
            ShowTips("轴" + _axisNames[i] + "伺服" + (isCurrSerOn?"去使能":"使能") + "成功");
        }
Пример #25
0
        public int ClearImageQueue(string cmrName, out string errMsg)
        {
            IJFInitializable dev = null;
            JFDevCellInfo    ci  = null;

            errMsg = "";

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.Cmr, cmrName, out dev, out ci, out errMsg))
            {
                return((int)ErrorDef.InvokeFailed);
            }

            IJFDevice_Camera cmr = (dev as IJFDevice_Camera);
            int errCode          = cmr.ClearBuff();

            if (errCode != (int)ErrorDef.Success)
            {
                errMsg = cmr.GetErrorInfo(errCode);
                return(errCode);
            }
            return((int)ErrorDef.Success);
        }
Пример #26
0
        private void btAbsMoveR_Click(object sender, EventArgs e)
        {
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(_axisNames[3], out errInfo);

            if (null == ci)
            {
                MessageBox.Show("R轴:\"" + _axisNames[3] + "\" 定位操作失败,ErrorInfo:" + errInfo);
                return;
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;
            IJFModule_Motion    md  = dev.GetMc(ci.ModuleIndex);
            double tgtPos           = Convert.ToDouble(numAbsCmdR.Value);
            int    errCode          = md.AbsMove(ci.ChannelIndex, tgtPos);

            if (errCode != 0)
            {
                MessageBox.Show("R轴:\"" + _axisNames[3] + "\" 定位操作失败,ErrorInfo:" + md.GetErrorInfo(errCode));
                return;
            }
            ShowTips("R轴:\"" + _axisNames[3] + "\" 开始移动到 :" + tgtPos);
        }
Пример #27
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            string axisID = GetInitParamValue("轴ID") as string;

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainAxisName(axisID))
            {
                errorInfo = "参数项:\"轴ID\" = " + axisID + " 在设备名称表中不存在";
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            IJFInitializable dev = null;
            JFDevCellInfo    ci  = null;

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.Axis, axisID, out dev, out ci, out errorInfo))
            {
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }
            IJFModule_Motion md = (dev as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
            //if(!md.IsSVO(ci.ChannelIndex)) //HTM控制卡在未上电时,调用Stop会异常退出
            //{
            //    errorInfo = "\"轴ID\" = " + axisID + " 未励磁";
            //    SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
            //    return true;
            //}
            int errCode = md.StopAxis(ci.ChannelIndex);

            if (errCode != 0)
            {
                errorInfo = md.GetErrorInfo(errCode);
                SetOutputParamValue("执行结果", JFWorkCmdResult.ActionError);
                return(false);
            }

            errorInfo = "Success";
            SetOutputParamValue("执行结果", JFWorkCmdResult.Success);
            return(true);
        }
Пример #28
0
        /// <summary>
        /// 停止连续运动X
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btPX_MouseUp(object sender, MouseEventArgs e)
        {
            if (cbMoveMode.SelectedIndex != 1) //未选中连续模式
            {
                return;
            }
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(_axisNames[0], out errInfo);

            if (null == ci)
            {
                return;
            }
            IJFModule_Motion md = (JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
            int errCode         = md.StopAxis(ci.ChannelIndex);

            if (errCode != 0)
            {
                ShowTips("X轴停止运动失败!Name = \"" + _axisNames[0] + "\" ErrorInfo:" + errInfo);
                return;
            }
            ShowTips("X轴已停止");
        }
Пример #29
0
        private void btPY_MouseDown(object sender, MouseEventArgs e)
        {
            if (cbMoveMode.SelectedIndex != 1) //未选中连续模式
            {
                return;
            }
            string        errInfo;
            JFDevCellInfo ci = CheckAxisDevInfo(_axisNames[1], out errInfo);

            if (null == ci)
            {
                MessageBox.Show("Y轴正向连续运动失败!配置中没有通道信息,Name = \"" + _axisNames[1] + "\" ErrorInfo:" + errInfo);
                return;
            }
            IJFModule_Motion md = (JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq).GetMc(ci.ModuleIndex);
            int errCode         = md.VelMove(ci.ChannelIndex, _dVelParam, true);

            if (errCode != 0)
            {
                MessageBox.Show("Y轴正向连续运动失败!Name = \"" + _axisNames[1] + "\" ErrorInfo:" + errInfo);
                return;
            }
        }
        JFDevCellInfo CheckTrigDevInfo(string trigName, out string errorInfo)
        {
            JFDevCellInfo ci = JFHubCenter.Instance.MDCellNameMgr.GetCmpTrigCellInfo(trigName); //在命名表中的通道信息

            if (null == ci)
            {
                errorInfo = "未找到设备信息";
                return(null);
            }
            IJFDevice_MotionDaq dev = JFHubCenter.Instance.InitorManager.GetInitor(ci.DeviceID) as IJFDevice_MotionDaq;

            if (null == dev)
            {
                errorInfo = "未找到所属设备:\"" + ci.DeviceID + "\"";
                return(null);
            }
            if (!dev.IsDeviceOpen)
            {
                errorInfo = "所属设备:\"" + ci.DeviceID + "\"未打开";
                return(null);
            }
            if (ci.ModuleIndex >= dev.McCount)
            {
                errorInfo = "模块序号:\"" + ci.ModuleIndex + "\"超出限制!";
                return(null);
            }
            IJFModule_CmprTrigger md = dev.GetCompareTrigger(ci.ModuleIndex);

            if (ci.ChannelIndex >= md.EncoderChannels)
            {
                errorInfo = "通道序号:\"" + ci.ChannelIndex + "\"超出限制!";
                return(null);
            }

            errorInfo = "";
            return(ci);
        }