/// <summary>
        /// A constructor for the TrackModel module
        /// </summary>
        /// <param name="environment">Requires a reference to the surrounding environment object</param>
        public TrackModel(ISimulationEnvironment environment)
        {
            _redLoaded   = false;
            _greenLoaded = false;
            _env         = environment;
            _dbCreator   = new DBCreator("", environment);
            _dbManager   = new DBManager(_dbCreator.DBCon);

            _changeState = TrackChanged.None;

            IBlock redTemp   = requestBlockInfo(1, "Red");
            IBlock greenTemp = requestBlockInfo(1, "Green");

            if (redTemp != null)
            {
                List <IBlock>[] tempBlockList = createBlockListArray(0);
                _dbCreator.populateTCs(tempBlockList, true);
                _changeState = TrackChanged.Red;
                _redLoaded   = true;
            }

            if (greenTemp != null)
            {
                List <IBlock>[] tempBlockList = createBlockListArray(1);
                _dbCreator.populateTCs(tempBlockList, false);
                if (_changeState == TrackChanged.Red)
                {
                    _changeState = TrackChanged.Both;
                }
                else
                {
                    _changeState = TrackChanged.Green;
                }
                _greenLoaded = true;
            }

            if (_changeState != TrackChanged.None)
            {
                alertTrackChanged();
            }

            //_environment.Tick+=
        }
Ejemplo n.º 2
0
        /// <summary>
        /// A constructor for the TrackModel module
        /// </summary>
        /// <param name="environment">Requires a reference to the surrounding environment object</param>
        public TrackModel(ISimulationEnvironment environment)
        {
            _redLoaded = false;
            _greenLoaded = false;
            _env = environment;
            _dbCreator = new DBCreator("",environment);
            _dbManager = new DBManager(_dbCreator.DBCon);

            _changeState = TrackChanged.None;

            IBlock redTemp = requestBlockInfo(1, "Red");
            IBlock greenTemp = requestBlockInfo(1, "Green");
            if (redTemp != null)
            {
                List<IBlock>[] tempBlockList=createBlockListArray(0);
                _dbCreator.populateTCs(tempBlockList, true);
                _changeState = TrackChanged.Red;
                _redLoaded = true;
            }

            if (greenTemp != null)
            {
                List<IBlock>[] tempBlockList = createBlockListArray(1);
                _dbCreator.populateTCs(tempBlockList, false);
                if (_changeState == TrackChanged.Red)
                    _changeState = TrackChanged.Both;
                else
                    _changeState = TrackChanged.Green;
                _greenLoaded = true;
            }

            if (_changeState != TrackChanged.None)
            {
                alertTrackChanged();
            }

            //_environment.Tick+=
        }