private void EngineStatusChangedHandler(Object sender, EngineStatusChangedArgs e)
 {
     Dispatcher.Invoke(() =>
     {
         Status = e.NewStatus;
     });
 }
Пример #2
0
        /// <summary>
        /// Update engine status on the taskbroker
        /// </summary>
        /// <param name="engineId">engine to update the status for</param>
        /// <param name="status">status</param>
        public void UpdateEngineStatus(string engineId, EngineStatus status)
        {
            _log.DebugFormat("Received request to update engine status for engine {0} to {1}", engineId, status.ToString());
            try
            {
                _engineCollection[engineId].Status = status;

                // if an engine wants to register its state as Idle, signal the execute task loop to continue.
                // It also means the engine has finished processing a task - so let's update the corresponding task's status
                // and notify the client
                if (status == EngineStatus.Idle)
                {
                    _waitTillEngineIdle.Set();
                    RequestHandle request = _taskEngineMap[engineId];
                    request.TaskStatus = TaskStatus.Finished;

                    // notify client
                    _handleCallbackMap[request.Handle].TaskComplete(request);
                    _taskEngineMap.Remove(engineId);
                }
            }
            catch (Exception e)
            {
                _log.ErrorFormat("Error updating engine status for engine {0}: {1}\n{2}", engineId, e.Message, e.StackTrace);
            }
        }
Пример #3
0
        public void Accept(Func <ICarPartVisitor> visitorFactory)
        {
            var structure = new EngineStructure(this.power, this.cylinderVolume);
            var status    = new EngineStatus(this.temperatureC, 0);

            visitorFactory().VisitEngine(structure, status);
        }
Пример #4
0
 public ActionsManager(EngineStatus eStatus, ITrackingForm formBase)
 {
     Items          = new List <Action>();
     actionsFactory = new ActionsFactory();
     this.eStatus   = eStatus;
     this.formBase  = formBase;
 }
Пример #5
0
        override protected void triggerInternal(GameStateData previousGameState, GameStateData currentGameState)
        {
            if (engineData == null)
            {
                clearState();
            }
            if (maxSafeWaterTemp == 0)
            {
                maxSafeWaterTemp = currentGameState.carClass.maxSafeWaterTemp;
            }
            if (maxSafeOilTemp == 0)
            {
                maxSafeOilTemp = currentGameState.carClass.maxSafeOilTemp;
            }
            if (currentGameState.SessionData.SessionRunningTime > 60 * currentGameState.EngineData.MinutesIntoSessionBeforeMonitoring)
            {
                engineData.addSample(currentGameState.EngineData.EngineOilTemp, currentGameState.EngineData.EngineWaterTemp,
                                     currentGameState.EngineData.EngineOilPressure);

                if (currentGameState.SessionData.SessionRunningTime > gameTimeAtLastStatusCheck + statusMonitorWindowLength)
                {
                    EngineStatus currentEngineStatus = engineData.getEngineStatusFromAverage(maxSafeWaterTemp, maxSafeOilTemp);
                    if (currentEngineStatus != lastStatusMessage)
                    {
                        switch (currentEngineStatus)
                        {
                        case EngineStatus.ALL_CLEAR:
                            lastStatusMessage = currentEngineStatus;
                            audioPlayer.playMessage(new QueuedMessage(folderAllClear, 0, this));
                            break;

                        case EngineStatus.HOT_OIL:
                            // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                            if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                            {
                                lastStatusMessage = currentEngineStatus;
                                audioPlayer.playMessage(new QueuedMessage(folderHotOil, 0, this));
                            }
                            break;

                        case EngineStatus.HOT_WATER:
                            // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                            if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                            {
                                lastStatusMessage = currentEngineStatus;
                                audioPlayer.playMessage(new QueuedMessage(folderHotWater, 0, this));
                            }
                            break;

                        case EngineStatus.HOT_OIL_AND_WATER:
                            lastStatusMessage = currentEngineStatus;
                            audioPlayer.playMessage(new QueuedMessage(folderHotOilAndWater, 0, this));
                            break;
                        }
                    }
                    gameTimeAtLastStatusCheck = currentGameState.SessionData.SessionRunningTime;
                    engineData = new EngineData();
                }
            }
        }
Пример #6
0
 public Engine(string name, int capacity, double power)
 {
     Name     = name;
     Capacity = capacity;
     Power    = power;
     Status   = EngineStatus.Stopped;
 }
Пример #7
0
        /// <summary>
        /// 启动引擎
        /// </summary>
        /// <returns></returns>
        public bool StartEngine()
        {
            bool result = false;

            if (EngineStatus == EngineStatus.NotReady)
            {
                FireAtonEngineFaultEvent(this, new EngineFaultEventArgs("Engine is not ready", "", EngineName));
                return(result);
            }
            try
            {
                cancelTokeSource = new CancellationTokenSource();
                task             = Async.LongRun(ProcContext, ProcParameter, cancelTokeSource.Token, EngineException);
                EngineStatus     = EngineStatus.Running;
                FireAtonEngineStartedEvent(this, new EngineStartedEventArgs(result, EngineName));
                result = true;
            }
            catch (Exception ex)
            {
                string e = ex.StackTrace;
                result = false;
            }

            return(result);
        }
Пример #8
0
    // Send a request to CoreServer
    // -------------------------------------------------------------
    void SendRequest(string method, string uri)
    {
        Debug.Log("SendRequest : " + uri);

        // Launch request
        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);

        httpWebRequest.Method = method;

        // Encode SAN info to create the new game
        if (method == "POST")
        {
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[]        byte1    = encoding.GetBytes("san=false");
            httpWebRequest.ContentType   = "application/x-www-form-urlencoded";
            httpWebRequest.ContentLength = byte1.Length;
            Stream newStream = httpWebRequest.GetRequestStream();
            newStream.Write(byte1, 0, byte1.Length);
        }

        // Get the response from the server
        HttpWebResponse response      = (HttpWebResponse)httpWebRequest.GetResponse();
        Stream          receiveStream = response.GetResponseStream();
        StreamReader    readStream    = new StreamReader(receiveStream);

        switch (method)
        {
        // Create a new game
        case "POST":
            gameId = readStream.ReadToEnd();
            Debug.Log("New game id allocated : " + gameId);
            accessible = true;
            LetKnow3D();
            break;

        // Request for the best move
        case "GET":
            answer = readStream.ReadToEnd();
            if (answer == "NULL")
            {
                status = EngineStatus.Error;
                return;                         // <=> return;
            }
            GetResponse();
            break;

        // End game
        case "DELETE":
            Debug.Log(response.StatusCode);
            Debug.Log("Game '" + gameId + "' deleted");
            status = EngineStatus.Ended;
            break;
        }

        response.Close();
        readStream.Close();

        return;
    }
