public IAutomaton Next(int i) { var s1 = State1.Next(i); if (State1.Empty) { var s2 = State2.Next(i); return(OrState.Create(s2, SeqState.Create(s1, State2))); } else { return(SeqState.Create(s1, State2)); } }
// Evento que genera una cadena de estados anidados OR de las filas seleccionadas private void crearORToolStripMenuItem_Click(object sender, EventArgs e) { List <AbstractState> selectedStates = getSelectedStates(); if (selectedStates.Count > 1) { AbstractState aS = new OrState(selectedStates[0], selectedStates[1], "OR " + selectedStates.Count); for (int index = 2; index < selectedStates.Count - 1; index++) { aS = new OrState(selectedStates[index], aS, "OR " + selectedStates.Count); } myStates.Add(aS); this.dataGridView1.Rows.Add(aS.getStateName(), "---"); this.label1.Text = "Cantidad de estados: " + myStates.Count.ToString(); } else { MessageBox.Show("Deben seleccionar al menos 2 estados", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public AbstractState makeState(string stateName, string p1, string p2, string p3, float precision, float grados, string stateType, int posState1, int posState2) { AbstractState aS; AbstractState aS1 = getState(posState1); AbstractState aS2 = getState(posState2); switch (stateType) { case "AND": aS = new AndState(aS1, aS2, stateName); break; case "ANGLE": aS = new AngleState(p1, p3, p2, grados, precision, stateName); break; case "CENTER_X": aS = new CenterStateX(p1, p2, precision, stateName); break; case "CENTER_Y": aS = new CenterStateY(p1, p2, precision, stateName); break; case "CENTER_Z": aS = new CenterStateZ(p1, p2, precision, stateName); break; case "DISTANCE": aS = new DistanceState(p1, p2, precision, stateName); break; case "LEFT": aS = new LeftState(p1, p2, precision, stateName); break; case "OR": aS = new OrState(aS1, aS2, stateName); break; case "OVER": aS = new OverState(p1, p2, precision, stateName); break; case "POSITION": aS = new PositionState(p1, precision, stateName); break; case "RIGHT": aS = new RightState(p1, p2, precision, stateName); break; case "UNDER": aS = new UnderState(p1, p2, precision, stateName); break; default: aS = new InvalidState(stateName); break; } return(aS); }