From: Alan Baldwin, Jr.
To: All
I am working on a project to do automatic updates to several screens, and I'm hoping someone else has run into the problem I'm having. We have up to 40 people taking calls and using a program to write call records to the same file. We also have up to 15 dispatchers running the same program to view this file. The program reads the call records file and fills a subfile with call records depending on what the dispatcher has chosen to see. The way the program works now, the dispatcher has to hit a function key to refresh the screen with any new calls.
I have been attempting to do automatic refresh using data queues. I'm having a problem enabling multiple dispatchers to read from the same data queue. Because records received from a data queue are removed from the data queue, only one dispatcher gets the record.
Does a data queue have to be associated with the program's screen file for the program to be able to wait for input from the screen or the keyboard?
From: Art Tostaine
To: Alan Baldwin, Jr.
I've been writing almost the exact same application. Instead of calls, we have radio frequency (RF) units scanning trailers and tractors into the yard, and we want to have an airport-type arrivals screen constantly refreshing. We could have up to five dispatch screens around the building. I do it just as you described.
I was able to get our system to work. The technique really isn't that difficult, it's just that none of it is written down in any one place. What follows is an explanation of how I currently have it working with automatic update. Figures 6-8 contain pieces of the code related to the data queue technique.
6 contains the RPG code that sends the data to the data queue. In our circumstance, we work with RF. Each truck we dispatch to has its own frequency, and each dispatcher watches two to three frequencies. When dispatchers log in, I write their device names and what frequencies they have to a file (more on this later). The code in 6 reads the Emergency Road Service Frequency (ERSFREQ) and sends just the frequency to all dispatchers in the file that match that frequency.
Figure 6 contains the RPG code that sends the data to the data queue. In our circumstance, we work with RF. Each truck we dispatch to has its own frequency, and each dispatcher watches two to three frequencies. When dispatchers log in, I write their device names and what frequencies they have to a file (more on this later). The code in Figure 6 reads the Emergency Road Service Frequency (ERSFREQ) and sends just the frequency to all dispatchers in the file that match that frequency.
Next, I use a CL program (see 7) to call the dispatcher's program. I create a non-keyed data queue (keyed data queues are not supported) using the name of the device. The program does some error checking to see if the data queue already exists. Then the program overrides the display file to associate the data queue with it. Using this method, dispatchers get their own data queues!
Next, I use a CL program (see Figure 7) to call the dispatcher's program. I create a non-keyed data queue (keyed data queues are not supported) using the name of the device. The program does some error checking to see if the data queue already exists. Then the program overrides the display file to associate the data queue with it. Using this method, dispatchers get their own data queues!
8 shows a segment of the RPG code for the program used by the dispatchers. The first three statements clear the data queue because I just updated the screens. I then wrote the subfile that displays the outstanding calls. Setting on indicator 89 activates the INVITE keyword in the display file. Next, I wrote the KEYS1 record. By calling the QRCVDTAQ program, the RPG program waits (WAIT = -1) until it receives input from the screen or the data queue. (If you receive something from the data queue, write KEYS1 again with indicator 89 off to turn off the INVITE keyword, and then update the subfile. Otherwise, read KEYS1 and proceed as normal.)
Figure 8 shows a segment of the RPG code for the program used by the dispatchers. The first three statements clear the data queue because I just updated the screens. I then wrote the subfile that displays the outstanding calls. Setting on indicator 89 activates the INVITE keyword in the display file. Next, I wrote the KEYS1 record. By calling the QRCVDTAQ program, the RPG program waits (WAIT = -1) until it receives input from the screen or the data queue. (If you receive something from the data queue, write KEYS1 again with indicator 89 off to turn off the INVITE keyword, and then update the subfile. Otherwise, read KEYS1 and proceed as normal.)
This is my first attempt with data queues. No "real" data is being sent from one program to another. It's just a message saying, "Hey, I wrote a record to the file. Update your screen."
By the way, two articles helped me a lot: "Line Up for Data Queues," MC, May 1992, and "Event-driven Programming with Data Queues," MC, December 1993.
TechTalk: Using Data Queues for Automatic Screen Painting
Figure 6: RPG Code for Sending Data to Data Queue
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 I DS I 1 7 DQDATA I 1 5 DQRQST I 6 70DQFRQ C*================================================================ C* Write records to data queues C CLRAFQ SETLLERSFREQ C CLRAFQ READEERSFREQ 61 C *IN61 DOWEQ*OFF C CALL 'QSNDDTAQ' C PARM DEVNAM C PARM DQLIB C PARM LEN C PARM DQDATA C CLRAFQ READEERSFREQ 61 C ENDDO *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
TechTalk: Using Data Queues for Automatic Screen Painting
Figure 7: CL Program to Create Data Queue Named as Device
PGM /* */ DCL VAR(&USRDEV) TYPE(*CHAR) LEN(10) RTVJOBA JOB(&USRDEV) CRTDTAQ DTAQ(AAAPROD/&USRDEV) MAXLEN(100) TEXT('ERS + Data Queue') AUT(*ALL) MONMSG MSGID(CPF9870) EXEC(GOTO CMDLBL(CLRQUE)) GOTO SKPCLR /* */ CLRQUE: DLTDTAQ DTAQ(AAAPROD/&USRDEV) CRTDTAQ DTAQ(AAAPROD/&USRDEV) MAXLEN(100) TEXT('ERS + Data Queue') AUT(*ALL) /* */ SKPCLR: OVRDSPF FILE(SERS998) TOFILE(AAAPROD/SERS998) + DTAQ(AAAPROD/&USRDEV) CALL PGM(AAAPROD/ERS998) DLTDTAQ DTAQ(AAAPROD/&USRDEV) ENDPGM
TechTalk: Using Data Queues for Automatic Screen Painting
Figure 8: Partial RPG Code to Receive Input from Data Queue
*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 C CALL 'QCLRDTAQ' C PARM STJOB C PARM DQLIB C WRITESFLCTL1 C BADRID TAG C SETON 89 C WRITEKEYS1 C*===================================================== C CALL 'QRCVDTAQ' C PARM STJOB C PARM DQLIB C PARM 7 LEN C PARM DQDATA C PARM -1 WAIT 50 C*===================================================== C SETOF 89 C DQRQST IFEQ '*UPDT' C WRITEKEYS1 C GOTO UPDSTS C ENDIF C READ KEYS1 99 C*===================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
LATEST COMMENTS
MC Press Online