示例#1
0
        public JointSensorEditorForm(SkeletalJoint_Base passJoint, int sourceIndex = -1)
        {
            InitializeComponent();
            AnalyticsUtils.LogPage("Advanced Joint Editor / Sensor List", "Sensor Editor");
            this.sourceIndex = sourceIndex;
            joint            = passJoint;
            typeBox.Items.Clear();
            sensorTypeOptions = RobotSensor.GetAllowedSensors(joint);
            foreach (RobotSensorType sensorType in sensorTypeOptions)
            {
                typeBox.Items.Add(char.ToUpper(Enum.GetName(typeof(RobotSensorType), sensorType).Replace('_', ' ')[0])
                                  + Enum.GetName(typeof(RobotSensorType), sensorType).Replace('_', ' ').Substring(1).ToLower());
            }
            Console.WriteLine(sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count);
            base.Text = (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count) ? ("Editing Sensor # " + sourceIndex) : "New Sensor";
            if (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count)
            {
                RobotSensor sensor = joint.attachedSensors[sourceIndex];
                typeBox.SelectedIndex         = Array.IndexOf(sensorTypeOptions, sensor.type);
                PortANumericUpDown.Value      = (decimal)sensor.portA;
                PortBNumericUpDown.Value      = (decimal)sensor.portB;
                ConversionNumericUpDown.Value = (decimal)sensor.conversionFactor;
            }
            switch (joint.GetJointType())
            {
            case SkeletalJointType.ROTATIONAL:
                this.ConversionLbl.Text = "Counts Per Rev";
                break;

            case SkeletalJointType.LINEAR:
                this.ConversionLbl.Text = "Counts Per Inch";
                break;

            case SkeletalJointType.CYLINDRICAL:
                this.ConversionLbl.Text = "Counts Per Rev";
                break;
            }
            if (typeBox.SelectedIndex == 0)
            {
                this.PortALbl.Enabled                = true;
                this.PortANumericUpDown.Enabled      = true;
                this.PortBLbl.Visible                = true;
                this.PortBNumericUpDown.Visible      = true;
                this.ConversionLbl.Visible           = true;
                this.ConversionNumericUpDown.Visible = true;
            }
            else
            {
                this.PortALbl.Enabled                = false;
                this.PortANumericUpDown.Enabled      = false;
                this.PortBLbl.Visible                = false;
                this.PortBNumericUpDown.Visible      = false;
                this.ConversionLbl.Visible           = false;
                this.ConversionNumericUpDown.Visible = false;
            }
        }
示例#2
0
        public EditSensorForm(SkeletalJoint_Base passJoint, int sourceIndex = -1)
        {
            InitializeComponent();
            this.sourceIndex = sourceIndex;
            joint            = passJoint;
            typeBox.Items.Clear();
            sensorTypeOptions = RobotSensor.GetAllowedSensors(joint);
            foreach (RobotSensorType sensorType in sensorTypeOptions)
            {
                typeBox.Items.Add(Enum.GetName(typeof(RobotSensorType), sensorType).Replace('_', ' ').ToLowerInvariant());
            }
            Console.WriteLine(sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count);
            base.Text = (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count) ? ("Editing Sensor # " + sourceIndex) : "New Sensor";
            if (sourceIndex >= 0 && sourceIndex < joint.attachedSensors.Count)
            {
                RobotSensor sensor = joint.attachedSensors[sourceIndex];
                typeBox.SelectedIndex = Array.IndexOf(sensorTypeOptions, sensor.type);
                portTextBox.Text      = Convert.ToString(sensor.port);
                moduleTextBox.Text    = Convert.ToString(sensor.module);
                secondaryBox.Checked  = sensor.useSecondarySource;
                {
                    StringBuilder coeffTxt = new StringBuilder();
                    for (int i = sensor.equation.coeff.Length - 1; i >= 0; i--)
                    {
                        coeffTxt.Append(sensor.equation.coeff[i]);
                        if (i > 0)
                        {
                            coeffTxt.Append(",");
                        }
                    }
                    coefficentTextBox.Text = coeffTxt.ToString();
                    coefficentTextBox_TextChanged(null, null);
                }
            }

            ///Only applies to cylindrical joints.  True use secondary means to use the linear component rather than rotation.
            if (joint.GetJointType() == SkeletalJointType.CYLINDRICAL)
            {
                secondaryBox.Visible = true;
            }

            FormClosing += delegate(object sender, FormClosingEventArgs e) { LegacyInterchange.LegacyEvents.OnRobotModified(); };
        }