/// <summary> /// Constructor /// </summary> /// <param name="msgListner">The event listner object that receives events</param> /// <param name="msgStore">The object that stores the messages</param> /// <param name="eventBehavior">The behavior object that interacts with incoming events</param> /// <param name="stateMachine">The state machine that interprets the events</param> /// <param name="timer">The periodic timer</param> public SpStateMachineEngine(ISpEventListner msgListner, ISpEventStore msgStore, ISpBehaviorOnEvent eventBehavior, ISpStateMachine stateMachine, ISpPeriodicTimer timer) { WrapErr.ChkParam(msgListner, "msgListner", 50050); WrapErr.ChkParam(msgStore, "msgStore", 50051); WrapErr.ChkParam(eventBehavior, "eventBehavior", 50052); WrapErr.ChkParam(stateMachine, "stateMachine", 50053); WrapErr.ChkParam(timer, "timer", 50054); WrapErr.ToErrorReportException(50055, () => { this.wakeUpAction = new Action(timer_OnWakeup); this.msgReceivedAction = new Action <ISpEventMessage>(this.eventListner_MsgReceived); this.msgListner = msgListner; this.msgStore = msgStore; this.eventBehavior = eventBehavior; this.stateMachine = stateMachine; this.timer = timer; this.driverThread = new Thread(new ThreadStart(this.DriverThread)); this.driverThread.Start(); this.msgListner.MsgReceived += this.msgReceivedAction; this.timer.OnWakeup += this.wakeUpAction; }); }
/// <summary> /// Constructor /// </summary> /// <param name="msgListner">The event listner object that receives events</param> /// <param name="msgStore">The object that stores the messages</param> /// <param name="eventBehavior">The behavior object that interacts with incoming events</param> /// <param name="stateMachine">The state machine that interprets the events</param> /// <param name="timer">The periodic timer</param> public SpStateMachineEngine(ISpEventListner msgListner, ISpEventStore msgStore, ISpBehaviorOnEvent eventBehavior, ISpStateMachine stateMachine, ISpPeriodicTimer timer) { WrapErr.ChkParam(msgListner, "msgListner", 50050); WrapErr.ChkParam(msgStore, "msgStore", 50051); WrapErr.ChkParam(eventBehavior, "eventBehavior", 50052); WrapErr.ChkParam(stateMachine, "stateMachine", 50053); WrapErr.ChkParam(timer, "timer", 50054); WrapErr.ToErrorReportException(50055, () => { this.wakeUpAction = new Action(timer_OnWakeup); this.msgReceivedAction = new Action<ISpEventMessage>(this.eventListner_MsgReceived); this.msgListner = msgListner; this.msgStore = msgStore; this.eventBehavior = eventBehavior; this.stateMachine = stateMachine; this.timer = timer; this.driverThread = new Thread(new ThreadStart(this.DriverThread)); this.driverThread.Start(); this.msgListner.MsgReceived += this.msgReceivedAction; this.timer.OnWakeup += this.wakeUpAction; }); }
/// <summary> /// Dispose managed resources (those with Dispose methods) /// </summary> private void DisposeManagedResources() { Log.DebugEntry(this.className, "DisposeManagedResources"); this.DisposeObject(this.timer, "timer"); this.DisposeObject(this.eventBehavior, "eventBehavior"); this.DisposeObject(this.stateMachine, "stateMachine"); this.DisposeObject(this.msgStore, "msgStore"); this.DisposeObject(this.msgListner, "msgListner"); this.timer = null; this.eventBehavior = null; this.stateMachine = null; this.msgStore = null; this.msgListner = null; }