Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/10 01:15:16 (14 years ago)
Author:
swagner
Message:

Implemented logs of engines (#963).

Location:
trunk/sources/HeuristicLab.Core/3.3
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Engine.cs

    r3288 r3289  
    3030  public abstract class Engine : Executable, IEngine {
    3131    [Storable]
     32    protected ILog log;
     33    public ILog Log {
     34      get { return log; }
     35    }
     36
     37    [Storable]
    3238    private Stack<IOperation> executionStack;
    3339    protected Stack<IOperation> ExecutionStack {
     
    4147    protected Engine()
    4248      : base() {
     49      log = new Log();
    4350      executionStack = new Stack<IOperation>();
     51      pausePending = stopPending = false;
     52      timer = new System.Timers.Timer(100);
     53      timer.AutoReset = true;
     54      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
     55    }
     56    [StorableConstructor]
     57    protected Engine(bool deserializing)
     58      : base(deserializing) {
    4459      pausePending = stopPending = false;
    4560      timer = new System.Timers.Timer(100);
     
    5166      if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
    5267      Engine clone = (Engine)base.Clone(cloner);
     68      clone.log = (ILog)cloner.Clone(log);
    5369      IOperation[] contexts = executionStack.ToArray();
    5470      for (int i = contexts.Length - 1; i >= 0; i--)
     
    7187      OnPrepared();
    7288    }
     89    protected override void OnPrepared() {
     90      Log.LogMessage("Engine prepared");
     91      base.OnPrepared();
     92    }
     93
    7394    public override void Start() {
    7495      base.Start();
    7596      ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null);
    7697    }
     98    protected override void OnStarted() {
     99      Log.LogMessage("Engine started");
     100      base.OnStarted();
     101    }
     102
    77103    public override void Pause() {
    78104      base.Pause();
    79105      pausePending = true;
    80106    }
     107    protected override void OnPaused() {
     108      Log.LogMessage("Engine paused");
     109      base.OnPaused();
     110    }
     111
    81112    public override void Stop() {
    82113      base.Stop();
    83114      stopPending = true;
    84115      if (ExecutionState == ExecutionState.Paused) OnStopped();
     116    }
     117    protected override void OnStopped() {
     118      Log.LogMessage("Engine stopped");
     119      base.OnStopped();
     120    }
     121
     122    protected override void OnExceptionOccurred(Exception exception) {
     123      Log.LogException(exception);
     124      base.OnExceptionOccurred(exception);
    85125    }
    86126
  • trunk/sources/HeuristicLab.Core/3.3/Executable.cs

    r3262 r3289  
    5959      executionTime = TimeSpan.Zero;
    6060    }
     61    [StorableConstructor]
     62    protected Executable(bool deserializing) : base(deserializing) { }
    6163
    6264    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r3262 r3289  
    103103    <Compile Include="Attributes\CreatableAttribute.cs" />
    104104    <None Include="HeuristicLabCorePlugin.cs.frame" />
     105    <Compile Include="Log.cs" />
    105106    <Compile Include="Executable.cs" />
    106107    <Compile Include="ExecutionState.cs" />
     108    <Compile Include="Interfaces\ILog.cs" />
    107109    <Compile Include="Interfaces\IExecutable.cs" />
    108110    <Compile Include="Interfaces\IParameterizedNamedItem.cs" />
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IEngine.cs

    r3262 r3289  
    2020#endregion
    2121
    22 using System;
    23 using HeuristicLab.Common;
    24 
    2522namespace HeuristicLab.Core {
    2623  public interface IEngine : IExecutable {
     24    ILog Log { get; }
     25
    2726    void Prepare(IOperation initialOperation);
    2827  }
Note: See TracChangeset for help on using the changeset viewer.