System Layout
In this section we will discuss how to extend a system by describing how to encapsulate or extend functionality in a system. We will discuss how to access data from other systems, a circuit, and compartments. It is important to read the linked references as well as be familiar with the Pulse Common Data Model when extending a system.
Functionality Encapsulation
As discussed in the system documentation, a system's functionality is encapsulated and referenced by several high level methods: Preprocess, Process, and Post Process. Functionality methods are always called during the PreProcess stage. Unless you are creating a new system with a new circuit, you will not need to add any functionality to Process or PostProcess. If you have created a new or extended an existing algorithm to compute new system data, you should add code to push data to the CDM in the systems CalculateVitalSigns
(or similarly named) method called in the Process method.
System should strive to encapsulate a model in a single function that is called from the system preprocess function. You may need to just add code to an existing function, or create a whole new function if this is completely new functionality.
Adding System Member Variables
System Initialization/Setup
Accessing Data from the CDM
Other Systems
Compartments and Circuits
Circuit Data
As described in the system documentation, circuit data can have 3 values: baseline
, current
, and next
. Since we are pulling data from the circuit in our physiology model algorithm functions that are called during PreProcess, to use the latest value of the circuit node/path data, use the next
value (ex. GetNextVolume()
). Each system PreProcess method is called in a set order determined by the engine implementation, and the next
value could have any updates from other systems called previously to the system you are working in. For example, if your system wants to update a node's resistance you should pull the next
value and modify it via a scale factor equation* in order to preserve any changes to this next
value made from a previously called PreProcss method that is called before your systems PreProcess method. The current
value is the value calculated from the circuit solver, you should never modify it, but you can use it as well as the baseline
value as a reference in computing a scale factor to apply to the Next
value. So we always use Next
. If no system modifies it then it is the same as current anyway. It is possible that you may want to modify the baseline, you should only do this ...
*A scale factor equation is where...