/// <summary> /// String representation of state is created /// </summary> /// <param name="timeStamp">Time for which the state is generated</param> /// <param name="loggingEngine">The logging engine for which the state is generated</param> /// <param name="controlUnit">The control unit for which the state is generated</param> public LogControlUnitState(DateTime timeStamp, BaseLoggingEngine loggingEngine, ControlUnit controlUnit) { StringBuilder description = new StringBuilder(); description.Append(timeStamp.ToString("MM.dd:HH:mm:ss:fff")).Append(": ").Append(controlUnit.Name).Append(": RAEL length: ").Append(controlUnit.RAEL.Count).Append(", "); foreach (KeyValuePair <Type, HashSet <Entity> > entityType in controlUnit.ControlledEntities) { description.Append(loggingEngine.GetStringRepDefaultEntityType(entityType.Key)).Append(": ,").Append(entityType.Value.Count).Append(", "); } // end foreach foreach (KeyValuePair <string, List <Activity> > activityType in controlUnit.CurrentActivitiesPerType) { description.Append(activityType.Key).Append(": ,").Append(activityType.Value.Count).Append(", "); } // end foreach description.AppendLine(); foreach (ControlUnit child in controlUnit.ChildControlUnits) { LogControlUnitState childState = new LogControlUnitState(timeStamp, loggingEngine, child); description.Append(childState.GetDescription()); } // end foreach _logState = description.ToString(); } // end of LogControlUnitState
/// <summary> /// /// </summary> /// <param name="rootControlUnitState"></param> /// <param name="triggeredEvents"></param> /// <param name="time"></param> public SimulationState(LogControlUnitState rootControlUnitState, IEnumerable <Event> triggeredEvents, DateTime time) { _rootControlUnitState = rootControlUnitState; //_triggeredEvents = triggeredEvents; _timeStamp = time; StringBuilder state = new StringBuilder(); //state.Append(RootControlUnitState.GetDescription()); foreach (Event ev in triggeredEvents) { state.Append(TimeStamp.ToString("MM.dd:HH:mm:ss:fff") + ": "); state.Append(ev.GetDescription()); state.AppendLine(); } // end foreach //state.AppendLine("----------------------------------------------------------------------------------------------------------"); _logState = state.ToString(); } // end of SimulationState
} // end of ParentSimulationModel #endregion //-------------------------------------------------------------------------------------------------- // Methods //-------------------------------------------------------------------------------------------------- #region CreateCurrentState /// <summary> /// Creates a LogControlUnitState and stores it in the simulation result /// </summary> /// <param name="currentEvents">Events triggered at current time</param> /// <param name="time">Current time of simulation execution</param> public void CreateCurrentState(List <Event> eventsTriggered, DateTime time) { LogControlUnitState currentState = new LogControlUnitState(time, this, ParentSimulationModel.RootControlUnit); SimulationResult.Add(new SimulationState(currentState, eventsTriggered, time)); } // end of StoreCurrentState