static void ctcOfficeGui_ShowTrain(object sender, ShowTrainEventArgs e) { var formTrainController = new Form(); UserControl controlTrainController = null; var tc = (TrainController.TrainController)e.TrainModel.TrainController; controlTrainController = new TrainControllerUI(tc, env); formTrainController.Text = "Terminal Velocity - Train Controller (ID:" + e.TrainModel.TrainID + ")"; formTrainController.Controls.Add(controlTrainController); formTrainController.AutoSize = true; formTrainController.ShowDialog(); }
private void controlCTC_ShowTrain(object sender, ShowTrainEventArgs e) { var formTrainController = new Form(); UserControl controlTrainController = null; var tc = (TrainController.TrainController)e.TrainModel.TrainController; controlTrainController = new TrainControllerUI(tc, _env); formTrainController.Text = "Train Controller"; formTrainController.Controls.Add(controlTrainController); formTrainController.AutoSize = true; formTrainController.ShowDialog(); }
private static Form GuiTestFramework(int test) { //////////////////////////////////////////////////////////////////////////////////////// // Initializations // //////////////////////////////////////////////////////////////////////////////////////// // Environment object var environment = new SimulationEnvironment.SimulationEnvironment(); IBlock b0 = new TrackModel.Block(1, StateEnum.Healthy, 0, 0, 0, new[] { 0, 0 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70); IBlock b1 = new TrackModel.Block(2, StateEnum.Healthy, 1, 0, 0, new[] { 1, 1 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70); IBlock b2 = new TrackModel.Block(3, StateEnum.Healthy, 2, 0, 0, new[] { 2, 2 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70); IBlock b3 = new TrackModel.Block(4, StateEnum.BrokenTrackFailure, 3, 0, 0, new[] { 3, 3 }, 10, DirEnum.East, new[] { "" }, 0, 0, 0, "Red", 70); var sectionA = new List <IBlock> { b0 }; var sectionB = new List <IBlock> { b1, b2 }; var sectionC = new List <IBlock> { b3 }; // Previous track controller's circuit var prevCircuit = new TrackCircuit(environment, sectionA); // Our track circuit var currCircuit = new TrackCircuit(environment, sectionB); // Next track controller's circuit var nextCircuit = new TrackCircuit(environment, sectionC); var prev = new TrackController.TrackController(environment, prevCircuit); var curr = new TrackController.TrackController(environment, currCircuit); var next = new TrackController.TrackController(environment, nextCircuit); //Create TrackModel var trackMod = new TrackModel.TrackModel(environment); //Let TrackModel read in the lines before you proceed..shouldnt be done this way, but needed to stop CTC Office from faulting bool res = trackMod.provideInputFile("red.csv"); //Console.WriteLine("Res was "+res); res = trackMod.provideInputFile("green.csv"); //Console.WriteLine("Res was " + res); environment.TrackModel = trackMod; prev.Previous = null; prev.Next = curr; curr.Previous = prev; curr.Next = next; next.Previous = curr; next.Next = null; // Assign the same track controller to both lines var office = new CTCOffice.CTCOffice(environment, prev, prev); environment.CTCOffice = office; environment.PrimaryTrackControllerGreen = prev; environment.PrimaryTrackControllerRed = prev; //////////////////////////////////////////////////////////////////////////////////////// // End Initializations // //////////////////////////////////////////////////////////////////////////////////////// var form = new Form(); var control = new UserControl(); switch (test) { case 0: // SystemScheduler var testSystemScheduler = new SystemScheduler.SystemScheduler(environment, office); control = new SystemSchedulerGUI(environment, testSystemScheduler, office); environment.StartTick(); break; case 1: // CTCOffice environment = null; b0 = null; b1 = null; b2 = null; b3 = null; sectionA = null; sectionB = null; sectionC = null; prevCircuit = null; currCircuit = null; nextCircuit = null; prev = null; curr = null; next = null; trackMod = null; office = null; new CTCGUITest(); break; case 2: // TrackModel control = new TrackModelGUI(environment, trackMod); break; case 3: // TrackController ITrainModel t = new Train(0, b0, environment); environment.AllTrains.Add(t); prevCircuit.Trains.Add(0, t); control = new TrackControllerUi(environment, environment.PrimaryTrackControllerRed); break; case 4: // TrainModel var loc = new int[2]; loc[0] = 10; loc[1] = 10; var start = new Block(0, StateEnum.Healthy, 0, 0, -0.02, loc, 100, DirEnum.East, null, 1, 2, 0, "Red", 70); environment.AddTrain(new Train(0, start, environment)); environment.AddTrain(new Train(1, start, environment)); var train0 = (Train)environment.AllTrains[0]; train0.ChangeMovement(200); control = new TrainGUI(environment); break; case 5: // TrainController var loc2 = new int[2]; loc2[0] = 10; loc2[1] = 10; var start2 = new Block(0, StateEnum.Healthy, 0, 0, 0, loc2, 100, DirEnum.East, null, 1, 2, 0, "Red", 70); var tc = new TrainController.TrainController(environment, new Train(0, start2, environment)); control = new TrainControllerUI(tc, environment); break; } if (environment != null) { environment.StartTick(); } if (form != null) { form.Controls.Add(control); form.AutoSize = true; } else { return(null); } return(form); }