Ejemplo n.º 1
0
        /// <summary>
        /// Connects this signal to other lineside equipment.
        /// </summary>
        /// <remarks>
        /// This must only be called by the SubArea constructor.
        /// </remarks>
        /// <param name="schema">The schema object containing data about this signal.</param>
        /// <param name="region">The region that contains this signal.</param>
        public void InitLinks(Schema.ControlledSignal schema, Region region)
        {
            {
                Dictionary <Signal, Route> routesFrom = new Dictionary <Signal, Route>();
                foreach (Schema.Route i in schema.Routes)
                {
                    Route r = new Route(i, region, this);
                    routesFrom[r.Exit] = r;
                }
                RoutesFrom = new ReadOnlyDictionary <Signal, Route>(routesFrom);
            }

            ISet <Signal>       allExitSignals = new HashSet <Signal>();
            ISet <Points>       allPoints      = new HashSet <Points>();
            ISet <TrackCircuit> allTCs         = new HashSet <TrackCircuit>();

            foreach (KeyValuePair <Signal, Route> i in RoutesFrom)
            {
                allExitSignals.Add(i.Key);
                foreach (RoutePointPosition j in i.Value.PointPositions)
                {
                    allPoints.Add(j.Points);
                }
                foreach (RouteElement j in i.Value.Elements)
                {
                    allTCs.Add(j.TrackCircuit);
                }
            }
            foreach (Signal i in allExitSignals)
            {
                i.PropertyChanged += OnNextSignalPropChanged;
            }
            foreach (Points i in allPoints)
            {
                i.PropertyChanged += OnPointsPropChanged;
            }
            foreach (TrackCircuit i in allTCs)
            {
                i.PropertyChanged += OnTCPropChanged;
            }

            {
                CALExemption[] ary = new CALExemption[schema.CALExemptions.Count];
                for (int i = 0; i != schema.CALExemptions.Count; ++i)
                {
                    ary[i] = new CALExemption(schema.CALExemptions[i], region, SubArea);
                }
                CALExemptions = Array.AsReadOnly(ary);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a controlled signal.
 /// </summary>
 /// <param name="schema">The schema object containing data about this signal.</param>
 /// <param name="id">The internal Run8 ID number.</param>
 /// <param name="subArea">The ID of the sub-area that contains this signal.</param>
 /// <param name="world">The containing world.</param>
 public ControlledSignal(Schema.ControlledSignal schema, ushort id, ushort subArea, World world) : base(subArea, (short)id, schema.HeadCount, schema.DivergenceLookahead)
 {
     Debug.Assert(world != null);
     World = world;
 }