Ejemplo n.º 1
0
 public AxesProfile()
 {
     InputEEZ      = new MoveProfileBase();
     PrecisorX     = new MoveProfileBase();
     PrecisorY     = new MoveProfileBase();
     PrecisorTheta = new MoveProfileBase();
     TestProbeZ    = new MoveProfileBase();
     OutputEEZ     = new MoveProfileBase();
 }
Ejemplo n.º 2
0
        private MoveProfileBase GetMoveProfile(MoveProfileBase mp)
        {
            MoveProfileBase newMp = new MoveProfileBase();

            {
                newMp.Acceleration = mp.Acceleration;
                newMp.Deceleration = mp.Deceleration;
                newMp.Velocity     = mp.Velocity;
            }
            return(newMp);
        }
Ejemplo n.º 3
0
        public static void SaveHelper(string section, SettingsXml xml, object obj)
        {
            xml.OpenSection(section);
            // Loop through all properties of this type and read from
            // config based on property's name.

            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                if (pi.PropertyType == typeof(String))
                {
                    xml.Write(pi.Name, (String)pi.GetValue(obj, null));
                }

                if (pi.PropertyType == typeof(Int32))
                {
                    xml.Write(pi.Name, (Int32)pi.GetValue(obj, null));
                }

                if (pi.PropertyType == typeof(Double))
                {
                    xml.Write(pi.Name, (Double)pi.GetValue(obj, null));
                }

                if (pi.PropertyType == typeof(Boolean))
                {
                    xml.Write(pi.Name, (Boolean)pi.GetValue(obj, null));
                }

                if (pi.PropertyType == typeof(MoveProfileBase) && pi.CanWrite)
                {
                    MoveProfileBase mp = (MoveProfileBase)pi.GetValue(obj, null);
                    xml.Write(pi.Name + "/" + "Acceleration", (Double)mp.Acceleration);
                    xml.Write(pi.Name + "/" + "Deceleration", (Double)mp.Deceleration);
                    xml.Write(pi.Name + "/" + "Velocity", (Double)mp.Velocity);
                }
            }
            xml.CloseSection();
        }
Ejemplo n.º 4
0
        public static void LoadHelper(string section, SettingsXml xml, object obj)
        {
            xml.OpenSection(section);
            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                // Loop through all properties and save them into config.
                if (pi.PropertyType == typeof(String))
                {
                    pi.SetValue(obj, xml.Read(pi.Name, (String)pi.GetValue(obj, null)), null);
                }

                if (pi.PropertyType == typeof(Int32))
                {
                    pi.SetValue(obj, xml.Read(pi.Name, (Int32)pi.GetValue(obj, null)), null);
                }

                if (pi.PropertyType == typeof(Double))
                {
                    pi.SetValue(obj, xml.Read(pi.Name, (Double)pi.GetValue(obj, null)), null);
                }

                if (pi.PropertyType == typeof(Boolean))
                {
                    pi.SetValue(obj, xml.Read(pi.Name, (Boolean)pi.GetValue(obj, null)), null);
                }

                if (pi.PropertyType == typeof(MoveProfileBase) && pi.CanWrite)
                {
                    MoveProfileBase mp = new MoveProfileBase();

                    mp.Acceleration = xml.Read(pi.Name + "/" + "Acceleration", 1000);
                    mp.Deceleration = xml.Read(pi.Name + "/" + "Deceleration", 1000);
                    mp.Velocity     = xml.Read(pi.Name + "/" + "Velocity", 50);
                    pi.SetValue(obj, mp, null);
                }
            }
            xml.CloseSection();
        }
Ejemplo n.º 5
0
        private void AxisJoggingHelper(object sender, MouseEventArgs e, bool isMOuseDown)
        {
            Control            con = (Control)sender;
            AxisAndMovePackage pkg = null;

            if (con.Tag != null)
            {
                pkg = (AxisAndMovePackage)con.Tag;
                IAxis axis = pkg.Axis;

                // Reduction of speed
                IMoveProfile mf = new MoveProfileBase();
                mf.Acceleration = pkg.MoveProfile.Acceleration;
                mf.Deceleration = pkg.MoveProfile.Deceleration;
                mf.Velocity     = pkg.MoveProfile.Velocity;

                double spdReduction = Convert.ToDouble(touchscreenNumBoxSpeedPercentage.Text);
                mf.Velocity     = pkg.MoveProfile.Velocity * spdReduction / 100.0;
                mf.Acceleration = pkg.MoveProfile.Acceleration * spdReduction / 100.0;
                mf.Deceleration = pkg.MoveProfile.Deceleration * spdReduction / 100.0;

                double sign = pkg.IsPositiveMove ? 1 : -1;
                if (e.Button == MouseButtons.Left)
                {
                    try
                    {
                        if (checkBoxIsRelativeMove.Checked)
                        {
                            if (isMOuseDown)
                            {
                                if (BeforeRelativeMove != null)
                                {
                                    CancelEventArgs ce = new CancelEventArgs();
                                    BeforeRelativeMove(axis, sign * Convert.ToDouble(touchscreenNumBoxRelativeMoveDistance.Text), ce);
                                    if (ce.Cancel == true)
                                    {
                                        return;
                                    }
                                }
                                if (axis.IsMoveDone)
                                {
                                    double relDist = Math.Round(Convert.ToDouble(touchscreenNumBoxRelativeMoveDistance.Text), 3);
                                    axis.MoveRelativeStart(mf, relDist * sign);
                                    if (_simulationX)
                                    {
                                        if (sign == 1)
                                        {
                                            _actualPositionX = _actualPositionX + relDist;
                                        }
                                        else
                                        {
                                            _actualPositionX = _actualPositionX - relDist;
                                        }
                                    }

                                    if (_simulationY)
                                    {
                                        if (sign == 1)
                                        {
                                            _actualPositionY = _actualPositionY + relDist;
                                        }
                                        else
                                        {
                                            _actualPositionY = _actualPositionY - relDist;
                                        }
                                    }

                                    if (_simulationTheta)
                                    {
                                        if (sign == 1)
                                        {
                                            _actualPositionTheta = _actualPositionTheta + relDist;
                                        }
                                        else
                                        {
                                            _actualPositionTheta = _actualPositionTheta - relDist;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (isMOuseDown) //
                            {
                                if (axis.IsMoveDone)
                                {
                                    axis.MoveRelativeStart(mf, 5000 * sign);
                                    labelStatus.Text = string.Format("{0} is moving...", axis.Name);
                                }
                            }
                            else
                            {
                                axis.Stop();
                                labelStatus.Text = string.Format("{0} is stopped.", axis.Name);
                                labelStatus.Refresh();
                                System.Threading.Thread.Sleep(100);
                                labelStatus.Text = "Status";
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        axis.Stop();
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }