Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private void Step(Double IntegrStep)
        {
            TimeInModeControl += IntegrStep;
            var lastForce   = ForceKGC;
            var lastCurrent = Ip;

            Current = ModeControl.GetCurrent(Velocity, this);
            if (Voltage > 750)
            {
                Current = Current * VoltageNominal / Voltage;
            }
            ForceKGC = ModeControl.GetForce(Velocity, this);
            if (Math.Abs(ForceKGC - lastForce) > IntegrStep * dF)
            {
                ForceKGC = lastForce + Math.Sign(ForceKGC - lastForce) * IntegrStep * dF;
            }
            if (Math.Abs(Math.Abs(Current) - Math.Abs(lastCurrent)) > (dIc * IntegrStep))
            {
                Current = lastCurrent + Math.Sign(Current - lastCurrent) * dIc * IntegrStep;
            }
            Ip = Current;

            var dA     = Voltage * Current;
            var dAeown = Converter.GetInKilo(OwnNeedsElectricPower) * IntegrStep;

            A       += dAeown;
            Current  = Current + dAeown / Voltage;
            Current *= NumberCars;
            Force    = Converter.GetForceInKNewton(ForceKGC) * motorCount / (UnladenWeight + Mass);

            ForceBaseResistance = ModeControl.GetBaseResistance(this);
            var acc = Force - ForceAdditionalResistance - ForceBaseResistance;
            var dV  = factor * IntegrStep * acc;

            if (ModeControl is IBreak)
            {
                Current *= -1 * 2.5 * kF;
                Force   *= -1;
                dV       = -BreakAverage * IntegrStep * 3.6;
            }
            if (ModeControl is IAverageBreak)
            {
                Acceleration = BreakAverage;
            }
            else
            {
                Acceleration = Converter.GetVelocityMeterPerSec(dV) / IntegrStep;
            }
            Velocity += dV;
            Space    += Converter.GetVelocityMeterPerSec(Velocity) * IntegrStep;
            Time     += IntegrStep;

            A += dA * IntegrStep;

            if (Velocity >= MaxVelocity && ModeControl is IInert && dV > 0)
            {
                ModeControl       = ModeControl.Low(ByMass);
                TimeInModeControl = 0;
            }
        }
Ejemplo n.º 2
0
        private void CreateDelayEditor(ModeControl modeControl)
        {
            VerticalParameterEditor durationEditor = new VerticalParameterEditor(modeControl.Delay);

            modesFlowPanel.Controls.Add(durationEditor);
            durationEditor.Name = "durationEditor " + modeControl.Mode.ModeName;
            durationEditor.Size = new Size(81, 49);
            durationEditor.UnitSelectorVisibility = true;
            durationEditor.setMinimumAllowableManualValue(0);
        }
Ejemplo n.º 3
0
    /*************************************/


    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 4
0
        private void replaceSelectedButton_Click(object sender, EventArgs e)
        {
            if (!updatingModes)
            {
                updatingModes = true;
                modeListEditor_Click(sender, e);
                //Create lists of the modes we need to add to the list, as well as all of the mode buttons currently in the list
                List <ModeControl> modeControlsToAdd = MainClientForm.instance.runModesLists.SelectedModeButtons;
                List <Button>      buttons           = OrderButtons(ModeButtons, ListModes.Modes);

                //For each selected button currently in the list, either replace it with one of the
                //modes we need to add to the list, or delete the button
                Button button;
                for (int ind = 0; ind < buttons.Count; ind++)
                {
                    button = buttons[ind];
                    if (ModeButtons[button].Selected)
                    {
                        //If there are more modes to add, replace the current button's mode
                        if (modeControlsToAdd.Count > 0)
                        {
                            ModeButtons[button] = new ModeControl(modeControlsToAdd[0]);
                            button.Text         = ModeButtons[button].Mode.ModeName;
                            ColorBox(button);
                            ModeButtons[button].ListPosition = ind;
                            ListModes.Modes[ind]             = ModeButtons[button];
                            modeControlsToAdd.RemoveAt(0);
                        }
                        else //Otherwise delete the button entirely
                        {
                            ListModes.Modes.Remove(ModeButtons[button]);
                            DeleteDelayEditor(button);
                            modesFlowPanel.Controls.Remove(button);
                            ModeButtons.Remove(button);
                            ListModes.UpdateListPositions();
                        }
                    }
                }

                //If there are still modes left to add, do so now by creating new buttons for them
                foreach (ModeControl newMode in modeControlsToAdd)
                {
                    ListModes.Modes.Add(new ModeControl(newMode));
                    ListModes.Modes.Last().ListPosition = ListModes.Modes.Count - 1;
                    button = CreateButton(ListModes.Modes.Last());
                    modesFlowPanel.Controls.Add(button);
                    CreateDelayEditor(newMode);
                }

                EnableAndDisableControls();
                updatingModes = false;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private void Step(Double IntegrStep)
        {
            var lastForce   = ForceKGC;
            var lastCurrent = Current;

            Current = ModeControl.GetCurrent(Converter.GetVelocityKmPerHour(Velocity), this) * NumberCars;
            if (Voltage > 750)
            {
                Current = Current * VoltageNominal / Voltage;
            }
            ForceKGC = ModeControl.GetForce(Converter.GetVelocityKmPerHour(Velocity), this);

            if (Math.Abs(ForceKGC - lastForce) > IntegrStep * dF)
            {
                ForceKGC = lastForce + Math.Sign(ForceKGC - lastForce) * IntegrStep * dF;
                var kpd = ModeControl.GetKPD(Velocity);
                if (kpd > 0)
                {
                    Current = Converter.GetVelocityMeterPerSec(Velocity) * Converter.GetForceInK(ForceKGC) / kpd / Voltage * motorCount;
                }
                else
                {
                    Current = 0.0;
                }
            }
            if (Math.Abs(Math.Abs(Current) - Math.Abs(lastCurrent)) > (dIc * IntegrStep))
            {
                Current = lastCurrent + Math.Sign(Current - lastCurrent) * dIc * IntegrStep;
            }
            Force = Converter.GetForceInKNewton(ForceKGC) * motorCount / (UnladenWeight + Mass);
            ForceBaseResistance = ModeControl.GetBaseResistance(this);
            var a  = Force - ForceAdditionalResistance - ForceBaseResistance;
            var dV = factor * a;

            if (ModeControl is IAverageBreak)
            {
                Acceleration = BreakAverage;
            }
            else
            {
                Acceleration = Converter.GetVelocityMeterPerSec(dV) / IntegrStep;
            }
            Velocity          += dV;
            Space             += Converter.GetVelocityMeterPerSec(Velocity) * IntegrStep;
            Time              += IntegrStep;
            TimeInModeControl += IntegrStep;
            if (Converter.GetVelocityKmPerHour(Velocity) >= MaxVelocity && ModeControl is IInert && dV > 0)
            {
                ModeControl       = ModeControl.Low(ByMass);
                TimeInModeControl = 0;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Changes whether the button has been selected or not, and colors it appropriately.
 /// </summary>
 private void modeButton_Click(object sender, EventArgs e)
 {
     if (!updatingModes)
     {
         updatingModes = true;
         Button      button      = sender as Button;
         ModeControl modeControl = ModeButtons[button];
         modeControl.Selected = !modeControl.Selected;
         ColorBox(button);
         modeListEditor_Click(sender, e);
         updatingModes = false;
     }
 }
Ejemplo n.º 7
0
        private void InsertModesIntoList(bool before)
        {
            int off = 1;

            if (before)
            {
                off = 0;
            }

            //Find the first selected mode in the list
            List <Button> buttons             = OrderButtons(ModeButtons, ListModes.Modes);
            Button        firstSelectedButton = buttons[0];

            int  ind      = 0;
            bool notFound = true;

            while (ind < buttons.Count && notFound)
            {
                if (ModeButtons[buttons[ind]].Selected)
                {
                    firstSelectedButton = buttons[ind];
                    notFound            = false;
                }
                ind++;
            }
            //Now insert all of the selected modes into the list in front of the first selected button
            List <ModeControl> modeControlsToAdd = MainClientForm.instance.runModesLists.SelectedModeButtons;

            ind = ListModes.Modes.IndexOf(ModeButtons[firstSelectedButton]);

            //Insert the new mode controls
            ModeControl newMode;

            for (int ind2 = 0; ind2 < modeControlsToAdd.Count; ind2++)
            {
                newMode = new ModeControl(modeControlsToAdd[ind2]);
                newMode.ListPosition = ind + ind2 + off;
                ListModes.Modes.Insert(ind + ind2 + off, newMode);
            }
            //Now re-do all the buttons in the editor
            modesFlowPanel.Controls.Clear();
            ModeButtons.Clear();
            for (int ind2 = 0; ind2 < ListModes.Modes.Count; ind2++)
            {
                Button button = CreateButton(ListModes.Modes[ind2]);
                modesFlowPanel.Controls.Add(button);
                CreateDelayEditor(ListModes.Modes[ind2]);
                ListModes.Modes[ind].ListPosition = ind2;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Copies the modes in copyMe over to the current mode list
        /// </summary>
        /// <param name="copyMe">The mode controls that should be copied over</param>
        private void CopyOverModesAndButtons(List <ModeControl> copyMe)
        {
            ModeControl newMode;   //We'll create a new mode control to add to the current list
            Button      newButton; //We'll also create a shiny new button for this mode

            foreach (ModeControl modeControl in copyMe)
            {
                //For each mode to add, create a new mode control and button for it, then add it to the list
                newMode = new ModeControl(modeControl);
                newMode.ListPosition = ListModes.Modes.Count;
                ListModes.Modes.Add(newMode);
                newButton = CreateButton(newMode);
                modesFlowPanel.Controls.Add(newButton);
                CreateDelayEditor(newMode);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new button for the input mode control (does not add the button to the mode list).
        /// </summary>
        /// <param name="modeControl">Mode control of the new button.</param>
        /// <returns>The newly created button.</returns>
        public Button CreateButton(ModeControl modeControl)
        {
            Button modeButton = new Button();

            if (modeControl.Mode != null)
            {
                modeButton.Text = modeControl.Mode.ModeName;
            }

            modeButton.Size = new Size(110, 25);
            modeButton.Font = DeepCopy(ModeFont);

            modeButton.Click += new EventHandler(this.modeButton_Click);
            ModeButtons.Add(modeButton, modeControl);
            ColorBox(modeButton);
            return(modeButton);
        }
Ejemplo n.º 10
0
 private void addModeButton_Click(object sender, EventArgs e)
 {
     if (!updatingModes)
     {
         updatingModes = true;
         SequenceMode mode    = modesComboBox.SelectedItem as SequenceMode;
         ModeControl  newMode = new ModeControl(mode.ID);
         newMode.Mode         = mode;
         newMode.ListPosition = ListModes.Modes.Count;
         ListModes.Modes.Add(newMode);
         Button button = CreateButton(newMode);
         modesFlowPanel.Controls.Add(button);
         CreateDelayEditor(newMode);
         EnableAndDisableControls();
         modeListEditor_Click(sender, e);
         updatingModes = false;
     }
 }
Ejemplo n.º 11
0
Archivo: afin.cs Proyecto: zi-su/afin
    // Use this for initialization
    void Start()
    {
        meshFilter = GetComponent<MeshFilter>();
        controlPoints = GameObject.FindGameObjectsWithTag("ControlPoint");
        start_controlPoints = GameObject.FindGameObjectsWithTag("ControlPoint");
        mode = GameObject.Find("ModeControl").GetComponent<ModeControl>();

        W = new float[meshFilter.mesh.vertexCount,controlPoints.Length];
        A = new float[meshFilter.mesh.vertexCount,controlPoints.Length];

        A00 = new float[meshFilter.mesh.vertexCount,controlPoints.Length];
        A01 = new float[meshFilter.mesh.vertexCount,controlPoints.Length];
        A10 = new float[meshFilter.mesh.vertexCount,controlPoints.Length];
        A11 = new float[meshFilter.mesh.vertexCount,controlPoints.Length];

        Vector3[] vertices = meshFilter.mesh.vertices;
        start_vertices = vertices;

        D = new Vector3[meshFilter.mesh.vertexCount];

        for(int i = 0 ; i < vertices.Length ; i++){
            vertices[i] = (Quaternion.AngleAxis(180.0f, Vector3.up) * Quaternion.AngleAxis(90.0f, Vector3.right)) * vertices[i];
        }
        meshFilter.mesh.vertices = vertices;
        meshFilter.mesh.RecalculateNormals();

        precompSimilarityMLS();
        precompAffinMLS();
    }