/// <inheritdoc/> public override void CreateBehaviors(ISimulation simulation) { var behaviors = new BehaviorContainer(Name); if (Parameters.Definition != null && Parameters.Definition.Entities.Count > 0) { // Create our local simulation and binding context to allow our behaviors to do stuff var localSim = new SubcircuitSimulation(Name, simulation, Parameters.Definition, NodeMap); var context = new SubcircuitBindingContext(this, localSim, behaviors); Entities.DependencyInjection.DI.Resolve(simulation, this, behaviors, context); // Run the simulation localSim.Run(Parameters.Definition.Entities); // Allow the behaviors to fetch the behaviors if they want foreach (var behavior in behaviors) { if (behavior is ISubcircuitBehavior subcktBehavior) { subcktBehavior.FetchBehaviors(context); } } } simulation.EntityBehaviors.Add(behaviors); }
/// <inheritdoc/> public override void CreateBehaviors(ISimulation simulation) { var behaviors = new BehaviorContainer(Name); if (Parameters.Definition != null && Parameters.Definition.Entities.Count > 0) { // Create our local simulation and binding context to allow our behaviors to do stuff var localSim = new SubcircuitSimulation(Name, simulation, Parameters.Definition, NodeMap); var context = new SubcircuitBindingContext(this, localSim, behaviors); // Add the necessary behaviors behaviors.Add(new EntitiesBehavior(context)); behaviors.Build(simulation, context) .AddIfNo <ITemperatureBehavior>(context => new Temperature(context)) .AddIfNo <IAcceptBehavior>(context => new Accept(context)) .AddIfNo <ITimeBehavior>(context => new Time(context)) .AddIfNo <IBiasingBehavior>(context => new Biasing(context)) .AddIfNo <IBiasingUpdateBehavior>(context => new BiasingUpdate(context)) .AddIfNo <IFrequencyBehavior>(context => new Frequency(context)) .AddIfNo <IFrequencyUpdateBehavior>(context => new FrequencyUpdate(context)) .AddIfNo <INoiseBehavior>(context => new Subcircuits.Noise(context)); // Run the simulation localSim.Run(Parameters.Definition.Entities); // Allow the behaviors to fetch the behaviors if they want foreach (var behavior in behaviors) { if (behavior is ISubcircuitBehavior subcktBehavior) { subcktBehavior.FetchBehaviors(context); } } } simulation.EntityBehaviors.Add(behaviors); }