Пример #9
0
 public override void clearState()
 {
     lastStatusMessage         = EngineStatus.ALL_CLEAR;
     engineData                = new EngineData();
     gameTimeAtLastStatusCheck = 0;
     maxSafeOilTemp            = 0;
     maxSafeWaterTemp          = 0;
 }
Пример #10
0
 public static  EngineStatus[] Predict(EngineStatus initialStatus, float totalTime, float deltaTime)
 {
     if (deltaTime <= 0)
     {
         Debug.LogWarning("Delta Time set to zero, unable to predict engine status");
     }
     return(Predict(initialStatus, (int)1, (int)Mathf.Round(totalTime / deltaTime)));
 }
Пример #11
0
 public override void clearState()
 {
     lastStatusMessage = EngineStatus.ALL_CLEAR;
     engineData = new EngineData();
     gameTimeAtLastStatusCheck = 0;
     maxSafeOilTemp = 0;
     maxSafeWaterTemp = 0;
 }
Пример #12
0
        protected virtual void OnStatusChange(EngineStatus oldStatus, EngineStatus newStatus)
        {
            var e = EngineStatusChanged;

            if (e != null)
            {
                EngineStatusChanged(this, new EngineStatusChangedArgs(oldStatus, newStatus));
            }
        }
Пример #13
0
        /// <summary>
        /// Engine Status and test summary
        /// </summary>
        /// <param name="response">4 Bytes</param>
        /// <returns>EngineStatus</returns>
        public EngineStatus pid0101(string response)
        {
            EngineStatus vehicleStatus = new EngineStatus();

            byte[] troubleBytes = new byte[4];
            for (int byteNum = 0; byteNum < response.Length / 2; byteNum++)
            {
                troubleBytes[byteNum] = byte.Parse(response.Substring(byteNum, 2), System.Globalization.NumberStyles.HexNumber);
            }

            // Trouble Codes
            if (troubleBytes[0] > 0x80)
            {
                vehicleStatus.MILActive = true;
                troubleBytes[0]        -= 0x80;
            }
            vehicleStatus.TroubleCodeCount = (int)(troubleBytes[0]);

            // System Tests
            vehicleStatus.Misfire.Available = ((troubleBytes[1] & 0x01) > 0);
            vehicleStatus.Misfire.Passed    = ((troubleBytes[1] & 0x10) > 0);

            vehicleStatus.FuelSystem.Available = ((troubleBytes[1] & 0x02) > 0);
            vehicleStatus.FuelSystem.Passed    = ((troubleBytes[1] & 0x20) > 0);

            vehicleStatus.Components.Available = ((troubleBytes[1] & 0x04) > 0);
            vehicleStatus.Components.Passed    = ((troubleBytes[1] & 0x40) > 0);

            vehicleStatus.Reserved.Available = ((troubleBytes[1] & 0x08) > 0);
            vehicleStatus.Reserved.Passed    = ((troubleBytes[1] & 0x80) > 0);

            vehicleStatus.Catalyst.Available = ((troubleBytes[2] & 0x01) > 0);
            vehicleStatus.Catalyst.Passed    = ((troubleBytes[3] & 0x01) > 0);

            vehicleStatus.CatalystHeated.Available = ((troubleBytes[2] & 0x02) > 0);
            vehicleStatus.CatalystHeated.Passed    = ((troubleBytes[3] & 0x02) > 0);

            vehicleStatus.EvapSystem.Available = ((troubleBytes[2] & 0x04) > 0);
            vehicleStatus.EvapSystem.Passed    = ((troubleBytes[3] & 0x04) > 0);

            vehicleStatus.SecondaryAirSystem.Available = ((troubleBytes[2] & 0x08) > 0);
            vehicleStatus.SecondaryAirSystem.Passed    = ((troubleBytes[3] & 0x08) > 0);

            vehicleStatus.ACRefrigerant.Available = ((troubleBytes[2] & 0x10) > 0);
            vehicleStatus.ACRefrigerant.Passed    = ((troubleBytes[3] & 0x10) > 0);

            vehicleStatus.O2Sensor.Available = ((troubleBytes[2] & 0x20) > 0);
            vehicleStatus.O2Sensor.Passed    = ((troubleBytes[3] & 0x20) > 0);

            vehicleStatus.O2SensorHeater.Available = ((troubleBytes[2] & 0x40) > 0);
            vehicleStatus.O2SensorHeater.Passed    = ((troubleBytes[3] & 0x40) > 0);

            vehicleStatus.EGRSystem.Available = ((troubleBytes[2] & 0x80) > 0);
            vehicleStatus.EGRSystem.Passed    = ((troubleBytes[3] & 0x80) > 0);

            return(vehicleStatus);
        }
Пример #14
0
 public void Start()
 {
     if (engineStatus != EngineStatus.Start && _tank > 0)
     {
         engineStatus   = EngineStatus.Start;
         _engineStarted = DateTime.Now;
         _notify("Engine started");
     }
 }
Пример #15
0
        public Biometrics()
        {
            engine = new ZKFPEngX();

            engine.SensorIndex = 0;
            Status             = (EngineStatus)engine.InitEngine();
            MessageBox.Show(Status.ToString());
            AddActions();
        }
Пример #16
0
 public override void clearState()
 {
     lastStatusMessage = EngineStatus.ALL_CLEAR;
     engineData = new EngineData();
     gameTimeAtLastStatusCheck = 0;
     gotBaseline = false;
     baselineSamples = 0;
     baselineOilTemp = 0;
     baselineWaterTemp = 0;
 }
Пример #17
0
 public override void clearState()
 {
     lastStatusMessage         = EngineStatus.ALL_CLEAR;
     engineData                = new EngineData();
     gameTimeAtLastStatusCheck = 0;
     maxSafeOilTemp            = 0;
     maxSafeWaterTemp          = 0;
     nextOilPressureCheck      = DateTime.MinValue;
     nextFuelPressureCheck     = DateTime.MinValue;
     nextStalledCheck          = DateTime.MinValue;
 }
