void CreateReceiveLogicalMessageList()
        {
            var behaviorList = new BehaviorList<ReceiveLogicalMessageContext>();
            behaviorList.Add<ApplyIncomingMessageMutatorsBehavior>();
            //todo: we'll make this optional as soon as we have a way to manipulate the pipeline
            behaviorList.Add<DataBusReceiveBehavior>();
            behaviorList.Add<LoadHandlersBehavior>();

            foreach (var pipelineOverride in pipelineOverrides)
            {
                pipelineOverride.Override(behaviorList);
            }
            receiveLogicalMessageBehaviorList = behaviorList.InnerList;
        }
        void CreateSendPhysicalMessageList()
        {
            var behaviorList = new BehaviorList<SendPhysicalMessageContext>();

            behaviorList.Add<SerializeMessagesBehavior>();
            behaviorList.Add<MutateOutgoingPhysicalMessageBehavior>();
            behaviorList.Add<DispatchMessageToTransportBehavior>();

            foreach (var pipelineOverride in pipelineOverrides)
            {
                pipelineOverride.Override(behaviorList);
            }

            sendPhysicalMessageBehaviorList = behaviorList.InnerList;
        }
Example #3
0
        /// <summary>
        /// Set up the simulation.
        /// </summary>
        /// <param name="circuit">The circuit that will be used.</param>
        /// <exception cref="ArgumentNullException">circuit</exception>
        /// <exception cref="SpiceSharp.CircuitException">
        /// {0}: No time configuration".FormatString(Name)
        /// or
        /// {0}: No integration method specified".FormatString(Name)
        /// </exception>
        protected override void Setup(Circuit circuit)
        {
            if (circuit == null)
            {
                throw new ArgumentNullException(nameof(circuit));
            }

            // Get base behaviors
            base.Setup(circuit);

            // Get behaviors and configurations
            var config = Configurations.Get <TimeConfiguration>() ?? throw new CircuitException("{0}: No time configuration".FormatString(Name));

            _useIc = config.UseIc;
            Method = config.Method ?? throw new CircuitException("{0}: No integration method specified".FormatString(Name));
            _transientBehaviors = SetupBehaviors <BaseTransientBehavior>(circuit.Entities);

            // Allow all transient behaviors to allocate equation elements and create states
            for (var i = 0; i < _transientBehaviors.Count; i++)
            {
                _transientBehaviors[i].GetEquationPointers(RealState.Solver);
                _transientBehaviors[i].CreateStates(Method);
            }
            Method.Setup(this);

            // TODO: Compatibility - initial conditions from nodes instead of configuration should be removed eventually
            if (config.InitialConditions.Count == 0)
            {
                foreach (var ns in Variables.InitialConditions)
                {
                    _initialConditions.Add(new ConvergenceAid(ns.Key, ns.Value));
                }
            }

            // Set up initial conditions
            foreach (var ic in config.InitialConditions)
            {
                _initialConditions.Add(new ConvergenceAid(ic.Key, ic.Value));
            }
        }
Example #4
0
        /// <summary>
        /// Set up the simulation.
        /// </summary>
        /// <param name="circuit">The circuit that will be used.</param>
        protected override void Setup(EntityCollection circuit)
        {
            circuit.ThrowIfNull(nameof(circuit));

            // Get behaviors and configuration data
            var config = Configurations.Get <BaseConfiguration>().ThrowIfNull("base configuration");

            DcMaxIterations = config.DcMaxIterations;
            AbsTol          = config.AbsoluteTolerance;
            RelTol          = config.RelativeTolerance;

            // Create the state for this simulation
            RealState = new BaseSimulationState
            {
                Gmin = config.Gmin
            };
            _isPreordered  = false;
            _shouldReorder = true;
            var strategy = RealState.Solver.Strategy;

            strategy.RelativePivotThreshold = config.RelativePivotThreshold;
            strategy.AbsolutePivotThreshold = config.AbsolutePivotThreshold;

            // Setup the rest of the circuit.
            base.Setup(circuit);

            // Cache local variables
            _temperatureBehaviors      = EntityBehaviors.GetBehaviorList <ITemperatureBehavior>();
            _loadBehaviors             = EntityBehaviors.GetBehaviorList <IBiasingBehavior>();
            _initialConditionBehaviors = EntityBehaviors.GetBehaviorList <IInitialConditionBehavior>();
            _realStateLoadArgs         = new LoadStateEventArgs(RealState);
            RealState.Setup(Variables);

            // Set up nodesets
            foreach (var ns in config.Nodesets)
            {
                _nodesets.Add(new ConvergenceAid(ns.Key, ns.Value));
            }
        }
