Beispiel #1
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);
        }
        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?"去使能":"使能") + "成功");
        }