1 / 50

Day 4

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.

wilmer
Download Presentation

Day 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 F —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-1

  2. Section 7 - Simulation Control Part 1 - User Interface Forms —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-2

  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 variable Show .FORM.PTR with “FORMNAME.FRM" • Now the variable .FORM.PTR contains the address of the form displayed on the screen. —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-3

  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. —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-4

  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". —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-5

  6. Field Attributes • To access the field values, use the field attributes: ddval.a: numeric value associated with .FIELD.PTR dtval.a: text value associated with .FIELD.PTR dary.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)) —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-6

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-8

  9. Section 7 - Simulation Control Part 2 - Efficiency —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-9

  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)) —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-10

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-11

  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)) —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-12

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-13

  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) —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-14

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-15

  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. —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-16

  17. Section 7 - Simulation Control Part 3 - Monitoring —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-17

  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 tally Graphics Entities Variables • 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. —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-18

  19. Monitoring (continued) Preamble Processes include MESSAGE After 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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-19

  20. Monitoring (continued) • Can use before or after with create or destroy entities activate or cancel processes file 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) —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-20

  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 right End • In another routine Let .CURRENT.INVENTORY = INVENTORY Right routine INVENTORY Move to .LOCAL.VARIABLE <STATEMENTS> Return with .EXPRESSION End ''Right routine INVENTORY —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-21

  22. Monitoring (continued) • Can pass control before receiving a new value Preamble Define FLOW.RATE as a real variable monitored on the left End ''Preamble • In another routine Let FLOW.RATE = 3000 Left routine FLOW.RATE Enter with .LOCAL.VARIABLE <STATEMENTS> Move from .EXPRESSION End ''Left routine FLOW.RATE —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-22

  23. Section 7 - Simulation Control Part 4 - User-Defined Distributions —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-23

  24. Arbitrary Probability Distributions Message Priority Probability of Occurrence 5 .05 4 .20 3 .40 2 .30 1 .05 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-24

  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 variable End • 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 * —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-25

  26. Arbitrary Probability Distributions (continued) f.message.priority random.e prob.a .05 ivalue.a 5 s.message.priority .25 4 If MESSAGE.PRIORITY were real ivalue.a would become rvalue.a .65 3 Probabilities are stored a cumulative values Probabilities can safely sum to 1.0 + or - .005 .95 2 1.0 1 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-26

  27. Arbitrary Probability Distributions (continued) Salary Probability of Occurrence 15,000 0.0 20,000 0.10 30,000 0.40 40,000 0.30 50,000 0.15 60,000 0.05 1.0 0 5 15 25 35 45 55 65 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-27

  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 variable End • 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 * —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-28

  29. Section 7 - Simulation Control Part 5 - Interrupting Processes —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-29

  30. Interrupting Processes • Sometimes one process wants to interrupt another process • Cause it to pause • Preempt a resource —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-30

  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) —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-31

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-32

  33. Suspend & Reactivate Processes If PRIORITY(.MIN.MSG) >= PRIORITY(MESSAGE) Let STATUS(MESSAGE) = ..WAITING File MESSAGE in MESSAGE.SET Suspend Call TRANSMIT.MESSAGE Endif ''PRIORITY(.MIN.MSG) >= PRIORITY(MESSAGE) End ''MESSAGE • In another routine where suspended messages can be identified: Reactivate the MESSAGE now —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-33

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-34

  35. Canceling Processes • Relinquish resources and remove notice from sets Every MESSAGE has a FUTURE Interrupt MESSAGE Let FUTURE(MESSAGE) = ..NONE Let time.a(MESSAGE) = 0 Resume MESSAGE If FUTURE(MESSAGE) = ..NONE Remove MESSAGE from MESSAGE.SET ''Relinquish any resources” Return Endif ''FUTURE(MESSAGE) = ..NONE —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-35

  36. This page is intentionally blank —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-36

  37. Exercise 7 The Communications Center C:\Program Files\Simscript3\models\MessageG —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-37

  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? —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-38

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-39

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-40

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-41

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-42

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-43

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-44

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-45

  46. 38 39 Endif ''NUMBER.BUSY.CIRCUITS < TOTAL.NUMBER.OF.CIRCUITS 40 41 End ''MESSAGE —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-46

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-47

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-48

  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 —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-49

  50. The Communications Center —————————— CACI Products Company ———————————————————————————— SimScript II.5 —————————————— 7-50

More Related