Пример #18
0
        private void SoundLoaded(ElementEvent e)
        {
            _engine.RemoveEventListener("canplaythrough", _playThroughListener, false);
            _engine.AddEventListener("timeupdate", _timeUpdatedListener, false);

            _engineStatus = EngineStatus.Low;
            // _engine.CurrentTime = EngineLowStart;

            _engine.Volume = 0.5f;
            _engine.Play();
        }
Пример #19
0
        public static  EngineStatus[] Predict(EngineStatus initialStatus, float stepTime, int count, float deltaTime)
        {
            if (deltaTime <= 0)
            {
                Debug.LogWarning("Delta Time set to zero, unable to predict engine status");
                return(null);
            }
            int stepLength = (int)Mathf.Round(stepTime / deltaTime);

            return(Predict(initialStatus, stepLength, count));
        }
Пример #20
0
        public void Client_GetEngineStatus_Test()
        {
            ITaskBroker client = new GridTaskBrokerClient(new GridTaskBrokerCallback());

            string       engineId = Guid.NewGuid().ToString();
            EngineStatus status   = client.GetEngineStatus(engineId);

            _log.DebugFormat("Status: {0}", status.ToString());

            (client as GridTaskBrokerClient).Close();
        }
Пример #21
0
 // Tell to the 3D client the availability of Core Server
 // -------------------------------------------------------------
 void LetKnow3D()
 {
     (GameObject.Find("MainScript")).SendMessage("CoreServerAccess", (accessible ? "YES" : "NO"));
     if (accessible)
     {
         status = EngineStatus.Sleep; requestFEN = ""; answer = "";
     }
     else
     {
         status = EngineStatus.Error; requestFEN = ""; answer = "";
     }
 }
Пример #22
0
 /// <summary>
 /// 启动引擎
 /// </summary>
 /// <returns></returns>
 public bool LoadEngine(Action <object> procContext, object param)
 {
     if (EngineStatus != EngineStatus.Running && EngineStatus != EngineStatus.WaitToStop)
     {
         ProcContext   = procContext;
         ProcParameter = param;
         FireAtonEngineInitEvent(this, new EngineInitEventArgs(EngineName));
         EngineStatus = GenericEngine.EngineStatus.Ready;
         return(true);
     }
     return(false);
 }
Пример #23
0
        /// <summary>
        /// Resets the Engine instance to its
        /// INIT Status; also reset the error code to OK.
        /// <exception cref="System.ApplicationException">Thrown if the Engine
        /// is currently WORKING.</exception>
        /// </summary>
        public void Reset()
        {
            if (status == EngineStatus.WORKING)
            {
                throw new ApplicationException("CFGLite: [Engine::Reset()]\n" +
                                               "The Engine is currently Working.");
            }

            status     = EngineStatus.INIT;
            errCode    = ErrorCode.OK;
            errDetails = "";
        }
Пример #24
0
        public void ResumeThreads()
        {
            if (m_CoreScheduler != null)
            {
                m_CoreScheduler.ResumeThreads();

                OnStatusChange(m_Status, EngineStatus.Started);
                m_Status = EngineStatus.Started;

                logger.Trace("Execution resumed");
            }
        }
Пример #25
0
        public void Start()
        {
            logger.Trace("Starting emulator engine");

            TaskFactory factory = new TaskFactory(m_CoreScheduler);

            StartTasks(factory, m_TokenSource.Token);
            m_CoreScheduler.RunThreads();

            OnStatusChange(m_Status, EngineStatus.Started);
            m_Status = EngineStatus.Started;
        }
Пример #26
0
 // Tell to the 3D client the availability of Core Server
 // -------------------------------------------------------------
 void LetKnow3D()
 {
     (GameObject.Find("MainScript")).SendMessage("CoreServerAccess", (accessible ? "YES" : "NO"));
     if (accessible)
     {
         status = EngineStatus.Sleep; requestFEN = ""; answer = "";
     }
     else
     {
         status = EngineStatus.Error; requestFEN = ""; answer = "";
     }
 }
Пример #27
0
 private void Engine_OnStatusChanged(EngineStatus status)
 {
     if (status == EngineStatus.Running)
     {
         this.timer.Start();
     }
     else
     {
         this.timer.Stop();
         this.UpdateCurrentPos();
     }
 }
Пример #28
0
 protected String get_status_msg()
 {
     try
     {
         EngineStatus s = engine.Status();
         return("Engine Status: " + s.ToString());
     }
     catch (EngineMessageException)
     {
         return("Engine is offline");
     }
 }
Пример #29
0
        public void Stop()
        {
            logger.Trace("Stopped emulator engine");

            if (m_CoreScheduler != null)
            {
                m_TokenSource.Cancel(false);
            }

            OnStatusChange(m_Status, EngineStatus.Stopped);
            m_Status = EngineStatus.Stopped;
        }
Пример #30
0
 public EngineStatus(EngineStatus copyFrom)
 {
     this.position          = copyFrom.position;
     this.rotation          = copyFrom.rotation;
     this.velocity          = copyFrom.velocity;
     this.mass              = copyFrom.mass;
     this.accelerationForce = copyFrom.accelerationForce;
     this.brake             = copyFrom.brake;
     this.brakeDrag         = copyFrom.brakeDrag;
     this.sideVelocityDrag  = copyFrom.sideVelocityDrag;
     this.steer             = copyFrom.steer;
     this.fixedDeltaTime    = copyFrom.fixedDeltaTime;
 }
Пример #31
0
 void Start()
 {
     GetComponent <Rigidbody>().centerOfMass = centerOfMass;
     renderer            = GetComponentsInChildren <Renderer>().Aggregate((r1, r2) => (r1.bounds.extents.x * r1.bounds.extents.y * r1.bounds.extents.z) > (r2.bounds.extents.x * r2.bounds.extents.y * r2.bounds.extents.z) ? r1 : r2);
     longestSide         = Math.Max(renderer.bounds.size.z, renderer.bounds.size.x);
     shortestSide        = Math.Min(renderer.bounds.size.z, renderer.bounds.size.x);
     distanceBetweenRays = (shortestSide / (numberOfSensorRays - 1));
     startTime           = Time.time;
     startPos            = transform.position;
     engineStatus        = EngineStatus.STOP;
     targetSpeed         = maxSpeed;
     currentMotorTorque  = maxMotorTorque;
 }
Пример #32
0
        internal static void Free()
        {
            Critical.NoThrow(() => _user.Core.Log.Info("--- Application shutting down ---"));
            EngineStatus[] status = new EngineStatus[5];

            status[4] = Proxy.Game.Free();
            status[1] = Proxy.Physics.Free();
            status[2] = Proxy.Scripting.Free();
            status[3] = Proxy.Render.Free();
            status[0] = Proxy.Core.Free();

            Critical.NoThrow(() => Memory.Collect(false));
        }
Пример #33
0
    void Update()
    {
        if (!accessible)
        {
            return;
        }

        switch (status)
        {
        case EngineStatus.Sleep:
            if (requestFEN.Length > 0)
            {
                status = EngineStatus.SendRequest;
                SendRequest("GET", url + gameId + "/" + ConvertFEN(requestFEN));
                lastRequestFEN = requestFEN;
                requestFEN     = "";
            }
            break;

        case EngineStatus.SendRequest:
            // Just wait for answer from CoreServer
            // TODO : add timeout
            break;

        case EngineStatus.GetResponse:
            if (answer.Length > 0)
            {
                Debug.Log("Response from CoreServer : " + answer);
                ((TextMesh)GetComponent(typeof(TextMesh))).text = answer;
                (GameObject.Find("MainScript")).SendMessage("EngineAnswer", answer);
                answer = "";
                status = EngineStatus.Sleep;
            }
            break;

        case EngineStatus.Error:
            Debug.Log("No response from CoreServer : you may check URI");
            accessible = false;
            LetKnow3D();
            break;

        case EngineStatus.Ended:
            accessible = false;
            LetKnow3D();
            break;

        default:
            Debug.LogWarning("Update status CoreServer not implemented : " + status.ToString());
            break;
        }
    }
Пример #34
0
        public PonderEngine(System.IO.TextWriter _output)
        {
            this._output = _output;
            useBook      = false;
#if DEBUG
            isDebug = true;
#else
            isDebug = false;
#endif
            openingBookFile = null;
            status          = EngineStatus.Boot;
            //TODO: !!!时间限制
            timeLimit = 60000;
        }
Пример #35
0
 public override void respond(string voiceMessage)
 {
     Boolean gotData = false;
     if (engineData != null)
     {
         gotData = true;
         EngineStatus currentEngineStatus = engineData.getEngineStatusFromCurrent(maxSafeWaterTemp, maxSafeOilTemp);
         switch (currentEngineStatus)
         {
             case EngineStatus.ALL_CLEAR:
                 lastStatusMessage = currentEngineStatus;
                 audioPlayer.playClipImmediately(new QueuedMessage(folderAllClear, 0, null), false);
                 break;
             case EngineStatus.HOT_OIL:
                 // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                 if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                 {
                     lastStatusMessage = currentEngineStatus;
                     audioPlayer.playClipImmediately(new QueuedMessage(folderHotOil, 0, null), false);
                 }
                 break;
             case EngineStatus.HOT_WATER:
                 // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                 if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                 {
                     lastStatusMessage = currentEngineStatus;
                     audioPlayer.playClipImmediately(new QueuedMessage(folderHotWater, 0, null), false);
                 }
                 break;
             case EngineStatus.HOT_OIL_AND_WATER:
                 lastStatusMessage = currentEngineStatus;
                 audioPlayer.playClipImmediately(new QueuedMessage(folderHotOilAndWater, 0, null), false);
                 break;
         }
         audioPlayer.closeChannel();
     }
     if (!gotData)
     {
         audioPlayer.playClipImmediately(new QueuedMessage(AudioPlayer.folderNoData, 0, this), false);
         audioPlayer.closeChannel();
     }
 }
Пример #36
0
        public override void Update(CanvasContext2D context)
        {
            if (_level.Status != RaceStatus.Running && _level.Status != RaceStatus.Crashing) return;

            switch (_engineStatus)
            {
                case EngineStatus.Low:
                    if (_level.Up)
                    {
                        _engineStatus = EngineStatus.Up;
                        _engine.CurrentTime = EngineUpStart;
                    }
                    break;

                case EngineStatus.Up:
                    if (!_level.Up)
                    {
                        _engine.CurrentTime = EngineDownStart + (EngineUpEnd - _engine.CurrentTime);

                        _engineStatus = EngineStatus.Down;
                    }
                    break;

                case EngineStatus.Down:
                    if (_level.Up)
                    {
                        _engine.CurrentTime = EngineUpStart + (EngineDownEnd - _engine.CurrentTime);
                        _engineStatus = EngineStatus.Up;
                    }
                    break;

                case EngineStatus.High:
                    if (!_level.Up)
                    {
                        _engineStatus = EngineStatus.Down;
                        _engine.CurrentTime = EngineDownStart;
                    }
                    break;
            }
        }
Пример #37
0
        /// <summary>
        /// Processes a Line from the cfg file.
        /// If any error is encountered during the process,
        /// the method sets the Engine's errCode and errDetails
        /// private fields accordingly.
        /// Lines are assumed to be in parameter_name = parameter_value form.
        /// Spaces before and after parameter_name and parameter_value are skipped.
        /// Empty lines (after trimming) are skipped.
        /// Lines beginning with '#' (after trimming) are comments, and are skipped;
        /// For other lines:
        ///	  if no '=' is found: error
        ///	  if multiple '=': the first one is the separator; others are bundled
        ///		in the parameter value;
        ///	  if no parameter name or no parameter value is found: error
        ///	  if parameter name is not one of the defined parameters, the line is skipped
        ///	  if multiple lines define the same parameter: the last one overrides the previous ones.
        ///	In general, when a well-formed line is processed, if the parameter_name matches
        ///	the name of one of the parameters defined in the Engine instance, then the
        ///	value extracted from the line is assigned to the Parameter.
        /// </summary>
        /// <param name="line">The line to be processed.</param>
        private void ProcessLine(string line)
        {
            line=line.Trim();
              if(line.Length<=0)  return;

              if(line[0]=='#')	  return;

              StringBuilder sb = new StringBuilder();

              if(line.IndexOf('=')<0)
              {
            status = EngineStatus.FAIL;
            sb.Append("Malformed line detected: no '=' character in the following line:\n");
            sb.Append(line);
            errDetails = sb.ToString();
            errCode=ErrorCode.MALFORMED_LINE;
            return;
              }

              string[] parts = line.Split(new char[] {'='}, 2);

              if(parts[0]!=null)  parts[0]=parts[0].Trim();
              if(parts[1]!=null)  parts[1]=parts[1].Trim();

              if(parts[0]==null || parts[0].Length<=0)
              {
            status = EngineStatus.FAIL;
            sb.Append("Malformed line detected: no <parameter name> in the following line:\n");
            sb.Append(line);
            errDetails = sb.ToString();
            errCode = ErrorCode.MALFORMED_LINE;
            return;
              }
              if(parts[1]==null || parts[1].Length<=0)
              {
            status = EngineStatus.FAIL;
            sb.Append("Malformed line detected: no <parameter values> in the following line:\n");
            sb.Append(line);
            errDetails = sb.ToString();
            errCode = ErrorCode.MALFORMED_LINE;
            return;
              }

              if(!parameters.ContainsKey(parts[0]))	return;
              Parameter p = (Parameter)parameters[parts[0]];
              p.Val=parts[1];
              parameters[parts[0]]=p;
        }
