Пример #1
0
        public LineData(IBlock[,] layout, ISimulationEnvironment env, ResourceWrapper res)
        {
            _env = env;
            _res = res;
            _trains = new List<ITrainModel>();
            _blocks = new List<IBlock>();
            _layout = new LayoutCellDataContainer[layout.GetUpperBound(0) + 1,layout.GetUpperBound(1) + 1];

            //for each item in the 1st dimension (row)
            for (int i = 0; i <= layout.GetUpperBound(0); i++)
            {
                //for each item in the 2nd dimension (col)
                for (int j = 0; j <= layout.GetUpperBound(1); j++)
                {
                    //make a new container
                    var container = new LayoutCellDataContainer();

                    //determine tile
                    if (layout[i, j] == null)
                    {
                        //null container
                        container.BaseTile = _res.Unpopulated;
                        container.Tile = container.BaseTile;
                        container.Block = null;
                        container.Train = null;
                    }
                    else
                    {
                        container.Train = null;
                        _blocks.Add(layout[i, j]);
                        container.Block = layout[i, j];

                        //expand after prototype
                        if (layout[i, j].Line.CompareTo("Red") == 0 || layout[i, j].Line.CompareTo("red") == 0 ||
                            layout[i, j].Line.CompareTo("R") == 0 || layout[i, j].Line.CompareTo("r") == 0)
                        {
                            //red line
                            container.BaseTile = GetBlockType(container.Block);
                            container.Tile = container.BaseTile;
                        }
                        else if (layout[i, j].Line.CompareTo("Green") == 0 || layout[i, j].Line.CompareTo("green") == 0 ||
                                 layout[i, j].Line.CompareTo("G") == 0 || layout[i, j].Line.CompareTo("g") == 0)
                        {
                            //green line
                            container.BaseTile = GetBlockType(container.Block);
                            container.Tile = container.BaseTile;
                        }
                        else
                        {
                            container.BaseTile = _res.TrackError;
                            container.Tile = container.BaseTile;
                            env.SendLogEntry("CTC Office: Line Data - IBlock.Line is invalid");
                        }
                    } //end determine tile

                    //add the container to the layout panel
                    _layout[i, j] = container;
                } //end for 2nd dimension
            } //end for 1st dimentsion
        }
Пример #2
0
        public CTCOffice(ISimulationEnvironment env, ITrackController redTC, ITrackController greenTC)
        {
            _populateTrackMutex = new Mutex(false);
            _updateTrackMutex   = new Mutex(false);
            _loadTrackMutex     = new Mutex(false);
            _rate      = 100; //num of ticks
            _tickCount = 0;
            _rate      = env.GetInterval();
            _env       = env;
            _primaryTrackControllerGreen = greenTC;
            _primaryTrackControllerRed   = redTC;

            _env.TrackModel.TrackChangedEvent += new EventHandler <EventArgs>(TrackModel_TrackChangedEvent);

            _messages = new List <string>();

            //subscribe to Environment Tick
            _env.Tick += _env_Tick;

            //create new resource wrapper
            _res = new ResourceWrapper();

            //create new operator object
            _op = new Operator();
            //set credentials
            _op.SetAuth("root", "admin");

            //create queues
            _requestsOut = new Queue <IRequest>();
            _requestsIn  = new Queue <IRequest>();

            //create queue events
            RequestQueueIn  += CTCOffice_RequestQueueIn;
            RequestQueueOut += CTCOffice_RequestQueueOut;

            //create queue processing flags / mutex
            _processingOutRequests = false;
            _processingInRequests  = false;

            _redLoaded   = false;
            _greenLoaded = false;

            _containedTrainAndBlock = new List <TrainAndBlock>();

            if (_env.TrackModel == null)
            {
                _env.SendLogEntry("CTCOffice: NULL Reference to TrackModel");
            }
        }//Constructor