Example #5
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                for (x = 0; (x < _specialMovement.Count); x = (x + 1))
                {
                    SpecialMovement.Add(new SpecialMovementBlockBlock());
                    SpecialMovement[x].Read(reader);
                }
                for (x = 0; (x < _specialMovement.Count); x = (x + 1))
                {
                    SpecialMovement[x].ReadChildData(reader);
                }
                for (x = 0; (x < _behaviorList.Count); x = (x + 1))
                {
                    BehaviorList.Add(new BehaviorNamesBlockBlock());
                    BehaviorList[x].Read(reader);
                }
                for (x = 0; (x < _behaviorList.Count); x = (x + 1))
                {
                    BehaviorList[x].ReadChildData(reader);
                }
            }
        void CreateReceivePhysicalMessageList()
        {
            var behaviorList = new BehaviorList<ReceivePhysicalMessageContext>();

            behaviorList.Add<ChildContainerBehavior>();
            behaviorList.Add<MessageHandlingLoggingBehavior>();
            behaviorList.Add<ImpersonateSenderBehavior>();
            behaviorList.Add<AuditBehavior>();
            behaviorList.Add<ForwardBehavior>();
            behaviorList.Add<UnitOfWorkBehavior>();
            behaviorList.Add<ApplyIncomingTransportMessageMutatorsBehavior>();
            behaviorList.Add<RaiseMessageReceivedBehavior>();
            behaviorList.Add<RemoveIncomingHeadersBehavior>();
            behaviorList.Add<ExtractLogicalMessagesBehavior>();
            behaviorList.Add<CallbackInvocationBehavior>();
            behaviorList.Add<ExecuteLogicalMessagesBehavior>();

            foreach (var pipelineOverride in pipelineOverrides)
            {
                pipelineOverride.Override(behaviorList);
            }
            receivePhysicalMessageBehaviorList = behaviorList.InnerList;
        }
Example #7
0
        /// <summary>
        /// Destroys the simulation.
        /// </summary>
        protected override void Unsetup()
        {
            // Remove references
            for (var i = 0; i < _transientBehaviors.Count; i++)
            {
                _transientBehaviors[i].Unsetup(this);
            }
            _transientBehaviors = null;

            // Destroy the integration method
            Method.Unsetup();
            Method = null;

            // Destroy the initial conditions
            AfterLoad -= LoadInitialConditions;
            foreach (var ic in _initialConditions)
            {
                ic.Unsetup();
            }
            _initialConditions.Clear();

            base.Unsetup();
        }
Example #8
0
        /// <summary>
        /// Destroys the simulation.
        /// </summary>
        protected override void Unsetup()
        {
            base.Unsetup();

            // Remove nodeset
            AfterLoad -= LoadNodeSets;
            foreach (var aid in _nodesets)
            {
                aid.Unsetup();
            }
            _nodesets.Clear();

            // Unsetup all behaviors
            for (var i = 0; i < _initialConditionBehaviors.Count; i++)
            {
                _initialConditionBehaviors[i].Unsetup(this);
            }
            for (var i = 0; i < _loadBehaviors.Count; i++)
            {
                _loadBehaviors[i].Unsetup(this);
            }
            for (var i = 0; i < _temperatureBehaviors.Count; i++)
            {
                _temperatureBehaviors[i].Unsetup(this);
            }

            // Clear the state
            RealState.Unsetup();
            RealState          = null;
            _realStateLoadArgs = null;

            // Remove behavior and configuration references
            _loadBehaviors             = null;
            _initialConditionBehaviors = null;
            _temperatureBehaviors      = null;
        }
Example #9
0
        /// <inheritdoc/>
        protected override void CreateBehaviors(IEntityCollection entities)
        {
            base.CreateBehaviors(entities);
            _transientBehaviors  = EntityBehaviors.GetBehaviorList <ITimeBehavior>();
            _acceptBehaviors     = EntityBehaviors.GetBehaviorList <IAcceptBehavior>();
            _truncatingBehaviors = EntityBehaviors.GetBehaviorList <ITruncatingBehavior>();
            _method.Initialize();

            // Set up initial conditions
            var state = GetState <IBiasingSimulationState>();

            _initialConditions.Clear();
            foreach (var ic in TimeParameters.InitialConditions)
            {
                if (state.ContainsKey(ic.Key))
                {
                    _initialConditions.Add(new ConvergenceAid(state.GetSharedVariable(ic.Key), GetState <IBiasingSimulationState>(), ic.Value));
                }
                else
                {
                    SpiceSharpWarning.Warning(this, Properties.Resources.Simulations_ConvergenceAidVariableNotFound.FormatString(ic.Key));
                }
            }
        }
