/// <summary>
        /// the proxy's onload event method
        /// </summary>
        /// <param name="sender">the caller of the event</param>
        /// <param name="isLoaded">a bool value of the control loaded event</param>
        void SimProxy_OnLoadEvent(object sender, bool isLoaded)
        {
            //a request is being made to the service to initalite the flights simulator
            RequestInitializeSimulator reqInitSim =
                new RequestInitializeSimulator()
            {
                IsWindowLoaded = isLoaded
            };
            ResponseInitializeSimulator resInitSim = simProxy.InitializeSimulator(reqInitSim);

            //if the simulator is initialized successfully, a timer starts with the simulator data
            if (resInitSim.IsSuccess)
            {
                //resInitSim.TimerInterval => simulator data
                Timer arrivalTimer = new Timer(resInitSim.TimerInterval);
                arrivalTimer.Elapsed += CreateFlight_ArrivalTimerElapsed;
                arrivalTimer.Start();
            }
        }
        /// <summary>
        /// The flight creation interval & serial simualtor class initialization request method
        /// </summary>
        /// <param name="req">the request from the user side</param>
        /// <returns>the response to the user side</returns>
        public ResponseInitializeSimulator InitializeSimulator(RequestInitializeSimulator req)
        {
            double timerInterval = default(double);

            try
            {
                //retrieves a global timer fixed value
                timerInterval = arrivalSim.ArrivalTimer.Interval;
            }
            catch (Exception e)
            {
                throw new Exception($"Could not create timer. {e.Message}");
            }
            return(new ResponseInitializeSimulator()
            {
                IsSuccess = true,
                Message = $"Arrival object generator timer created with {timerInterval} interval.",
                TimerInterval = timerInterval,
            });
        }
示例#3
0
 public ResponseInitializeSimulator InitializeSimulator(RequestInitializeSimulator req)
 {
     return(simService.InitializeSimulator(req));
 }