/// <summary> /// Notifies that a machine exited a state. /// </summary> /// <param name="machine">AbstractMachine</param> internal override void NotifyExitedState(AbstractMachine machine) { if (base.Configuration.Verbose <= 1) { return; } if (machine is Machine) { string machineState = (machine as Machine).CurrentStateName; base.Log($"<StateLog> Machine '{machine.Id}' exits " + $"state '{machineState}'."); } else if (machine is Monitor) { string liveness = ""; string monitorState = (machine as Monitor).CurrentStateName; if ((machine as Monitor).IsInHotState()) { liveness = "'hot' "; monitorState += "[hot]"; } else if ((machine as Monitor).IsInColdState()) { liveness = "'cold' "; monitorState += "[cold]"; } base.Log($"<MonitorLog> Monitor '{machine.GetType().Name}' " + $"exits {liveness}state '{monitorState}'."); } }
/// <summary> /// Determines whether the specified System.Object is equal /// to the current System.Object. /// </summary> /// <param name="obj">Object</param> /// <returns>Boolean</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } AbstractMachine m = obj as AbstractMachine; if (m == null || this.GetType() != m.GetType()) { return(false); } return(this.Id.Value == m.Id.Value); }
/// <summary> /// Notifies that a machine raised an <see cref="Event"/>. /// </summary> /// <param name="machine">AbstractMachine</param> /// <param name="eventInfo">EventInfo</param> /// <param name="isStarter">Is starting a new operation</param> internal override void NotifyRaisedEvent(AbstractMachine machine, EventInfo eventInfo, bool isStarter) { if (base.Configuration.Verbose <= 1) { return; } if (machine is Machine) { string machineState = (machine as Machine).CurrentStateName; base.Log($"<RaiseLog> Machine '{machine.Id}' raised " + $"event '{eventInfo.EventName}'."); } else if (machine is Monitor) { string monitorState = (machine as Monitor).CurrentStateName; base.Log($"<MonitorLog> Monitor '{machine.GetType().Name}' raised " + $"event '{eventInfo.EventName}'."); } }
/// <summary> /// Notifies that a machine invoked an action. /// </summary> /// <param name="machine">AbstractMachine</param> /// <param name="action">Action</param> /// <param name="receivedEvent">Event</param> internal override void NotifyInvokedAction(AbstractMachine machine, MethodInfo action, Event receivedEvent) { if (base.Configuration.Verbose <= 1) { return; } if (machine is Machine) { string machineState = (machine as Machine).CurrentStateName; base.Log($"<ActionLog> Machine '{machine.Id}' invoked action " + $"'{action.Name}' in state '{machineState}'."); } else if (machine is Monitor) { string monitorState = (machine as Monitor).CurrentStateName; base.Log($"<MonitorLog> Monitor '{machine.GetType().Name}' executed " + $"action '{action.Name}' in state '{monitorState}'."); } }