Logical Devices and Channels Logical Devices and Channels

In MOSES the concepts of channel and logical device are quite similar. A logical device is simply an additional layer of abstraction which allows one to achieve precisely the results he wishes. We will begin with the process of defining a logical device which is accomplished by the command:


     &LOGDEVICE, LDVNAM, -OPTIONS

and the available options are:


     -CHANNEL, CHANAM

     -STYLE, T_STYLE, N_STYLE, A_STYLE

     -MARGIN, IM, OM, TM, BM

     -LANDSCAPE, YES/NO

     -PSOURCE, TRAY

Here, LDVNAM is the logical device name which must be either: LOG, OUTPUT, SCREEN, GRA_DEVI, DOCUMENT, TABLE, PPOUT, or MODEL. These logical devices serve to provide output for screen reports, hard copy reports, screen graphics, hard copy graphics, hard copy documents, stored tables, post-processing information, and MOSES model data respectively. The options serve to define the appearance of the results. The -CHANNEL option associates a channel with the logical device. More will be said about channels later, but the valid values for CHANAM are exactly the same as for LDVNAM.

The -STYLE option defines a style which will normally be used when writing things to this logical device. For graphics devices, three styles can be specified with T_STYLE defining the style for text on the graphics, N_STYLE the numbers, and A_STYLE the axes.

The -MARGIN option defines the margins for a page in points. IM and OM define the "inside" and "outside" margins, and TM and BM define the top and bottom margin. The -LANDSCAPE option can alter the orientation of the print on the paper. If YES/NO is NO, the results are placed on the paper so that they should be read with the "long edge of the paper" on the left. If YES/NO is YES, then the page will be rotated 90 degrees. The margins are a property of the paper itself with the program taking care of the details when landscape and double sided printing are performed. The -PSOURCE option selects the current paper tray. Here, TRAY must be either UPPER or LOWER, and this option only works for certain physical devices.

Channels are defined with the command:


     &CHANNEL, CHANAM, -OPTIONS

where the available options are:


     -PAGE_DIMEN, WIDTH, HEIGHT

     -DOUSIDE, YES/NO

     -P_DEVICE, PDVNAM, LEVEL

     -FILE, FILE

     -SINGLE, YES/NO

Basically, this command associates a true physical device with the channel, CHANAM, and the valid values for CHANAM are those given for LDVNAM. Here the -PAGE_DIMEN option defines the size of a page on the channel in points,and the -DOUSIDE option instructs the printer to print on both sides of the paper, and currently works only on PCL devices.

The physical devices which can be connected to channels are defined with the -P_DEVICE option. Here valid values of PDVNAM are: SCREEN, DEFAULT, POSTSCRIPT, TEX, PCL, JPG, PNG, UGX, DXF, HTML, or CSV. If the physical device is PCL, then LEVEL defines the PCL level for the device, which must be either 3, 4, or 5. Here, the physical device SCREEN does double duty in that it is specified for both the LOG and graphics screen channels, and the particular behavior of the SCREEN depends upon the user interface one is using.

Normally, logical devices of the same name are associated with these channels, but it is not necessary. More will be said about this later. Not all physical devices can be connected to all channels. In particular:

With the exception of the SCREEN, channels are connected to files. For example, the results for channel OUTPUT will be written to the file OUTXXXXX.TXT in the ROOT.ANS directory. In general, the file name is the first three characters of the channel names followed by a five character number and having a suffix which corresponds to the physical device. Here, the physical device/suffixes are:

DEFAULT txt
POSTSCRIPT eps
TEX tex
PCL pcl
DXF dxf
JPG jpg
PNG png
UGX ugx
HTML htm
CSV csv

If you want to change the directory where the "answer files" are stored, you can use the command &FILE USE discussed below. If you want to change the location of the file for a given channel, you can use the -FILE can be used. Normally all of the graphics for a given run will be stored in a single file (except for types of JPG or PNG). This can be changed with the -SINGLE option where a YES/NO of YES will result in each frame of graphics being written to a separate file.

Each time a &CHANNEL is issued, the file currently connected to the channel will be closed and a new file will be used. For example, suppose GRA00001.eps is the file currently connected to the GRA_DEV channel. Then the command

     &CHANNEL GRA_DEV

will result in GRA00001.eps being closed and the next graphics will be written to GRA00002.eps. If GRA00001.eps is empty, then nothing will happen.

It may seem odd that the available channels and logical devices are the same, but it offers quite a bit of flexibility. For example if one has a postscript printer, then he only needs one of the channels OUTPUT, DOCUMENT, or GRA_DEV, and he can connect all three of these logical devices to it. This makes the results of all three logical devices appear in order when printed. A drawback of this approach, however, is that once the OUTPUT logical device is formatted for a particular device it may become unreadable.

The TEX device is actually a file written in a format that can be processes by the popular text formatting program LaTeX. When this device is connected to the DOCUMENT channel, it generates a stand alone file for input into LaTeX. Included in this file is a set of macros which "make it work". When connected to the OUTPUT channel, the file is not complete in that it is missing the macros, the prologue, the "begin document" and the "end document" statements. This occurs since one normally wants to input the output file into the document file to produce a complete document.

The DXF and UGX physical devices are for saving graphical results. The DXF device is used to store MOSES graphics into DXF format. The UGX device was designed as a page description language, and is more completely defined later. When this device is used, the file can be read by MOSES and converted to a graph on the specified logical device. In particular, graphics saved in this format can be viewed on the screen by simply issuing the command:

     &INSERT GRA00001.UGX

Also, if the primary graphics device is the GRA_DEV logical device, then the above command will format the graphics for a hard copy device.

For any channel which has a physical device of PCL, the results in the file contain escape sequences which control the device. Thus, files representing these channels should be sent to the device in raw form. If MOSES is being run on a PC, these files should be copied to the printer using the /B option on the DOS COPY command. This avoids the DOS spooler treating the printer escape sequences as end of line or end of file characters.