Пример #38
0
        /// <summary>
        /// Resets the Engine instance to its
        /// INIT Status; also reset the error code to OK.
        /// <exception cref="System.ApplicationException">Thrown if the Engine
        /// is currently WORKING.</exception>
        /// </summary>
        public void Reset()
        {
            if(status==EngineStatus.WORKING)
            throw new ApplicationException("CFGLite: [Engine::Reset()]\n"+
              "The Engine is currently Working.");

              status	  = EngineStatus.INIT;
              errCode	  = ErrorCode.OK;
              errDetails  = "";
        }
Пример #39
0
        /// <summary>
        /// Requests the Engine to read the cfg file.
        /// The name of the cfg file should be already set in the Engine's
        /// filename private method (specified in the Engine's constructor,
        /// or in a call to ChangeFile).
        /// <exception cref="System.ApplicationException">Thrown if the Engine
        /// is currently WORKING, or in any state other than INIT or OK.</exception>
        /// </summary>
        /// <returns>EngineStatus.OK if the Engine encountered no erroneous condition;
        /// otherwise EngineStatus.FAIL is returned.</returns>
        public EngineStatus ReadFile()
        {
            if(status==EngineStatus.WORKING)
            throw new ApplicationException("CFGLite: [Engine::ReadFile()]\n"+
              "The Engine is currently Working.");
              if(	status!=EngineStatus.INIT
            &&	status!=EngineStatus.OK	)
            throw new ApplicationException("CFGLite: [Engine::ReadFile()]\n"+
              "The Engine is currently in its "+Engine.EngineStatusName(status)+" state.\n"+
              "The Engine must be reset before a new cfg file may be read.");

              StringBuilder sb = new StringBuilder();
              status=EngineStatus.WORKING;

              filename=filename.Trim();
              if(filename.Length==0)
              {
            sb.Append("The name of the cfg file to be read is null after trimming.");
            errDetails = sb.ToString();
            errCode = ErrorCode.BAD_FILENAME;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              try
              {
            if(!File.Exists(filename))
            {
              sb.Append("The cfg file to be read ('");
              sb.Append(filename);
              sb.Append("')\ndoes not exist, or could not be located.");
              errDetails = sb.ToString();
              errCode=ErrorCode.NO_SUCH_FILE;
              status = EngineStatus.FAIL;
              return EngineStatus.FAIL;
            }
              }
              catch(ArgumentException)
              {
            sb.Append("The name of the cfg file to be read ('");
            sb.Append(filename);
            sb.Append("')\ncaused an 'ArgumentException' exception when the\n");
            sb.Append("CFGLite Engine attempted to verify if the file exists.\n");
            sb.Append("This is generally caused by a null file name or a file name or\n");
            sb.Append("including illegal characters.");
            errDetails = sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              catch(PathTooLongException)
              {
            sb.Append("The name of the cfg file to be read ('");
            sb.Append(filename);
            sb.Append("')\nrepresents a path that is too long for the system.");
            errDetails=sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              catch(NotSupportedException)
              {
            sb.Append("The name of the cfg file to be read ('");
            sb.Append(filename);
            sb.Append("')\ncontains a semi-colon (:).");
            errDetails=sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }

              //File exists.

              StreamReader sr = null;
              try
              {
            sr = File.OpenText(filename);
            string line = "";
            line = sr.ReadLine();
            while(line!=null)
            {
              ProcessLine(line);
              if(status==EngineStatus.FAIL)
            return EngineStatus.FAIL;
              line = sr.ReadLine();
            }//WEND

            CheckParameters();
            if(errCode==ErrorCode.OK)
            {
              status = EngineStatus.OK;
              return EngineStatus.OK;
            }
            else
            {
              status = EngineStatus.FAIL;
              return EngineStatus.FAIL;
            }
              }
              catch(SecurityException)
              {
            sb.Append("The CFGLite Engine could not access the cfg file to be read\n('");
            sb.Append(filename);
            sb.Append("')\nbecause it does not have\n");
            sb.Append("sufficient access rights.");
            errDetails=sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              catch(DirectoryNotFoundException)
              {
            sb.Append("The CFGLite Engine could not access the cfg file to be read\n('");
            sb.Append(filename);
            sb.Append("')\nbecause its parent directory could\n");
            sb.Append("not be located.");
            errDetails=sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              catch(OutOfMemoryException)
              {
            sb.Append("An 'OutOfMemoryException' exception was raised\n");
            sb.Append("while reading the content of the cfg file\n('");
            sb.Append(filename);
            sb.Append("').");
            errDetails = sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              catch(IOException)
              {
            sb.Append("An 'IOException' exception was raised\n");
            sb.Append("while reading the content of the cfg file\n('");
            sb.Append(filename);
            sb.Append("').");
            errDetails = sb.ToString();
            errCode = ErrorCode.SYS_ERROR;
            status = EngineStatus.FAIL;
            return EngineStatus.FAIL;
              }
              finally
              {
            sr.Close();
              }
        }
Пример #40
0
 /// <summary>
 /// Produces a human-readable form of the EngineStatus received
 /// as parameter.
 /// </summary>
 /// <param name="x">The EngineStatus to be transformed to human-readable form.</param>
 /// <returns>The human-readable string form of the EngineStatus x.</returns>
 public static string EngineStatusName(EngineStatus x)
 {
     switch(x)
       {
     case EngineStatus.INIT:		return "Initializing";
     case EngineStatus.WORKING:	return "Working";
     case EngineStatus.OK:		return "Ok";
     case EngineStatus.FAIL:		return "Failed";
     default:  return "Unrecognized Engine Status: "+x.ToString();
       }
 }
Пример #41
0
 // Get best move from CoreServer
 // -------------------------------------------------------------
 void GetResponse()
 {
     status = EngineStatus.GetResponse;
 }
Пример #42
0
 protected override void triggerInternal(Shared lastState, Shared currentState)
 {
     if (CommonData.isRaceStarted)
     {
         if (engineData == null)
         {
             clearState();
         }
         if (!gotBaseline)
         {
             if (currentState.Player.GameSimulationTime > baselineStartSeconds && currentState.Player.GameSimulationTime < baselineFinishSeconds)
             {
                 baselineSamples++;
                 baselineWaterTemp += currentState.EngineWaterTemp;
                 baselineOilTemp += currentState.EngineOilTemp;
             }
             else if (currentState.Player.GameSimulationTime >= baselineFinishSeconds && baselineSamples > 0)
             {
                 gotBaseline = true;
                 baselineOilTemp = baselineOilTemp / baselineSamples;
                 baselineWaterTemp = baselineWaterTemp / baselineSamples;
                 Console.WriteLine("Got baseline engine temps, water = " + baselineWaterTemp + ", oil = " + baselineOilTemp);
             }
         }
         else
         {
             if (currentState.Player.GameSimulationTime > gameTimeAtLastStatusCheck + statusMonitorWindowLength)
             {
                 EngineStatus currentEngineStatus = engineData.getEngineStatus(baselineOilTemp, baselineWaterTemp);
                 if (currentEngineStatus != lastStatusMessage)
                 {
                     switch (currentEngineStatus)
                     {
                         case EngineStatus.ALL_CLEAR:
                             audioPlayer.queueClip(folderAllClear, 0, this);
                             lastStatusMessage = currentEngineStatus;
                             break;
                         case EngineStatus.HOT_OIL:
                             // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                             if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                             {
                                 audioPlayer.queueClip(folderHotOil, 0, this);
                                 lastStatusMessage = currentEngineStatus;
                             }
                             break;
                         case EngineStatus.HOT_WATER:
                             // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                             if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                             {
                                 audioPlayer.queueClip(folderHotWater, 0, this);
                                 lastStatusMessage = currentEngineStatus;
                             }
                             break;
                         case EngineStatus.HOT_OIL_AND_WATER:
                             audioPlayer.queueClip(folderHotOilAndWater, 0, this);
                             lastStatusMessage = currentEngineStatus;
                             break;
                         case EngineStatus.LOW_OIL_PRESSURE:
                             audioPlayer.queueClip(folderLowOilPressure, 0, this);
                             lastStatusMessage = currentEngineStatus;
                             break;
                     }
                 }
                 gameTimeAtLastStatusCheck = currentState.Player.GameSimulationTime;
                 engineData = new EngineData();
             }
             engineData.addSample(currentState);
             if (logTemps)
             {
                 Console.WriteLine(currentState.EngineWaterTemp + ", " + currentState.EngineOilTemp + ", " + currentState.EngineOilPressure);
             }
         }
     }
 }
Пример #43
0
        protected override void triggerInternal(GameStateData previousGameState, GameStateData currentGameState)
        {
            if (engineData == null)
            {
                clearState();
            }
            if (maxSafeWaterTemp == 0) {
                maxSafeWaterTemp = currentGameState.carClass.maxSafeWaterTemp;
            }
            if (maxSafeOilTemp == 0) {
                maxSafeOilTemp = currentGameState.carClass.maxSafeOilTemp;
            }
            if (currentGameState.SessionData.SessionRunningTime > 60 * currentGameState.EngineData.MinutesIntoSessionBeforeMonitoring)
            {
                engineData.addSample(currentGameState.EngineData.EngineOilTemp, currentGameState.EngineData.EngineWaterTemp,
                    currentGameState.EngineData.EngineOilPressure);

                if (currentGameState.SessionData.SessionRunningTime > gameTimeAtLastStatusCheck + statusMonitorWindowLength)
                {
                    EngineStatus currentEngineStatus = engineData.getEngineStatusFromAverage(maxSafeWaterTemp, maxSafeOilTemp);
                    if (currentEngineStatus != lastStatusMessage)
                    {
                        switch (currentEngineStatus)
                        {
                            case EngineStatus.ALL_CLEAR:
                                lastStatusMessage = currentEngineStatus;
                                audioPlayer.queueClip(new QueuedMessage(folderAllClear, 0, this));
                                break;
                            case EngineStatus.HOT_OIL:
                                // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                                if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                                {
                                    lastStatusMessage = currentEngineStatus;
                                    audioPlayer.queueClip(new QueuedMessage(folderHotOil, 0, this));
                                }
                                break;
                            case EngineStatus.HOT_WATER:
                                // don't play this if the last message was about hot oil *and* water - wait for 'all clear'
                                if (lastStatusMessage != EngineStatus.HOT_OIL_AND_WATER)
                                {
                                    lastStatusMessage = currentEngineStatus;
                                    audioPlayer.queueClip(new QueuedMessage(folderHotWater, 0, this));
                                }
                                break;
                            case EngineStatus.HOT_OIL_AND_WATER:
                                lastStatusMessage = currentEngineStatus;
                                audioPlayer.queueClip(new QueuedMessage(folderHotOilAndWater, 0, this));
                                break;
                        }
                    }
                    gameTimeAtLastStatusCheck = currentGameState.SessionData.SessionRunningTime;
                    engineData = new EngineData();
                }
            }
        }
Пример #44
0
 public EngineStatusChangedArgs(EngineStatus oldStatus, EngineStatus newStatus)
 {
     m_OldStatus = oldStatus;
     m_NewStatus = newStatus;
 }
Пример #45
0
        private void SoundLoaded(ElementEvent e)
        {
            _engine.RemoveEventListener("canplaythrough", _playThroughListener, false);
            _engine.AddEventListener("timeupdate", _timeUpdatedListener, false);

            _engineStatus = EngineStatus.Low;
            // _engine.CurrentTime = EngineLowStart;

            _engine.Volume = 0.5f;
            _engine.Play();
        }
Пример #46
0
 /// <summary>
 /// Update engine status
 /// </summary>
 /// <param name="engineId"></param>
 /// <param name="status"></param>
 public void UpdateEngineStatus(string engineId, EngineStatus status)
 {
     throw new NotImplementedException();
 }
Пример #47
0
        /// <summary>
        /// Engine Status and test summary
        /// </summary>
        /// <param name="response">4 Bytes</param>
        /// <returns>EngineStatus</returns>
        public EngineStatus pid0101(string response)
        {
            EngineStatus vehicleStatus = new EngineStatus();

            byte[] troubleBytes = new byte[4];
            for (int byteNum = 0; byteNum < response.Length / 2; byteNum++)
            {
                troubleBytes[byteNum] = byte.Parse(response.Substring(byteNum, 2), System.Globalization.NumberStyles.HexNumber);
            }

            // Trouble Codes
            if (troubleBytes[0] > 0x80)
            {
                vehicleStatus.MILActive = true;
                troubleBytes[0] -= 0x80;
            }
            vehicleStatus.TroubleCodeCount = (int)(troubleBytes[0]);

            // System Tests
            vehicleStatus.Misfire.Available = ((troubleBytes[1] & 0x01) > 0);
            vehicleStatus.Misfire.Passed = ((troubleBytes[1] & 0x10) > 0);

            vehicleStatus.FuelSystem.Available = ((troubleBytes[1] & 0x02) > 0);
            vehicleStatus.FuelSystem.Passed = ((troubleBytes[1] & 0x20) > 0);

            vehicleStatus.Components.Available = ((troubleBytes[1] & 0x04) > 0);
            vehicleStatus.Components.Passed = ((troubleBytes[1] & 0x40) > 0);

            vehicleStatus.Reserved.Available = ((troubleBytes[1] & 0x08) > 0);
            vehicleStatus.Reserved.Passed = ((troubleBytes[1] & 0x80) > 0);

            vehicleStatus.Catalyst.Available = ((troubleBytes[2] & 0x01) > 0);
            vehicleStatus.Catalyst.Passed = ((troubleBytes[3] & 0x01) > 0);

            vehicleStatus.CatalystHeated.Available = ((troubleBytes[2] & 0x02) > 0);
            vehicleStatus.CatalystHeated.Passed = ((troubleBytes[3] & 0x02) > 0);

            vehicleStatus.EvapSystem.Available = ((troubleBytes[2] & 0x04) > 0);
            vehicleStatus.EvapSystem.Passed = ((troubleBytes[3] & 0x04) > 0);

            vehicleStatus.SecondaryAirSystem.Available = ((troubleBytes[2] & 0x08) > 0);
            vehicleStatus.SecondaryAirSystem.Passed = ((troubleBytes[3] & 0x08) > 0);

            vehicleStatus.ACRefrigerant.Available = ((troubleBytes[2] & 0x10) > 0);
            vehicleStatus.ACRefrigerant.Passed = ((troubleBytes[3] & 0x10) > 0);

            vehicleStatus.O2Sensor.Available = ((troubleBytes[2] & 0x20) > 0);
            vehicleStatus.O2Sensor.Passed = ((troubleBytes[3] & 0x20) > 0);

            vehicleStatus.O2SensorHeater.Available = ((troubleBytes[2] & 0x40) > 0);
            vehicleStatus.O2SensorHeater.Passed = ((troubleBytes[3] & 0x40) > 0);

            vehicleStatus.EGRSystem.Available = ((troubleBytes[2] & 0x80) > 0);
            vehicleStatus.EGRSystem.Passed = ((troubleBytes[3] & 0x80) > 0);

            return vehicleStatus;
        }
Пример #48
0
    void Update()
    {
        if (!accessible) return;

        switch (status)
        {
            case EngineStatus.Sleep:
                if (requestFEN.Length > 0)
                {
                    status = EngineStatus.SendRequest;
                    SendRequest("GET", url + gameId + "/" + ConvertFEN(requestFEN));
                    lastRequestFEN = requestFEN;
                    requestFEN = "";
                }
                break;

            case EngineStatus.SendRequest:
                // Just wait for answer from CoreServer
                // TODO : add timeout
                break;

            case EngineStatus.GetResponse:
                if (answer.Length > 0)
                {
                    Debug.Log("Response from CoreServer : " + answer);
                    ((TextMesh)GetComponent(typeof(TextMesh))).text = answer;
                    (GameObject.Find("MainScript")).SendMessage("EngineAnswer", answer);
                    answer = "";
                    status = EngineStatus.Sleep;
                }
                break;

            case EngineStatus.Error:
                Debug.Log("No response from CoreServer : you may check URI");
                accessible = false;
                LetKnow3D();
                break;

            case EngineStatus.Ended:
                accessible = false;
                LetKnow3D();
                break;

            default:
                Debug.LogWarning("Update status CoreServer not implemented : "+status.ToString());
                break;
        }
    }
Пример #49
0
    // Test WWW (renvoi contenu page)
    void Start()
    {
        gameId = "";
        status = EngineStatus.Initializing;
        accessible = false;

        using (StreamReader sr = new StreamReader("config.ini"))
        {
            while (sr.Peek() >= 0)
            {
                url = sr.ReadLine();
            }
            //Debug.Log(url);
        }

        SendRequest("POST", url);
    }
Пример #50
0
 /// <summary>
 /// 引擎异常
 /// </summary>
 /// <param name="ex"></param>
 protected void EngineException(Exception ex)
 {
     EngineStatus = EngineStatus.Stopped;
     FireAtonEngineFaultEvent(this,new EngineFaultEventArgs (ex.Message,ex.StackTrace,EngineName));
     FireAtonEngineStoppedEvent(this,new EngineStoppedEventArgs (EngineName,true,"Engine Process Exception Stop"));
 }
Пример #51
0
        public void ResumeThreads()
        {
            if (m_CoreScheduler != null)
            {
                m_CoreScheduler.ResumeThreads();

                OnStatusChange(m_Status, EngineStatus.Started);
                m_Status = EngineStatus.Started;

                logger.Trace("Execution resumed");
            }
        }
Пример #52
0
    // Send a request to CoreServer
    // -------------------------------------------------------------
    void SendRequest(string method, string uri)
    {
        Debug.Log("SendRequest : " + uri);

        // Launch request
        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
        httpWebRequest.Method = method;

        // Encode SAN info to create the new game
        if (method == "POST") {
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] byte1 = encoding.GetBytes("san=false");
            httpWebRequest.ContentType = "application/x-www-form-urlencoded";
            httpWebRequest.ContentLength = byte1.Length;
            Stream newStream = httpWebRequest.GetRequestStream();
            newStream.Write(byte1, 0, byte1.Length);
        }

        // Get the response from the server
        HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
        Stream receiveStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(receiveStream);

        switch (method) {
            // Create a new game
            case "POST":
                gameId = readStream.ReadToEnd();
                Debug.Log("New game id allocated : " + gameId);
                accessible = true;
                LetKnow3D();
                break;

            // Request for the best move
            case "GET":
                answer = readStream.ReadToEnd();
                if (answer == "NULL") {
                    status = EngineStatus.Error;
                    return; // <=> return;
                }
                GetResponse();
                break;

            // End game
            case "DELETE":
                Debug.Log(response.StatusCode);
                Debug.Log("Game '" + gameId + "' deleted");
                status = EngineStatus.Ended;
                break;
        }

        response.Close();
        readStream.Close();

        return;
    }
Пример #53
0
 /// <summary>
 /// 构造函数
 /// 设定引擎名称
 /// </summary>
 /// <param name="_engineName"></param>
 public AtonGenericEngine(string _engineName)
 {
     EngineName = _engineName;
     EngineStatus = EngineStatus.NotReady;
 }
Пример #54
0
 private void TimeUpdated(ElementEvent e)
 {
     if (_engineStatus == EngineStatus.Low && _engine.CurrentTime >= EngineLowEnd)
     {
         _engine.CurrentTime = EngineLowStart;
     }
     else if (_engineStatus == EngineStatus.High && _engine.CurrentTime >= EngineHighEnd)
     {
         _engine.CurrentTime = EngineHighStart;
     }
     else if (_engineStatus == EngineStatus.Down && _engine.CurrentTime >= EngineDownEnd)
     {
         _engineStatus = EngineStatus.Low;
         _engine.CurrentTime = EngineLowStart;
     }
     else if (_engineStatus == EngineStatus.Up && _engine.CurrentTime >= EngineUpEnd)
     {
         _engineStatus = EngineStatus.High;
         _engine.CurrentTime = EngineHighStart;
     }
 }
Пример #55
0
        public void PauseThreads()
        {
            if (m_CoreScheduler != null)
            {
                m_CoreScheduler.PauseThreads();

                /* Use an async task to keep event handlers from deadlocking this method */
                Task.Factory.StartNew(() =>
                {
                    OnStatusChange(m_Status, EngineStatus.Paused);
                    m_Status = EngineStatus.Paused;
                }, new CancellationTokenSource().Token, TaskCreationOptions.None, TaskScheduler.Default);

                logger.Trace("Execution paused");
            }
        }
Пример #56
0
 /// <summary>
 /// 启动引擎
 /// </summary>
 /// <returns></returns>
 public bool LoadEngine(Action<object> procContext, object param)
 {
     if (EngineStatus != EngineStatus.Running && EngineStatus!= EngineStatus.WaitToStop)
     {
         ProcContext = procContext;
         ProcParameter = param;
         FireAtonEngineInitEvent(this, new EngineInitEventArgs(EngineName));
         EngineStatus = GenericEngine.EngineStatus.Ready;
         return true;
     }
     return false;
 }
Пример #57
0
        /// <summary>
        /// 启动引擎
        /// </summary>
        /// <returns></returns>
        public  bool StartEngine()
        {
            bool result = false;
            if (EngineStatus == EngineStatus.NotReady)
            {
                FireAtonEngineFaultEvent(this, new EngineFaultEventArgs("Engine is not ready","",EngineName));
                return result;
            }
            try
            {
                cancelTokeSource = new CancellationTokenSource();
                task = Async.LongRun(ProcContext,ProcParameter,cancelTokeSource.Token,EngineException);
                EngineStatus = EngineStatus.Running;
                FireAtonEngineStartedEvent(this, new EngineStartedEventArgs(result, EngineName));
                result = true;
            }
            catch(Exception ex)
            {
                string e = ex.StackTrace;
                result = false;
            }

            return result;
        }
Пример #58
0
 /// <summary>
 /// 停止引擎
 /// </summary>
 /// <returns></returns>
 public  bool StopEngine()
 {
     bool result = false;
     if (EngineStatus == EngineStatus.Running)
     {
         cancelTokeSource.Cancel();
         EngineStatus = EngineStatus.Stopped;
         FireAtonEngineStoppedEvent(this, new EngineStoppedEventArgs(EngineName, true, "Engine normaly Stop"));
         result = true;
     }
     else
     {
         result = false;
     }
     return result;
 }
Пример #59
0
        protected virtual void OnStatusChange(EngineStatus oldStatus, EngineStatus newStatus)
        {
            var e = EngineStatusChanged;

            if (e != null)
            {
                EngineStatusChanged(this, new EngineStatusChangedArgs(oldStatus, newStatus));
            }
        }
Пример #60
0
        /// <summary>
        /// Update engine status on the taskbroker
        /// </summary>
        /// <param name="engineId">engine to update the status for</param>
        /// <param name="status">status</param>
        public void UpdateEngineStatus(string engineId, EngineStatus status)
        {
            _log.DebugFormat("Received request to update engine status for engine {0} to {1}", engineId, status.ToString());
            try
            {
                _engineCollection[engineId].Status = status;

                // if an engine wants to register its state as Idle, signal the execute task loop to continue. 
                // It also means the engine has finished processing a task - so let's update the corresponding task's status
                // and notify the client
                if (status == EngineStatus.Idle)
                {
                    _waitTillEngineIdle.Set();
                    RequestHandle request = _taskEngineMap[engineId];
                    request.TaskStatus = TaskStatus.Finished;

                    // notify client
                    _handleCallbackMap[request.Handle].TaskComplete(request);
                    _taskEngineMap.Remove(engineId);
                }
            }
            catch (Exception e)
            {
                _log.ErrorFormat("Error updating engine status for engine {0}: {1}\n{2}", engineId, e.Message, e.StackTrace);
            }
        }