View this PageEdit this PageAttachments to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

SmallDEVS Kernel API

SmallDEVS Kernel allows for class-based as well as for prototype-based object-oriented model construction. Our current focus is put on the prototype-based approach which is described below and which is also supported by visual tools for modeling.

Essential classes for DEVS-based modeling and simulation in SmallDEVS are:
Additionaly, a Petri Net-based DEVS specification is possible (not fully implemented yet). Corresponding classes are:
Below we list protocols intended for model/simulation buiding, editing and inspecting.

MyRepository

MyRepository instance protocol (AKA component protocol) is composed of:
Atomic component protocol:
isAtom returns true/false
isFolder returns true/false
namereturns name of the component
pathNamereturns pathname of the component
parentreturns the hierarcically superordinated component
rootreturns the root component
copyreturns a copy of the component
storeStringreturns storeString of the component
sixxStringreturns sixxString of the component
Folder protocol is composed of the atomic component protocol as well as folder-specific protocol:
componentNamesreturns a list of subcomponents
componentNamed: nreturns the subcomponent named n
addComponent: c named: nadds the subcomponent c under the name named n
removeComponentNamed: nremoves subcomponent named n
renameComponentNamed: n1 to: n2renames component named n1 to n2
addComponents: a adds subcomponents; a is an array of associations name-component
removeComponents: a removes subcomponents; a is an array component names


PrototypeObjectForSimulation

Instance protocol is composed of:
Atomic component protocol,
PrototypeObject protocol:
addSlot: n withValue: vadds a slot named n with vaule v
addSlots: aadds slots; a is an array of associations name-value
addMethod: codeadds method; iths message selector is part of code; code is string
addDelegate: n withValue: vadds delegate (trait) v named n
addDelegates: aadds delegates; a is an array of associations name-delegate
removeSlot: nremoves slot named n
removeSlots: aremoves slots; a is an array of slot names
removeMethod: nremoved method with message selector n
removeDelegate: nremoves delegate slot named n
removeDelegates: aremoves delegates; a is an array of delegate names
slotNamesreturns slot names
methodNamesreturns method names (message selectors)
delegateNamesreturns delegate names
slotValueAt: nreturns value of slot n (also available by sending n to the object)
methodSourceAt: nreturns source code of method with message selctor n
delegateAt: nreturns delegate named n
Comment protocol:
comment: aString sets comment (not implemented here)
commentreturns comment (not implemented here)

AtomicDEVSPrototype

AtomicDEVSPrototype instance protocol is composed of:
PrototypeObjectForSimulation protocol,
BaseDEVS protocol:
inputPortNamesreturns array of names of input ports
outputPortNamesreturns array of names of output ports
addInputPortNamed: nadds input port named n
addOutputPortNamed: nadds output port named n
renameInputPortNamed: n1 to: n2renames input port n1 to n2
renameOutputPortNamed: n1 to: n2renames output port n1 to n2
removeInputPortNamed: nremoves input port named n
removeOutputPortNamed: nremoved output port named n
rootSolverreturns root solver of the model or nil if no root solver is attached
getSimulatorRTwraps the model to a rootSolver; returns the rootSolver
beVerbose: truefalse sets whether to log events of the component
deepVerbose: truefalse sets whether to log events of the component and all its eventual subcomponents
reset initializes model and its simulation-related metadata
Simulation model protocol (intended for use by DEVS methods intTransition, extTransition, timeAdvance, outputFnc added by means of addMethod: m):
self peekFrom: p returns a value of p or nil, usable only by extTranition
self poke: v to: p pokes value v to port p, usable only by outputFnc
self elapsed returns time elapsed since last event
self remaining returns time remainig to the next scheduled event
self slotname: v sets value of slot
self slotname returns value of slot
self reportStream returns reportStream (a stream for log)
self signalStateEvent asynchronously signals to the rootSolver that the component needs to be stepped (intended for external world interface components)

AtomicDEVSTrait

Instances protocol is the same as PrototypeObjectForMyRepository protocol.

CoupledDEVSPrototype

CoupledDEVSPrototype instance protocol is composed of:
BaseDEVS Protocol,
MyRepositoryFolder protocol (providing that components are AtomicDEVSPrototype and/or CoupledDEVSPrototype),
PrototypeObject protocol (it can define methods for implementation of select),
coupling protocol:
couplingsreturns aCouplingSpecification; aCouplingSpecification is a collection of associations from->to where from and to are tuples (componentName, portName); symbol #self is also valid componentName
addCouplings: aCouplingSpecification adds couplings
removeCouplings: aCouplingSpecification removes couplings
positions returns a dictionary of component positions (used by GUI)
positions: p sets positions of components; p is a dictionary of component positions


DEVSRootSolverRT

Instance protocol is composed of:
AbstractSimulator protocol:
stopTimereturns stop time
stopTime: tsets stop time
isRunningreturns true if simulation is running
startstarts simulation
stopstops simulation
resetstops and initializes simulation
doOneStepmakes one step of simulation
asyncStopTime:, asyncStart, asyncStop, asyncReset, asyncStep asynchronous simulation control (action is perforned in a separate thread without waiting)
DEVSRootSolverRT-specific protocol:
rootDEVSreturns root component of the model
rootDEVS: mattaches model to the simulator
rtFactorreturns RT factor
rtFactor: nsets RT factor; 0 indicates no RT factor - fast simulation mode
asyncRtFactor: nasyncronous variant
reportStream: s sets reportStream (log)
beVerbose: truefalse sets whether to log events of the component
deepVerbose: truefalse sets whether to log events of the component and all its eventual subcomponents
and MyRepository atomic component protocol.


PetriNetPrototype (usable in place of Atomic DEVS)

PetriNetPrototype instance protocol is composed of:
Atomic component protocol,
MyRepositoryFolder protocol (providing that components are instnces of PNPlace, PNTransition, PNSyncPort),
Comment protocol
BaseDEVS protocol

PNPlace

PNPlace instance protocol is composed of:
Atomic component protocol,
PNPlace protocol:
addTokens: aBagOfTokensadds tokens to the place (tokens are arbitrary serializable objects)
removeTokens: aBagOfTokensremoves tokens from the place
testTokens: aBagOfTokenstests availability if tokens in the place
removeAllTokensremoves all tokens from the place
contentsreturns a bag of tokens
contents: aBagOfTokenssets contents of the place

PNTransition

PNTransition instance protocol is composed of:
Atomic component protocol,
PNTransition protocol:
preconditions: aConditionSpecificationsets the trancition precondoitions. aConditionSpecification is a set of associations placeName -> code where code is a multiset specification, e.g. 3`x+n`y
conditions: aConditionSpecificationsets the trancition conditions
postconditions: aConditionSpecificationsets the trancition postconditions
guard: codesets guard of the transition (code is a string)
action: codesets action of the transition (code is a string)
preconditionsreturns aConditionSpecification
conditionsreturns aConditionSpecification
postconditionsreturns aConditionSpecification
guardreturns a code of the guard of the transition (code is a string)
actionreturns a code of the action of the transition (code is a string)

PNSyncPort

PNSyncPort instance protocol is composed of:
Transition protocol,
PNSyncPort protocol:
parametres: parametersSpecification parametersSpecification is a string containg names of parameters separated by spaces
parametresreturns parametersSpecification


-----------

Links to this Page