Example #10
0
 public override void Override(BehaviorList <HandlerInvocationContext> behaviorList)
 {
     //add our behavior to the pipeline just before NSB actually calls the handlers
     behaviorList.InsertBefore <InvokeHandlersBehavior, MyExceptionFilteringBehavior>();
 }
 /// <inheritdoc/>
 public virtual void FetchBehaviors(SubcircuitBindingContext context)
 {
     Behaviors = context.GetBehaviors <B>();
 }
Example #12
0
 /// <inheritdoc/>
 public override void FetchBehaviors(SubcircuitBindingContext context)
 {
     base.FetchBehaviors(context);
     _convergenceBehaviors = context.GetBehaviors <IConvergenceBehavior>();
     _state?.Initialize(context.Bridges);
 }
 public void Override(BehaviorList <ReceivePhysicalMessageContext> behaviorList)
 {
     behaviorList.Replace <ExtractLogicalMessagesBehavior, ForwardReceivedMessageToAzureServiceBus>();
 }
        void CreateHandlerInvocationList()
        {
            var behaviorList = new BehaviorList<HandlerInvocationContext>();

            behaviorList.Add<SetCurrentMessageBeingHandledBehavior>();
            behaviorList.Add<AuditInvokedSagaBehavior>();
            behaviorList.Add<SagaPersistenceBehavior>();
            behaviorList.Add<InvokeHandlersBehavior>();

            foreach (var pipelineOverride in pipelineOverrides)
            {
                pipelineOverride.Override(behaviorList);
            }
            handlerInvocationBehaviorList = behaviorList.InnerList;
        }
 public override void Override(BehaviorList <ReceiveLogicalMessageContext> behaviorList)
 {
     //and also hook into to logical receive pipeline to make filtering on message types easier
     behaviorList.Add <MyFilteringAuditBehavior>();
 }
        void CreateSendLogicalMessageList()
        {
            var behaviorList = new BehaviorList<SendLogicalMessageContext>();

            behaviorList.Add<SendValidatorBehavior>();
            behaviorList.Add<SagaSendBehavior>();
            behaviorList.Add<MutateOutgoingMessageBehavior>();
            //todo: we'll make this optional as soon as we have a way to manipulate the pipeline
            behaviorList.Add<DataBusSendBehavior>();

            foreach (var pipelineOverride in pipelineOverrides)
            {
                pipelineOverride.Override(behaviorList);
            }
            sendLogicalMessageBehaviorList = behaviorList.InnerList;
        }
 public override void Override(BehaviorList <HandlerInvocationContext> behaviorList)
 {
     behaviorList.InsertAfter <InvokeHandlersBehavior, SampleBehavior>();
 }
 public void Override(BehaviorList<SendLogicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter<MutateOutgoingMessageBehavior, StreamSendBehavior>();
 }
Example #19
0
 public override void Override(BehaviorList<ReceivePhysicalMessageContext> behaviorList)
 {
     behaviorList.Add<LicenseBehavior>();
 }
 public override void Override(BehaviorList <HandlerInvocationContext> behaviorList)
 {
     behaviorList.InsertBefore <InvokeHandlersBehavior, CaptureChildBuilderBehavior>();
 }
 public void Override(BehaviorList <HandlerInvocationContext> behaviorList)
 {
     behaviorList.InsertBefore <InvokeHandlersBehavior, HandlerTimerBehavior>();
 }
 public virtual void Override(BehaviorList<ReceivePhysicalMessageContext> behaviorList)
 {
 }
Example #23
0
 public StateMachine(IEnumerable <AppBehavior> behaviors)
 {
     _behaviors = new BehaviorList(behaviors);
 }
