Beispiel #1
0
        public IControlGroup GetFromValues(GroupTabPage tab)
        {
            var allControls = ((TableLayoutPanel)((Panel)tab.Controls[0]).Controls[0]).Controls;
            int state       = 0;

            foreach (Control c in allControls)
            {
                if (c is ComboBox)
                {
                    ComboBox combo = (ComboBox)c;
                    switch (state)
                    {
                    case 0:
                        //Forward limit switch
                        LimitSwitchForward = (eModeOfOperation)combo.SelectedItem;
                        state = 1;
                        break;

                    case 1:
                        LimitSwitchReverse = (eModeOfOperation)combo.SelectedItem;
                        break;
                    }
                }
            }
            return(this);
        }
Beispiel #2
0
        public IControlGroup GetFromValues(GroupTabPage tab)
        {
            var allControls = ((TableLayoutPanel)((Panel)tab.Controls[0]).Controls[0]).Controls;
            int state       = 0;

            foreach (Control c in allControls)
            {
                if (c is NumericUpDown)
                {
                    NumericUpDown numeric = (NumericUpDown)c;
                    switch (state)
                    {
                    case 0:
                        //Forward limit switch
                        SlotNumber = (int)numeric.Value;
                        state      = 1;
                        break;

                    case 1:
                        //Forward limit switch
                        pGain = (float)numeric.Value;
                        state = 2;
                        break;

                    case 2:
                        //Forward limit switch
                        iGain = (float)numeric.Value;
                        state = 3;
                        break;

                    case 3:
                        //Forward limit switch
                        dGain = (float)numeric.Value;
                        state = 4;
                        break;

                    case 4:
                        //Forward limit switch
                        fGain = (float)numeric.Value;
                        state = 5;
                        break;

                    case 5:
                        //Forward limit switch
                        iZone = (float)numeric.Value;
                        state = 6;
                        break;

                    case 6:
                        //Forward limit switch
                        clRampRate = (float)numeric.Value;
                        break;
                    }
                }
            }
            return(this);
        }
Beispiel #3
0
        public IControlGroup GetFromValues(GroupTabPage tab)
        {
            var allControls = ((TableLayoutPanel)((Panel)tab.Controls[0]).Controls[0]).Controls;

            foreach (Control c in allControls)
            {
                if (c is ComboBox)
                {
                    NeutralMode = (eNeutralMode)((ComboBox)c).SelectedItem;
                }
            }
            return(this);
        }
Beispiel #4
0
        public IControlGroup GetFromValues(GroupTabPage tab)
        {
            var allControls  = ((TableLayoutPanel)((Panel)tab.Controls[0]).Controls[0]).Controls;
            int checkState   = 0;
            int numericState = 0;

            foreach (Control c in allControls)
            {
                if (c is CheckBox)
                {
                    CheckBox check = (CheckBox)c;
                    switch (checkState)
                    {
                    case 0:
                        //Forward limit switch
                        ForwardSoftLimitEnable = check.Checked;
                        checkState             = 1;
                        break;

                    case 1:
                        ReverseSoftLimitEnable = check.Checked;
                        break;
                    }
                }
                if (c is NumericUpDown)
                {
                    NumericUpDown numeric = (NumericUpDown)c;
                    switch (numericState)
                    {
                    case 0:
                        //Forward limit switch
                        SoftLimitForwardValue = (float)numeric.Value;
                        numericState          = 1;
                        break;

                    case 1:
                        SoftLimitReverseValue = (float)numeric.Value;
                        break;
                    }
                }
            }
            return(this);
        }
        private void refreshConfigs()
        {
            groupedControls.TabPages.Clear();
            if (deviceView.SelectedItems.Count == 1)
            {
                var descriptor = _deviceStatus.DeviceArray[deviceView.SelectedIndices[0]];
                CTRProductStuff.Devices dev = CTRProductStuff.DeviceIDMap[descriptor.ID & 0xFFFFFFC0];
                uint id = (uint)descriptor.ID & 0x3F;

                //Populate Configs with TalonSRX.json
                FileStream configParams;
                switch (dev)
                {
                case CTRProductStuff.Devices.TalonSRX:
                    configParams = File.Open("TalonSRX.json", FileMode.Open);
                    break;

                case CTRProductStuff.Devices.VictorSPX:
                    configParams = File.Open("VictorSPX.json", FileMode.Open);
                    break;

                default:
                    configParams = File.Open("NotRecognized.json", FileMode.Open);
                    break;
                }
                string builtIP = WebServerScripts.buildIP(_connectedIp, dev, id, CTRProductStuff.Action.GetConfig);
                string txt     = WebServerScripts.HttpPost(builtIP, configParams);
                configParams.Close();

                if (txt == "Failed")
                {
                    updateReturnTextBox();
                    return;
                }

                GetConfigsReturn configs = JsonConvert.DeserializeObject <GetConfigsReturn>(txt);

                if (configs == null)//Should never happen
                {
                    updateReturnTextBox();
                    return;
                }
                //Update return text box before doing anything else
                updateReturnTextBox(configs.GeneralReturn.Error, configs.GeneralReturn.ErrorMessage);
                if (configs.Device == null || configs.Device.Configs == null)
                {
                    return;
                }

                foreach (ConfigGroup group in configs.Device.Configs)
                {
                    Type t = Type.GetType("DiagServerAccessor." + group.Type);

                    IControlGroup newGroup = (IControlGroup)Activator.CreateInstance(t);

                    GroupTabPage newTab = new GroupTabPage(newGroup);
                    newTab.Text = group.Name;

                    newGroup.SetFromValues(group.Values, group.Ordinal);

                    newTab.Controls.Add(newGroup.CreateLayout());

                    groupedControls.TabPages.Add(newTab);
                }
            }
        }