public void SetCarsToBackSide(float position, int carNum) { RollingStock rs = GetCar(carNum); //clear engine if (rs.IsEngine) { rs.Engine.IsActive = false; rs.Engine.IsPlayer = false; } //clear all connections ClearConnections(rs); //release prev TC tempTC = rs.OwnTrackCircuit; // set new TPU rs.OwnTrack = TrackPath.Instance.GetTrackPathUnitByName(Constants.TRACK_BACKSIDE); // set new TC rs.OwnTrackCircuit = rs.OwnTrack.TrackCircuit; // release prev tracks ReleaseStartTracks(rs, tempTC); //set position rs.OwnPosition = position; //set bogeys the same trackpathunit rs.ResetBogeys(); CompositionManager.Instance.FormCompositionOnBackSide(rs); IndicationManager.Instance.UpdateCouplerIndication(); }
public void DefaultSwitches() { foreach (GameObject item in switches) { tc = item.GetComponent <TrackCircuit>(); } }
private void TrackColor(TrackCircuit track) { if (TrackCircuit && track.Equals(TrackCircuit)) { if (gameObject.activeSelf) { if (!TrackCircuit.IsInRoute && !TrackCircuit.IsInUse) { if (!TrackCircuit.HasCarPresence && PIUMeshRend.material != colorDefault) { PIUMeshRend.material = colorDefault; } else if (TrackCircuit.HasCarPresence && PIUMeshRend.material != colorBlocked) { PIUMeshRend.material = colorBlocked; } } else if (TrackCircuit.IsInRoute && !TrackCircuit.IsInUse && PIUMeshRend.material != colorRoute) { PIUMeshRend.material = colorRoute; } else if (TrackCircuit.IsInRoute && TrackCircuit.IsInUse && PIUMeshRend.material != colorBlocked) { PIUMeshRend.material = colorBlocked; } } } }
private void ReleaseStartTracks(RollingStock _rs, TrackCircuit _tc) { if (_tc != null) { _tc.RemoveCars(_rs.BogeyLeft); _tc.RemoveCars(_rs.BogeyRight); } }
public void ResetBogey() { OwnPosition = RollingStock.OwnPosition + Offset; OwnTrack = RollingStock.OwnTrack; OwnPath = RollingStock.OwnPath; OwnTrackCircuit = OwnTrack.TrackCircuit; tempTC = OwnTrackCircuit; OwnTrackCircuit.AddCars(this); }
private TrackCircuit[] ParseDataToTrackCircuits(string[] list) { TrackCircuit[] tempList = new TrackCircuit[list.Length]; for (int i = 0; i < list.Length; i++) { tempList[i] = GetTC(list[i]); } return(tempList); }
public static void SendEvent(string eventName, TrackCircuit param = null) { GameEvent thisEvent = null; if (instance._eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(param); } }
private void OnLoaded(object sender, EventArgs e) { MainViewModel vm = DataContext as MainViewModel; if (vm != null) { TCObject = vm.World.Region.SubAreas[SubAreaID].TrackCircuits[TrackCircuitID]; TCObject.Trains.CollectionChanged += OnTrainsChanged; } UpdateTrain(); }
private void SetTrackLightsToTC(TrackCircuit tc, string signal_0, string signal_1) { if (signal_0 != null) { tc.TrackLights [0] = TrafficLightsManager.Instance.GetTrafficLightByName(signal_0); } if (signal_1 != null) { tc.TrackLights [1] = TrafficLightsManager.Instance.GetTrafficLightByName(signal_1); } }
/// <summary> /// Finishes initialization of this object. /// </summary> /// <param name="sender">This object.</param> /// <param name="e">Details of the event.</param> private void OnLoaded(object sender, EventArgs e) { MainViewModel vm = DataContext as MainViewModel; if (vm != null) { NormalTrackCircuit = vm.World.Region.SubAreas[SubAreaID].TrackCircuits[NormalTrackCircuitID]; NormalTrackCircuit.PropertyChanged += OnTCPropChanged; ReverseTrackCircuit = vm.World.Region.SubAreas[SubAreaID].TrackCircuits[ReverseTrackCircuitID]; ReverseTrackCircuit.PropertyChanged += OnTCPropChanged; } Update(); }
public void ProvidePresence() { if (tempTC) { if (tempTC.Equals(OwnTrackCircuit)) { return; } tempTC.RemoveCars(this); } if (OwnTrackCircuit) { OwnTrackCircuit.AddCars(this); } tempTC = OwnTrackCircuit; }
public void SetCarsPosition(string trackName, float position, int [] carsNums, int activeEngine = 0) { RollingStock [] cars = new RollingStock [carsNums.Length]; RollingStock rs = GetCar(carsNums [0]); RollingStock actEng = GetCar(activeEngine); // fill array of cars cars [0] = rs; //clear all connections ClearConnections(rs); //release prev TC tempTC = rs.OwnTrackCircuit; rs.OwnTrack = TrackPath.Instance.GetTrackPathUnitByName(trackName); rs.OwnTrackCircuit = rs.OwnTrack.TrackCircuit; ReleaseStartTracks(rs, tempTC); //set position rs.OwnPosition = position; //set bogeys the same trackpathunit rs.ResetBogeys(); // if one car no need for (int i = 1; i < carsNums.Length; i++) { //take previous car rs = GetCar(carsNums [i - 1]); // get next car RollingStock rightCar = GetCar(carsNums [i]); // fill array of cars cars [i] = rightCar; //clear all connections ClearConnections(rightCar); //release prev TC tempTC = rightCar.OwnTrackCircuit; rightCar.OwnTrack = rs.OwnTrack; rightCar.OwnTrackCircuit = rs.OwnTrack.TrackCircuit; ReleaseStartTracks(rightCar, tempTC); rs.RSConnection.InitConnection(rightCar.RSConnection); rightCar.ResetBogeys(); } CompositionManager.Instance.FormCompositionsAfterSettingCars(cars, actEng); IndicationManager.Instance.UpdateCouplerIndication(); }
public void createTrackController() { IBlock b0 = new Block(0, StateEnum.Healthy, -1, 0, 0, new[] { 0, 0 }, 1000, DirEnum.East, new[] { "" }, 0, 0, 0, "Green", 70); IBlock b1 = new Block(1, StateEnum.Healthy, 0, 0, 0, new[] { 1, 1 }, 1000, DirEnum.East, new[] { "" }, 0, 0, 0, "Green", 70); IBlock b2 = new Block(2, StateEnum.Healthy, 1, 0, 0, new[] { 2, 2 }, 1000, DirEnum.East, new[] { "" }, 0, 0, 0, "Green", 70); IBlock b3 = new Block(3, StateEnum.BrokenTrackFailure, 2, 0, 0, new[] { 3, 3 }, 1000, DirEnum.East, new[] { "" }, 0, 0, 0, "Green", 70); var sectionA = new List <IBlock>(); sectionA.Add(b0); var sectionB = new List <IBlock>(); sectionB.Add(b1); sectionB.Add(b2); var sectionC = new List <IBlock>(); sectionC.Add(b3); // Track Controller _currCircuit = new TrackCircuit(_env, sectionA); // Next track controller's circuit _nextCircuit = new TrackCircuit(_env, sectionB); // Previous track controller's circuit _prevCircuit = new TrackCircuit(_env, sectionC); _prev = new TrackController.TrackController(_env, _prevCircuit); _curr = new TrackController.TrackController(_env, _currCircuit); _next = new TrackController.TrackController(_env, _nextCircuit); _prev.Previous = null; _prev.Next = _curr; _curr.Previous = _prev; _curr.Next = _next; _next.Previous = _curr; _next.Next = null; _env.PrimaryTrackControllerGreen = _prev; _env.PrimaryTrackControllerRed = _prev; }
/// <summary> /// Finishes initialization of this object. /// </summary> /// <param name="sender">This object.</param> /// <param name="e">Details of the event.</param> private void OnLoaded(object sender, EventArgs e) { MainViewModel vm = DataContext as MainViewModel; if (vm != null) { // You can't populate both PointPositions and Routes. Debug.Assert((PointPositions == null) || (PointPositions.Count == 0) || (Routes == null) || (Routes.Count == 0)); if (TrackCircuitID >= 0) { TrackCircuit = vm.World.Region.SubAreas[SubAreaID].TrackCircuits[TrackCircuitID]; TrackCircuit.PropertyChanged += OnTCPropChanged; } PointPositionsResolved = new SectionPointPositionResolved[PointPositions.Count]; for (int i = 0; i != PointPositions.Count; ++i) { SectionPointPosition p = PointPositions[i]; PointPositionsResolved[i].Points = vm.World.Region.SubAreas[SubAreaID].PowerPoints[p.Points]; PointPositionsResolved[i].Reversed = p.Reversed; PointPositionsResolved[i].Points.PropertyChanged += OnConditionalPointsPropChanged; } PointPositions = null; RoutesResolved = new Route[Routes.Count]; for (int i = 0; i != Routes.Count; ++i) { ControlledSignal entrance = (ControlledSignal)vm.World.Region.GetSignal(Routes[i].Entrance, SubAreaID); World.Signal exit = vm.World.Region.GetSignal(Routes[i].Exit, SubAreaID); RoutesResolved[i] = entrance.RoutesFrom[exit]; } Routes = null; if (BlinkForSignal.HasValue) { BlinkForSignalResolved = vm.World.Region.SubAreas[SubAreaID].Signals[BlinkForSignal.Value]; vm.PropertyChanged += OnVMPropChanged; } } Update(); }
/// <summary> /// Constructs a new route element. /// </summary> /// <param name="schema">The schema object containing data about this route.</param> /// <param name="region">The region the route exists in.</param> /// <param name="subArea">The default sub-area ID against which to resolve a short TC ID.</param> public RouteElement(Schema.RouteTC schema, Region region, ushort subArea) { TrackCircuit = region.GetTrackCircuit(schema.TC, subArea); Direction = schema.Direction; }
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); }
private void Awake() { trackCircuit = GetComponent <TrackCircuit> (); carsHolder = FindObjectOfType <CarsHolder> (); EventManager.onMinutePassed += CheckCars; }
public void GetTrackLightsByTrack(TrackCircuit tc) { if (tc.name.Equals("Track_Cross9_10")) { SetTrackLightsToTC(tc, "Cross9_10", null); } else if (tc.name.Equals("Track_I_CH")) { SetTrackLightsToTC(tc, null, "CH"); } else if (tc.name.Equals("Track_I_N")) { SetTrackLightsToTC(tc, "N", null); } else if (tc.name.Equals("Track_I_16_15")) { SetTrackLightsToTC(tc, "NI", "CHI"); } else if (tc.name.Equals("Track_12_17_19")) { SetTrackLightsToTC(tc, "M5", null); } else if (tc.name.Equals("Track_2")) { SetTrackLightsToTC(tc, "N2", "CH2"); } else if (tc.name.Equals("Track_3")) { SetTrackLightsToTC(tc, "N3", "CH3"); } else if (tc.name.Equals("Track_4")) { SetTrackLightsToTC(tc, "N4", "CH4"); } else if (tc.name.Equals("Track_5")) { SetTrackLightsToTC(tc, "N5", "CH5"); } else if (tc.name.Equals("Track_6")) { SetTrackLightsToTC(tc, "End6", "M2"); } else if (tc.name.Equals("Track_7")) { SetTrackLightsToTC(tc, "M1", "End7"); } else if (tc.name.Equals("Track_8")) { SetTrackLightsToTC(tc, "End8", "M4"); } else if (tc.name.Equals("Track_9")) { SetTrackLightsToTC(tc, "Cross9", "End9"); } else if (tc.name.Equals("Track_10")) { SetTrackLightsToTC(tc, "Cross10_11", "End10"); } else if (tc.name.Equals("Track_11")) { SetTrackLightsToTC(tc, "Cross11", "End11"); } else if (tc.name.Equals("Track_12")) { SetTrackLightsToTC(tc, "Cross12N", "Cross12CH"); } else if (tc.name.Equals("Track_12A")) { SetTrackLightsToTC(tc, null, "End12"); } else if (tc.name.Equals("Track_13")) { SetTrackLightsToTC(tc, "Cross13N", "Cross13CH"); } else if (tc.name.Equals("Track_StoreYard")) { SetTrackLightsToTC(tc, "M3", "CrossStoreYard"); } else if (tc.name.Equals("Track_14")) { SetTrackLightsToTC(tc, "End14", "Cross14"); } else if (tc.name.Equals("Switch_19")) { SetTrackLightsToTC(tc, null, null); } }