MATHVisualSimulator
A BPMN2 simulator for MATH
Public Member Functions | Static Public Member Functions
Simulator.Simulator Class Reference

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.

List of all members.

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< BPProcessgetAllProcesses ()
 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< BPNodegetAllNodes ()
 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)

Detailed Description

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.


Member Function Documentation

void Simulator.Simulator.complain ( string  complaint)

Note a complaint from the simulation engine. Typically the UI would display a popup to the user.

Parameters:
complaintThe complaing message
BPFlow Simulator.Simulator.createFlow ( BPNode  src,
BPNode  dest,
BPFlow.flowTypeEnum  type 
)

Create a flow between two existing objects.

Parameters:
srcThe source of the flow
destThe destination of the flow
typeWhat type of flow this is
Returns:
The created flow object

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.

Parameters:
procThe parent process
xmlTypeNameThe BPMN XML type name of the object to be created
nameThe name of the new object
finishUpImmediatelyIf false, the finishUp operation will not be called immediately.
Returns:
The new object

Implements Simulator.IBPNodeTypeLookup.

BPProcess Simulator.Simulator.createProcess ( BPProcess  proc,
string  newProcName 
)

Create a new BPProcess object.

Parameters:
procThe parent process
newProcNameThe name of the new process
Returns:
The new process object

Implements Simulator.IBPNodeTypeLookup.

void Simulator.Simulator.delayNode ( Runner  r,
BPNode  n 
)

Note a token delaying before entering a node.

Parameters:
rThe token
nThe node
void Simulator.Simulator.deleteNode ( BPNode  n)

Delete a node. If this node has attached flows, delete those as well.

Parameters:
nThe node to be deleted

Implements Simulator.IBPNodeTypeLookup.

void Simulator.Simulator.enterNode ( Runner  r,
BPNode  n 
)

Note the entry of a token into a node.

Parameters:
rThe token
nThe node
void Simulator.Simulator.enterOblivion ( Runner  r)

Note the destruction of a token.

Parameters:
rThe token being destroyed
void Simulator.Simulator.exitNode ( Runner  r,
BPNode  n 
)

Note the exit of a token from a node.

Parameters:
rThe token
nThe node
void Simulator.Simulator.finishNode ( BPNode  n)

Finish up a node, after necessary parameters have been entered.

Parameters:
nThe 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.

Parameters:
fgThe geometry object to be affected

Implements Simulator.IBPNodeTypeLookup.

EmpiricalRandomVariableCollection Simulator.Simulator.getAllIndividualResults ( )

Retrieve the individual per-instance results.

Returns:
A variable collection containing the results.
LinkedList<BPNode> Simulator.Simulator.getAllNodes ( )

Retrieve a list of all nodes in the model.

Returns:
A list of BPNode objects.

Implements Simulator.IBPNodeTypeLookup.

EmpiricalRandomVariableCollection Simulator.Simulator.getAllOuterResults ( )

Retrieve the outer, per-trial results.

Returns:
A variable collection containing the results.
LinkedList<BPProcess> Simulator.Simulator.getAllProcesses ( )

Retrieve a list of all Process objects in the model.

Returns:
A list of BPProcess objects
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.

Returns:
A random variable, or null
bool Simulator.Simulator.isFileLoaded ( )

Tell whether a model has been loaded into the simulator.

Returns:
bool Simulator.Simulator.load ( XmlReader  reader)

Load a BPMN 2.0 XML file from a pre-existing XmlReader stream.

Parameters:
readerThe XML reader object
Returns:
True if the load succeeded, false otherwise.
bool Simulator.Simulator.load ( string  bpmnFilename,
bool  doValidation = false 
)

Load a BPMN 2.0 XML file into the simulator.

Parameters:
bpmnFilenameThe filename to load from
doValidationIf 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.
Returns:
BPProcess Simulator.Simulator.loadProcess ( string  filename,
string  page1name,
BPProcess  p 
)

Load a second model into this model as a subprocess.

Parameters:
filenameThe filename of the second model
page1nameThe name to be given to the "Page-1" main process
pThe parent process in the original model
Returns:
The new process object

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).

