static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Environment env = new SimulationEnvironment.SimulationEnvironment(); // TrackModel TrackModel.TrackModel trackModel = new TrackModel.TrackModel(env); env.TrackModel = trackModel; TrackModel.TrackModelGUI trackModelGui = new TrackModelGUI(env, trackModel); // CTCOffice CTCOffice.CTCOffice ctcOffice = new CTCOffice.CTCOffice(env, env.PrimaryTrackControllerRed, env.PrimaryTrackControllerGreen); env.CTCOffice = ctcOffice; CTCOffice.CTCOfficeGUI ctcOfficeGui = new CTCOfficeGUI(env, ctcOffice); ctcOfficeGui.ShowTrain += new EventHandler<ShowTrainEventArgs>(ctcOfficeGui_ShowTrain); ctcOfficeGui.ShowSchedule += new EventHandler<EventArgs>(ctcOfficeGui_ShowSchedule); // Scheduler SystemScheduler.SystemScheduler scheduler = new SystemScheduler.SystemScheduler(env, ctcOffice); env.SystemScheduler = scheduler; SystemScheduler.SystemSchedulerGUI schedulerGui = new SystemScheduler.SystemSchedulerGUI(env, scheduler, ctcOffice); // train model form TrainModel.TrainGUI trainGui = new TrainGUI(env); // Track Controllers if (env.PrimaryTrackControllerRed != null) { TrackController.TrackController red = (TrackController.TrackController)env.PrimaryTrackControllerRed; TrackControllerUi redTcGui = new TrackControllerUi(env, red); trackControllerRedForm = new Form() { Controls = { redTcGui }, TopLevel = true, AutoSize = true, Parent = null, Text = "Terminal Velocity - Track Controller Red" }; } if (env.PrimaryTrackControllerGreen != null) { TrackController.TrackController green = (TrackController.TrackController)env.PrimaryTrackControllerGreen; TrackControllerUi greenTcGui = new TrackControllerUi(env, green); trackControllerGreenForm = new Form() { Controls = { greenTcGui }, TopLevel = true, AutoSize = true, Parent = null, Text = "Terminal Velocity - Track Controller Green" }; } ctcForm = new Form() { Controls = { ctcOfficeGui }, AutoSize = true, Text="Terminal Velocity - CTC Office"}; schedulerForm = new Form() { Controls = { schedulerGui }, TopLevel = true, AutoSize = true, Parent = null, Text="Terminal Velocity - System Scheduler" }; trackModelForm = new Form() { Controls = { trackModelGui }, TopLevel = true, AutoSize = true, Parent = null, Text="Terminal Velocity - Track Model"}; trainModelForm = new Form() { Controls = { trainGui }, TopLevel = true, AutoSize = true, Parent = null, Text = "Terminal Velocity - Trains" }; //TODO /* * Train Controller Form(s) * Train Model Form */ ctcForm.Shown += new EventHandler(ctcForm_Shown); Application.Run(ctcForm); }
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; }
public void createTrackForm() { var formTrack = new Form(); UserControl controlTrack; controlTrack = new TrackModelGUI(_env, _trackMod); formTrack.Controls.Add(controlTrack); formTrack.AutoSize = true; formTrack.Text = "Track Model"; formTrack.ShowDialog(); }