MATHVisualSimulator
A BPMN2 simulator for MATH
|
The Simulator class controls all aspects of simulation (not animation), including loading models from BPMN files, as well as editing and saving functionality. More...
Inherits Simulator.IBPNodeTypeLookup.
Public Member Functions | |
BPProcess | lookupProcessByName (string name) |
Locate a BPProcess object contained in the currently loaded model. | |
BPResource | lookupResourceByName (string name) |
Locate a BPResource object contained in the currently loaded model. | |
BPNode | lookupSemanticNodeById (string id) |
Locate a BP node (of any kind) with the given ID. | |
void | setVerbose (bool v) |
Set verbose output. | |
double | rand () |
Use the strong pseudo-random number generator to get a random number between 0 and 1. | |
void | save (string outputFilename, bool strictConformance=false) |
Save the currently loaded model to a BPMN 2.0 XML file. | |
bool | load (string bpmnFilename, bool doValidation=false) |
Load a BPMN 2.0 XML file into the simulator. | |
bool | load (XmlReader reader) |
Load a BPMN 2.0 XML file from a pre-existing XmlReader stream. | |
EmpiricalRandomVariableCollection | getAllIndividualResults () |
Retrieve the individual per-instance results. | |
EmpiricalRandomVariableCollection | getAllOuterResults () |
Retrieve the outer, per-trial results. | |
bool | saveResultsAsCSV (string filename) |
Save all the results (outer and inner) in CSV format. | |
bool | saveResultsAsXls (string filename) |
Write the results (inner and outer) to an XLS formatted file. | |
bool | saveResults (string filename, string format) |
Save the results in the given format to the named file. Known formats are "csv" and "xls". | |
void | saveSummary (string filename) |
Save summary results in text format in the given file. Mostly useful for debugging. | |
bool | validate () |
Perform a semantic validation of the model. This includes things like flows being connected at both ends. | |
void | resetResults () |
Delete the results of the previous run. | |
IRandomVariable | getStartNodeCharacteristics () |
We expect the model to have only one start node at the outer level. Look at it and, if it has timer start information, return that information. Otherwise, return null. | |
bool | simulate (int outer, int qty, IRandomVariable var) |
Run qty individual cases, with random delay depending on the input from a given random variable. This function is not forgiving of errors in the model that might crash the model! | |
bool | simulate (int outer, int qty, int n) |
Run a simulation of qty cases, n at a time. | |
bool | isFileLoaded () |
Tell whether a model has been loaded into the simulator. | |
void | registerListener (ISimulatorListener newListener) |
Register an ISimulatorListener object. This object will receive news of events as they occur in the simulator. | |
void | log (string s, Logger.LogType logtype) |
Write something to the log file (not to be confused with the "Simulation Log" kept by the UI). | |
void | enterNode (Runner r, BPNode n) |
Note the entry of a token into a node. | |
void | enterOblivion (Runner r) |
Note the destruction of a token. | |
void | exitNode (Runner r, BPNode n) |
Note the exit of a token from a node. | |
void | delayNode (Runner r, BPNode n) |
Note a token delaying before entering a node. | |
void | resourceWaitNode (Runner r, int duration, BPNode n) |
Note that a token has been held at a node due to lack of resources. | |
void | useResource (Runner r, BPNode n, BPResource res, double amount, double totalCost) |
Note the use of a resource by a token. | |
void | useInfoResource (Runner r, BPNode n, string res, string attr, string value) |
Note the consultation of an information resource by a token. | |
void | complain (string complaint) |
Note a complaint from the simulation engine. Typically the UI would display a popup to the user. | |
void | reportError (RunningProcess rp, string error) |
Note an error in the running of the process. | |
BPProcess | createProcess (BPProcess proc, string newProcName) |
Create a new BPProcess object. | |
BPProcess | loadProcess (string filename, string page1name, BPProcess p) |
Load a second model into this model as a subprocess. | |
BPNode | createNode (BPProcess proc, string xmlTypeName, string name=null, bool finishUpImmediately=true) |
Create a non-process node in an existing model. | |
void | finishNode (BPNode n) |
Finish up a node, after necessary parameters have been entered. | |
BPFlow | createFlow (BPNode src, BPNode dest, BPFlow.flowTypeEnum type) |
Create a flow between two existing objects. | |
void | fixFlow (BpmnGeometry fg) |
Fix the geometry of a flow so that it points from its source object to its destination object. | |
void | deleteNode (BPNode n) |
Delete a node. If this node has attached flows, delete those as well. | |
void | renameProcess (BPProcess proc, string newName) |
Rename a process, together with its associated callActviity node. | |
LinkedList< BPProcess > | getAllProcesses () |
Retrieve a list of all Process objects in the model. | |
bool | newDocument () |
Delete the existing model, if any, and replace it with a blank model. | |
LinkedList< BPNode > | getAllNodes () |
Retrieve a list of all nodes in the model. | |
Static Public Member Functions | |
static void | runAllTests (string[] args) |
static void | runTests (string inFile, string outFile) |
The Simulator class controls all aspects of simulation (not animation), including loading models from BPMN files, as well as editing and saving functionality.
Callers can register listeners to be informed of changes that occur during simulation, for animation and logging purposes.
void Simulator.Simulator.complain | ( | string | complaint | ) |
Note a complaint from the simulation engine. Typically the UI would display a popup to the user.
complaint | The complaing message |
Create a flow between two existing objects.
src | The source of the flow |
dest | The destination of the flow |
type | What type of flow this is |
Implements Simulator.IBPNodeTypeLookup.
BPNode Simulator.Simulator.createNode | ( | BPProcess | proc, |
string | xmlTypeName, | ||
string | name = null , |
||
bool | finishUpImmediately = true |
||
) |
Create a non-process node in an existing model.
proc | The parent process |
xmlTypeName | The BPMN XML type name of the object to be created |
name | The name of the new object |
finishUpImmediately | If false, the finishUp operation will not be called immediately. |
Implements Simulator.IBPNodeTypeLookup.
Create a new BPProcess object.
proc | The parent process |
newProcName | The name of the new process |
Implements Simulator.IBPNodeTypeLookup.
Note a token delaying before entering a node.
r | The token |
n | The node |
void Simulator.Simulator.deleteNode | ( | BPNode | n | ) |
Delete a node. If this node has attached flows, delete those as well.
n | The node to be deleted |
Implements Simulator.IBPNodeTypeLookup.
Note the entry of a token into a node.
r | The token |
n | The node |
void Simulator.Simulator.enterOblivion | ( | Runner | r | ) |
Note the destruction of a token.
r | The token being destroyed |
Note the exit of a token from a node.
r | The token |
n | The node |
void Simulator.Simulator.finishNode | ( | BPNode | n | ) |
Finish up a node, after necessary parameters have been entered.
n | The affected node. |
Implements Simulator.IBPNodeTypeLookup.
void Simulator.Simulator.fixFlow | ( | BpmnGeometry | fg | ) |
Fix the geometry of a flow so that it points from its source object to its destination object.
fg | The geometry object to be affected |
Implements Simulator.IBPNodeTypeLookup.
EmpiricalRandomVariableCollection Simulator.Simulator.getAllIndividualResults | ( | ) |
Retrieve the individual per-instance results.
LinkedList<BPNode> Simulator.Simulator.getAllNodes | ( | ) |
Retrieve a list of all nodes in the model.
Implements Simulator.IBPNodeTypeLookup.
EmpiricalRandomVariableCollection Simulator.Simulator.getAllOuterResults | ( | ) |
Retrieve the outer, per-trial results.
LinkedList<BPProcess> Simulator.Simulator.getAllProcesses | ( | ) |
Retrieve a list of all Process objects in the model.
IRandomVariable Simulator.Simulator.getStartNodeCharacteristics | ( | ) |
We expect the model to have only one start node at the outer level. Look at it and, if it has timer start information, return that information. Otherwise, return null.
bool Simulator.Simulator.isFileLoaded | ( | ) |
Tell whether a model has been loaded into the simulator.
bool Simulator.Simulator.load | ( | XmlReader | reader | ) |
Load a BPMN 2.0 XML file from a pre-existing XmlReader stream.
reader | The XML reader object |
bool Simulator.Simulator.load | ( | string | bpmnFilename, |
bool | doValidation = false |
||
) |
Load a BPMN 2.0 XML file into the simulator.
bpmnFilename | The filename to load from |
doValidation | If true, the file should be validated against the BPMN 2.0 specification. Note that the XSD file has to be in the expected place for that to work. |
Load a second model into this model as a subprocess.
filename | The filename of the second model |
page1name | The name to be given to the "Page-1" main process |
p | The parent process in the original model |
Implements Simulator.IBPNodeTypeLookup.
void Simulator.Simulator.log | ( | string | s, |
Logger.LogType | logtype | ||
) |
Write something to the log file (not to be confused with the "Simulation Log" kept by the UI).
s | |
logtype |
BPProcess Simulator.Simulator.lookupProcessByName | ( | string | name | ) |
Locate a BPProcess object contained in the currently loaded model.
name | The process name to look up |
Implements Simulator.IBPNodeTypeLookup.
BPResource Simulator.Simulator.lookupResourceByName | ( | string | name | ) |
Locate a BPResource object contained in the currently loaded model.
name | The resource name to look up |
Implements Simulator.IBPNodeTypeLookup.
BPNode Simulator.Simulator.lookupSemanticNodeById | ( | string | id | ) |
Locate a BP node (of any kind) with the given ID.
id | The ID to search for |
Implements Simulator.IBPNodeTypeLookup.
bool Simulator.Simulator.newDocument | ( | ) |
Delete the existing model, if any, and replace it with a blank model.
double Simulator.Simulator.rand | ( | ) |
Use the strong pseudo-random number generator to get a random number between 0 and 1.
void Simulator.Simulator.registerListener | ( | ISimulatorListener | newListener | ) |
Register an ISimulatorListener object. This object will receive news of events as they occur in the simulator.
newListener | The listener |
void Simulator.Simulator.renameProcess | ( | BPProcess | proc, |
string | newName | ||
) |
Rename a process, together with its associated callActviity node.
proc | The process to be renamed |
newName | Its new name |
Implements Simulator.IBPNodeTypeLookup.
void Simulator.Simulator.reportError | ( | RunningProcess | rp, |
string | error | ||
) |
Note an error in the running of the process.
rp | The process that encountered the error |
error | A string representation of the error |
void Simulator.Simulator.resetResults | ( | ) |
Delete the results of the previous run.
Note that a token has been held at a node due to lack of resources.
r | The token |
duration | The duration of the wait |
n | The node |
void Simulator.Simulator.save | ( | string | outputFilename, |
bool | strictConformance = false |
||
) |
Save the currently loaded model to a BPMN 2.0 XML file.
outputFilename | The filename to save to |
strictConformance | If true, simulation properties and other non-conformant structures will be left out. |
bool Simulator.Simulator.saveResults | ( | string | filename, |
string | format | ||
) |
Save the results in the given format to the named file. Known formats are "csv" and "xls".
filename | The filename to save to |
format | The format to save results in |
bool Simulator.Simulator.saveResultsAsCSV | ( | string | filename | ) |
Save all the results (outer and inner) in CSV format.
filename | The filename to save to |
bool Simulator.Simulator.saveResultsAsXls | ( | string | filename | ) |
Write the results (inner and outer) to an XLS formatted file.
filename | The filename to write to |
void Simulator.Simulator.saveSummary | ( | string | filename | ) |
Save summary results in text format in the given file. Mostly useful for debugging.
filename | The filename to save under |
void Simulator.Simulator.setVerbose | ( | bool | v | ) |
Set verbose output.
v | True for verbose output; false otherwise. |
bool Simulator.Simulator.simulate | ( | int | outer, |
int | qty, | ||
int | n | ||
) |
Run a simulation of qty cases, n at a time.
outer | The number of trials |
qty | The number of instances per trial |
n | How many instances are permitted to be in the model at any given time |
bool Simulator.Simulator.simulate | ( | int | outer, |
int | qty, | ||
IRandomVariable | var | ||
) |
Run qty individual cases, with random delay depending on the input from a given random variable. This function is not forgiving of errors in the model that might crash the model!
outer | The number of trials |
qty | The number of instances per trial |
var | The variable to control start time interval |
void Simulator.Simulator.useInfoResource | ( | Runner | r, |
BPNode | n, | ||
string | res, | ||
string | attr, | ||
string | value | ||
) |
Note the consultation of an information resource by a token.
r | The token |
n | The node |
res | The information resource |
attr | The attribute consulted |
value | The value retrieved |
void Simulator.Simulator.useResource | ( | Runner | r, |
BPNode | n, | ||
BPResource | res, | ||
double | amount, | ||
double | totalCost | ||
) |
Note the use of a resource by a token.
r | The token |
n | The node at which the use occurred |
res | The resource |
amount | The amount of the resource used |
totalCost | The cost of the use |
bool Simulator.Simulator.validate | ( | ) |
Perform a semantic validation of the model. This includes things like flows being connected at both ends.