예제 #1
0
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
        {
            IOInput io = new IOInput();

            io.CardNo  = (CardNo)propertyValues["CardNo"];
            io.AxisNo  = (int)propertyValues["AxisNo"];
            io.InputNo = (InputNo)propertyValues["InputNo"];
            return(io);
        }
예제 #2
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            //将对象转换为字符串
            if ((destinationType == typeof(string)) && value != null && value != null)
            {
                return(((IOInput)value).ToString());
            }

            //生成设计时的构造器代码
            if (destinationType == typeof(InstanceDescriptor) && value != null)
            {
                IOInput         p    = (IOInput)value;
                ConstructorInfo ctor = typeof(IOInput).GetConstructor(new Type[] { typeof(CardNo), typeof(int), typeof(InputNo) });
                return(new InstanceDescriptor(ctor, new object[] { p.CardNo, p.AxisNo, p.InputNo }));
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
예제 #3
0
 public short GoHome(int timeout, HostarSpeed goLimit, HostarSpeed goHome, IOInput limit, bool Wait = true)
 {
     return(this.GoHomeWithInput(timeout, this.HomeMode, this.HomeDirection, goLimit, goHome, limit));
 }
예제 #4
0
        private short GoHomeWithInput(int timeout, HomeMode homeMode, bool direction, HostarSpeed goLimit, HostarSpeed goHome, IOInput limit)
        {
            short     rtn       = 0;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            this.StopAxis();
            this.GetAxisSts();

            #region 到轴的极限位置
            if (!limit.GetIO())
            {
                rtn = this.Jog(goLimit, !direction); // 到极限
                while (!limit.GetIO())
                {
                    Thread.Sleep(1);
                    this.GetAxisSts();
                    if (stopwatch.ElapsedMilliseconds > timeout || MotionHelper.Instance.Emg)
                    {
                        stopwatch.Stop();
                        this.StopAxis();
                        this.ClearAxisSts();
                        return(-1);
                    }
                }
            }

            this.StopAxis();
            #endregion
            Thread.Sleep(200);

            #region 开始回原点
            stopwatch.Reset();
            stopwatch.Start();
            var homeSpeed = goHome.GetActSpeed(this.AxisRatio);
            rtn += this.AxisGoHome(homeMode, direction, homeSpeed.StartSpeed, homeSpeed.MaxSpeed, homeSpeed.AccTime, homeSpeed.DecTime);
            Thread.Sleep(200);
            this.GetAxisSts();

            while (this.bAxisIsHoming || this.bAxisIsRunning)
            {
                Thread.Sleep(1);
                this.GetAxisSts();
                if (stopwatch.ElapsedMilliseconds > timeout || MotionHelper.Instance.Emg)
                {
                    stopwatch.Stop();
                    this.StopAxis();
                    this.ClearAxisSts();
                    return(-1);
                }
            }

            this.StopAxis();
            this.ClearAxisSts();
            this.ZeroAxis();
            stopwatch.Stop();
            return(rtn);

            #endregion
        }