- All Implemented Interfaces:
Runnable
The system class "simulation" may be considered an "application package" oriented towards simulation problems. It has the class "simset" as prefix, and set-handling facilities are thus immediately available.
The concepts defined in "simulation" are explained with respect to a prefixed block, whose prefix part is an instance of the body of "simulation" or of a subclass. The prefixed block instance acts as the head of a quasi-parallel system which may represent a "discrete event" simulation model.
simset class simulation; begin ref (head) SQS; link class EVENT_NOTICE (EVTIME, PROC); long real EVTIME; ref (process) PROC; begin ref (EVENT_NOTICE) procedure suc; suc:- if SUC is EVENT_NOTICE then SUC else none; ref (EVENT_NOTICE) procedure pred; pred:- PRED; procedure RANK_IN_SQS (afore); Boolean afore; begin ref (EVENT_NOTICE) evt; evt:- SQS.last; while evt.EVTIME > EVTIME do evt :- evt.pred; if afore then while evt.EVTIME = EVTIME do evt :- evt.pred; follow(evt) end RANK_IN_SQS; end EVENT_NOTICE; ref (MAIN_PROGRAM) main; ref (EVENT_NOTICE) procedure FIRSTEV; FIRSTEV :- SQS.first; ref (process) procedure current; current :- FIRSTEV.PROC; long real procedure time; time := FIRSTEV.EVTIME; link class process; .................... 12.1; procedure ACTIVAT .................. 12.3; procedure hold ..................... 12.4; procedure passivate ................ 12.4; procedure wait ..................... 12.4; procedure cancel ................... 12.4; process class MAIN_PROGRAM ................. 12.5; procedure accum .................... 12.6; SQS :- new head; main :- new MAIN_PROGRAM; main.EVENT :- new EVENT_NOTICE(0,main); main.EVENT.into(SQS) end simulation;When used as a prefix to a block or a class, "simulation" introduces simulation-oriented features through the class "process" and associated procedures.
The variable SQS refers to a set which is called the "sequencing set", and serves to represent the system time axis. The members of the sequencing set are event notices ranked according to increasing value of the attribute "EVTIME". An event notice refers through its attribute PROC to a "process" object and represents an event which is the next active phase of that object, scheduled to take place at system time EVTIME. There may be at most one event notice referencing any given process object.
The event notice at the lower end of the sequencing set refers to the currently active process object. The object can be referenced through the procedure "current". The value of EVTIME for this event notice is identified as the current value of system time. It may be accessed through the procedure "time".
Note: Since the statements and procedures introduced by "simulation" make implicit use of the sequencing procedures (detach, call and resume) explicit sequencing by these procedures should be done with care.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Nested Class Summary
Nested classes/interfaces inherited from class simula.runtime.RTS_RTObject
RTS_RTObject.ForElt, RTS_RTObject.ForList, RTS_RTObject.ForListIterator, RTS_RTObject.OperationalState, RTS_RTObject.RTS_BOOLEAN_ARRAY, RTS_RTObject.RTS_BOUNDS, RTS_RTObject.RTS_CHARACTER_ARRAY, RTS_RTObject.RTS_INTEGER_ARRAY, RTS_RTObject.RTS_LABEL, RTS_RTObject.RTS_LONG_REAL_ARRAY, RTS_RTObject.RTS_NAME<T>, RTS_RTObject.RTS_REAL_ARRAY, RTS_RTObject.RTS_REALTYPE_ARRAY, RTS_RTObject.RTS_REF_ARRAY<T>, RTS_RTObject.RTS_TEXT_ARRAY, RTS_RTObject.SingleElt<T>, RTS_RTObject.SingleTValElt, RTS_RTObject.StepUntil, RTS_RTObject.UncaughtExceptionHandler, RTS_RTObject.WhileElt<T>, RTS_RTObject.WhileTValElt
-
Field Summary
Modifier and TypeFieldDescriptionfinal RTS_MAIN_PROGRAM
The main program.(package private) final RTS_Ranking
The sequencing set.Fields inherited from class simula.runtime.RTS_ENVIRONMENT
_STARTTIME, CURRENTDECIMALMARK, CURRENTLOWTEN, EXCEPTION_HANDLER, maxint, maxlongreal, maxreal, minint, minlongreal, minreal, simulaReleaseID
Fields inherited from class simula.runtime.RTS_RTObject
_CORUT, _CTX, _CUR, _DL, _INPUT_LINELENGTH, _JTX, _OUTPUT_LINELENGTH, _SL, _STATE, _SYSIN, _SYSOUT, NOTEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription_STM()
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.void
accum
(RTS_RTObject.RTS_NAME<Double> a, RTS_RTObject.RTS_NAME<Double> b, RTS_RTObject.RTS_NAME<Double> c, double d) Utility procedure accum.private void
ACTIVATE3
(boolean REAC, RTS_Process X, boolean BEFORE, RTS_Process Y) Utility: Activate after: (re)Activate x after or after yvoid
ActivateAfter
(boolean REAC, RTS_Process X, RTS_Process Y) Activate after: (re)Activate x after yvoid
ActivateAt
(boolean REAC, RTS_Process X, double T, boolean PRIO) Activate at: (re)activate x at t [ prior ]void
ActivateBefore
(boolean REAC, RTS_Process X, RTS_Process Y) Activate before: (re)Activate x before yvoid
ActivateDelay
(boolean REAC, RTS_Process X, double T, boolean PRIO) Delayed activation: (re)activate x delay t [ prior ]void
ActivateDirect
(boolean REAC, RTS_Process X) Direct activation: (re)activate xvoid
The Procedure cancel.current()
Returns the current process.void
hold
(double time) Procedure hold.boolean
Always true in this class.void
The procedure passivate.(package private) RTS_Process
Special version of 'passivate'private void
Utility: Remove event from SQSprivate void
Utility: Trace Simulation eventprivate RTS_EVENT_NOTICE
Utility: Returns the first event in the SQS.double
time()
Returns the current simulation time.toString()
Returns a string representation of the object.private void
TRACE_ACTIVATE
(boolean REAC, String msg) Utility: Trace (re)activatevoid
The procedure wait.Methods inherited from class simula.runtime.RTS_ENVIRONMENT
_char, _IPOW, _IS, abs, abs, abs, addepsilon, addepsilon, arccos, arcsin, arctan, arctan2, Char, clocktime, cos, cosh, cotan, cputime, datetime, decimalmark, DEFEXCEPTION, digit, discrete, draw, edfix, edit, edit, edit, edit, edit, edtime, entier, Erlang, error, exp, getIntInfo, getTextInfo, giveIntInfo, giveTextInfo, hash, histd, histo, isochar, isorank, letter, linear, ln, loadChar, log10, lowcase, lowerbound, lowten, max, max, max, max, max, min, min, min, min, min, mod, negexp, normal, Poisson, printStaticChain, printThreadList, randint, rank, rem, rts_utility, sign, simulaid, sin, sinh, sqrt, storeChar, subepsilon, subepsilon, tan, tanh, uniform, upcase, upperbound, waitSomeTime
Methods inherited from class simula.runtime.RTS_RTObject
_ASGSTR, _ASGTXT, _GOTO, _JUMPTABLE, _JUMPTABLE, _LABEL, _PRE_LABEL, _PRE_TABLE, _SIM_LABEL, _TXTREL_EQ, _TXTREL_GE, _TXTREL_GT, _TXTREL_LE, _TXTREL_LT, _TXTREL_NE, _VALUE, arrayValue, BBLK, blanks, BPRG, call, call, CONC, copy, detach, detach, detach, doubleValue, EBLK, edObjectAttributes, edObjectIdent, floatValue, getErrorMessage, intValue, isQPSystemBlock, objectTraceIdentifier, objectTraceIdentifier, objectValue, procValue, resume, resume, resume, swapCoroutines, sysin, sysout, terminate_program, TRACE_GOTO, TRF_EQ, TRF_NE
-
Field Details
-
sqs
The sequencing set. -
main_1
The main program.
-
-
Constructor Details
-
RTS_Simulation
Create a new Simulation.- Parameters:
SL
- staticLink
-
-
Method Details
-
isDetachUsed
public boolean isDetachUsed()Always true in this class.- Overrides:
isDetachUsed
in classRTS_RTObject
- Returns:
- true: this object is a QPS System block
-
_STM
Description copied from class:RTS_RTObject
Method representing the Statements in this Block
This method is virtual and must be redefined in blocks.- Overrides:
_STM
in classRTS_Simset
- Returns:
- a pointer to this _RTObject
-
SQS_FIRST
Utility: Returns the first event in the SQS.- Returns:
- the first event in the SQS
-
time
public double time()Returns the current simulation time.long real procedure time; time := FIRSTEV.EVTIME;
- Returns:
- the current simulation time
-
current
Returns the current process.ref (process) procedure current; current :- FIRSTEV.PROC;
- Returns:
- the current process
-
hold
public void hold(double time) Procedure hold.The statement "hold(T)", where T is a long real number greater than or equal to zero, halts the active phase of the currently active process object, and schedules its next active phase at the system time "time + T". The statement thus represents an inactive period of duration T. During the inactive period the reactivation point is positioned within the "hold" statement. The process object becomes suspended.
procedure hold(T); long real T; inspect FIRSTEV do begin if T > 0 then EVTIME:= EVTIME + T; if suc =/= none and then suc.EVTIME <= EVTIME then begin out; RANK_IN_SQS(false); resume(current) end if end hold;
- Parameters:
time
- holding time
-
passivate
public void passivate()The procedure passivate. It stops the active phase of the currently active process object and deletes its event notice. The process object becomes passive. Its next active phase must be scheduled from outside the process object. The statement thus represents an inactive period of indefinite duration. The reactivation point of the process object is positioned within the "passivate" statement.procedure passivate; begin inspect current do begin EVENT.out; EVENT :- none end; if SQS.empty then error("...") else resume(current) end passivate;
-
passivate1
RTS_Process passivate1()Special version of 'passivate'- Returns:
- next Process
-
wait
The procedure wait. It includes the currently active process object in a referenced set, and then calls the procedure "passivate".procedure wait(S); ref (head) S; begin current.into(S); passivate end wait;
- Parameters:
S
- the head of the set
-
cancel
The Procedure cancel.
The statement "cancel(X)", where X is a reference to a process object, deletes the corresponding event notice, if any. If the process object is currently active or suspended, it becomes passive. Otherwise, the statement has no effect. The statement "cancel(current)" is equivalent to "passivate".procedure cancel(X); ref (process) X; if X == current then passivate else inspect X do if EVENT =/= none then begin EVENT.out; EVENT :- none end cancel;
- Parameters:
x
- the argument process
-
accum
public void accum(RTS_RTObject.RTS_NAME<Double> a, RTS_RTObject.RTS_NAME<Double> b, RTS_RTObject.RTS_NAME<Double> c, double d) Utility procedure accum.procedure accum (a,b,c,d); name a,b,c; long real a,b,c,d; begin a:= a + c * (time-b); b:= time; c:= c + d end accum;
A statement of the form "accum (A,B,C,D)" may be used to accumulate the "system time integral" of the variable C, interpreted as a step function of system time. The integral is accumulated in the variable A. The variable B contains the system time at which the variables were last updated. The value of D is the current increment of the step function.- Parameters:
a
- argument ab
- argument bc
- argument cd
- argument d
-
ActivateDirect
Direct activation: (re)activate x- Parameters:
REAC
- signals reactivationX
- the Process to avtivate
-
removeEvent
Utility: Remove event from SQS- Parameters:
EV
- the event- Throws:
RTS_SimulaRuntimeError
- if this action empties SQS.
-
ActivateDelay
Delayed activation: (re)activate x delay t [ prior ]- Parameters:
REAC
- signals reactivationX
- the Process to activateT
- the delay timePRIO
- indicates priority
-
ActivateAt
Activate at: (re)activate x at t [ prior ]- Parameters:
REAC
- signals reactivationX
- the Process to activateT
- the activation timePRIO
- indicates priority
-
ActivateBefore
Activate before: (re)Activate x before y- Parameters:
REAC
- signals reactivationX
- the Process to activateY
- the Process to precede
-
ActivateAfter
Activate after: (re)Activate x after y- Parameters:
REAC
- signals reactivationX
- the Process to activateY
- the Process to succeed
-
ACTIVATE3
Utility: Activate after: (re)Activate x after or after y- Parameters:
REAC
- signals reactivationX
- the Process to activateBEFORE
- indicates before/afterY
- the other process
-
TRACE_ACTIVATE
Utility: Trace (re)activate- Parameters:
REAC
- true if Reactivatemsg
- trace message
-
SIM_TRACE
Utility: Trace Simulation event- Parameters:
msg
- the event message
-
toString
Description copied from class:RTS_RTObject
Returns a string representation of the object.- Overrides:
toString
in classRTS_BASICIO
-