Example #24
0
 public override void Override(BehaviorList <HandlerInvocationContext> behaviorList)
 {
     behaviorList.Replace <InvokeHandlersBehavior, MyInvokeHandlersBehavior>();
 }
 public override void Override(BehaviorList<HandlerInvocationContext> behaviorList)
 {
     behaviorList.InsertAfter<InvokeHandlersBehavior, SampleBehavior>();
 }
 public override void Override(BehaviorList <ReceivePhysicalMessageContext> behaviorList)
 {
     //we replace the default audit behavior with out own
     behaviorList.Replace <AuditBehavior, MyFilteringAuditBehavior>();
 }
Example #27
0
 public override void Override(BehaviorList <ReceiveLogicalMessageContext> behaviorList)
 {
     behaviorList.InnerList.Insert(0, typeof(RavenUnitOfWorkBehavior));
 }
        void CreateSendLogicalMessagesList()
        {
            var behaviorList = new BehaviorList<SendLogicalMessagesContext>();

            behaviorList.Add<MultiSendValidatorBehavior>();
            behaviorList.Add<MultiMessageBehavior>();
            behaviorList.Add<CreatePhysicalMessageBehavior>();

            foreach (var pipelineOverride in pipelineOverrides)
            {
                pipelineOverride.Override(behaviorList);
            }
            sendLogicalMessagesBehaviorList = behaviorList.InnerList;
        }
 public void Override(BehaviorList <SendPhysicalMessageContext> behaviorList)
 {
 }
Example #30
0
 private void saveBehaviorList(BehaviorList list, int creatureId)
 {
     throw new NotImplementedException();
 }
Example #31
0
 public void Override(BehaviorList <SendPhysicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter <MutateOutgoingPhysicalMessageBehavior, OutgoingHeaderBehavior>();
 }
 public override void Override(BehaviorList <ReceivePhysicalMessageContext> behaviorList)
 {
     behaviorList.Add <LicenseBehavior>();
 }
Example #33
0
 public void Override(BehaviorList <HandlerInvocationContext> behaviorList)
 {
 }
Example #34
0
 /// <inheritdoc />
 public override void FetchBehaviors(SubcircuitBindingContext context)
 {
     base.FetchBehaviors(context);
     _behaviors = context.GetBehaviors <ITimeBehavior>();
 }
Example #35
0
 public void Override(BehaviorList <ReceivePhysicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter <ApplyIncomingTransportMessageMutatorsBehavior, IncomingHeaderBehavior>();
 }
 public void Override(BehaviorList<SendPhysicalMessageContext> behaviorList)
 {
 }
Example #37
0
 public override void Override(BehaviorList <ReceivePhysicalMessageContext> behaviorList)
 {
     behaviorList.Replace <ExtractLogicalMessagesBehavior, MyRawMessageHandler>();
 }
Example #38
0
 /// <inheritdoc />
 protected override void CreateBehaviors(IEntityCollection entities)
 {
     base.CreateBehaviors(entities);
     _noiseBehaviors = EntityBehaviors.GetBehaviorList <INoiseBehavior>();
 }
 public void Override(BehaviorList<ReceiveLogicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter<ApplyIncomingMessageMutatorsBehavior, StreamReceiveBehavior>();
 }
 public void Override(BehaviorList <SendLogicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter <MutateOutgoingMessageBehavior, StreamSendBehavior>();
 }
 public void Override(BehaviorList<SendPhysicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter<MutateOutgoingPhysicalMessageBehavior, OutgoingHeaderBehavior>();
 }
 public void Override(BehaviorList <ReceiveLogicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter <ApplyIncomingMessageMutatorsBehavior, StreamReceiveBehavior>();
 }
 public void Override(BehaviorList<ReceiveLogicalMessageContext> behaviorList)
 {
 }
Example #44
0
 public void Override(BehaviorList <ReceiveLogicalMessageContext> behaviorList)
 {
 }
 public void Override(BehaviorList<HandlerInvocationContext> behaviorList)
 {
 }
Example #46
0
 public void Override(BehaviorList <SendLogicalMessagesContext> behaviorList)
 {
 }
 public void Override(BehaviorList<SendLogicalMessagesContext> behaviorList)
 {
 }
 public void Override(BehaviorList<ReceivePhysicalMessageContext> behaviorList)
 {
     behaviorList.InsertAfter<ApplyIncomingTransportMessageMutatorsBehavior, IncomingHeaderBehavior>();
 }
 public void Override(BehaviorList<HandlerInvocationContext> behaviorList)
 {
     behaviorList.InsertBefore<InvokeHandlersBehavior, HandlerTimerBehavior>();
 }