Пример #3
0
        public CTCOffice(ISimulationEnvironment env, ITrackController redTC, ITrackController greenTC)
        {
            _populateTrackMutex = new Mutex(false);
            _updateTrackMutex = new Mutex(false);
            _loadTrackMutex = new Mutex(false);
            _rate = 100; //num of ticks
            _tickCount = 0;
            _rate = env.GetInterval();
            _env = env;
            _primaryTrackControllerGreen = greenTC;
            _primaryTrackControllerRed = redTC;

            _env.TrackModel.TrackChangedEvent += new EventHandler<EventArgs>(TrackModel_TrackChangedEvent);

            _messages = new List<string>();

            //subscribe to Environment Tick
            _env.Tick += _env_Tick;

            //create new resource wrapper
            _res = new ResourceWrapper();

            //create new operator object
            _op = new Operator();
            //set credentials
            _op.SetAuth("root", "admin");

            //create queues
            _requestsOut = new Queue<IRequest>();
            _requestsIn = new Queue<IRequest>();

            //create queue events
            RequestQueueIn += CTCOffice_RequestQueueIn;
            RequestQueueOut += CTCOffice_RequestQueueOut;

            //create queue processing flags / mutex
            _processingOutRequests = false;
            _processingInRequests = false;

            _redLoaded = false;
            _greenLoaded = false;

            _containedTrainAndBlock = new List<TrainAndBlock>();

            if (_env.TrackModel == null)
            {
                _env.SendLogEntry("CTCOffice: NULL Reference to TrackModel");
            }
        }
Пример #4
0
 public KeyInfo(ResourceWrapper res)
 {
     InitializeComponent();
     _res = res;
     PopulateImages();
 }
        public LineData(IBlock[,] layout, ISimulationEnvironment env, ResourceWrapper res)
        {
            _env    = env;
            _res    = res;
            _trains = new List <ITrainModel>();
            _blocks = new List <IBlock>();
            _layout = new LayoutCellDataContainer[layout.GetUpperBound(0) + 1, layout.GetUpperBound(1) + 1];


            //for each item in the 1st dimension (row)
            for (int i = 0; i <= layout.GetUpperBound(0); i++)
            {
                //for each item in the 2nd dimension (col)
                for (int j = 0; j <= layout.GetUpperBound(1); j++)
                {
                    //make a new container
                    var container = new LayoutCellDataContainer();

                    //determine tile
                    if (layout[i, j] == null)
                    {
                        //null container
                        container.BaseTile = _res.Unpopulated;
                        container.Tile     = container.BaseTile;
                        container.Block    = null;
                        container.Train    = null;
                    }
                    else
                    {
                        container.Train = null;
                        _blocks.Add(layout[i, j]);
                        container.Block = layout[i, j];

                        //expand after prototype
                        if (layout[i, j].Line.CompareTo("Red") == 0 || layout[i, j].Line.CompareTo("red") == 0 ||
                            layout[i, j].Line.CompareTo("R") == 0 || layout[i, j].Line.CompareTo("r") == 0)
                        {
                            //red line
                            container.BaseTile = GetBlockType(container.Block);
                            container.Tile     = container.BaseTile;
                        }
                        else if (layout[i, j].Line.CompareTo("Green") == 0 || layout[i, j].Line.CompareTo("green") == 0 ||
                                 layout[i, j].Line.CompareTo("G") == 0 || layout[i, j].Line.CompareTo("g") == 0)
                        {
                            //green line
                            container.BaseTile = GetBlockType(container.Block);
                            container.Tile     = container.BaseTile;
                        }
                        else
                        {
                            container.BaseTile = _res.TrackError;
                            container.Tile     = container.BaseTile;
                            env.SendLogEntry("CTC Office: Line Data - IBlock.Line is invalid");
                        }
                    } //end determine tile


                    //add the container to the layout panel
                    _layout[i, j] = container;
                } //end for 2nd dimension
            }     //end for 1st dimentsion
        }
        public CTCOfficeGUI(ISimulationEnvironment env, CTCOffice ctc)
        {
            InitializeComponent();
            //set refs to ctc office and environment
            _ctcOffice = ctc;
            _environment = env;
            _speedState = 0;

            _res = _ctcOffice.Resource;

            _ctcOffice.LoadData += new EventHandler<EventArgs>(_ctcOffice_LoadData);
            _ctcOffice.UnlockLogin += new EventHandler<EventArgs>(_ctcOffice_UnlockLogin);
            _ctcOffice.MessagesReady += new EventHandler<EventArgs>(_ctcOffice_MessagesReady);
            _ctcOffice.UpdatedData += new EventHandler<EventArgs>(_ctcOffice_UpdatedData);
            _loginState = false;

            _btnLoginLogout.Enabled = _loginState;
            _txtPassword.Enabled = _loginState;
            _txtUsername.Enabled = _loginState;

            _rate = 100;
            _tickCount = 0;

            //init routing vars
            _routeTool = null;
            _inRoutingPoint = false;
            _routingToolOpen = false;
            _routeToolMode = RoutingMode.Dispatch;

            _lastRightClickContainer = null;

            _keyForm = null;
            _keyOpen = false;

            //subscribe to Environment Tick
            _environment.Tick += _environment_Tick;

            //ensure the user is logged out
            _ctcOffice.Logout();
            //change button text
            _btnLoginLogout.Text = "Login";

            //show team logo (block out user)
            MainDisplayLogo();
            DisableUserControls();
            _loginStatusImage.Image = _res.RedLight;
            _imageTeamLogo.Image = Properties.Resources.TerminalVelocity;

            UpdateMetrics();
            RefreshStatus();

            //populate red line and green line panel
            //parseLineData();

            //enables double buffering for control drawings
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            //post to log that the gui has loaded
            _environment.SendLogEntry("CTCOffice: GUI Loaded");

            _tt = null;
        }
