Day 4

50
—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-1 Day 4 Section 7 - Simulation Control User Interface Forms Efficiency Monitoring User-Defined Distributions Interrupting and Suspending Processes Exercise 7 Section 8 - Process Activation Externally Activated Processes Exercise 8

description

Day 4. Section 7 - Simulation Control User Interface Forms Efficiency Monitoring User-Defined Distributions Interrupting and Suspending Processes Exercise 7 Section 8 - Process Activation Externally Activated Processes Exercise 8. F. Section 7 - Simulation Control. - PowerPoint PPT Presentation

Transcript of Day 4

Page 1: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-1

Day 4

• Section 7 - Simulation Control– User Interface Forms– Efficiency– Monitoring – User-Defined Distributions– Interrupting and Suspending Processes– Exercise 7

• Section 8 - Process Activation– Externally Activated Processes– Exercise 8

Page 2: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-2

Section 7 - Simulation Control

Part 1 - User Interface Forms

Page 3: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-3

User Interface Forms

• In SIMLAB, SELECT PROBLEMD and run the model. Stop when the user interface form appears.

• In order to display user interface forms, first build the form with the SIMDRAW editor and save the form to a graphics.sg2 file with an appropriate name (e.g. “FORMNAME.FRM").

• To display the form, load “FORMNAME.FRM" and initialize a pointer variable to its address. i.e.

Define .FORM.PTR as a pointer variableShow .FORM.PTR with “FORMNAME.FRM"

• Now the variable .FORM.PTR contains the address of the form displayed on the screen.

Page 4: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-4

Interacting with Forms

• To initiate an interaction with a form, use the system function accept.f

• Accept.f requires two arguments– address of the form (e.g. .FORM.PTR)– control routine (e.g. 'FORM.CTRL')

• Since accept.f is a function, it returns a text value equal to the last terminating button Reference Name selected by the user in the form. (Note: When the form is built, each field within the form has a Reference Name.)

Define .FIELD.ID as a text variable.FIELD.ID = accept.f (.FORM.PTR, 'FORM.CTRL')

• The control routine, FORM.CTRL is called by the function accept.f, not the user. The control routine may be 0.

Page 5: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-5

Accessing Values in the Forms

• To access the values in a form, use the system function dfield.f

• dfield.f requires two arguments– Reference Name (e.g. "RUN LENGTH")– address of form (e.g. .FORM.PTR)

• Since dfield.f is a function, it returns a pointer value equal to the address of the fields within the form.

Define .FIELD.PTR as a pointer variable.FIELD.PTR = dfield.f("RUN LENGTH", .FORM.PTR)

• Now the pointer, .FIELD.PTR, can be used as a subscript to gain access to the attributes of the field, "RUN LENGTH".

Page 6: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-6

Field Attributes

• To access the field values, use the field attributes:

ddval.a: numeric value associated with .FIELD.PTRdtval.a: text value associated with .FIELD.PTRdary.a: array pointer associated with .FIELD.PTR

• For example:

.FIELD.PTR = dfield.f("RUN LENGTH", .FORM.PTR)RUN.LENGTH = ddval.a(.FIELD.PTR)

or

RUN.LENGTH = ddval.a(dfield.f("RUN LENGTH", .FORM.PTR))

Page 7: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-7

1 Routine INITIALIZE 2 3 Define .FORM as a pointer variable 4 Define .FIELD as a text variable 5 6 '' Display the form and get run data from the user 7 8 Show .FORM with "INPUT.FRM" 9 Let .FIELD = accept.f(.FORM, 'FORM.CTRL') 10 11 '' Create the tug and docks 12 13 Create every TUG(1) 14 Let U.TUG(1) = NBR.TUGS 15 Create every DOCK(1) 16 Let U.DOCK(1) = NBR.DOCKS 17 18 '' Warning elimination 19 20 Let .FIELD = .FIELD 21 22 End ''INITIALIZE

Page 8: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-8

1 Routine FORM.CTRL 2 3 Given 4 .FIELD, 5 .FORM 6 Yielding 7 .STATUS 8 9 '' Control routine for the input form 10 11 Define .FORM as a pointer variable 12 Define .FIELD as a text variable 13 Define .STATUS as an integer variable 14 15 Select case .FIELD 16 17 Case "RUN" 18 Let RUN.LENGTH = ddval.a(dfield.f("RUN LENGTH", .FORM)) 19 Let NBR.DOCKS = 3 20 Let NBR.TUGS = 1 21 Return 22 23 Case "QUIT" 24 Stop 25 26 Default 27 28 Endselect ''.FIELD 29 30 '' Warning elimination 31 Let .STATUS = .STATUS 32 33 End ''FORM.CTRL

Page 9: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-9

Section 7 - Simulation Control

Part 2 - Efficiency

Page 10: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-10

Saving Memory - Field Packing

• An alpha variable is one byte and will never occupy a full computer word. Integers are frequently less than a full word. You can save memory by packing two or more variables in one word. (All of the following code is in the Preamble)

Every HUMAN has a HMN.NAME, a HMN.AGE and ''0 to 99 a HMN.SEX ''M or F

Every HUMAN has a HMN.NAME, a (HMN.AGE (1/2) and HMN.SEX (3/4))

Page 11: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-11

Saving Memory - Field Packing (continued)

Every HUMAN has a HMN.NAME, a HMN.AGE (1/2) in word 1, a HMN.SSN, a HMN.SEX (3/4) in word 1

• Works only for attributes of temporary entities

Page 12: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-12

Saving Memory - Bit Packing

• Some integer values take less than a full byte.

Every NETWORK has a NWK.SEMAPHORE.1, ''0 to 1 a NWK.SEMAPHORE.2, a NWK.SEMAPHORE.3, a NWK.SEMAPHORE.4 and a NWK.NUMBER ''0 to 99

Every NETWORK has a (NWK.SEMAPHORE.1 (1-1), NWK.SEMAPHORE.2 (2-2), NWK.SEMAPHORE.3 (3-3), NWK.SEMAPHORE.4 (4-4) and NWK.NUMBER (9-32))

Page 13: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-13

Saving Memory - Intrapacking

• You can pack attributes of permanent entities in a manner similar to that for field packing.

Every AIRPORT has an APT.STATUS (*/4) ''O OR C

Page 14: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-14

Saving Memory - Eliminating Attributes and Routines

• Every set definition

– Assigns 3 attributes to the owner– Assigns 3 attributes to each member– Copies 7 routines for filing and removing members

• File first (FF)• File last (FL)• File before (FB)• File after (FA)

• Remove first (RF)• Remove last (RL)• Remove specific (RS)

Page 15: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-15

Saving Memory - Eliminating Attributes and Routines (continued)

• Suppose you have a set where you file members, never remove them and always search the set from start to finish -- a read only FIFO set.

• You don't need the predecessor and membership attributes nor the remove routines. Further, you only need the file last routine.

Every SHIP belongs to a FLEET

Define FLEET as a FIFO set without P and M attributes and without FF, FB, FA and R routines

Page 16: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-16

Saving Memory - Equivalencing

• Suppose a ship can be in a dock waiting line or a tug waiting line but never at the same time.

Every SHIP has a P.DOCK.WAITING.LINE in word 1, a P.TUG.WAITING.LINE in word 1, a S.DOCK.WAITING.LINE in word 2, a S.TUG.WAITING.LINE in word 2, a M.DOCK.WAITING.LINE in word 3, a M.TUG.WAITING.LINE in word 3, belongs to a DOCK.WAITING.LINE and belongs to a TUG.WAITING.LINE

• This makes P.DOCK.WAITING.LINE and P.TUG.WAITING.LINE synonyms or equivalent.

Page 17: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-17

Section 7 - Simulation Control

Part 3 - Monitoring

Page 18: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-18

Monitoring

• When something is about to happen or has just happened, SIMSCRIPT II.5 can intercept control and pass it to a subroutine that you write. When done, control returns to where it came from.

Accumulate or tallyGraphicsEntitiesVariables

• Suppose a communications center keeps a number of circuits in reserve. When the number of waiting messages exceeds a certain level, it brings another circuit up.

Page 19: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-19

Monitoring (continued)

PreambleProcesses include MESSAGEAfter activating MESSAGE call CIRCUIT.CHECKER

End ''Preamble

Routine CIRCUIT.CHECKER Given .MSG, ''Pointer to current message .TIME ''time.a

If N.Q.CIRCUIT(1) > 10 Add 3 to U.CIRCUIT(1) Endif ''N.Q.CIRCUIT(1)

End ''CIRCUIT.CHECKER

Page 20: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-20

Monitoring (continued)

• Can use before or after with

create or destroy entitiesactivate or cancel processesfile or remove from sets

• but not

before create or after destroy

• SIMSCRIPT II.5 passes arguments to the routine including the address of the process notice. (See p. 80 in Reference Manual for details – Page 98 of the acrobat reader)

Page 21: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-21

Monitoring (continued)

• Can monitor assignment of variables

• Can pass control before getting a value from a variable

Preamble Define INVENTORY as a real variable monitored on the rightEnd

– In another routine

Let .CURRENT.INVENTORY = INVENTORY

Right routine INVENTORY Move to .LOCAL.VARIABLE <STATEMENTS> Return with .EXPRESSIONEnd ''Right routine INVENTORY

Page 22: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-22

Monitoring (continued)

• Can pass control before receiving a new value

Preamble Define FLOW.RATE as a real variable monitored on the leftEnd ''Preamble

– In another routine

Let FLOW.RATE = 3000

Left routine FLOW.RATE Enter with .LOCAL.VARIABLE <STATEMENTS> Move from .EXPRESSIONEnd ''Left routine FLOW.RATE

Page 23: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-23

Section 7 - Simulation Control

Part 4 - User-Defined Distributions

Page 24: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-24

Arbitrary Probability Distributions

Message Priority Probability of Occurrence

5 .05 4 .20 3 .40 2 .30 1 .05

Page 25: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-25

Arbitrary Probability Distributions (continued)

• Four steps:

Preamble The system has a MESSAGE.PRIORITY random step variable Define MESSAGE.PRIORITY as an integer stream 9 variableEnd

– Outside the Preamble

Open unit 10 for input, name = "message.dat"Use unit 10 for input

Read MESSAGE.PRIORITY

Let .PRIORITY = MESSAGE.PRIORITY

.05 5 .20 4 .40 3 .30 2 .05 1 *

Page 26: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-26

f.message.priority

prob.aivalue.a

s.message.priority

random.e

.055

.254

.653

.952

1.01

If MESSAGE.PRIORITY were realivalue.a would become rvalue.a

Probabilities are stored a cumulative valuesProbabilities can safely sum to 1.0 + or - .005

Arbitrary Probability Distributions (continued)

Page 27: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-27

5 15 25 35 45 55 650

1.0

Salary

15,00020,00030,00040,00050,00060,000

Probability of Occurrence

0.0 0.10 0.40 0.30 0.15 0.05

Arbitrary Probability Distributions (continued)

Page 28: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-28

Arbitrary Probability Distributions (continued)

• Same four steps:

Preamble Permanent entities PROFESSION Every PROFESSION has a SALARY.DISTRIBUTION random linear variable Define SALARY.DISTRIBUTION as a real stream 6 variableEnd

– Outside the Preamble

For each PROFESSION do Read SALARY.DISTRIBUTION(PROFESSION)Loop

LET .SALARY = SALARY.DISTRIBUTION(PROFESSION)

.0 15000 .10 20000 .50 30000 .80 40000

.95 50000 1.0 60000 *

Page 29: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-29

Section 7 - Simulation Control

Part 5 - Interrupting Processes

Page 30: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-30

Interrupting Processes

• Sometimes one process wants to interrupt another process

– Cause it to pause– Preempt a resource

Page 31: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-31

Interrupting Processes (continued)Process MESSAGE

For each .OLD.MESSAGE in the MESSAGE.SET with STATUS(.OLD.MESSAGE) = ..IN.TRANSMISSION do Compute .MIN.MSG as the minimum(.OLD.MESSAGE)

of PRIORITY(.OLD.MESSAGE) Loop ''each .OLD.MESSAGE in the MESSAGE.SET

If PRIORITY(.MIN.MSG) < PRIORITY(MESSAGE) Interrupt MESSAGE called .MIN.MSG Call TRANSMIT.MESSAGE Resume the MESSAGE called .MIN.MSG

Endif ''PRIORITY(.MIN.MSG) < PRIORITY(MESSAGE)

Page 32: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-32

Interrupt & Resume

• Interrupt– The process being interrupted must be in the event set

(work, wait or activate)

– User must be file interrupted process in another set because interrupt will remove the process notice from the event set

– System will change time.a to the time remaining until the next activity

• Let time.a = time.a - time.v

• Resume– System will reset time.a = time.a + time.v

– Refiles the process notice in the event set

Page 33: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-33

Suspend & Reactivate Processes

If PRIORITY(.MIN.MSG) >= PRIORITY(MESSAGE)

Let STATUS(MESSAGE) = ..WAITING

File MESSAGE in MESSAGE.SETSuspendCall TRANSMIT.MESSAGE

Endif ''PRIORITY(.MIN.MSG) >= PRIORITY(MESSAGE)

End ''MESSAGE

• In another routine where suspended messages can be identified:

Reactivate the MESSAGE now

Page 34: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-34

Suspend & Reactivate Processes (continued)

• Suspend:

– Process is active

– Process notice is not in event set

– Process notice was filed in a set before suspending itself

– Another process reactivated it -- put it back in event set

Page 35: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-35

Canceling Processes

• Relinquish resources and remove notice from sets

Every MESSAGE has a FUTURE

Interrupt MESSAGELet FUTURE(MESSAGE) = ..NONELet time.a(MESSAGE) = 0Resume MESSAGE

If FUTURE(MESSAGE) = ..NONERemove MESSAGE from MESSAGE.SET''Relinquish any resources”Return

Endif ''FUTURE(MESSAGE) = ..NONE

Page 36: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-36

This page is intentionally blank

Page 37: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-37

Exercise 7

The Communications CenterC:\Program Files\Simscript3\models\MessageG

Page 38: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-38

The Communications Center

• Project located in MessageG subdirectory– Messages arrive at a communications center about 15

seconds apart.– If a circuit is free, the message is sent. If a circuit is not

free and if the message priority is flash or immediate, the center will look for a message of lower priority and interrupt it to send the higher priority message. The interrupted message will be retransmitted in its entirety.

– If a message cannot interrupt another message, it waits to be transmitted.

• Modifications– Make sure you understand how the user interface is set

up. Try improving the graphics by modifying the clock– Why does the graph end at 30 for messages created

and interrupted, but not for waiting messages?

Page 39: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-39

1 Preamble 2 3 '' The Communications Center Model - CACI Products Company 4 '' Demonstrates the use of Interrupt and Suspend 5 '' Graphics version of program demonstrating trace plot, level meter, clock 6 '' files: MESSAGEG.SRC, MESSAGE.DAT, MENU.FRM, 7 '' MESSAGES.GRF, BUSY.GRF, CLOCK.GRF 8 9 Normally mode is undefined 10 11 The system has a MESSAGE.PRIORITY random step variable 12 Define MESSAGE.PRIORITY as an integer stream 9 variable 13 14 Permanent entities 15 Every COMM.CENTER owns a MESSAGE.SET 16 17 Processes include 18 MESSAGE.GENERATOR 19 20 Every MESSAGE has 21 a PRIORITY, 22 a LENGTH, 23 a STATUS and 24 belongs to a MESSAGE.SET 25 26 Define PRIORITY, STATUS as integer variables 27 Define LENGTH as a real variable 28 Define MESSAGE.SET as a set ranked by high PRIORITY 29 30 Define RUN.LENGTH, 31 NUMBER.BUSY.CIRCUITS, 32 NUMBER.OF.MESSAGES, 33 NUMBER.OF.MESSAGES.INTERRUPTED, 34 TOTAL.NUMBER.OF.CIRCUITS 35 as integer variables

Page 40: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-40

36 37 Define CLOCKTIME as a real variable 38 39 Display variables include 40 CLOCKTIME, 41 NUMBER.BUSY.CIRCUITS, 42 NUMBER.OF.MESSAGES, 43 NUMBER.OF.MESSAGES.INTERRUPTED, 44 N.MESSAGE.SET 45 46 Define ..FLASH to mean 5 47 Define ..IMMEDIATE to mean 4 48 Define ..PRIORITY to mean 3 49 Define ..ROUTINE to mean 2 50 Define ..DEFERRED to mean 1 51 52 Define ..IN.TRANSMISSION to mean 1 53 Define ..SUSPENDED to mean 2 54 Define ..INTERRUPTED to mean 3 55 56 Define minutes to mean units 57 Define seconds to mean /60 minutes 58 59 Define ..TEXT.PAUSE to mean Read as / using unit 5 60 61 End ''Preamble

Page 41: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-41

1 Main 2 3 Call INITIALIZE 4 Call SET.GRAPHICS 5 6 Activate a MESSAGE.GENERATOR now 7 Start simulation 8 Call REPORT 9 ..TEXT.PAUSE 10 11 End ''Main

1 Routine INITIALIZE 2 3 Open unit 10 for input, name "MESSAGE.DAT" 4 Use unit 10 for input 5 Read MESSAGE.PRIORITY 6 7 Create every COMM.CENTER(1) 8 Let COMM.CENTER = 1 9 10 End ''INITIALIZE

Page 42: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-42

1 Routine SET.GRAPHICS 2 3 Define .FORM as a pointer variable 4 Define .FIELD as a text variable 5 6 Show .FORM with "MENU.FRM" 7 Let .FIELD = accept.f(.FORM, 'FORM.CTRL') 8 9 Show CLOCKTIME with "CLOCK.GRF" 10 Show NUMBER.BUSY.CIRCUITS with "BUSY.GRF" 11 Show NUMBER.OF.MESSAGES, 12 N.MESSAGE.SET, 13 NUMBER.OF.MESSAGES.INTERRUPTED 14 with "MESSAGES.GRF" 15 16 Let .FIELD = .FIELD 17 18 Let timesync.v = 'CLOCK.UPDATE' 19 Let timescale.v = 100 20 21 End ''SET.GRAPHICS

1 Routine CLOCK.UPDATE 2 Given 3 .PROPOSED.TIME.V 4 Yielding 5 .NEW.TIME.V 6 7 Define .PROPOSED.TIME.V and 8 .NEW.TIME.V 9 as double variables 10 11 Let .NEW.TIME.V = .PROPOSED.TIME.V 12 Let CLOCKTIME = .PROPOSED.TIME.V 13 14 End ''CLOCK.UPDATE

Page 43: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-43

1 Routine FORM.CTRL 2 3 Given 4 .FIELD.ID, 5 .FORM 6 Yielding 7 .STATUS 8 9 Define .FIELD.ID as a text variable 10 Define .FORM as a pointer variable 11 Define .STATUS as an integer variable 12 13 Select case .FIELD.ID 14 15 Case "RUN" 16 Let TOTAL.NUMBER.OF.CIRCUITS = ddval.a(dfield.f("CIRCUITS", .FORM)) 17 Let RUN.LENGTH = int.f(ddval.a(dfield.f("RUN LENGTH", .FORM))) 18 Return 19 20 Case "QUIT" 21 Stop 22 23 Default 24 25 Endselect ''.FIELD.ID 26 27 Let .STATUS = .STATUS 28 29 End ''FORM.CTRL

Page 44: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-44

1 Process MESSAGE.GENERATOR 2 3 Until time.v >= RUN.LENGTH 4 Do 5 6 Activate a MESSAGE now 7 Let PRIORITY(MESSAGE) = MESSAGE.PRIORITY 8 Let LENGTH(MESSAGE) = uniform.f(.25, 4.0, 1) 9 File MESSAGE in the MESSAGE.SET(COMM.CENTER) 10 11 Add 1 to NUMBER.OF.MESSAGES 12 13 Wait exponential.f(15, 2) seconds 14 15 Loop ''time.v >= RUN.LENGTH 16 17 End ''MESSAGE.GENERATOR

Page 45: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-45

1 Process MESSAGE 2 3 Define .MIN.MSG, 4 .OLD.MESSAGE as pointer variables 5 6 If NUMBER.BUSY.CIRCUITS < TOTAL.NUMBER.OF.CIRCUITS 7 8 Call TRANSMIT.MESSAGE 9 Given 10 MESSAGE 11 Else 12 13 For each .OLD.MESSAGE in the MESSAGE.SET(COMM.CENTER) 14 with STATUS(.OLD.MESSAGE) = ..IN.TRANSMISSION 15 Do 16 Compute .MIN.MSG as the minimum(.OLD.MESSAGE) of PRIORITY(.OLD.MESSAGE) 17 Loop ''each .MSG in the MESSAGE.SET(COMM.CENTER) 18 19 If PRIORITY(MESSAGE) >= ..IMMEDIATE and 20 PRIORITY(.MIN.MSG) < PRIORITY(MESSAGE) 21 22 Let STATUS(.MIN.MSG) = ..INTERRUPTED 23 Interrupt MESSAGE called .MIN.MSG 24 Add 1 to NUMBER.OF.MESSAGES.INTERRUPTED 25 Subtract 1 from NUMBER.BUSY.CIRCUITS 26 Let time.a(.MIN.MSG) = LENGTH(.MIN.MSG) 27 Call TRANSMIT.MESSAGE 28 Given 29 MESSAGE 30 Else 31 32 Let STATUS(MESSAGE) = ..SUSPENDED 33 Suspend 34 Call TRANSMIT.MESSAGE 35 Given 36 MESSAGE 37 Endif

Page 46: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-46

38 39 Endif ''NUMBER.BUSY.CIRCUITS < TOTAL.NUMBER.OF.CIRCUITS 40 41 End ''MESSAGE

Page 47: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-47

1 Routine TRANSMIT.MESSAGE 2 Given 3 .NEW.MESSAGE 4 5 Define .NUMBER.CIRCUITS as an integer variable 6 7 Define .NEW.MESSAGE, 8 .OLD.MESSAGE as pointer variables 9 10 Add 1 to NUMBER.BUSY.CIRCUITS 11 Let STATUS(.NEW.MESSAGE) = ..IN.TRANSMISSION 12 Wait LENGTH(.NEW.MESSAGE) minutes 13 14 Subtract 1 from NUMBER.BUSY.CIRCUITS 15 Remove .NEW.MESSAGE from the MESSAGE.SET(COMM.CENTER) 16 17 Let .NUMBER.CIRCUITS = NUMBER.BUSY.CIRCUITS 18

Page 48: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-48

19 For each .OLD.MESSAGE in the MESSAGE.SET(COMM.CENTER) 20 with STATUS(.OLD.MESSAGE) not equal to ..IN.TRANSMISSION 21 while .NUMBER.CIRCUITS < TOTAL.NUMBER.OF.CIRCUITS do 22 23 Select case STATUS(.OLD.MESSAGE) 24 25 Case ..SUSPENDED 26 Reactivate the MESSAGE called .OLD.MESSAGE now 27 28 Case ..INTERRUPTED 29 Resume the MESSAGE called .OLD.MESSAGE 30 Add 1 to NUMBER.BUSY.CIRCUITS 31 Let STATUS(.OLD.MESSAGE) = ..IN.TRANSMISSION 32 33 Default 34 Endselect ''STATUS(.OLD.MESSAGE) 35 Add 1 to .NUMBER.CIRCUITS 36 Loop ''each .OLD.MESSAGE in the MESSAGE.SET(COMM.CENTER) 37 38 End ''TRANSMIT.MESSAGE

Page 49: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-49

1 Routine REPORT 2 3 Print 5 lines with NUMBER.OF.MESSAGES, 4 TOTAL.NUMBER.OF.CIRCUITS, 5 RUN.LENGTH, 6 NUMBER.OF.MESSAGES.INTERRUPTED thus

*** messages were generated for a message center with ** circuits during a period of ** minutes.

*** messages were interrupted. 12 13 End ''REPORT

Page 50: Day 4

—————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-50

The Communications Center