Parameters:
s
logtype
BPProcess Simulator.Simulator.lookupProcessByName ( string  name)

Locate a BPProcess object contained in the currently loaded model.

Parameters:
nameThe process name to look up
Returns:
The BPProcess object, or null if none were found matching the given name.

Implements Simulator.IBPNodeTypeLookup.

BPResource Simulator.Simulator.lookupResourceByName ( string  name)

Locate a BPResource object contained in the currently loaded model.

Parameters:
nameThe resource name to look up
Returns:
The BPResource object, or null if none were found matching the given name.

Implements Simulator.IBPNodeTypeLookup.

BPNode Simulator.Simulator.lookupSemanticNodeById ( string  id)

Locate a BP node (of any kind) with the given ID.

Parameters:
idThe ID to search for
Returns:
The matchine BPNode, or null if none were found.

Implements Simulator.IBPNodeTypeLookup.

bool Simulator.Simulator.newDocument ( )

Delete the existing model, if any, and replace it with a blank model.

Returns:
True unless something very odd happens.
double Simulator.Simulator.rand ( )

Use the strong pseudo-random number generator to get a random number between 0 and 1.

Returns:
A pseudo-random number on [0,1].
void Simulator.Simulator.registerListener ( ISimulatorListener  newListener)

Register an ISimulatorListener object. This object will receive news of events as they occur in the simulator.

Parameters:
newListenerThe listener
void Simulator.Simulator.renameProcess ( BPProcess  proc,
string  newName 
)

Rename a process, together with its associated callActviity node.

Parameters:
procThe process to be renamed
newNameIts new name

Implements Simulator.IBPNodeTypeLookup.

void Simulator.Simulator.reportError ( RunningProcess  rp,
string  error 
)

Note an error in the running of the process.

Parameters:
rpThe process that encountered the error
errorA string representation of the error
void Simulator.Simulator.resetResults ( )

Delete the results of the previous run.

void Simulator.Simulator.resourceWaitNode ( Runner  r,
int  duration,
BPNode  n 
)

Note that a token has been held at a node due to lack of resources.

Parameters:
rThe token
durationThe duration of the wait
nThe node
void Simulator.Simulator.save ( string  outputFilename,
bool  strictConformance = false 
)

Save the currently loaded model to a BPMN 2.0 XML file.

Parameters:
outputFilenameThe filename to save to
strictConformanceIf 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".

Parameters:
filenameThe filename to save to
formatThe format to save results in
Returns:
True on success, false otherwise
bool Simulator.Simulator.saveResultsAsCSV ( string  filename)

Save all the results (outer and inner) in CSV format.

Parameters:
filenameThe filename to save to
Returns:
True on success, false otherwise
bool Simulator.Simulator.saveResultsAsXls ( string  filename)

Write the results (inner and outer) to an XLS formatted file.

Parameters:
filenameThe filename to write to
Returns:
True on success, false otherwise
void Simulator.Simulator.saveSummary ( string  filename)

Save summary results in text format in the given file. Mostly useful for debugging.

Parameters:
filenameThe filename to save under
void Simulator.Simulator.setVerbose ( bool  v)

Set verbose output.

Parameters:
vTrue 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.

Parameters:
outerThe number of trials
qtyThe number of instances per trial
nHow many instances are permitted to be in the model at any given time
Returns:
True if the simulation succeeds; false if there were too many errors.
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!

Parameters:
outerThe number of trials
qtyThe number of instances per trial
varThe variable to control start time interval
Returns:
True if the simulation was able to complete; false if it bailed due to too many errors.
void Simulator.Simulator.useInfoResource ( Runner  r,
BPNode  n,
string  res,
string  attr,
string  value 
)

Note the consultation of an information resource by a token.

Parameters:
rThe token
nThe node
resThe information resource
attrThe attribute consulted
valueThe 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.

Parameters:
rThe token
nThe node at which the use occurred
resThe resource
amountThe amount of the resource used
totalCostThe 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.

Returns:
True if everything was fine, false otherwise.

The documentation for this class was generated from the following file: