Skip to content

Commit

Permalink
Refactoring Symu examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorisse committed Oct 16, 2020
1 parent f956e91 commit 45083db
Show file tree
Hide file tree
Showing 121 changed files with 405 additions and 2,625 deletions.
6 changes: 6 additions & 0 deletions SourceCode/Symu/Environment/SymuEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class SymuEnvironment
public SymuEnvironment()
{
IterationResult = new IterationResult(this);
SysDynModel = new SysDynModel();
SysDynModel.SetSimulation(0.25F, 1, Schedule.Type);
}

/// <summary>
Expand All @@ -60,6 +62,9 @@ public SymuEnvironment()
/// </summary>
public IterationResult IterationResult { get; set; }

/// <summary>
/// Models from Symu.SysDyn
/// </summary>
public SysDynModel SysDynModel { get; set; }

/// <summary>
Expand Down Expand Up @@ -215,6 +220,7 @@ public virtual void InitializeIteration()
Messages.Clear();
//At this point, we must use Environment.Organization.MetaNetwork and not Organization.MetaNetwork
MainOrganization = MainOrganizationReference.Clone();
SysDynModel.Clear();
WhitePages.Clear();
IterationResult.Initialize();
SetAgents();
Expand Down
29 changes: 28 additions & 1 deletion SourceCode/Symu/Environment/SysDynModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class SysDynModel
{
private readonly StateMachine _stateMachine;
private readonly List<SysDynVariableAgent> _variableAgent = new List<SysDynVariableAgent>();

public SysDynModel()
{
throw new NotImplementedException();
}
public SysDynModel(string xmlFile)
{
_stateMachine = new StateMachine(xmlFile);
Expand Down Expand Up @@ -71,9 +74,33 @@ public void AddVariableAgent(string variableName, IAgentId agentId, string prope
_variableAgent.Add(new SysDynVariableAgent(variableName, agentId, property));
}

/// <summary>
/// Get the value of a variable by its name
/// </summary>
/// <param name="variableName"></param>
/// <returns></returns>
public float GetVariable(string variableName)
{
return _stateMachine.Variables.GetValue(variableName);
}

/// <summary>
/// Set the simulation
/// </summary>
/// <param name="pauseInterval"></param>
/// <param name="deltaTime"></param>
/// <param name="timeUnits"></param>
public void SetSimulation(float deltaTime, ushort pauseInterval, TimeStepType timeUnits)
{
_stateMachine.Simulation.DeltaTime = deltaTime;
_stateMachine.Simulation.PauseInterval = pauseInterval;
_stateMachine.Simulation.TimeUnits = timeUnits;
}

public void Clear()
{
_stateMachine.Simulation.Clear();
_stateMachine.Results.Clear();
}
}
}
65 changes: 0 additions & 65 deletions SourceCode/Symu/Environment/TimeStepTypeService.cs

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 45083db

Please sign in to comment.