Пример #7
0
 public KeyInfo(ResourceWrapper res)
 {
     InitializeComponent();
     _res = res;
     PopulateImages();
 }
Пример #8
0
        public CTCOfficeGUI(ISimulationEnvironment env, CTCOffice ctc)
        {
            InitializeComponent();
            //set refs to ctc office and environment
            _ctcOffice   = ctc;
            _environment = env;
            _speedState  = 0;

            _res = _ctcOffice.Resource;

            _ctcOffice.LoadData      += new EventHandler <EventArgs>(_ctcOffice_LoadData);
            _ctcOffice.UnlockLogin   += new EventHandler <EventArgs>(_ctcOffice_UnlockLogin);
            _ctcOffice.MessagesReady += new EventHandler <EventArgs>(_ctcOffice_MessagesReady);
            _ctcOffice.UpdatedData   += new EventHandler <EventArgs>(_ctcOffice_UpdatedData);
            _loginState = false;

            _btnLoginLogout.Enabled = _loginState;
            _txtPassword.Enabled    = _loginState;
            _txtUsername.Enabled    = _loginState;

            _rate      = 100;
            _tickCount = 0;

            //init routing vars
            _routeTool       = null;
            _inRoutingPoint  = false;
            _routingToolOpen = false;
            _routeToolMode   = RoutingMode.Dispatch;

            _lastRightClickContainer = null;

            _keyForm = null;
            _keyOpen = false;

            //subscribe to Environment Tick
            _environment.Tick += _environment_Tick;

            //ensure the user is logged out
            _ctcOffice.Logout();
            //change button text
            _btnLoginLogout.Text = "Login";


            //show team logo (block out user)
            MainDisplayLogo();
            DisableUserControls();
            _loginStatusImage.Image = _res.RedLight;
            _imageTeamLogo.Image    = Properties.Resources.TerminalVelocity;

            UpdateMetrics();
            RefreshStatus();

            //populate red line and green line panel
            //parseLineData();

            //enables double buffering for control drawings
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            //post to log that the gui has loaded
            _environment.SendLogEntry("CTCOffice: GUI Loaded");

            _tt = null;
        }