EPA-600/8-91-014 a
April 1991
IAQPC
INDOOR AIR QUALITY SIMULATOR
FOR PERSONAL COMPUTERS
Volume 1. TECHNICAL MANUAL
by
P. A. Lawless and M. X. Owen
Center for Aerosol Technology
Research Triangle Institute
P. 0. Box 12194
Research Triangle Park, North Carolina 27709-2194
EPA Cooperative Agreement CR 814169
EPA Project Officers Leslie E. Sparks
Air and Energy Engineering Research Laboratory
U.S. Environmental Protection Agency
Research Triangle Park, North Carolina 27711
Prepared for:
U.S. Environmental Protection Agency
Office of Research and Development
Washington, D.C. 20460

-------
TECHNICAL REPORT DATA
(Please read InUruaiont on the reverse before completing!
1, REPORT NO, 2.
EPA-600/8-91-014 a
3. RECIPIENT'S ACCESSION NO.
4. TITLE AND SUBTITLE
IAQPC: Indoor Air Quality Simulator for Personal
Computers; Volume 1, Technical Manual
5. REPORT DATE
April 1991
6. PERFORMING ORGANIZATION CODE
1. AUTMORIS!
P. A. Lawless and M. K. Owen
a. PERFORMING ORGANIZATION REPORT NO.
S. PERFORMING ORGANIZATION NAME AND ADDRESS
Research Triangle Institute
P.O. Box 12194
Research Triangle Park, North Carolina 27709
10. PROGRAM ELEMENT NO.
11. CONTRACT/GRANT NO.
CR814169-O1-0
12. SPONSORING AGENCY NAME AND ADDRESS
EPA, Office of Research and Development
Air and Energy Engineering Research Laboratory
Research Triangle Park, North Carolina 27711
13. TYPE OP REPORT AND PERIOD COVERED
Final; 10/87 - 10/89
14. SPONSORING AGENCY CODE
EPA/600/13
is. supplementarynotes ^EERL project officer is Leslie E. Sparks, Mail Drop 54, 919/
541-2458. Volume 2 is the related User's Guide.
18. abstractThe two_volume report describes the development of an indoor air quality
simulator for personal computers (IAQPC), a program that addresses the problems
of indoor air contamination. The program—systematic, user-friendly, and compu-
ter-based— can be used by administrators and engineers in developing control ap-
proaches to achieve acceptable concentrations of pollutants indoors. The technical
manual introduces the IAQPC, provides the theoretical background of the program,
and offers details of the algorithms. The manual should be useful to the experienced
user and to those who are interested in the fundamentals of the program. The user's
guide provides information on operation of the program. An extension of BASIC
(QuickBASIC 4.0) was selected to accommodate the complexities of the indoor air
space, maintain speed in calculations, and allow easy updates when new or improved
data become available. Inputs to the program include indoor space, pollutant sour-
ces, sinks, and HVAC system descriptions. Locations and types of air cleaners may
be specified. Output from the IAQPC includes printouts to screen, file, or printer of
input values; calculated concentrations with respect to time and location: and graphi-
cal presentations of the concentrations.
17- KEY WORDS AND DOCUMENT ANALYSIS
»- DESCRIPTORS
b, IDENTIFIERS/OPEN ENDED TERMS
c. cosati Field/Group
Pollution
Simulation
Mathematical Models
Computers
Pollution Control
Stationary Sources
Indoor Air Quality
Personal Computers
13 B
14G
12A
09B
Release to Public
19. SECURITY CLASS flhis Report J
Unclassified
21. NO. OP PAGES
205
20. SECURITY CLASS (Thispege)
Unclassified
22, PRICE
EPA form IlM-t t*-T3l
i

-------
NOTICE
This document has been reviewed in accordance with
U.S. Environmental Protection Agency policy and
approved fox publication. Mention of trade names
or commercial products does not constitute endorse-
ment or recommendation for use.
ii

-------
ABSTRACT
The Indoor Air Quality Simulator for Personal Computers, IAQPC, was
developed to address the problem of indoor air contamination. Ihe program
uses menus for the data input and to specify output. The IAQPC gives >
concentration profiles to cover up to 62 days for up to 6 pollutants based
on information entered on a building layout, the HVAC (heating, ventilating,
and air-conditioning) system parameters, and source and sink data.
The building layout is chosen from six standard configurations. The
building must be single-story and may have up to 20 rooms. The room volumes
and the cross-sectional areas of the interconnections between the rooms
(doors, cracks) may be entered. The HVAC parameters include the amount of
outdoor air entering the building and the schedule of the HVAC system.
Airflows for the building are calculated by the program.
The IAQPC provides graphical representations of the layout, source/
sink locations, calculated airflows, and source cycles. The concentrations
calculated by the program may be displayed both as linear and semilog plots.
The minimum required computer setup which will run the IAQPC includes
an IBM-PC or compatible with two floppy disk drives, DOS Version 2.0 or
later, and 350 K of memory.
The technical manual provides the theoretical background of the
program, offers details on the algorithms, and includes the program
listings. This manual should be useful to the experienced user and to those
who are interested in the fundamentals of the program.

-------
CONTENTS
Page
About This Manual....				1
Philosophy and Background.				2
Literature Review							2
Establishment of Hardware Requirements	...3
Background Programming					3
Simulator Development					3
Documentation					4
Concentration Algorithm: Theory and Development	7
Flow Balancing Algorithms Theory and Development	11
References14
Appendix
A Program Maintenance.			.A-1
B Program Listings			B-l
Index.				Index-1
TABLE
Number
1 Program Flowchart.
FIGURE
Number
1 Typical HVAC System for Indoor Air Quality
Control.							.8
Preceding page blank

-------
about this manual
This technical manual introduces the Indoor Air Quality Simulator for
Personal Computers (IAQPC), provides the theoretical background of the
program, and offers details on the algorithms. This manual should be useful
to the experienced user and to those who are interested in the fundamentals
of the program. For information on the operation of the program, refer to
the Users' Guide.
1

-------
PHILOSOPHY AND BACKGROUND
The complexity of indoor air quality (IAQ) planning and prediction
requires a systematic computer-based method to assist administrators and
engineers in developing control approaches to achieve accepted
concentrations. After we examined other indoor air models that are, in
general, very cumbersome to use, we decided that it is extremely important
to produce a user-friendly program. Our program is simple enough so that
users will not become discouraged or require weeks of training in order to
use it. The program is also fast and accurate and provides a useful tool to
analyze IAQ Issues.
We chose an extension of BASIC (QuickBASIC 4.0) as an appropriate
1 ain 011 a ao n arr rawnnrf ef a f-Via f^firnn	ftl- tha 4 fifinn t* a 4 f erifl f* o fflA int* a in
aI>1*KUAKC UU	vHBIIUUtt LC bilC W» VJU1LJ «l» C J»	U4 I>4li6 *iluUU4	a UttWC j MlAiitlLBXu
speed in calculations, and allow easy updates when new or improved data
become available. This language allows the writing of independent modules
which can be linked together, but can be changed separately. This feature
also allowed the parallel development of window modules (for use in the user
interface), low-level language modules, and the actual algorithms to produce
the numerical results.
Inputs to the program include indoor space, pollutant sources, sinks,
and HVAC system descriptions. You may specify the locations and types of
air cleaners. We have provided sample case values for at least two cases.
Output from the IAQPC includes printouts to either screen, file, or printer
of input values; calculated concentrations with respect to time and
location; and graphical presentations of the concentrations.
Literature Review
We have identified and examined currently available models. Host of
the available indoor air models (D0E2, LOAD123, etc.) address only heating
and cooling load. The models that do address indoor pollution levels tend
to be extremely simplistic (one room, one source), difficult to use, or
slow. For example, the HIST (National Institute of Standards and
Technology) CONTAM model requires users to construct elaborate input data
files, a requirement that has the potential for confusion. In addition, the
documentation to support most available programs is often limited. Our goal
was to produce a simulator that not only improves user access to IAQ
calculations, but also improves the speed with which results can be
obtained. We hope we have addressed the problem of documentation by
producing a Users* Guide and a Technical Manual that will assist you without
confusing you.
We examined the theoretical aspects of the available programs to
determine which approaches have been taken and what methods are currently
considered acceptable for use in determining indoor concentrations. In this
way, we have ensured that our model is an improvement over those currently
available.
2

-------
Establishment of Hardware Requirements
We have written this simulator to run on the Tandy 3000, IBM PC/XT/AT,
and compatibles. To accommodate the complexities of the program, we
recommend you use a 10 MB hard disk (or two floppy disk drives if there is
no hard disk). Your PC will need 350 K of RAM (this is the least amount
tested) and DOS version 2.0 or later. A printer is optional but
recommended. The monitor may be color or monochrome. It is possible that
other computers or less memory will work, but we have not made such tests
yet.
We recommend strongly that your hardware configuration be a PC/AT or
compatible with a hard disk, a math coprocessor, and a color monitor
(preferably with Enhanced Graphics Adapter [EGA]).
Background Programming
We developed in earlier programs low level modules for use in this
program. We also produced window and menu modules so that the user
interface could be rapidly completed as the input choices were made or are
changed.
Concurrently with the module development, we developed and tested two
algorithms that could be used in the simulator. The results of these
programs and the respective runtimes have been compared to those for the
NIST C0NTAM model. All three of these approaches yield similar results for
a sample problem modeling the Research Triangle Institute (RTI) Ragland
building during our earlier experimentation. All of these programs yield
results higher than the measured concentrations. Both RTI programs ran
faster than CONTAM; we used the faster of these in the IAQPC.
Simulator Development
To develop the the IAQPC simulator, we first needed to choose which
variables (in which units) would be input, which would be calculated, and
which would be output. To begin the decision process, we examined the
AIERL-RTP indoor air model (INDOOR), which was developed by L. E. Sparks of
the U.S. EPA (Sparks 1988, Sparks et al. 1988, Sparks et al. 1989). Since
this model served as part of the basis for IAQPC, which was developed in
conjunction with Sparks), this model is considered Version 1.0 with IAQPC
earning the Version 2.0 label.
The first major difference between Versions 1.0 and 2.0 is the choice
of input units. For example, because the average homeowner or builder is
more familiar with square feet as the way of specifying room size (as
compared to cubic meters), Version 2.0 uses common English units. Variables
whose values are usually specified in metric units are input in the
appropriate units, e.g., mg/m for pollutants. All variables in Version 2.0
have default values. As an integral part of this program, sample cases
provide an easy way to try different configurations or to minimize data
input by choosing the case closest to the desired building.
The user interface makes it possible for you to easily input data.
3

-------
After entering data, you will choose the "start simulator" option. As the
program progresses, screen output (either graphical or numerical) enables
you to keep apprised of both the solution and the progress. To facilitate
pollutant exposure assessment, time-aweraged values are also calculated for
each pollutant.
Program output includes data tables for room concentrations and input
values, plots for each pollutant in each room over time, and data storage to
a file. For information on the IAQPCs menus and functions, refer to
fable 1. See the User's Guide for more details.
Documentation
Two manuals are available for this program: this Technical Manual and
the User's Guide.
The Technical Manual details the calculations performed and the
theoretical basis for each. It also includes instructions on how to write
new modules for the program so that you can update the program as new
information becomes available or to better suit your individual needs.
The User's Guide describes the objectives of the program. It includes
a tutorial that leads you step by step through a typical problem. We
describe each input and show representative menus. We wrote the IAQPC
documentation so that you may become familiar with the program in a simple
yet productive manner.
4

-------
TABLE 1. PROGRAM FLOWCHART
SHOWING MENDS AND FUNCTIONS1
r—PRELIMINARY
(DOS exits)
Master File Options
Reconfigure Program
(-Basic Building -
| Design
j (data input)
Interconnections
(data input)
Building Statistics Display
|—HVAC System
MAIM
Description ]
(data input, '	
airflow balancing)
|—Pollutant
Characteristics
On/Off Times
2
Basic Building Design
Pollutant Choices
Generic Sources 	
Averaging Periods
TLVs or Limits
Outside Concentrations
Cyclic Variations
Source Strength
Menus
(data input)
|—Air Cleaners
I & S JLsdc s
Choose Cleaners
Efficiency levels -
(choose cleaners)
Passive Sinks
(choose sink)
a (continued)
Reemission from Sinks
(choose sink)
Efficiency Input
Menus
Efficiency Input
Menus
Reemission Rate
Input Menus
5

-------
TABLE 1. (continued)
a
I
J— In-Room 	j	 Roam Sources
| Locations	j
j	|	 Passive Sinks
I	I
I	I
|	|	Mr Cleaners
I	I
j	|	5 Cyclic Variations
I	I
|	j	 Initial Concentrations
I	I
|	1	 Building Statistics
I
(—Runtime
j Configurations
I
{—Start Simulator
I
|—Continue Simulator
I
|—Graphical Output
|	(choices)
1
^-Output Results 	 Output Device Selection
(choices)
2 Menus are in bold print
this menu can be reached in two ways.
6

-------
CONCENTRATION ALGORITHM; THEORY AMD DEVELOPMENT
For the IAQPC we developed a fast, direct solution method for solving
multizone indoor contaminant distribution. The equations derived from
pollutant mass conservation are a nonhomogeneous linear system of
first-order partial differential equations. Therefore, it is extremely
difficult and time-consuming to obtain the direct solution, especially when
more than four zones are being studied. Our algorithm allows concentrations
to be analyzed rapidly for specified airflow conditions. Moreover, our
program is able to calculate a 24-hour time-dependent concentration profile
for up to 20 zones in only a few minutes of computational time; it is fast
in comparison with other available multizone models (Yamamoto et al. 1988).
The solution method we employ is a discrete step method. It requires
certain assumptions and improves computational time significantly over the
conventional solution methods. In the following paragraphs, we present the
methodology used in solving these equations.
Consider the necessary structure of a physical IAQ model. Figure 1
schematically represents a multizone configuration model with an HVAC
system. The pollutant concentration in the ith room may be expressed by a
generalized form of differential equations:
Vi «i(t>/dt - ViVt) * 1otiCi^
n
2 q. .C.(t) + G.(t) + S.(t) + q, ,C ,	(1)
j=1 J.* J	i	i	in,ia *	K '
j+i
where
n
Ch(t) - (1 - , , X q Ci(t) / X q
i-1 "	i-1 *
(2)
n
Vi ¦ ^"i.i + Vi+ '«.i •	<3>
j+i
and, with metric units in parentheses,
3
= volume of room i (m )
CA(t) - concentration in room i (pg/m3)
3
Cj(t) = concentration in room j (pg/m )
t = time (min)
7

-------

-------
3
q, . = HVAC flowrate into room i (m /min)
3
C^(t) = concentration in HVAC supply air (yg/m )
qQ ^ = flowrate leaving room i (m3/min)
3
q. , = flowrate entering room i from neighboring room j (m /min)
J»i
Gi(t) = source rate in room i (yg/min)
S^(t) ¦ sink rate in room i (yg/min)
3
C =» concentration in outdoor air (Mg/m )
a
¦ filter collection efficiency.
3
^ * infiltration rate into room i C® /min)
3
q . = HVAC return air flow rate from room i (m /min)
r, 1
3
q . «= exfiltration rate from room i (m /min)
ex, i
fhe mass balance for the HVAC system becomes:
n
Q — S q ,	(4)
4 » * •> # ¦¦¦
i»l
When the HV^^C systeim has exhaust and makeup air § mass balance jls
expressed as:
^h ^r + ^makeup " ^exhaust "
where
Qh = total supply air flowrate and
Q = total return airflow rate,
r
£quation CI) can be s iiiii^j 1 xfied as*
dC.(t)/dt - - L.C.(t) + P. ,	(6)
i	xi 1
where
L. = 1It.	= q ,/V, + S, (7)
l i	Mo,i' i i x '
and
Pi " ^h,iCh(t)	+ Gi + qin.iCa] ' Vi
(8)
9

-------
j=f=i	.
where
T. = a characteristic time constant = q„ 4/V,.
i	0,1 i
Here, L, r|presents the loss rate of pollutants leaving room i per
unit time (min~ ), and P^ i| the^production rate of pollutants entering
room i per unit time (pg m" min~ ).
For the general multizone indoor air configuration, P^Ct) is a function
of neighboring concentrations. The homogeneous equation must be solved
first; P,(t) in Equation (6) is zero. Then the method of variation of
parameters can be used to solve the nonhomogeneous Equation (6). Ryan et
al. (1988) demonstrated this computational method for a four sequential box
model. Waters and Simons (1987) demonstrated the computational method for a
multizone model. Sparks et al. (1988) developed a multicomponent IAQ model
using this method. The results compared quite favorably with EPA test house
data.
However, the complexity of a multizone model increases roughly as the
square of the number of zones. It may be feasible to solve up to four
zones, but this is not practical within reasonable computational time
constraints for more than four zones. It is especially cumbersome to
evaluate the inverse matrix of loss term in Equation (6). A fast and
accurate algorithm is needed to compute the concentrations for up to 20
rooms.
Assuming that the neighboring concentrations and source term do not
change during the time step selected (i.e., and P^ become constant with
time). Equation (6) can be integrated analytically to give:
Ci " Ci(V Bxp(" Lit} + VLi[1 " exp(" Lit)]	(9)
idie re
C.(t ) i= concentration in room i at time t « t .
io	o
Obviously, the discrete solution method approaches the exact solution
as the time step decreases.
At any given starting time, the concentration for each room is known.
After you have computed the concentrations of all zones during the time
step, compute the pollutant concentration for supply air according to
Equation (2). Use the most recently calculated concentration for each room
as an initial value of the concentration for the next time step. Repeat
this procedure until the final time is reached. The order of calculation is
not important. Note that the solution method is direct and exact during
each time step; the key is to select an appropriate time step to achieve an
accurate and fast solution. Therefore, no numerical instabilities are
involved for this algorithm.
We validated this model against several experimental cases (Yamamoto
et al. 1988, Owen et al. 1989, Insor et al. 1989).
10

-------
FLOW BALANCING ALGORITHM! THEORY AND DEVELOPMENT
In modeling the flow for indoor air movement, it is common to select a
flow equation of the form:
Q * A(P - PQ)n ,	(10)
where
Q « the volume flow of air
A - an equivalent area of an opening
P and PQ = the pressures on both sides of the opening and
n • an exponent from % to 1.
You can adjust the value of n to account for different flow regimes. If
it is %, the flow is nondissipative and the equation represents Bernoulli's
law. If it is 1, the flow is dissipative. These limits are often
associated with turbulent and laminar flows, respectively, because
turbulence occurs when the kinetic motion of the gas overcomes the viscous
retardation of the gas.
Whatever the value of the exponent, the net flow of gas into any room
must be zero. This is expressed by:
XQ± - 0 ,	(11)
where the subscript ranges over all openings in the room. By substituting
the right-hand side of Equation (10) into Equation (2}, we obtain:
XAiCPi - Pp)n ¦ 0 .	(12)
This equation relates the pressure in a room. PQ, to the pressures in
the surrounding rooms. If the exponent, n, is 1, then the particularly
simple result is;
P0 -
That is, the pressure in the room is the area-weighted average of the
pressures in the surrounding rooms. The nature of Equation (12) is such
that, if the exponent varies from 1 by the least amount, then reduction to
the form of Equation (13) is impossible. This carries over to methods of
solution based on Equation (13) as well.
The solution method we used in the IAQPC is a relaxation technique.
Relaxation is used because it uses less computer memory since most of the
parameters are adjusted in place. We built the following assumptions into
the solution method:
1. Ambient (outside) pressure is everywhere equal to zero.
11

-------
2.	The HVAC fan delivers a fixed quantity of air, independent of
pressure.
3.	The HVAC return ducts collect a fixed quantity of air, the
air delivered minus the makeup air.
4.	A quantity of air equal to the makeup sir flows into or out
of the building through windows or other openings to the
outside.
5.	There are no pressure drops along the supply and return
ducts.
These assumptions ensure global conservation of mass. The relaxation
solution moves toward mass conservation on a room-by-room basis. The
pressure independence of HVAC delivery and return flows is only
approximately correct.
It is possible to obtain a solution, for a fixed makeup airflow, for
which the HVAC delivery and return pressures are both greater than ambient
pressure. This means that the building is pressurized. If the building
does not actually operate above ambient pressure, then additional flow
openings to the outside are required to bring the HVAC return pressure below
ambient.
In practice, you should begin the solution process by assuming each
room is at zero pressure (outside pressure). You then calculate the flow
into the room through the HVAC inlet as a fraction of the total flow. Use
the flow resistance of the openings to calculate the HVAC supply pressure.
The same flow, reduced by the makeup air fraction, is exhausted through the
HVAC returns in each room. Use the flow through the HVAC return openings to
calculate the HVAC return pressure.
Next, treat each room separately. Calculate the pressure in the room
from the pressure drop to the outside of the makeup air fraction of the
volume flow into the room. This makes the room pressure differ from zero,
but usually not enough to affect the HVAC supply and return values very
much. If the flow resistance to the outside is large, the room pressure
becomes large in this step.
After you have obtained all the room pressures, you calculate the
total flows into and out of each room using the connecting areas and the
pressure differences between rooms. At this step, the mass balance in each
room is not guaranteed. The net flow is calculated for use in determining
the convergence of the process.
After you have determined the flows, you can calculate new room
pressures by using flow-weighted averages of the pressures in the adjoining
rooms and ducts. Use these new pressures to begin recalculating the duct
delivery and return flows, instead of zero pressure.
Two factors complicate the convergence: the presence of the hall and
12

-------
the noninteger flew exponent. The hall, if there is one, represents a
sensitive pressure sink for all the rooms. If its pressure changes
slightly, the effect is felt in each room in a major way. We overcame this
numerically by using a combination of integral and proportional correction
to adjust the hall pressure with greater damping but high cumulative
accuracy.
fhe noninteger exponent causes the successive solutions to oscillate
for a variety of interconnection areas. This occurs because the flow
changes more rapidly than the pressure when the exponent is not equal to 1,
resulting in overcorrections to the pressures. One solution has been to
adjust the HVAC supply and return pressures with a correction that depends
on the flow exponent and the difference between the desired supply air and
that calculated from summing the room flows. This nonlinear correction does
work, but the rate of convergence slows markedly as the exponent is varied
away from 1. Because the rate of convergence decreases so much, we limited
the flow exponent to values near 1.
13

-------
REFERENCES
Insor, D. S., f. Yamamoto, P. A. Lawless, M. K. Owen, and L. I. Sparks.
1989. "Indoor Air Quality Simulator for Personal Computers.1" In: Proceedings
of the AWMA Conference, Anaheim, CA, June.
Owen, M. K., P. A. Lawless, 7. Yamamoto, D. S. Ensor, and L. 1. Sparks,
1989. "IAQPC• An Indoor Air Quality Simulator." In: Proceedings of ASHRAE's
IAQ 89 Conference, San Diego, CA, April.
Ryan, P. B., J. D. Spengler, and P. F. Halfpenny. 1988. "Sequential Box
Models for Indoor Air Quality! Application to Airliner Cabin Air Quality.*
Atmospheric Environment, Vol. 22, No. 6, pp. 1031-38.
Sparks, L. E. 1988. "Indoor Air Quality Model Version 1.0," EPA Report
EPA-600/8-88-097a, (NTIS PB89-133607), Research Triangle Park, NC,
September.
Sparks, L. E., M. D. Jackson, and B. A. Tichenor. 1988. "Comparison of EPA
Test House Data with the Predictions of an Indoor Air Quality Model." Ins
Proceedings of the ASHRAE Conference IAQ 88, Atlanta, , Ap 2T i 1 1 — 13 .
Sparks, L. E., B. A. Tichenor, M. D. Jackson, and J. B. White. 1989.
Verification and Uses of the Environmental Protection Agency (EPA} Indoor
Air Quality Model, In: Proceedings of ASHRAE's IAQ 89 Conference, San Diego,
CA, April.
Waters, J. R., and M. W. Simons. 1987. "The Evaluation of Contaminant
Concentrations and Air Flows in a Multizone Model of a Building." Building
and Environment, Vol. 22, No. 4, pp. 305-315.
Yamamoto, T., D. S. Ensor, P. A. Lawless, A. S. Damle, M. K. Owen, and L.
E. Sparks. 1988. "Fast Direct Solution Method for Multizone Indoor Model."
In: Proceedings of Building Systems: Room Air and Air Contaminant
Distribution, University of Illinois at Champaign-Urbana, December 5-8.
14

-------
APPENDIX A PROGRAM MAINTENANCE
This part of the manual describes the function of each routine in
IAQPC and gives the program nodule in which it may be found. Despite the
modularity afforded by Quick Basic 4.0 (QB4), the program is a complex
series of interrelated modules. Before introducing the individual routines,
we consider the general purpose of each program module here.
The descriptions of the routines themselves are brief. The routines
are listed in alphabetical order. Generally, a routine will only be needed
within the module in which it is placed. However, routines in IAQMENUS may
be expected to be called from any other routine.
IAQPC
This module is the introduction to the main program. It displays the
title and credits and can be used for program configuration modifications.
If IAQPC is called with /H or /M on the command line, it branches to a
separate routine before calling IAQPCRUN.
When the distribution disk is first used, IAQPC is the only executable
file on the disk. It renames IAQPCRUN as an .EXE file and then proceeds to
execute it. This ensures that the title/credit program is run at least
once. If IAQPC is initiated with an extra keystroke, it produces the title
screen about 8 times as fast.
IAQMAIN
This module is the main module for the program, containing the basic
ordering of the program and giving control to the menu routines needed for
its execution. It contains an error handler to allow reporting of
unforeseen errors and prevent premature termination of the program.
BASICD
This module contains the routines for entering a basic structure design
with its HVAC system. The choice of floorplans is limited to 6 fundamental
ones, but the number of rooms is adjustable up to 20. Single floor
buildings are the only allowed structures in this version. This is
essentially two independent units placed in the same module.
BALANCE
This module contains the flow balancing algorithm and the display of
the balancing process. The flow balancing algorithm computes the pressure
in each room and determines flows into and out of all the openings in the
room. The process is driven toward mass flow balance by adjusting the
individual room pressures. Pressures in the HVAC system are calculated to
allow verification of adequate air exchange with the outside.
CALC
This module contains the pollutant concentration calculations, along
A-l

-------
with the treatments provided by cleaners and sinks. This module also
contains the text-graphic routines needed for the real-time display of
concentrations, fhe calculations assume well-mixed flow within each room
and instantaneous plug flow in the HVAC system.
GRAPH
This module provides the graphics detailed programming need to display
floor plans, flows, cycles, and pollutant history, fhe graphics displays
are made to be as independent of the video adapter as possible.
IAQMENUS
This module contains mostly first-level menus that would not be need in
a batch processing program. They are grouped together for convenience. The
runtime and operating configuration menus are also in this group.
This module also contains routines used in many parts of the program.
It was originally developed as a Quick Library, but is too specific to be
distributed as a library. Those routines have now been folded into the menu
module.
INROOM
This module contains the routines for locating and displaying sources,
sinks, and cleaners within specific rooms of the building. It is
essentially two independent units placed in the same module.
OUTPUT
This module contains the output routines for printing or displaying the
input data or results. The output channel may be directed to the screen, a
printer, the COM port, or to a file.
STRENGTH
This module contains the routines for the descriptions of the
pollutants and source strengths, and the air cleaner/sink properties. These
are two independent units gathered into the same module.
Within these modules, variables may be passed as arguments or by being
SHARED. Between separate modules, variables may only be passed as arguments
or in COMMON blocks.
In QB4, procedures (subroutines) may either be called explicitly, as
CALL XYZ(x, y, z), or implicitly, as XY2 x,y,z. The former style requires the
parentheses, while the latter style requires the absence of parentheses.
The implicit call has been used throughout IAQPC because it resembles spoken
English more closely. The procedure has a verb-like function, and the
arguments resemble nouns.
Functions, in QB$, are like functions in other computer languages:
A-2

-------
they return a value and require arguments in parentheses. It is difficult
to distinguish QB4 functions from data arrays, which also return values and
require arguments in parentheses. In fact, some data arrays in the
development of IAQPC were later replaced by functions with the same name.
The distinguishing feature of functions in QB4 is that they are defined in
DECLARE statements at the beginning of each module in which they appear. If
you cannot determine whether an array-like object is a function or an array,
look for its appearance in the DECLARE statements jgl tihs beginning of the
module.
QB4 also allows for INCLUDE files in its syntax. These are files
specified in a certain way which do not reside with the module itself, but
which are read into the compiler when the INCLUDE statement is encountered.
Most of the INCLUDE files in IAQPC are used to introduce DECLARE statements
consistently from module to module. Some are used in a similar way to
introduce COMMON blocks consistently.
Procedures and functions whose names are given with all capital
letters are library routines. Some are ones provided in QB4, while the
remainder have been written for IAQPC.
A-3

-------
Module IAQMENUS
AIRCHANGES Function
a Action Calculates fresh air volume flow(per hour) / room volume.
m Syntax
z - A1RCHANGES (Rtf Z, VOL{), RHFL0W(), MAKEUP AIR)
Module STRENGTH
AIRCLIAN Statement
m Action Menu text for air cleaners,
p Syntax
AIRCLEAN ACZ
Module BASICD
ALLOVABLEROOMS2 Function
H Action Returns the maximum or minimum number of rooms for floorplan FPZ and
requested number of rooms NRZ.
m Syntax
x = ALLOWABLEROOMSZ(FPZ, NZ)
Module STRENGTH
AMBCONC Statement
a Action Menu for input of ambient pollutant concentrations.
B Syntax
AMBCONC
A-4

-------
Module BALANCE
ARRAYTOTAL Statement
m Action Procedure which totals the contribution for room RNZ in array XC. The
total is returned in TA.
a Syntax
ARRAYTOTAL RNZ, ICQ, TA
Module CALC
AVGCONCVAL Function
H Action Returns the present value of the time-averaged concentration of
pollutant KZ.
B Syntax
x - AVGCONCVAL(KZ)
Module BALANCE
BALANCE Statement
m Action Balancing procedure for the room flows. Entry data are number of
rooms (NRZ), volume flow (VOLFLOW), fraction of makeup air (MAKEUPAI1), pressure
drop across the fan (FANDP), and intercotmecing areas (INTERCONO). The global
variable RmFlow contains the balanced flows on return, and the HVAC delivery and
return pressures (HVP and RETP) are returned.
u Syntax
BALANCE NRZ, VOLFLOW, MAKEUPAIR, FANDP, HVP, RETP, INTERCONO
A-5

-------
Module BALANCE
BALANCEINIT Statement
m Action Sets up temporary arrays for balancing the flows.
m Syntax
BALANCEINIT NRZ, VOLFLOW, MAKEUPAIR, INTERCON()
Module IAQMENUS
BARCATCH Statement
m Action Procedure for capturing the central part of the menu and displaying it
on the right side of the screen as the menu levels are traversed.
H Syntax
BARCATCH R0W2, COL2, LEVELI
Module BASICD
BASICDESIGN Statement
m Action Menu for entering the floorplan data.
m Syntax
BASICDESIGN
Module BASICD
BASICFLOORPLANS Statement
in Action Proceedure which displays the 6 fundamental floor plans.
m Syntax
BASICFLOORPLANS N2
A-6

-------
Module BASICD
BUILDINGSTAT Statement
B Action Procedure for listing the current floorplan and interconnecting areas.
B Syntax
BUILDINGSTAT
Module CALC
CALCCONC Statement
H Action Procedure which calculates the time-development of the pollutant
concentrations. This is the heart of the simulator. Input is a start time and
a stop time.
B Syntax
CALCCONC TO, TF
Module IAQMENUS
CALCCONFIG Statement
a Action Menu for setting the runtime options used in controlling the display
and stopping of the pollutant calculations.
B Syntax
CALCCONFIG
Module CALC
CALCPIRST1K1T Statement
B Action Routine to initialize the minimum number of variables for use with the
command line batch operation option.
¦ Syntax
CALCFIRSTINIT

-------
Module CALC
CALCINIT Statement
H Action Procedure to setup temporary arrays for CALCCQNC.
m Syntax
CALCINIT
Module CALC
CALCPOLAVGXHXT Statement
^ Action Procedure to xnxtxalxze the txme-avsrs^es of the pollutants*
a Syntax
calcpolavginit
Module CALC
CALCRKTOTSK Statement
m Action Procedure to total the sink efficiencies for each pollutant in each
room.
v Syntax
CALCKMTOTSK J2, KX
Module CALC
CALCRMTOTSRC Statement
¦ Action Procedure to total the source emissions rates for each pollutant in
each rooms.
B Syntax
CALCRMTOTSRC JZ, K2
A-8

-------
Module GRAPH
CENTEROFROOM Statement
m Action Returns the graphical center of each room for displaying other objects
in relation to it.
B Syntax
CENTEROFROOM RNZ, X, Y
Module BALANCE
CHANNELTOTAL Statement
m Action Totals a particular component of the input vector over all rooms.
m Syntax
CHANNSLTOTAL SWZ, NRZ. IC(), TA
Module CALC
C1ECKTIM1 Statement
a Action Procedure which determines if a display, graph, or interrupt should be
done after a calculation step.
B Syntax
CHECKTIME DT, X$
Module STRENGTH
CLEANERMENU Statement
m Action Menu for entering air cleaner and sink data.
a Syntax
CLEANERMENU
A-9

-------
Module IAQMENUS
CLNAME$ Function
a Action Function which gives the name of the air cleaner selected by II.
m Syntax
x$ - CLNAMESdt)
Module GRAPH
COLOROF Function
m Action Sets the video adapter appropriate color according to a consistent
color scheme.
s Syntax
x - COLOROF(12)
Module CALC
COMMA IfDSELP Statement
B Action This routine displays the command line options for IAQPC.
COMMANDHELP
Module 1AQMAIN
COMMANDLINEPROC Statessent
B Action This routine loads and executes the file whose name is given, on the
command line of IAQPCRUN or IAQPC.
¦ Syntax
COMMANDLINEPROC F$
A-10

-------
Module CALC
C0NC2NXT Statement
a Action Initializes the pollutant concentrations throughout the building.
m Syntax
CONCINIT ICZ
Module CALC
CONCEAL Function
a Actios Returns the current concentration of pollutant KZ in room RNZ.
B Syntax
x ¦ CONCVAL(KZ, RNZ)
Module INROOM
COPYALLRM Statement
m Action Copies all variables in the current room from a lower room number to a
higher room number.
¦ Syntax
COPYALLRM RNZ, ILZ, IUZ
Module BASICD
COPYDOVN Statement
m Action Copies one building variable from the present room to lower numbered
rooms.
m Syntax	^
COPYDOWN RNZ, SWZ
A-11

-------
Module INRGQM
COPYRM Statement
m Actios Copies index variable of the present room to lower or higher room
numbers.
m Syntax
COPYRM RNZ, ILZ, IUZ, A AS LONG
Module BASICD
COPYCP Statement
B Action Copies one building variable from the present room to higher room
numbers.
a Syntax
COPYUP RNZ, SWZ
Module IAQMENUS
CYCLENAME$ Function
H Action Function returning the description of the time cycles.
¦ Syntax
x$ - CYCLENAME$ (IZ}
Module CALC
CYCLIONI Function
m Action Function which returns a TRUE/FALSE value according to the cyclic
source in room RNZ and time T.
B Syntax'
x - CYCLEONZ(T, RNZ)
A-12

-------
Module STRENGTH
CYCLICVAR Statement
m Action Menu for selecting cyclic variation times.
B Syntax
CYCLICVAR
Module GRAPH
TlPFUTM^nUC C ¥ » ¥ Atnen *
y&fNinyuid duiteiuciiL
m Action Procedure which defines a graphic window fro displaying each
pollutant's time history.
B Syntax
DEFWINDOWS
Module IAQMENUS
DIRECTENTRY? Function
m Action Punction which returns the current directory entry.
m Syntax
x$ - DIRECTENTRY?
Module BALANCE
DISPLAYBALANCE Statement
¦ Action Displays the state of flow balancing on the screen.
a Syntax
DISPLAYBALANCE NRI, X(), TOL
A-IS

-------
Module IAQMENUS
DISPLAYFILES Statement
u Action Lists the files of the current type on the screen.
B Syntax
DISPLAYFILES DPATH$, EXT$
^lodule BASICD
DISPLAYFLOWS Statement
¦	Action Lists the current room flows and the amount of imbalance in each room.
¦	Syntax
DISPLAYFLOWS
Module OUTPUT
DISPLAYINDAT Statement
¦	Action Presents the input data on several succesive pages.
m Syntax
DISPLAYINDAT
Module GRAPH
DRAWARROW Statement
B Action Draws an arrow.
m Syntax
DRAWARROW XB, XE, YB, YE, DY, IC2
A-14

-------
Module GRAPH
DRAtfAVERAGES Statement
B Action Displays current pollution average values in each room for all
pollutants.
m Syntax
DRAWAVERAGES
Module GRAPH
DELAVCYCLES Statement
B Action Graphs the cyclic variations on the screen.
B Syntax
DRAWCYCLES
Module GRAPH
DRAVDOORFLOVS Statement
¦ Action Graphs the interconnecting door flows.
m Syntax
DRAWDOORFLOWS RNZ, X, Y
Module GRAPH
DRAWDOORS Statement
a Action Draws the locations and size of doors to scale.
m Syntax
DRAWDOORS RNZ, X, Y


-------
Module GRAPH
DRAVDTJPCYCLES Statement
m Action This routine, like DRAWCYCLES, plots the on/off cycles, but over the
period of a week, rather than a day.
m Syntax
DRAWDUfCYCLES
Module GRAPH
DRAVFLOORPLAN Statement
¦	Action Draws the current floor plan as large as possible.
H Syntax
DRAVFLOORPLAN
Module GRAPH
DRAWFLOWS Statement
a Action Draws the various room flows.
¦	Syntax
DRAWFLOWS
Module GRAPH
DRAVHALLDOOR Statement
m Action Draws the hall door locations and opening areas to scale.
m Syntax
DRAWHALLDOOR RNX. X, Y
A-16

-------
Module GRAPH
DRAVHALLFLOW Statement
B Action Draws the hall flows to scale.
B Syntax
DRAWHALLFLOW RNZ, X, Y
Module GRAPH
DRAWHISTVINDOVS Statement
a Action Sets up graphic windows for the pollutant history and labels them.
m Syntax
DRAWHISTWINDOWS X AS IKTEGER, Y AS INTEGER
Module GRAPH
DRAVLEGEND1 Statement
a Action Writes legend for DRAWFLOORPLAN.
a Syntax
DRAWLEGEND1
Module GRAPH
DRAYLIGEHD2 Statement
B Action Writes legend for DRAWFLOWS.
Syntax
DRAWLEGEND2
A-17

-------
Module GRAPH
SRAWLIGEND3 Statement
m Action Write legend for DRAWAVERAGES.
a Syntax.
DKAWLEGEND3
Module GRAPH
DRAWLEGIND4 Statement
B Action Writes legend for DEALLOCATIONS.
B Syntax
DRAVLEGEND4
Module GRAPH
DRAWLSGEND5 Statement
B Action Writes legend for DRAWCYCLES.
H Syntax
DRAWLEGEND5
Module GRAPH
DEALLOCATIONS Statement
a Action Shows the location of sources, sinks, cleaners, and cycles in each
room.
Syntax
DRAWLOCATIONS
A-18

-------
DRAVLOGHISTVINDOVS Statement
Module GRAPH
m Action Draws pollutant history windows for eahc pollutant using a logarithmic
scale.
B Syntax
DRAVLOGHISTVINDOVS X AS INTEGER, Y AS INTEGER
Module GRAPH
DRAWOPENIHGS Statement
¦ Action Draws the window, door, and HVAC openings.
m Syntax
DRAWOPENINGS
Module GRAPH
DBA WINDOW, Statement
m Action Draws the window openings for each room to scale.
a Syntax
DRAWINDOV RNZ, X, Y
Module GRAPH
DRAWINDOVFLOV Statement
a Action Draws the flow into or out of the windows.
a Syntax
DRAWWINDOVFLOW RNZ, X, Y
A-19

-------
Module IAQMENUS
EDITMASTER. Statement
B Action Procedure to edit entries in the MASTER file.
m Syntax
EDITMASTER
Module IAQMENUS
EDITNOTES Statement
a Action Procedure within EDITMASTER for editing the notation lines.
m Syntax
EDITNOTES
Module IAQPC
EQ$ Function
H Action String function used to display the EQUIP settings,
H Syntax
x$ * EQ$(IZ)
Module IAQPC
!QD$ Function
a Action String function used to give range values for EQUIP.
B Syntax
x$ = EQD$(IZ)
A-20

-------
Module IAQMAIN
IRRMSG Statement
a Action Procedure to display text for selected errors that might be
encountered.
B Syntax
ERRMSG
Module BASICD
EXPANDEDFLOORPLAN Statement
H Action Procedure which displays a floorplan with the porper number of rooms.
B Syntax
EXPANDEDFLOORPLAN FPZ, NR2
Module 1AQMENUS
PXl*EAXi£R? Statement
m Action Message saying a file could not be found.
B Syntax
FILEALERT
Module IAQMENUS
FILENAMEWINDOV Statement
B Action Window for specifically entering a file name for loading or saving.
H Syntax
FILENAMEWINDOV HDRS, DPATH$, EXI$, FILES, AS
A-21

-------
Module IAQMENUS
FILESHOV Statement
m Action Lists files of s given type.
a Syntax
FILESHOV
Module GRAPH
FLOORGRAPHSETUP Statement
B Action Defines window for showing a graphical floorplan.
B Syntax
FLOORGRAPHSETUP
Module BASICD
FLOORPLAN Statement
B Action Draws a specified floor plan.
¦	Syntax
FLOORPLAN FPI, NRZ
Module CALC
GAXIS Statement
m Action Draws a crude axis representation for the dynamic concentration
display.
¦	Syntax
GAXXS HZ9 YOZ, XOZ, LZ
A-22

-------
Module IAQMENUS
G1NCOPYS Function
B Action Message describing the generic copy of data.
B Syntax
i$ - GENC0PY5
Module IAQMENUS
GENSINKS Function
u Action Function returning specific sink names.
¦ Syntax
x$ - GENSINKS(IZ)
Module IAQMENUS
GENSOURCE$ Function
a Action Function returning specific source names.
m Syntax
x$ - GENSOURCE $(IZ}
Module IAQMENUS
GETLASTTIME Statement
H Action Procedure to obtain the last recorded time in a pollutant history
file.
B Syntax
GETLASTTIME TZ, MSZ, MPOLZ, LAST!
A-23

-------
Module GRAPH
GRAPHAVERAGE Statement
m Actios Graphs the current pollution values in each room.
H Syntax
GRAPHAVERAGE
Module GRAPH
GRAPHAVERAGECLOSE Statement
B Action
B Syntax
GRAPHAVERAGECLOSE
Module GRAPH
GRAPHAVERAGEHIST Statement
H Action
B Syntax
GRAPHAVERAGEHIST
Module GRAPH
GRAPIAVERAGEIHIT Statement
a Action
m Syntax
GRAPHAV1RAGEINIT
A-24

-------
Module GRAPH
GRAPHCYCLES Statement
B Action Graphs the cyclic variation schedules.
B Syntax
GRAPHCYCLES
Module GRAPH
G1APHFL0WS Statement
B Action Graphs the flows in each room.
B Syntax
GRAPHFLOWS
Module GRAPH
GRAPHSXSTORY Statement
B Action Graphs the stored time history of pollutants,
S^^xtaix
GRAPHHISTORY
Module GRAPH
GRAPBXCSD1SPATCH Statement
B Action This routine sets up graphics calls and selects a particular routine
to call.
u Syntax
x « GRAPHICSDISPATCH(IPZ)
A-25

-------
Module GRAPH
GRAPHICSINIT Statement
m Action Initializes graphics functions for differnt video adapters.
B Syntax
GRAPHICSINIT WP AS SCRNPAR, WPO AS SCRNPAR
Module GRAPH
GRAPHICSRESTORE Statement
B Action Returns to proper text display after graphics displays.
B Syntax
GRAPHICSRESTORE WP AS SC1NPA1, WPO AS SCRNPAR
Module GRAPH
GRAPHLOCATIONS Statement
B Action Graphs location in each room of sources, sinks, cleaners, and cyclces.
B Syntax
GRAPHLOCATIONS
Module GRAPH
GRAPILOG1ISTORY Statement
B Action Graphs logarithmic display of stored pollutant history.
B Syntax
GRAPHLOGHISTORY
A-26

-------
Module GRAPH
GRAPHHENU Stat ement
u Action Selects graphing options.
m Syntax
GRAPHHENU
Module GRAPH
GRAPH100MS Statement
a Action Graphs floorplan, doors, windows, and ventilation openings.
B Syntax
GRAPHROOMS
Module CAliC
GRPH Statement
Dynmamic text-graphic display called during CALCCONC.
H Syntax
GRPH K2, T
Module CALC
GRPHINIT Statement
H Action Initializes varaibles for GRPH.
m Syntax
GRPHINIT T
A-27

-------
Module CALC
GRPHSHIFT Statement
a Action Moves the GRPH display to the left when times greater than 48 hours
are being displayed.
B Syntax
GRPHSHIFT
Module BALANCE
HALLCALC Statement
a Action Calculates flows into and out of the hall from all other rooms and the
HVAC.
B Syntax
HALLCALC
Module BALANCE
HALLFLOVS Statement
H Action Computes the flows from each room into the hall.
¦ Syntax
HALLFLOWS MI, HVF1, RETPR, 1MFL0¥(), RMPRESSU1EO , INTERCON
Module BASICD
HALLPRESSTJREAVG Function
a Action Computes the pressure in the hall by averaging pressure drops to
adjacent rooms.
B Syntax
at - HALLPRISSUREAVG
A-2B

-------
Module BASICD
HSCHSD Statement
m Action Menu for entering HVAC operating schedule.
H Syntax
HSCHED
Module CALC
HVACCALC Statement
H Action Calculates concentrations in the HVAC from outside and return air
flows.
H Syntax
HVACCALC
Module BASICD
HVDESCRIPTION Statement
m Action Menu for entering HVAC data and balancing flows.
B Syntax
HVDESCRIPTION
Module XAQMENUS
IAQCONFIG Statement
B Action Menu for setting the operating configuration of the program.
B Syntax
IAQCONFIG BSZ, GRZ, MFSZ, BMMZ, DPATHS
A-29

-------
Module IAQFC
IAQLOGO Statement
B Action Procedure whichs displays the opening logo and credits.
a Syntax
IAQLOGO TZ
Module IAQMAIN
INBDAT Statement
B Action Procedure which initialises variables to default values.
a Syntax
i
INHDAT
Module OUTPUT
INPAGE1 Statement
B Action Displays a page of input data.
m Syntax
INPAGE1
Module OUTPUT
INPAGE2 Statement
B Action Displays a page of input data.
H Syntax
INPAGE2
A-30

-------
Module OUTPUT
INPAGI3 Statement
¦	Action Displays s page of input data.
H Syntax
INPAGE3
Module OUTPUT
XNPAGE4 Statement
¦	Action Displays a page of input data.
m Syntax
INPAGE4
Module OUTPUT
INPAGE5 Statement
¦	Action Displays a page of input data.
^ Syntax
INPAGE5
Module OUTPUT
IHPAGE6 Statement
m Action Displays a page of input data.
a Syntax
INPAGE6
A-31

-------
Module OUTPUT
INPAGE7 Statement
m Action Displays a page of input data.
B Syntax
INPAGE7
Module OUTPUT
t
INPAGE8 Statement
B Action Displays a page of input data.
B Syntax
INPAGE8
Module IN1QQK
INKM Statement
B Action
B Syntax
INEM
Module BALANCE
INRMAIRCLEAN Statement
B Action Menu for setting locations cleaners in rooms.
B Syntax
INKMAIRCLEAN
A-32

-------
Module INROOM
INRMCYCLES Statement
a Action Menu for setting locations of cycles in rooms.
B Syntax
INRMCYCLES
Module INROOM
IHR.M1HITC0NC Statement
m Action Menu for selecting the initialization of room concentrations.
B Syntax
IN1MINITC0NC
Module INROOM
INRMSINKS Statement
a Action Menu for setting locations of sinks in rooms.
a Syntax
INRMSINKS
Module INROOM
INRMSOURCS Statement
m Action Menu for setting locations of sinks in rooms.
a Syntax
IN1MS0U1CE
A-3 3

-------
Module BALANCE
1NTEGRALFL0V Function
m Action Function which returns the time integral of its argument; used for
hall flows in the balancing process.
m Syntax
* - INTEGRALFLOW(SWX, X)
Module BASICD
INTERCONMENU Statement
m Actios Sub-menu for entering interconnecting areas.
m Syntax
INTERCONMENU RNZ) STATI
Module BASICD
INTERCONNECTIONS Statement
m Action Displays interconnection areas.
a Syntax
INTERCONNECTIONS FPI, NRZ, RNZ
Module BASICD
INTERCONSET Statement
¦ Action Zeroes hall interconnection areas when no hall is present.
B Syntax
INTERCONSET
A-34

-------
Module IAQMAIN
LDBASICDESIGNFILE Statement
/
M Action File loader for the basic design.
a Syntax
LDBASICDESIGNFILE
Module IAQMAIN
LDCLEANERFILE Statement
a Action File loader for the cleaners.
H Syntax
LDCLEANERFILE
Module IAQMAIN
LDHVACFILE Statement
B Action File loader for the HVAC and flows.
B Syntax
LDHVACFILE
Module IAQMAIN
LDINRMFILE Statement
m Action File loader for the inroom locations.
B Syntax
LDINRMFILE
A-3 5

-------
Module IAQMAIN
LDMASTERFILE Statement
m Action File loader for the MASTER file.
m Syntax
LDMASTERFILE
Module IAQMAIN
LDPOLFILI Statement
a Action File loader for the pollutant sources.
H Syntax
LDPOLFILE
Module IAQPC
LETTERA Statement
B Action Draws an "A" in the logo.
B Syntax
LITTERA XZ, YZ
Module IAQPC
LETTERC Statement
B Action Draws a "C" in the logo,
m Syntax
LETTERC XZ, YZ
A-36

-------
Module IAQPC
LETTERI Statement
a Action Draws an *1* in the logo.
Syntax
LEX^TERI XZ i YZ
Module IAQPC
LETTE1F Statement
a Action Draws a "P" in the logo.
B Syntax
LETTERP XZ. YZ
Module IAQPC
L1TTS&Q Statement
B Action Draws a *Q" in the logo.
B Syntax
LETTERQ XZ , YZ
Module CALC
LIMCONC Function
B Action Returns the limit specifed for pollutant KZ.
Syntax
x - LIMCONC(KZ)
A-37

-------
Module BASICS
LOADBASICDESIGN Stitemeot
B Actios Caller for file loader for basic design.
B Syntax
LOADBASICDESIGN
Module STRENGTH
L0ADCLEANE1 Statement
u Action Caller for file loader for cleaners.
m Syntax
LOADCLEANER
Module OUTPUT
LOADHISTORY Statement
¦ Action Caller for file loader for pollutant history.
B Syntax
LOADHISTORY
Module BASICD
LOADHVAC Statement
m Action Caller for file loader for HVAC/flows.
B Syntax
LOADHVAC
A-38

-------
Module IAQMENUS
LOADIAQCONFIG Ststemest
m Action File loader for configuration file.
H Syntax
LOADIAQCONFIG GRZ, DFATH$, MASTIRFILESAVEX, BEGINMAINMENUZ
Module IAQMAIN
LOADINRM Statement
a Action Caller for file loader for inroom data.
B Syntax
LOADINRM
Module IAQMENUS
LOADKASTIR Statement
m Action Caller for file loader for MASTER file.
S^ncit&3c
LOADMASTER
Module STRENGTH
LOADFOLLDTAKTS Statement
B Action Caller for file loader for pollutant sources.
m Syntax
LOADPOLLUTANTS
A-39

-------
Module IAQMENUS
MAINMENU Statement
H Action Menu for entering or exiting the program.
H Syntax
MAINMENU
Module CALC
MASTERCALCINIT Statement
B Action Procedure that controls all CALC intializations.
B Syntax
MASTERCALCINIT
Module CALC
MASTIRCALCEUN Statement
m Action Procedure that controls all CALC running.
a Syntax
MASTERCALCRUN TO, TF
Module IAQMENUS
MAXOP Statement
m Action ssage display>xng 1 xttixt IX.
H Syntax
MAXOF II
A-40

-------
Module GRAPH
MAX?IKE Function
m Actios This function rounds the value of the maximum time stored in the
pollutant history file to a convenient value for graphing.
m Syntax
i = MAXTIME(LASTT, NTTZ)
Module BALANCE
UAXVICIOtI Function
H Action This function returns a TRUE if the largest component of array E is
greater than TOL, the desired tolerance.
m Syntax
x - MAXVECTORZ(NRZ, R(), TOL)
Module IAQMENUS
HODIFYCONFIG Statement
m Action
B Syntax
MODIFYCONFIG
Module IAQMENUS
0PIHDATAFIL12 Function
¦ Action This procedure attempts to open a data file for input or output. If
it is sucessful, it returns a TRUE value.
a Syntax
x = OFENDATAFILEZ(DPATH$, FILES, EXT$, CHZ, WZ>
A-41

-------
Module 1AQMENUS
OPENMENUSCREEN Statement
B Action
a Syntax	-
OPENMENUSCREEN
Module IAQMENUS
OPEHTMPFXLE Statement
¦	Action This procedure opens a file with the MASTER file name and the
extension .IMP for storing the pollutant history as it is calculated.
Syn tfi3E
s,
OPENTMPFILE TI, F$
Module IAQMENXJS
OPERATINGMENU Statement
H Action This menu selects the principal program options for entering,
calculating, and storing program data.
a Syntax
OPERATINGMENU
Module CALQ
OUTCONC Statement
¦	Action This procedure stores the calculated concentrations in the temporary
file open by OPENTMPFILE.
¦	Syntax
OUTCONC
A-42

-------
Module OUTPUT
OUTPUTCOHC Statement
m Action This procedure prints or displays the current concentrations in all
rooms.
B Syntax
OUTPUTCONC
Module OUTPUT
OUTPUfFLOWS Statement
m Action This procedure prints or displays the values of the room flows.
a syntax
OUTPUTFLOWS
Module OUTPUT
OUTB.ES Statement
¦ Action This menu selects the data to be output and allows a choice of output
devices.
B Syntax
OUTRES
Module OUTPUT
PAGEHEADER Statement
a Action This procedure prints the page number as the input data are displayed
or printed.
B Syntax
PAGEREADER IZ
A-43

-------
Module OUTPUT
PL Statement
a Action Prints the string preceeding each line of output.
B Syntax
PL
Module STRENGTH
POLAVG Statement
m Action This procedure allows the pollutant averaging times to be input.
m Syntax
POLAVG
Module OUTPUT
FOLLIZST Statement
B Action This procedure prints or displays the contents of the pollution
history file.
B Syntax
POLLHIST
Module STRENGTH
POLLIM Statement
m Action This menu procedure allows the pollutant limits to be input.
a Syntax
POLLIM
A-44

-------
Module STRENGTH
POLLtJTANTMENU Statement
B Actios This menu controls the selection and dat input for the pollutant
sources.
H Syntax
POLLOTANTMENU
Module IAQMENUS
POLNAMES Function
B Action This function returns the name of pollutant 12.
B Syntax
x$ - P0LNAME$C1X)
Module STRENGTH
POLSETUP Statement
B Action This procedure formats some of the source display menus.
m Syntax
POLSETUP TEXTS, T$, A()
Module STRENGTH
POLSETUFB Statement
a Action This procedure formats other source display menus.
B Syntax
POLSETOTB TEXTS, T$. A(), NZ, SWZ
A-45

-------
Module STRENGTH'
FOLSRC Statement
m Action This menu allows the pollutant sources to be characterized.
a Syntax
FOLSRC
Module BALANCE
PRESSUREAVG Function
B Action Computes pressure in a room by averaging the pressure drops to
adjacent rooms, weigthted by volume flow.
a Syntax
x - PRESSUREAVG(IZ)
Module OUTPUT
PRINTC1 Statement
a Action This procedure formats the printing of output data.
B Syntax
FRINTCH X
Module CALC
PRNTCONC Statement
¦ Action This procedure prints the pollutant concnetrations as they are being
calculated.
m Syntax
PRNTCONC
A-46

-------
Module EASICD
PRHTFLOWS Statement
m Action This procedure prints the room flows.
H Syntax
PRNTFLOWS HZ
Module CALC
PRTCHCONC Statement
B Action Prints to the output device the current concentrations.
a Syntax
PRTCHCONC
Module OUTPUT
PRTCHFLOVS Statement
B Action Prints to the output device the flow values.
B Syntax
X - PRTCHFLOVS(HI)
Module CALC
P1TPR0CESS Statement
B Action This procedure controls the printing or graphing of calculated results
as they are being performed.
m Syntax
PRTPROCESS T, DELT
A-4 7

-------
Module STRENGTH
PSINK Statement
M Action This procedure allows the
H Syntax
PSINK SW2
KMDIS Statement
sinks to be characterized.
Module IAQMENUS
m Action This procedure prints the
_ S/utaz
RMDIS RNZ, NRZ, AO AS LONG
RMOD Function
building data for a given room.
Module IAQMENUS
B Action Real MOD function (remainder
¦ Syntax
i - RMOD(X, Y)
RMSTAT Statement
after integer division).
Module INROOM
¦ Action This procedure prints the inroom locations set in the menu.
H Syntax
RMSTAT
A-48

-------
Module IAQMENUS
RNCHANGEZ Function
m Action This function returns a permissible next room number in line with the
maximum and minimum values allowed for the floorplan.
¦	Syntax
x « RNCHANGEZ(KZ, RNZ, NRZ)
Module CALC
ROOMCALC Statement
a Action Calculates concentration in each room
B Syntax
ROOMCALC
Module IAQMAIN
ROOHDAT Statement
¦	Action This procedure assigns default values to building variables.
m Syntax
ROOMDAT
Module BALANCE
R0OMFLOWS Statement
m Action This procedure calculates the flows into and out of each room during
the flow balancing process.
a Syntax
ROOMFLOWS NRZ, HVPR, RETPR, RMFLOW(), RMFRESSURE(), INTERCON
A-49

-------
Module BASICD
ROOMNUMBERS Statement
m Action This procedure prints reference room numbers on the screen in a
pattern corresponding to the building layout.
H Syntax
ROOMNUMBERS FP2, NRX
Module BASICD
SAV1BAS1CDES1GN Statement
B Action This procedure controls the file save operation for basic design,
a Syntax
SAVEBASICDESIGN
Module STRENGTH
SAVECLEANER Statement
h Action This procedure controls the file save operation far cleaners.
a Syntax
SAVECLEANER
Module BASICD
SAVEHVAC Statement
m Action This procedure controls the file save operation for HVAC and flows.
m Syntax
SAVEHVAC
A-50

-------
Module IAQMSNUS
SAVEIAQCONFIG Statement
a Action This procedure saves the operating configuration data.
a Syntax
SAVIIAQCONFIG GR2, DPATH$» HFSI, BMMZ, WRZ, BSZ, NTBRZ, NTKEYZ
Module INROQM
SAVEINRM Statement
m Action This procedure controls the file save operation for inroom locations.
H Syntax
SAVEINHM
Module 1AQMENUS
SAVEMASTER Statement
B Action This procedure controls the file save operation for MASTER file data.
¦ Syntax
SAVEMASTER
Module STRENGTH
SAVEPOLLUTANTS Statement
H Action This procedure controls the file save operation for pollutant source
data.
Syntax
SAVE P 0 LLUTAN T S
A-51

-------
Module.STRENGTH
SELECTCLEANERS Statement
m Action This menu allows air cleaner types to be selected.
B Syntax
SELECTCLEANERS
Module STRENGTH
SELICTPOLLUTAHT Statement
B Action This menu allows up to 6 pollutants to be selected.
m Syntax
SELECTPOLLUTANT
Module STRENGTH
SETCLEANERPERF Statement
m Action This menu allows data entry for air cleaner efficiencies.
B Syntax
SETCLEANERPERF
Module IAQMAIN
SETDEFADLTS Statement
m Action This procedure controls the setting and reading of default values and
files.
m Syntax
SETDEFAULTS
A-S2

-------
Module OUTPUT
SETOUTDEV Statement
m Action This procedure allows the output channel to be selected.
a Syntax
SETOUTDEV DEVICE!
Module STRENGTH
SINKS?! Statement
m Action This menu allows the sink efficiencies to be input.
a Syntax
SINKSTR NSNKI, SWZ
Module IAQMENUS
SLXPCATCH Statement
B Action This procedure restores the screen when traversing to a higher menu
level.
b Syntax
SLIPCATCH WP AS SC1NPAR
Module BALANCE
SQRP Function
¦ Action This function returns the pressure dependence root of the absolute
value of its argument times the sign of its argument.
H Syntax
x - SQRP(X)
A-5 3

-------
Module STRENGTH
SKCSTR Statement
B Actios This menu allows the pollutant source strengths to be input.
B Syntax
SRCSTR NSRJ
Module IAQMENUS
STDBOfS Function
B Action This function returns a standard message for display at the bottom of
a menu.
B Syntax
x$ - STDBOTS
Module OUTPUT
STOREHISTORY Statement
B Action This procedure allows the pollutant history file to be stored under a
different name.
B Syntax
STOREHISTORY
Module IAQMAIN
SVHASTERFILE Statement
B Action This procedure saves the MASTER file data.
B Syntax
SVMASTERFILE
ASA

-------
Module BALANCE
TOTALAREA Function
m Action This function returns the total flow resistance of all rooms for HVAC
delivery, returns, or windows.
B Syntax
x - TOTALAREA (SWZ, IC())
Module IAQMENUS
USEIAQMENU Statement
u Action This procedure initializes the IAQMENUS module.
a Syntax
USEIAQMENU
Module IAQMENUS
VECTO&AVG Function
¦	Action This function returns the average value of a one-dimensional array
over all the rooms.
a Syntax
x - VECTORAVG(NUZ, R(J)
Module CALC
VENTFLOW Function
¦	Action This function scales the room flows according to the HVAC operating
schedule.
HI •* J W-
x = VENTFLOW(T)
A-SS

-------
APPENDIX B PROGRAM LISTINGS
This part of the manual lists in detail the modules that make up IAQPC,
except for the library routines. The following discussion was presented in
Appendix A, but is repeated here for convenience.
Within the modules, variables may be passed as arguments or by being
SHARED. Between separate modules, variables may only be passed as arguments or
in COMMON blocks.
In QB4, procedures (subroutines) may either be called explicitly, as CALL
XYZ(x,y,z), or implicitly, as XYZ x,y,z. The former style requires the
parentheses, while the latter style requires the absence of parentheses. The
implicit call has been used throughout IAQPC because it resembles spoken English
more closely. The procedure has a verb-like function, and the arguments
resemble nouns.
Functions, in QB$, are like functions in other computer languages: they
return a value and require arguments in parentheses. It is difficult to
distinguish QB4 functions from data arrays, which also return values and require
arguments in parentheses. In fact, some data arrays in the development of IAQPC
were later replaced by functions with the same name. The distinguishing feature
of functions in QB4 is that they are defined in DECLARE statements at the
beginning of each module in which they appear. If you cannot determine whether
an array-like object is a function or an array, look for its appearance in the
DECLARE statements at the beginning of the module.
QB4 also allows for INCLUDE files in its syntax. This are files specified
in a certain way which do not reside with the module itself, but which are read
into the compiler when the INCLUDE statement is encountered. Most of the
INCLUDE files in IAQPC are used to introduce DECLARE statements consistently
from module to module. Some are used in a similar way to introduce COMMON
blocks consistently.
Procedures and functions whose names are given with all capital letters
are library routines. Some are ones provided in QB4, while the remainder have
been written for IAQPC.
B-l

-------
Program Documentation
\ind\iaqpc.asc
Version 2.0
IAQPC
1:	* $INCLUDE: '\qb4\level0.pub'
2:	'$INCLUDE: '\qb4\levell.pub'
3j	'$INCLUDE: '\qb4\vindovp.pub'
4:	'$INCLUDE: '\qb4\level2.pub *
5:	•$INCLUDE: '\qb4\menup.pub'
6:
7s	DECLARE FUNCTION EQ$ (iZ)
8s	DECLARE FUNCTION EQD$ (12)
9s
10s	DECLARE SUB CommaodHelp ()
lis	DECLARE SUB Iaqlogo (tZ)
12:	DECLARE SUB Letterl (xZ, yZ)
13:	DECLARE SUB LetterA (xZ, yl)
14i	DECLARE SUB LetterQ (xZ, yZ)
15:	DECLARE SUB LetterP (xZ, yZ)
16:	DECLARE SUB LetterC (xZ, yZ)
17:	DECLARE SUB ModifyConfig ()
18:	DECLARE SUB ModifyDataPath ()
19:	DECLARE SUB OpenMenuScreen ()
20:
21:	OpenMenuScreen
22:
23:	IF COMMANDS <> ¦¦ TIEN
24:	c$ » UCASE$(COMMANDS}
25:	CENTXT 2, "IAQPC COMMAND OPTION"
26:	IF INSTR(c$, ¦/M") THEN
27 s	ModifyConfig
28:	ELSEIF INSTR(c$, */D"> THEN
2 9:	Modi fyDat aPa th
30;	ELSE
31:	CommandHelp
32:	END IF
33:	a$ ¦ UCASE$(PAUSESTR(0, "Proceed with IAQPC? (Y/N)"))
34:	CLV 1
35:	IF a$ <> *Y" THEN
36:	IF GRAPH > 1 THEN PALETTE
37:	CLS
38:	SYSTEM
39:	END IF
40:	tZ = 10
41:	END IF
42:
43:	IF tZ ¦ 0 THEN
44:	a$ * IMKEY$
45:	IF a$ <> •" THEN tZ • 10 ELSE tZ « 80
46:	END IF
47:
48:	Iaqlogo tZ
49:
50:	SCOLOR 10, 0
51:	CLS
52:	CENTXT MIDLINE, 'Loading IAQPCRUN..
B-2

-------
Program	Documentation. Version 2.0	IAQPC
53s	IF EXISTFILE{"iaqpcrun") THEN
54*.	IF EXISTFILECiaqpcrun.exe") THEN KILL 'iaqpcrun.exe*
55:	NAME "iaqpcrun" AS "iaqpcrun.exe"
56s	END IF
57s	CLEAR , , 1000
58s	RUN "iaqpcrun.exe"
59:
60:	END
61s
62:	SUB ConmandHelp
63:	il « 4
64:	PRUT iZ, 10, "Invoke options on the cosmand lines*
65:	PINT if + 2, 10, 'IAQPC /H(elp) for this screen."
66:	PRNT iX + 3, 10, 'IAQPC /M(od) for changing equipment
configuration.*
67s	PRNT iX + 4, 10, 'IAQPC /D(ata) for changing path to data
files.*
68:	END SUB
69:
70s	FUNCTION EQ$ (iX)
71:	IF iX ¦ 1 THIN EQ$ - "IBM «"
72:	IF IX - 2 THIN EQ$ - "MONITOR «"
73:	IF iX - 3 THEN EQ$ - "GRAPH -*
74:	IF iX ¦ 4 THEN EQ$ - "PRINTER ¦"
75:	IF iX - 5 THIN EQ$ - "SOUND -¦
76:	IF iX - 6 THIN EQ$ - "MOUSE -*
77s	IF iX - 7 THEN EQ$ - "ASPECT ¦¦
78 s	END FUNCTION
79:
80:	FUNCTION EQD$ (iX)
81:	IF iX - 1 THEN EQD$ - "[0=nonstandard, l=slow PC, 2=fast PC]'
82s	IF iX - 2 THEN EQD$ - "[O-BV, 1-colorj"
83:	IF iX - 3 THEN EQD$ - "[0-none, 1-CGA, 2-EGA, 3-VGA, -
l-Hercules]*
84:	IF iX - 4 THEN EQD$ = ¦[0-none, l=any]'
85:	IF iX - 5 THEN EQD$ - *[>100-frequency of chirp,0=no sound]"
86:	IF iX ¦ 6 THEN EQD$ * *[<50-slover response,>50=faster
response]"
87;	IF iX - 7 THEN EQD$ ¦ '[use values to adjust shapes of boxes,
0.-2.]*
88:	END FUNCTION
89:
90:	SUB laqlogo (tX)
91:	MPALETTI 7, 56
92:	COLOR 0, 7
93 :	CLS
94:	xboxX — 3
95:	yboxX ¦ 0
96:	NARROWFRAME yboxZ, xboxX, yboxX + 22, xboxl + 69
97:	NARROWFRAME yboxX + 2, xboxX + 1, yboxZ + 18, xboxX + 61
98:	NARROWFRAME yboxX + 4, xboxX + 2, yboxZ + 14, xboxX + 54
99:	DELAY tX
100i	xintZ = 6
101:	yintZ = 2
1-3

-------
Program Documentation
Version 2.0
IAQFC
102	s
103	s
104	s
105	s
106s
107	s
108	s
109	s
110	s
Ills
112:
113 s
114:
1151
116
117
118
119
120
121
122
123
124
125
126
127
128
129:
LOCATE
3,
60:
PRINT
"I
N
D 0
0
R"
130:
LOCATE
5,
64:
PRINT
"A
I
R*


131:
LOCATE
7.
60:
PRINT
¦Q
u
A L
I
T Y*
132
133
134
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
xshZ = 12
yshZ = 4
FOR iZ - 1 TO 2
IF iZ = 1 THEN
COLOR 0
LOCATE yshZ, xshZ
ELSE
COLOR 11
LOCATE yshZ + 2, xshZ
END IF
xZ - POS<0>: yZ
DELAY t Z
Letterl xZ, yZ
xZ ¦ xZ + xintZ:
DELAY tZ
LetterA xZ, yZ
xZ - xZ + 2 + xintZ: yZ - yZ ~ yintZ
DELAY tZ
LetterQ xZ,
xZ « xZ + 2
DELAY tZ
LetterP xZ,
xZ - xZ + 2
DELAY tZ
LetterC xZ, yZ
DELAY tZ
IF iZ «= 1 THEN
CSSLIN
yZ - yZ + yintZ
yZ
+ xintZ:
yZ
4- xintZ i
yZ = yZ - yintZ
yZ « yZ - yintZ
DELAY tZ
ELSE
COLOR 11
135:
LOCATE
4,
57:
PRINT
*1
N
D 0
0
R"
136:
LOCATE
6,
61s
PRINT
"A
I
R"


137:
LOCATE
8,
57s
PRINT
"Q
U
A L
I
T Y"
END IF
NEXT
DELAY tZ
IF GRAPH >- 2 THEN MCOLOR 3, -1
LOCATE 14, 45: PRINT 'Version 2.0"
DELAY tZ
LOCATE 18, 37s PRINT "Research Triangle Institute";
LOCATE , 7: PRINT "PAL"
DELAY 2 * tZ
PRINT "US Environmental Protection Agency'
LOCATE 22
DELAY 2 *
END SUB
38:
tZ
SUB LetterA (xZ,	yZ)
LOCATE yZ + 0,	xZ + 0:	PRINT
LOCATE yZ + 1,	xZ + Os	PRINT
LOCATE yZ + 1,	xZ + 4:	PRINT
LOCATE yZ + 2,	xZ + 0:	PRINT
1-4

-------
Program Documentation
156
157
158
159
160
161
162
163
164
165
166
167
168
169	j
170	s
171s
172:
204;
205s
206:
207 s
208:
209:
LOCATE yZ
LOCATE yZ
LOCATE y2
LOCATE yZ
LOCATE yZ
LOCATE yZ
END SUB
LOCATE J 2
LOCATE yZ
LOCATE yZ
LOCATE yl
T nrATF «!
uUvA 4 £t y &
LOCATE yl
END SUB
Version 2.0
+ 2,	xZ + 4:	PRINT
+3,	xZ + 0:	PRINT
+ 4,	xZ + 0:	PRINT
+ 4,	xZ + 4s	PRINT
+5,	xZ + Os	PRINT
+ 5,	xZ + 4:	PRINT
IAQPC
IxZ,
yZ5


+ o,
xZs
PRINT
Him
+ 1.
xZs
PRINT
*11"
+ 2,
xZs
PRINT
"II'
+ 3,
xZs
PRINT
.n.
+ 4,
xZi
PRINT
.n.
+ 5,
XZ:
PRINT
"Ill
173:
SUB Letterl
(xZ, yZ)



174:
LOCATE yZ
+
0, xZ
+
Os PRINT
"mr
175:
LOCATE yZ
+
1, xZ
+
1: PRINT
"H"
176:
LOCATE yZ
+
2, xZ
+
1: PRINT
"H"
177:
LOCATE yZ
+
3, xZ
+
Is PRINT
"n*
178:
LOCATE yZ
+
4, XZ
+
Is PRINT
"U"
179:
LOCATE yl
+
5, XZ
+
Os PRINT
"¦m*
180:
END SUB





181:






182:
SUB LetterP
 ** THEN
B-5

-------
Program Documentation	Version 2.0	IAQPC
210;	aZ = 1
211:	PRNT CSRLNW +2, 10, 'Environment: EQUIP*" + &$
212: ELSEIF EX1STFILE("equip.cnf*) THEN
213:	aZ « 2
214!	£Z - FREEFILE
215:	OPEN "equip.cnf" F01 INPUT AS ifX
216:	LINE INPUT #fl, a$
217:	CLOSE #fX
218:	PRNT CSRLNW +2, 10, "EQUIP.CNF: EQUIP-" + a$
219: ELSE
220:	al - 3
221s END IF
222: PINT CSRLNW + 2, 23, "IBM + STR$(IBM)
223s PINT CSELNW, 50, "{0, 1, 2]*
224: PRNT CSRLNW + 1, 25, 'MONITOR + STR$(MONITOR)
225: PRNT CSRLNW. 50, *[0, 1]'
225: PRNT CSRLNW + 1, 25, •GRAPHICS «¦ + STR$(GRAPH)
227: PRNT CSRLNW, 50, "[0, 1, 2, 3, -1, -2, -3]'
228: PRNT CSRLNW + 1, 25, 'PRINTER «=" + STR$(PRNTR)
229: PRNT CSRLNW, 50, * 10, 1]¦
230: PRNT CSRLNW + 1, 25, "SOUND ¦=' + STRS(SOUNDF)
231: PRNT CSRLNW, 50, "[0 - 10000]"
232s PRNT CSRLNW +1, 25, "MOUSE + STR$(MOUSEVAL)
233: PRNT CSRLNW, 50, "[2 - 92]"
234: r - 0
235: b$ « ASPECTR(O)
236: PINT CSRLNW +1, 25, "ASPECT «» + b$
237: PRNT CSRLNW, 50, "[x.jcxx]"
238:
239: IF aZ - 1 THEN
240s	PRNT CSRLNW +2, 10, "The environment value of EQUIP*
overides all other choices,"
241:	PRNT CSRLNW +1, 10, "You must reset it from DOS by using a
statemomt of the form:*
242:	PRNT CSRLNW + 2, 20, "set equip=i,m,g,p,s,m,a"
243:	PRNT CSRLNW +2, 10, "or delete it altogether with 'set
equip-*.*
244: ELSEIF al - 2 THEN
245:	rZ - CSRLNW
246:	PRNT CSRLNW +2, 10, "The EQUIP.CNF values overide internally
determined ones."
247:	PRNT CSRLNW +1, 10, "You may edit the file EQUIP.CNF
directly or use this program"
248:	PRNT CSRLNW + 1, 10, "to do it for you. Press *Y' for direct
changes to EQUIP.CNF,"
249:	PRNT CSRLNW + 1, 10, "or any other key to proceed."
250: ELSE
251:	rZ - CSRLNW
252:	PRNT CSRLNW + 2, 10, "The present values were determined by
the program, because neither"
253:	PRNT CSRLNW + 1, 10, "an environment variable EQUIP= nor an
EQUIP.CNF were found. If"
254:	PRNT CSRLNW + 1, 10, "these values are accurate, you may
proceedj if not, you may create*
B-6

-------
Program Documentation	Version 2.0	IAQPC
255:	PRNT CSRLNW + 1, 10, "EQUIP.CNF directly from this program.
Press *Y* to do so,"
256!	PUNT CSRLNW + 1, 10, "or any other key to proceed."
257:	END IF
258:	IF aZ ¦ 1 THIN
259;	PAK 0
260:	x$ - •"
261: ELSE
262:	x$ ¦ UCASE$(PAUSESTR(0, "Y or any key")}
263:	END IF
264:	IF x$ - "Y* THEN
265 s	DO
266:	CLB rZ, 0, HWIN, WIN
267s	c$ - »*
9CQ ,	PAP - 1 if A 7
Ai VU •	f Ulv X* X 1V »
ZOV *	Jfc Kfl i> Li » | |	\ X* y
270:	Cl - POSW
271:	PINT rZ + IX + 2, 25, EQD$(iZ)
272:	SETCURS0R rX + iX - 1, cX
273:	tS - SINPUT("")
274:	PINT rX + iX + 2, 25, SPACES(LEN(EQD$(iZ)))
275:	c$ ¦ c$ + tS
276:	IF iZ < 7 THEN eg - c$ + \"
277:	NEXT
278:	PRNT CSRLNW. 25, "EQUIP-' + e$
279:	z$ - DCASE$(PAUSESTR(0, "Is this correct? Y/N/Esc"))
280s	IF x$ = "Y" THEN
281s	fX - FREEFILE
282s	OPEN "equip.enf" FOR OUTPUT AS #fZ
283s	PRINT #fZ, c$
284:	CLOSE #fZ
285;	EXIT DO
286:	ELSIIF x$ «= CHR$(27) THEN
287:	EXIT DO
288:	END IF
289:	LOOP
290:	END IF
291: END SUB
292:
293:	SUB ModifyDataPath
294:	CENTXT 4, "Modify Data Path.*
295:	a$ ¦ "menu.cnf"
296: IF EXISTFILE(a$) THEN
297;	DIM t$(6)
298:	fZ - FREEFILE
299:	OPEN "menu.cnf" FOR INPUT AS fZ
300:	FOR jZ - 1 TO 6
301:	LINE INPUT #fl, tS(jZ)
302:	NEXT
303:	INPUT #fZ, grZ, d$, mfsZ, braZ
304:	CLOSE fZ
305:	PRNT CSRLNW + 2, 14, "The current data path is *" + d$ +
306:	PRNT CSRLNW +2, 14, "Enter a path to your data files, ending
with a \"
B-7

-------
Program
307;
308	s
309	s
310:
3XX •
312:
313:
314 s
315s
316	s
317	j
318	s
319s
320:
321s
322:
323:
324:
325 s
326:
327s
328	s
329	s
330	s
331s
332:
333 s
334s
335
336
337
338
339
340
341
342
343
344
Documentation	Version 2.0
rZ = CSRLNW
PINT CSRLNW + 4, 14, "Examples: c:\ind\dat\ -- for a full
data path"
FRNT CSRLNW +1. 14, •	dat\ -- for a
directory below the present one"
FRNT CSRLNW +1, 14, »	\dat\ -- for a
directory off the root directory"
FRNT CSRLNW + 1, 14, *	I -- for the
current directory*
FRNT rZ + 1, 32, "Paths *
x$ - SINPUTS("")
IF *$ « " THEN
CENTXT MIDLINE + 6, "Data Path Not Changed.*
ELSE
x$ - RTRIM$(LTRIM5(x$))
IF x$ • "f* THIN x$ - ¦¦
OPEN "menu.cnf" FOR OUTPUT AS fZ
FOR jZ « 1 TO 6
PRINT #fZ, t$(jZ)
NEXT
WRITE IfZ, grZ, x$, mfsZ, bmZ
CLOSE fZ
CENTXT MIDLINE + 6, "Data Path Updated.*
END IF
ERASE t$
ELSE
PRNT CSRLNW +3, 14, "The file MENU.CNF is not in the current
directory. You*
PRNT CSRLNW +1, 14, "you need to copy it into this directory
for the data *
PRNT CSRLNW +1, 14, "path modification. If you cannot find
a copy, the docu-*
PRNT CSRLNW + 1, 14, "mentation contains a listing that can
be entered by hand"
PRNT CSRLNW +1, 14, "with an ASCII text editor."
PA! 0
END
END IF
END SUB
SUB OpenMenuSereen
USEMENU
DEFINEWINDOW 1, 0, 0, 24, 79, 15, 1
MC0L0R 15, 1
END SUB
IAQPC
B-8

-------
Program Documentation
\IND\IAQSU1P.PUB
Version 2.0
IAQPC
1:	DECLARE FUNCTION AirChangesl (ml, VolI(). RmFlowi {))
2:	DECLARE FUNCTION CIName$ (iZ)
3:	DECLARE FUNCTION CycleName$ (iZ)
4;	DECLARE FUNCTION GenCopyS ()
S;	DECLARE FUNCTION GenSink$ (iZ)
6:	DECLARE FUNCTION GeriSource$ (iZ)
7:	DECLARE FUNCTION MaxVectorX (ilZ, iuZ, rl(), Tol!)
8:	DECLARE FUNCTION OpenDataFileZ (Dpath$, File$, EztS, wrZ)
9s	DECLARE FUNCTION PolNameS (iZ)
10:	DECLARE FUNCTION 1MOD (x, y)
lis	DECLARE FUNCTION StdBot$ ()
12s	DECLARE FUNCTION VectorAvg! (ilZ, iuZ, c())
13:
14:	DECLARE SUB BarCatch (rowZ, colZ, levelZ)
IS:	DECLARE SUB DisplmyFiles (Dpath$, Ext$)
16;	DECLARE SUB FileAlert ()
17:	DECLARE SUB FileNameVindov (Hdr$, Dpath$, Ext$, FileS, a$)
18:	DECLARE SUB GetLastTime (tZ, mrZ, mpolZ, lastt)
19:	DECLARE SUB OpenTmpFile (tZ, f$)
20:	DECLARE SUB MaxOf (iZ)
21;	DECLARE SUB RmDis (rnZ, NrZ, a() AS LONG}
22:	DECLARE SUB SlipCatch (vp AS SCRNPAR)
B-9

-------
Program Documentation	Version 2,0	IAQPC
\IND\1AQC0MMN.PUB
1: 'data file names
2: COMMON SHARED /FILECOMMON/ DpathS, MasterFile$, MfsZ, GrZ,
DeviceZ
3: COMMON SHARED /FILECOMMON/ NoteQ AS STRING, BuildingFileS,
HVACFile$
4: COMMON SHARED /FILECOMMON/ PolFile$, ClFile$, InFile$
5:
6: 'individual rooms
7: COMMON SHARED /ROOMS/ Fpl, NrX, Vol(), InterConO AS SINGLE
8:
§s *HVAC system
10s COMMON SHARED /HVACS/ FlowExp, VolFlow, FanDP, HVP, RetP,
MakeUpAir, MinFlow
11: COMMON SHARED /HVACS/ Balanced!, HtimesO AS SINGLE, lmFlow()
AS SINGLE
12:
13: 'pollutants
14: COMMON SHARED /PNMS/ In AS LONG, GenerieSrcf}, SinkO, SinkTcQ
15: COMMON SHARED /PNMS/ PavgTO, PlimC), AmbientConc(), Cycles O,
AlignTime
16: COMMON SHAKED /PNMS/ RmSk{) AS LONG, RmSrO AS LONG, RmCyt) AS
LONG
17:
18: 'cleaners
19s COMMON SHARED /CLEANERS/ Cn AS LONG, Cliff(), RmCn() AS LONG
20 s
21: 'runtime
22s COMMON SHARED /RunT/ StepTime, PrntTime, RunDuration,
ConcInitType AS INTEGER
23: COMMON SHARED /RunT/ IntrptAt, SdZ, Sdr2, FsdZ, OutchZ
24: COMMON SHARED /RunT/ Initialized AS INTEGER. TO, Tf
B-10

-------
Program Documentation
\ind\iaqmain.asc
Version 2.0
IAQPC
1:
' $INCLUDE
2:
»$INCLUDE
3:
'SINCLUDE
4:
'$INCLUDE
5:
* $INCLUDE
6:
* $INCLUDE
7:
•SINCLUDE
8:
~SINCLUDE:
9:
'$INCLUDE:
14
15
16
1?
18
'\qb4\level0.pub*
*\qb4\levell.pub'
*\qb4\windowp.pub'
*\qb4\graphp«pub *
*\qb4\minicalp.pub *
'\qb4\level2.pub*
*\qb4\menup.pub *
'\ind\iaqsubp.pub *
'\ind\iaqcoinmn.pub'
10 j
lis DECLARE SUB CalcFirstlnit ()
12t DECLARE SUB CommandLineProe (a$)
13s DECLARE SUB ErrMsg (}
DECLARE SUB Inhdat O
DECLARE SUB LdBasicDesignFile ()
DECLARE SUB LdCleanerFile <)
DECLARE SUB LdHVACFile (}
DECLARE SUB LdMasterFile (}
19: DECLARE SUB LdPolFlle ()
20: DECLARE SUB LdlnRmFile ()
21: DECLARE SUB LoadlaqConfig (GrI, Dpath$. MsfZ, BMMZ)
22i DECLARE SUB LoadlaqRunConfig (STime, PTime, RDur, IntAt, SdZ, FsdZ
, SdrZ)
23s DECLARE SUB MainMenu {)
24s DECLARE SUB MaaterCalcInit ()
25s DECLARE SUB MasterCalcRun (TOI, Tfl)
26: DECLARE SUB OperatingMenu ()
27; DECLARE SUB RoomDat ()
28: DECLARE SUB SavelaqRunConfig (Slime, PTime, RDur, IntAt, SdZ, FsdZ
, SdrZ)
29: DECLARE SUB SetDefaults ()
30: DECLARE SUB SvMasterFile ()
31: DECLARE SUB UselAQMemi ()
32:
33; CLEAR , , 1600
34 i	a
35: DIM SHARED Maxrooms
36: Maxrooms ¦ 20
37 j
38: USEMENU
39: USEGRAPHICS
40: IF PRNTR > 0 THEN GETPRINTER
41: MCLD
42: SCRNOPN 2: REM reserve channel 2 for output
43 s
44: 'these arrays are passed in iaqcommn.pub, but must be
dimensioned
45: 'before they can be used.
46:
47: DIM Noted TO 4) AS STRING
48s DIM Vol(0 TO Maxrooms), InterCon(0 TO Maxrooms, 0 TO 6) AS SINGLE
49: DIM Htimes(0 TO 8) AS SINGLE, RmFlow(0 TO Maxrooms, 1 TO 6) AS
B-ll

-------
Program	Documentation Version 2.0	IAQPC
SINGLE
50:	DIM RaPressure(0 TO Maxrooms) AS SINGLE
31i	DIM GenericSrc(1 TO 8, 1 TO 11}, Sink(l TO 4, 1 TO 11), SinkTc(l
TO 4. 1 TO 11}
52;	DIM PavgT(1 TO 11}, Plim(l TO 11), AmbientConc(1 TO 11), Cycles(1
TO 8)
53s	DIM RmSktl TO 4) AS LONG, RmSr(l TO 8) AS LONG, RmCyfl TO 8) AS
LONG
54i	DIM CIEffU TO 9, 1 TO 11), RmCn(l TO 2) AS LONG
56s	cmd$ ¦ RTRIM$(COMMANDS)
57s	IF cmd$ <> "" AND INSTR(cmd$, "/") * 0 THEN
58:	ComnandLineProc cmd$
59:	GOTO xit
60:	END IF
61:
62:	ON ERROR GOTO recover
63:	GETCONFIG WrZ, Bsl, NtbrX, NtKeyX
64:	LoadlaqConfig GrX, Dpath$, MfsZ, BMMI
65:	SetDefaults
66:	UselAQMenu
67:
68:	SETLEVEL 1
69s	IF BMMI THEN
70s	OperatingMenu
71s	END IF
72:
73:	conts
74;	IF SCREENMODE > 3 TIEN SCREEN 0
75:	MainMenu
76:
77s	IF GRAPH > 1 THEN PALETTE
78:	BLINKON
79:
80:	xit:
81:	SCREEN 0
82:	COLOR 10, 0
83:	CLS
84:	END
85;
86:	recovers
87:	ErrMsg
88 s	DELAY 50
89s	t$ - IMKEY5
90:	IF t$ - CHR$(27) THEN GOTO xit
91:	IF t$ - CHR$(13) THEN GOTO cont
92:	RESUME
93;
94:	* GenericSrc
95s	DATA 30,1,0,50,60,.8,0,1,.01,.001,300
96i	DATA 0,0,0,200,12.7,0,0,0,0,0,50000
97:	DATA ,1,0,0,565,50,40,0,2,0,0,165
98:	DATA 5e-5,0,0,20,4e-5,200,1,30,0,0,40
99:	DATA .01,.01,.01,.01..01,.01,.01..01,.01,.01,.01
B-12

-------
Program Documentation	Version 2.0	IAQPC
100:	DATA .01,.01..01,.01,.01,.01..01..01,.01,.01,.01
101:	DATA .01,.01,.01,.01..01,.01,.01,.01,.01,.01,.01
102:	DATA .01..01,.01, .01, .01,.01, .01. .01,.01,.01,.01
103 i
104s	* SINK
105;	DATA .01,.02,.03,.04,.05,.06,.07,.08,.09,.10,.11
106:	DATA .01,.02,.03,.04,.05,.06,.07,.08,,09,.10,.11
107:	DATA .01,.02,.03,.04,.05,.06,.07,.08,.09,.10,.11
108:	DATA .01,.02,.03,.04,.05,.06,.07,.08..09,.10,.11
109:
110:	' PavgT
111:	DATA 24,8,8,8,8,8,24,8,3,3,1
112:
113:	' Plim
114:	DATA .26,.075,.075,1760,40,30,4,.12,.16,.16,16.7
115:
116:	* Ambient
117:	DATA .01,.001,.0001,400,.4,.05,1,.01,.001,.001,1800
1 "l.'fl J
119:	SUB CommandLineProc (fS)
120:	COLOR 10, 0
121:	CLS
122:	LoadlaqConfig GrZ, Dpath$, Hfsl, BMMZ
123:	RoomDat
124:	Inhdat
125:	Chnl » FREEFILE
126:	0P1N Dpath$ + f$ + '.log* FOR OUTPUT AS #clmZ
127:	WRITE IchnZ, "Start time: * + TIME? + * for " + UCASE$(f$)
128:	HasterFileS « f$
129:	f$ » DpathS + HasterFile$ + ¦.mst*
130:	IF EXISTFILE(f$) THEN
131:	LdMasterFile
132:	a$ - DpathS + BuildingFile$ + ".bid"
133:	IF EXISTFILE(a$} THEN LdBasicDesignFile
134:	a$ = Dpath$ + HVACFile$ + *.hvc"
135:	IF EXISTFILE(a$) THEN LdHVACFile
136:	a$ ¦ DpathS + PolFile$ + ".pol"
137:	IF EXISTFILE(a$) THEN LdPolFile
138:	a$ = DpathS + ClFile$ + *.cln"
139:	IF EXISTFILE(a$) THEN LdCleanerFile
140:	a$ = DpathS + InFile$ + ".inr"
141:	IF EXISTFILE(a$) THEN LdlnRmFile
142:	SdZ ¦ 0
143:	IntrptAt = 0
144:	FsdZ ¦ TRUE
145:	TO ¦ 0
146:	Tf ¦ 24 * RunDuration
147:	MasterCalcInit
148:	MasterCalcRun TO, Tf
149:	END IF
150:	WRITE IchnZ, "Stop time: " + TIMES
151:	CLOSE
152:	END SUB
153:
B-13

-------
Program Documentation	Version 2.0	IAQFC
154:
SUB ErrMsg

155:
a$ =
•Error Code:" + STS$(ERR>
156s
SELECT CASE ERR
15? :
CASE
5

158:
b$
— 9
illegal function call."
159 j
CASE
6

160:
b$
•
overflow. Check for aero values.
161:
CASE
7

162:
b$
¦> »
out of memory.*
163:
CASE
9

164:
b$
m 9
subscript out of range.*
165:
CASE
li

166;
b$
¦ *
division by zero."
167:
CASE
14

168:
b$
s *
out of string space."
169:
CASE
24

170:
b$
¦ »
device timeout."
171:
CASE
25

172:
b$
SB *
device fault."
173:
CASE
27

174:
b$
m '
out of paper."
175:
CASE
51

176:
bS
m 9
internal error•
177;
CASE
52

178 s
bS
m 9
bad file naflie.
179:
CASE
53

180:
bS
_ *
file not found."
181:
CASE
54

182:
b$
m «
bad file mode."
183:
CASE
55

184:
b$
m 9
file already open.*
185:
CASE
57

186:
bS
m 9
device I/O error.*
187:
CASE
58

188:
bS
m 9
file already exists."
189:
CASE
61

190:
b$
m 9
disk full."
191:
CASE
62

192:
b$
B »
input past end of file."
193:
CASE
64

194:
b$
S *
bad file name."
195:
CASE
67

196:
b$
«. «
too many files."
197:
CASE
68

198:
b$
= •
device unavailable."
199:
CASE
69

200:
b$
m 9
COM buffer overflow."
201:
CASE
71

202:
b$
m 9
disk not ready.*
203:
CASE
72

204:
b$
_ ¦
disk media error."
205:
CASE
75

206:
b$
¦1 *
path/file access error."
207:
CASE
76

B-14

-------
Program Documentation	Version 2.0
208:	b$ = " path not found."
209:	CASE ELSE
210:	END SELECT
211:	CENTXT MIDLINE, a$ + b$
212:	CENTXT CSRLIN + 1, *Press  to halt program.*
213:	CENTXT CSRLIN + 1, "Press  to bypass problem.
214:	END SUB
215:
216:	SUB Inhdat
217:	FOR iZ ¦ 1 TO 2
218:	SETBITOF In, iZ
219:	NEXT
220:	FOR iZ - 1 TO 8
221:	FOR jZ - 1 TO 11
222:	READ GenericSrc(iZ, jZ)
223:	NEXT
224:	NEXT
225:	FOR iZ « 1 TO 4
226:	FOR jZ • 1 TO 11
227:	READ Sink(iZ, jZ)
228:	NEXT
229:	FOR jZ - 8 TO 11
230:	SinkTc(iZ, jZ) - 0
231:	NEXT
232:	NEXT
233:	FOR IZ - 1 TO 11
234:	READ PavgT(iZ)
235:	NEXT
236:	FOR iZ - 1 TO 11
237:	READ Plin(iZ)
238:	NEXT
239:	FOR iZ * 1 TO 11
240:	READ AmbientConc(iZ)
241:	NEXT
242:
243:	StepTime - .1
244:	PratTime = .2
245:
246:	Cn - 0
247:	CLRBITOF Cn, 0
248:	SETBITOF Cn, 5
249:
250:	FOR jZ = 1 TO 9
251:	ClEff (jZ, 1) = .08
252:	ClEff (jZ, 2) - .02
253:	ClEff(jl, 3) - .001
254:	FOR iZ = 4 TO 11
255:	ClEff(jZ, iZ) - .5
256:	NEXT
257:	NEXT
258:	END SUB
259:
260:	SUB LdBasicDesignFile
261:	chnZ = FREEFILE
B-15

-------
Program	Documentation Version 2.0	IAQPC
262s	OPEN DpathS + BuildingFileS + ".bid" FOR INPUT AS IchnZ
263:	INPUT IchllZ, FpZ, NrZ
264s	FOE II = 0 TO NrZ
265:	IF NOT (EOF(chnZ)) THIN INPUT IchnZ, Voi(iZ), InterCon(iZ, 1),
InterConUZ, 2), InterCon(iZ, 3), InterCon(iZ, 4), InterCon(i
266:	Z, 5), InterCon(iZ, 6)
267:	NEXT
268:	CLOSE chnZ
269:	END SUE
270:
271:	SUB LdCIesnerFile
272:	chnZ - FREEFILE
273:	OPEN DpathS + ClFileS + ".cln* FOR INPUT AS chnZ
274:	INPUT IchnZ, Cn
275:	FOR jZ « 1 TO 9
276:	FOR IZ - 1 TO 11
277:	INPUT IchnZ, Cliff(jZ, iZ)
278:	NEXT
279:	NEXT
280s	FOR iZ - 1 TO 4
281:	FOR jZ ¦ 1 TO 11
282:	INPUT IchnZ, Sink(iZ, jZ), SinkTc(iZ, jZ)
283 s	NEXT
284:	NEXT
285:	CLOSE chnZ
286:	ENS SUB
287:
288;	SUB LdHVACFile
289:	ChnZ = FREEFILE
290:	OPEN DpathS * HVACFile$ + ".hvc" FOR INPUT AS chnZ
291:	INPUT #chnZ, FlowExp, VolFlow, FanDP, MakeUpAir, MinFlow, HVP,
RetP, BalancedZ
292:	FOR iZ = 0 TO Maxrooms
293s	INPUT IchnZ, RmFlow(iZ, 1), RmFlow(iZ, 2), RmFlow(iZ, 3),
RmFlow(iZ, 4), RmFlow(iZ, 5), RmFlow(iZ, 6)
294:	NEXT
295:	INPUT #chnZ, Htimes(O), Htimes(1), Htimes(2), Htimes(3), Htimes(
4)
296:	INPUT IchnZ, Htimes(5), Htimes(6), Htimes<7), Htimes(85
297:	IF NOT EOF(chnZ) THEN
298:	FOR iZ » 0 TO Maxrooms
299s	INPUT IchnZ, RmPressure(iZ)
300:	NEXT
301:	INPUT IchnZ, HVPr
302:	END IF
303:	CLOSE chnZ
304:	END SUB
305:
306:	SUB LdlnRmFile
307:	chnZ - FREEFILE
308:	OPEN Dpath$ + InFileS + ".inr" FOR INPUT AS chnZ
309;	FOR jZ - 1 TO 2
310:	INPUT IchnZ, RmCn(jZ)
311:	NEXT
B-16

-------
Program Documentation	Version 2.0	IAQPC
312s	FOR jX = 1 TO 4
313s	INPUT IchnZ, RmSk(jZ)
314s	NEXT
315s	FOR jZ ¦ 1 TO 8
316s	INPUT IchnZ, RmSr(jX)
317s	NEXT
318s	FOR jZ - 1 TO 8
319s	INPUT IchnZ, RmCy(jZ)
320s	NEXT
321s	INPUT IchnZ, ConcInitType
322:	CLOSE chnZ
323s	END SUB
324s
325s	SOT LdMasterFile
326s	chnZ - FREEFILE
327s	OPEN DpathS + HasterFileS + ".mst" FOR INPUT AS chnZ
328s	INPUT IchnZ, BuildingFileS
329s	INPUT IchnZ, HVACFileS
330:	INPUT IchnZ, PolFileS
331s	INPUT IchnZ, ClFileg
332s	INPUT /chnZ, InFileg
333:	FOR jZ - 1 TO 4
334s	LINE INPUT IchnZ, Note(jZ)
335:	NEXT
336:	INPUT #chnZ, StepTime, PrntTime, RunDuration, IntAt, SdZ, FsdZ,
SdrZ
337:	CLOSE chnZ
338:	OPEN DpathS ~ 'current.fil* FOR INPUT AS chnZ
339:	INPUT IchnZ, t$
340:	CLOSE chnZ
341:	IF t$ <> HasterFile$ THEN
342:	OPEN DpathS ~ 'current.fil* FOR OUTPUT AS chnZ
343:	PRINT IchnZ, MasterFile$
344:	CLOSE chnZ
345:	END IF
346s	t$ * "
347;	END SUB
348:
349:	SUB LdPolFile
350:	chnZ ¦ FREEFILE
351:	OPEN DpathS + PolFileS + *.pol" FOE INPUT AS chnZ
352:	INPUT IchnZ, In
353 s	In - In AND 4094
354:	FOR iZ = 1 TO 8
355:	FOR jZ « 1 TO 11
356:	INPUT IchnZ, Genericsrc(iZ, jZ)
357:	NEXT
358:	NEXT
359:	FOR iZ - 1 TO 11
360;	INPUT IchnZ, PavgT(iZ)
361:	NEXT
362:	FOR iZ - 1 TO 11
363:	INPUT IchnZ, Plim(iZ)
364:	NEXT
B-17

-------
Program Documentation	Version 2.0	IAQFC
365s	FOR it - 1 TO 11
366s.	INPUT #ehnl, AmbientConc(il)
367s	NEXT
363s	FOR il ¦ 1 TO 8
369$	INPUT #ehnZ, Cycles (iZ)
370s	NEXT
371s	INPUT #chnZ, AlignTime
372s	CLOSE chnl
373s	END SUB
374s
375:	SUB RoomDat
376?	FpZ - 2
377s	NrZ » 4
378 s
379s	FOE il - 1 TO 20
380s	Vol(if) - 1000
381:	InterCon(iZ, 1) - .2
382:	InterConCiZ, 5) - 24J
383:	InterCon(iZ» 6) » .5
384:	FOR jZ - 2 TO 4
385:	InterCon(iZ, jZ) ¦= 0
386:	NEXT
387s	NEXT iZ
388:
389s	FlowExp - II
390:	VolFlow ¦ 20001
391s	FanDP - 81
392:	MakeUpAir ¦ .2
393s	MinFlov • 20!
394s	Htimes(O) ¦ 2
395s	Htiaes(l) « 01
396:	Htimes(2) - 24!
397:	FOR iZ - 1 TO 20
398:	FOR jZ - 2 TO 5
399s	RmFlovtiZ, jZ) ¦ 0
400s	NEXT
401:	RmFlow(iZ, 1) « VolFlow / NrZ
402:	RmFlow(iZ, 6) « -VolFlow / NrZ
403:	NEXT
404 s	END SUB
405:
406:	SUB SetDefaults
407:	RoomDat
408:	Inhdat
409s	MasterFileS = "fDEFAULT*
410:	chnZ - FREEFILE
411s	f$ « DpathS + "current.fil*
412:	IF EXISTFILE(fS) THEN
413:	OPEN f$ FOR INPUT AS #chnZ
414s	INPUT IchnZ, MasterFileS
415:	CLOSE chnZ
416s	END IF
417:	f $ ¦ DpathS + MasterFileS + *.mst"
418s	IF EXISTFILE(fS) THEN
B-18

-------
Program Documentation	Version 2.0	IAQPC
419:	LdMasterFile
420:	a$ ¦ Dpath$ + BuildingFileS + ".bid"
421:	IF EXISTFILE(aS) THIN LdBaeicDesignFile
422i	a$ = Dpath$ + HVACFile$ + ".hvc"
423.*	IF EXISTFILE(a$) THEN LdHVACFile
424s	a$ - Dpath$ + PolFile$ + *.pol"
425:	IF EXISTFlLE(aS) THIN LdPolFile
426:	a$ - Dpath$ + ClFile$ + ".cln"
427:	IF EXISTFILE(a$) THEN LdCleanerFile
428:	a$ - DpathS + InFile$ + ". inr*
429:	IF EXISTFILE(a$) THEN LdlnRaFile
430:	CalcFirstlait
431:	ELSE
432:	MC0L0R 10, 0
433:	CENTXT MIDLINE, "Data files not found. Please edit the data
path"
434i	CENTXT CSRLNV+1,'using IAQPC /D or any ASCII editor on MENU.CNI
435:	END
436:	END IF
437s	END SUB
438:
439:	SUB SvMasterFile
440:	chnZ - FREEFILE
441:	OPEN Dpath$ + MasterFile$ + *.mst" FOE OUTPUT AS chnZ
442:	PRINT IchnZ, BuildingFile$
443:	PRINT IchnI, HVACFileS
444:	PRINT #chnZ. PolFileS
445:	PRINT #chnZ, ClFile$
446:	PRINT #chnZ, InFile$
447s	FOR jZ » 1 TO 4
448s	PRINT IctrnZ, Note(jZ)
449s	NEXT
450:	WRITE #chnZ, StepTime, PrntTime, RunDuration, IntAt, SdZ, FsdZ,
Sdr Z
451s	CLOSE chnZ
452:	OPEN Dpath$ + "current.fil' FOR INPUT AS chnZ
453:	INPUT #chnZ, t$
454:	CLOSE chnZ
455s	IF t$ <> MasterFile$ THEN
456:	OPEN Dpath$ + 'current.fil" FOR OUTPUT AS chnZ
457:	PRINT IchnZ, MasterFile$
458:	CLOSE chnZ
459:	END IF
460:	t$ - "
461:	END SUB
B-19

-------
Program Documentation
\ind\inroom.asc
Version 2.0
IAQPC
Is
2
3
4
5
6
7
8
9
10
11
12:
13:
14:
IS:
16:
17:
18:
19:
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46:
47s
48:
49:
50:
51s
52:
*$INCLUDE:
'$INCLUDE:
*$INCLUDE:
'$INCLUDE:
'$INCLUDE:
'$INCLUDE:
*$INCLUDE:
'$INCLUDE:
'\qb4\level0.pub*
'\qb4\levell.pub'
' \qb4\windcrwp. pub'
*\qb4\minicalp.pub *
'\qb4\level2.pub *
'\qb4\menup.pub'
¦\ind\iaqsubp.pub *
' \ind\iaqcomnm.pub"
DECLARE FUNCTION RnChangeX (kZ, rnZ, NrZ)
DECLARE SUB Conclnit (icZ)
DECLARE SUB CopyAllRm (rnZ, ill, iuZ)
DECLARE SUB CopyRm (rnZ, HZ, iuZ, a AS LONG)
DECLARE SUB ExpandedFloorPlan (FpZ, NrZ)
DECLARE SUB GraphicsDispatch (iZ)
DECLARE SUB Innn ()
DECLARE SUB InRmAirClean ()
DECLARE SUB InRmCyclee {)
DECLARE SUB InRmSource (}
DECLARE SUB InRmlnitConc ()
DECLARE SUB InRmSinks ()
DECLARE SUB LdlnRmFile ()
DECLARE SUB LoadlnRm ()
DECLARE SUB RmStat ()
DECLARE SUB SavelnBm ()
DECLARE SUB SvMasterFile ()
DIM SHARED ml
END
SUB CopyAllRm (rnZ, ilZ, iuZ)
FOR jZ = 1 10 2
CopyRm rnZ, ilZ, iuZ, RmCn(jZ)
NEXT
FOR jZ - 1 TO 4
CopyRm rnZ, ilZ, iuZ, RmSk(jZ)
NEXT
FOR jZ - 1 TO 8
CopyRm rnZ, ilZ, iuZ, RmSr(jZ)
NEXT
END SUB
SUB CopyRm (rnZ, ilZ, iuZ, a AS LONG}
jZ ¦ idxZ
tlZ ¦ TSTBIT{a, rnZ)
FOR iZ ¦ ilZ TO iuZ
IF tlZ THEN SETBITOF s, xZ ELSE CLRBITOF a, iZ
NEXT
END SUB
B-20

-------
Program Documentation	Version 2.0
53 i
54s	SUB Inrm
55 :	DIM wp AS SCRNPAR
56:	STATIC ipZ
57;	ell - 10
58:	scZ « HIDSCRN + 10
59s	Title$ * "IN-ROOM, Locations"
60:	Te*t$ ¦ "Room Sources,Passive Sinks,Air Cleaners"
61i	Text$ = Text? + ".Cyclic Variation*
62:	TextS ¦ Text$ + *,Initial Concentrations"
63j	TextS ¦ TextS + Building Statistics.Load Inroom File"
64:	TextS " TextS + ".Save Inroom File,,Quit to Main Menu, 
65:	rnZ ¦ IMAXCO, IMIN(NrZ, rnZ}}
66:	DO
67:	SETCOL scZ
68:	MC0L0R 1, 0
69:	SETCTOSOl 8, 0
70:	ExpandedFloorPlan FpZ, NrZ
71:	PRNT 17, 1, *HVAC system is room #" + STR$(NrZ +1) +
72:	OPMEN Title$, TextS, StdBotS, ipZ, Key$
73:	IF Key$ - CHR$(27) OR ipZ - 10 THEN EXIT DO
74:	IF Key$ - CHR$(13) THEN
75:	IF ipZ < 6 THEN
76:	SAVEPAR 1, wp
77:	BarCatch ipZ + 7, scZ, 3
78:	IF ipZ » 1 THEN InRmSource
79:	IF ipZ * 2 THEN InRmSinks
80:	IF ipZ « 3 THEN InRmAirClean
81:	IF ipZ = 4 THEN InRmCycles
82:	IF ipZ » 5 THEN InSmlnitConc
83:	SETLEVEL 2
84:	SlipCatch wp
85:	CLW 1
86:	END IF
87:	IF ipZ - 6 THEN RmStat
88:	IF ipZ - 7 THEN LoadlnRm
89:	IF ipZ - 8 THEN SavelnRm
90:	END IF
91:	IF KeyS - *g" THEN GraphicsDispatch 3:SETLEVEL 2
92:	LOOP
93:	TitleS -
94:	TextS ¦
95:	END SOB
96:
97:	SUB InRmAirClean
98:	STATIC ipZ
99:	colZ - IMAX(24, 14 + NrZ + (NrZ + 1} \ 4)
100:	elZ - 7
101:	Title$ ¦ "In-Room Air, Cleaners,Mark the Ones in Use*
102:
103:	InRmAirCleanO:
104s	tl$ -
105:	t2$ =
106:	IF rnZ <= NrZ THEN
B-21

-------
Program Documentation	Version 2-0
107:	ill = 1
108s	iuZ - 5
109:	ELSE
110s	ill = 6
111:	iuZ - 9
112 •.	END IF
113s	FOR jZ = ilZ TO iuZ
114s	IF TSTBITCCn, jZ) AND tl$ « •, * THEN
115;	tl$ - tlS + ClName(jZ)
116:	ELSEIF TSTBIT(Cn. jZ) AND t2$ ¦ THEN
117:	t2$ = t2$ + ClName(jZ)
118:	EXIT FOR
119;	END IF
120:	NEXT
121:	Text? - "Room Number'
122:	Text$ - Text$ + tl$
123:	Text$ - TextS + t2$
124:	TextS ¦ TextS + GenCopy
125:	SETCOL colZ
126:	GETROW Title$, TextS, ""
127:	TOGGLEBOT
128:	PUTROW
129:	HCOLOR 0. 2
130:	CLB 10, 1, 12, NrZ + 6 + (NrZ + 1) \ 4
131:	DO
132:	t$ - STRS(rnZ) + CHR$(255)
133:	FOR jZ - 1 TO 2
134;	IF TSTBIT(RmCnCjX), rnZ) THIN Fsel$ - "x" ELSE Psel$ = CHR$(
255)
135:	t$ - COMPOSEVAL(t$, Psel$>
136:	NEXT
137;	GETVAL t$
138;	MCOLOR 1, 0
139;	PUTVAL
140:	HCOLOR 0, 2
141:	SETCURSOR 9, 2
142:	RmDis rnZ, NrZ, RmCn()
143:	MCOLOR 3, 0
144:	TOGGL1MEN ipZ, plusZ
145;	IF ipZ - 0 OR ipZ - elZ THIN EXIT DO
146;	IF plusZ - 61 THEN
147:	IF ipZ - 2 OR ipZ - 3 TIEN CopyRm mZ, ml + 1, NrZ, RmCn<
ipZ - 1)
148:	ELSEIF plusZ - 62 THEN
149:	IF ipZ - 2 OR ipZ - 3 THEN CopyRm rnZ, 1, rnZ - 1, RmCn(ipZ
- 1)
150:	END IF
151:	rZ - CSRLNV - ipZ + 1
152:	IF ipZ - 1 AND plusZ > 0 THEN plus! - TRUE
153:	IF plusZ - TRUE OR plusZ = FALSE THEN
154:	IF plusZ THEN
155:	rnZ = rnZ + 1
156:	IF rnZ > NrZ + 1 THEN ml = 0
157:	ELSE
B-22

-------
Program Documentation	Version 2.0	XAQPC
158:	rnZ = rnZ - 1
159:	IF raZ « 0 THEN rnZ - NrZ + 1
160:	END IF
161s	IF ml - NrZ OR rnZ = NrZ + 1 OR rnZ = 0 THEN
162:	CLB rZ + 1, colZ ~ 17, rZ + 2, coIZ + 23
163:	GOTO InRmAirCleanO
164:	END IF
165:	ELSEIF (ipZ - 2 OR ipZ - 3) AND plusZ <- 13 THEN
166:	X0RBIT0F RmCn(ipZ - 1), rnZ
167:	ELSEIF xpZ ¦= 4 THEN
168:	FOR jZ « 1 TO 2
169:	CopyRm rnZ, rnZ + 1, NrZ, RmCn(j Z)
170:	NEXT
171:	ELSEIF ipZ - 5 THEN	/
172:	FOR jZ - 1 TO 2
173:	CopyRm raZ, 1, rnZ - 1, RmCn(jZ)
174:	NEXT
175:	END IF
176:	LOOP
177:	END SUB
178:
179:	SUB InRmCycles
180:	STATIC ipZ
181:	colZ - IMAXC24, 14 + NrZ + (NrZ + 1) \ 4)
182:	elZ - 13
183:	TitleS * *In-Roon, Source Cycles,Mark those Present"
184:	Tezt$ - "Room Number*
185:	FOR jZ - 1 TO 8
186:	Text? - TextS + *,* + CycleName(jZ)
187:	NEXT
188:	Text$ ¦ TextS + GenCopy
189:	SETCOL colZ
190:	GETROW TitleS, TextS,
191:	TOGGLEBOT
192:	PtITROW
193:	MCOLOR 0, 2
194:	CLB 7, 1, 15, NrZ + 6 + (NrZ + 1) \ 4
195:	DO
196:	t$ - STR$(rnZ) + CHR$(255)
197:	FOR jZ - 1 TO 8
198:	IF TSTBIT(JtaCytjZ), rn!) THEN PselS = "x" ELSE PselS - CHR$(
255)
199:	t$ = COMPOSEVAL(tS, Psel$)
200:	NEXT
201:	GETVAL t$
202:	MCOLOR 1, 0
203:	PUTVAL
204:	MCOLOR 0, 2
205:	SETCURSOR 6, 2
206:	RmDis rnZ, NrZ, RmCy()
207:	MCOLOR 3. 0
208:	TOGGLEMEN ipZ, plusZ
209:	IF ipZ - 0 OR ipZ - elZ THEN EXIT DO
210:	rZ = CSRLNW - ipZ + 1
B-23

-------
Program	Documentation Version 2.0	IAQPC
211j	IF ipZ - 1 AND plusI > 0 THEN plus! - TRUE
212:	IP plusZ - 61 THEN
213s	IF ipZ >- 2 AND ipZ <« 9 THEN CopyRm rnZ, rnZ + 1, NrZ,
RmCy(ipZ - 1)
214:	ELSEIF plusZ - 62 THEN
215:	IF ipZ >« 2 OR ipl <= 9 THEN CopyBm rnZ, 1, rnZ - 1, RmCy (
ipX - 1)
216:	END IF
217:	IF plusZ - TRUE OR plus! = FALSE THEN
218:	IP plusZ THEN
219:	rnZ ¦ rnZ + 1
220:	IF raZ > NrZ + 1 THEN rnZ - 0
221:	ELSE
222:	rnZ « rnZ - 1
223 s	IF rnZ < 0 THEN mJ - NrZ + 1
224:	END IF
225j	ELSEIF ipZ >- 2 AND ipZ <- 9 AND plus! <- 13 THEN
226;	XQRBITOF RmCy(ipZ - 1), rnZ
001 •	VT GVTV {nf — in TIHTM
•tw' •	£"
253:	SETCOL 24
254:	DO
255:	OPMEN Title$, TextS. StdBotS. ipZ, KeyS
256:	IF Key$ - CHR$(27) OR ipZ - 7 THEN EXIT DO
257:	IF Key$ = CHR$(13) THEN
258:	ConcInitType ® ipZ
259:	IF ipZ ¦ 5 THEN ConcInitType = 0
260:	Conclnit (ConcInitType)
261:	EXIT DO
262:	END IF
B-24

-------
Program Documentation	Version 2.0	IAQPC
263s LOOP
264 2	SETCOL MIDSCRN
265:	END SUB
266:
267s	SUB InRmSinks
268:	STATIC Ipl
269:	col2 - IMAX(24, 14 + NrZ + (NrZ + 1) \ 4)
270:	elZ ¦ 9
271:	Title$ ¦ "In-Room,Passive Sinks,Mark Those Present"
272:	Text$ - "Room Number"
273s	FOR jZ - 1 TO 4
274:	Text$ ¦ Tezt$ + *,¦ + GenSink(jZ)
275s	NEXT
276j	Text? ™ TextS + GenCopy
277:	SETCOL COlZ
278s	GETROW Title$, TextS, ¦¦
279 s TOGGLEBOT
280: PUTROV
281s MCOLOR 0, 2
282s	CLS 9, 1, 13, NrZ + 6 + (NrZ + 1) \ 4
283:	DO
284:	t$ - STR$(rnZ) + CHR$(255>
285:	FOR jZ - 1 TO 4
286:	IF TSTBIT(SmSk(jZ), ml) THEN Psel$ - "x* ELSE Psel$ - CHR$(
255)
287:	t$ - COMPOSEVAL(t$, Psel$)
288:	NEXT
289s	GETVAL t$
290s	MCOLOR 1, 0
291:	PUTVAL
292:	MCOLOR 0, 2
293 s	SETCtJRSOR 8, 2
294:	RmDis rnZ, NrZ, RmSk()
295:	MCOLOR 3, 0
296:	TOGGLEMEN ipZ, plusZ
297:	IF ipZ - 0 OR ipZ - elZ THEN EXIT DO
298:	rZ = CSRLNW - ipZ + 1
299:	IF ipZ - 1 AND plusZ > 0 THEN plusZ «= TRUE
300:	IF plusZ = 61 THEN
301:	IF ipZ >- 2 AND ipZ <« 5 THEN CopyRm rnZ, rnZ + 1, NrZ,
RmSk (ip Z m 1)
302:	ELSEIF plusZ = 62 THEN
303:	IF ipZ >= 2 OR ipZ <¦ 5 THEN CopyRm rnZ, 1, rnZ - 1, HmSk(
ipZ - 1)
304:	END IF
305:	IF plusl - TRUE OR plusZ - FALSE THEN
306:	IF plusZ THEN
307:	rnZ ¦ rnZ + 1
308:	IF rnZ > NrZ + 1 THEN rnZ «= 0
309:	ELSE
310:	rnZ = rnZ - 1
311:	IF rnZ < 0 THEN rnZ = NrZ + 1
312:	END IF
313:	ELSEIF ipZ >= 2 AND ipZ <= 5 AND plusZ <= 13 THEN
B-25

-------
Program Documentation	Version 2.0	IAQPC
314s	XORBITOF RmSk(ip2 - 1), rnZ
315! •	ELSIIF ipZ - 6 THIN
316 r	FOR jZ = 1 TO 4
317*.	CopyRm ml, rnZ + 1, NrZ, RmSk(j 2)
318s	NEXT
319:	ELSIIF ipZ » 7 THIN
320s	FOR jZ = 1 TO 4
321s	CopyRm ml, 1, m2 - 1, RmSk(jZ)
322;	NEXT
323s	END IF
324:	LOOP
325:	END SUB
326:
327:	SUB InRmSource
328:	STATIC ipZ
329:	coll - IMAX(24, 14 + NrZ + (NrZ + 1) \ 4)
330:	elZ - 13
331:	TitleS = *In-Room, Sources,Hark those Present"
332:	TextS * "Room Number"
333:	FOR jZ ¦ 1 TO 8
334:	TextS = TextS + + GenSource(jZ)
335:	NEXT
336:	TextS * TextS + GenCopy
337:	SETCOL colZ
338:	GETROW TitleS, TextS,
339:	TOGGLIBOT
340:	PUTROW
341:	MCOLOR 0, 2
342:	CLB 7, 1, 15, NrZ + 6 + (NrZ + 1) \ 4
343:	DO
344:	tS - STRS(mZ) + CHR$(255)
345:	FOR jZ « 1 TO S
346:	IF TSTBIT(RmSr(jZ), rnZ) THEN Psel$ = "x" ELSE Pselg = CHR$(
255)
347:	t$ - COMFOSEVAL(t$, Psel$3
348:	NEXT
349:	GETVAL t$
350:	MCOLOR 1, 0
351:	PUTVAL
352:	MCOLOR 0, 2
353:	SETCURSOR 6, 2
354:	RmDis rnZ, NrZ, RmSr()
355:	MCOLOR 3, 0
356:	TOGGLEMEN ipZ, plusZ
357:	IF ipZ = 0 OR ipZ - elZ THEN EXIT DO
358:	rZ * CSRLNW - ipZ + 1
359:	IF ipZ ¦ 1 AND plusZ > 0 THEN plusZ * TRUE
360:	IF plusZ - 61 THEN
361:	IF ipZ >¦ 2 AND ipZ <= 9 THEN CopyRm rnZ, rnZ + 1, NrZ,
RmSr < ip2 - 1)
362:	ELSEIF plusZ - 62 THEN
363:	IF ipZ >= 2 OR ipZ <= 9 THEN CopyRm rnZ, 1, rnZ - 1, RmSr(
ipZ - 1)
364:	END IF
B-26

-------
Program Documentation	Version 2.0
,365 s	IF plus 2 «= TRUE OR plusZ - FALSE THEN
366i	IF plusZ THEN
367:	rnX = rnZ + 1
368s	IF rnZ > NrZ + 1 THEN mZ « 0
369s	ELSE
Z = rnZ - 1
- NrZ + 1
rnZ
IAQPC
370s
rnZ = rnZ - 1
371:
IF rnZ
< 0 THEN rnZ
372s
END IF

373s
ELSEIF ipZ
>== 2 AND ipZ
374:
XORBITOF
RmSr(ipZ - 1)
375:
ELSEIF ipZ
- 10 THEN
376:
FOR jZ -
1 TO 8
377;
CopyRm
rnZ, rnZ + 1,
378:
NEXT

379:
ELSEIF ipZ
» 11 THEN
380:
FOR jZ -
1 TO 8
381:
CopyRm
rnZ, 1, rnZ -
382s
NEXT

383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
1, NrZ, RmSr(jZ)
END IF
LOOP
END SUB
SUB LoadlnRm
IF OpenDataFile(Dpath$, InFileS,
LdlnRmFile
IF MfsZ THEN SvMasterFile
END IF
END SUB
"inr*. 0) THEN
DEFINT I
SUB RmStat
PUSHW 1, 7,
HEADER 1, '
CZ = 28
PINT 2, cZ,
1Z » NrZ +
FOR jZ « 1
PINT jZ + 2
PRNT jZ ~ 2
23, 58, 0, 7
Building Sources/Sinks/Cleaners'
•Hall ..... HVAC"
2 + (NrZ + 1) \ 8
TO 8
2, GenSource(j2)
cZ, LEFT$(REVERSE(BIN(RmSr(jZ))5,
12)
NEXT
FOR jZ
1 TO 4
PRNT jZ + 11, 2, GenSink(jZ)
PRNT jZ + 11, cZ, LEFT$(REVERSE(BIN(RmSk(jZ>>), 1Z)
NEXT
SETCURSOR CSRLNW, 1
mZ ¦ 0
FOR kZ - mZ + 1 TO 5
IF TSTBIT(Cn, kZ) THEN
PRNT CSRLBW +1, 2, ClName(kZ)
IF nZ > 0 THEN jZ = 2 ELSE jZ - 1
PRNT CSRLNW, cZ, LEFT$(REVERSE(BIN(RmCn(jZ))5, 1Z
mZ - kZ
END IF
NEXT
1)
B-27

-------
Program Documentation	Version 2.0	IAQPC
419s	nZ * 5
420s	FOE kl » nZ + 1 TO 9
421;	IF TSTBIT(Cn, kZ) THEN
422:	PINT CSRLNW +1, 2, ClName(kX)
423s	IF ml > 5 THEN jZ « 2 ELSE jZ = 1
424:	PENT CSRLNW, cZ, SPACES(1Z - 1) + RIGHT$(LEFT$(REVERSE(BIN{
BmCn(jZ)}), 11), 1)
425j	mZ - kZ
426 s	END IF
427s	NEXT
428 s	PAR 0
429;	CLB IX, 1, 20, 52
430;	FOE jl ¦ 1 TO 8
431s	PENT jZ + 11, 2, CycleName(jZ)
432:	PENT jZ + 11, cZ, LEFT$(EEVEESE(BIN(EfllCy(jZ))), II)
433;	NEXT
434;	PAX 0
435;	POPW
436:	END SUB
437;
438;	DEFSNG I
439:	SUB SavelnRa
440:	IF OpenDataFile(Dpath$, InFile$, "inr", 1) THEN
441:	chnZ = FREEFILE
442;	OPEN DpathS + InFile$ + ".inr* FOR OUTPUT AS chnZ
443;	FOR jZ - 1 TO 2
444;	PRINT #chnZ, RmCn(jZ);
445;	NEXT
446;	PRINT #chnZ,
447;	FOR jZ - 1 TO 4
448;	PRINT #chnZ, RmSk(jZ);
449s	NEXT
450;	PRINT #chnZ,
451;	FOR JZ = 1 TO 8
452:	PRINT IchnZ, RmSr(jZ);
453;	NEXT
454;	PRINT #chnZ,
455;	FOR jZ ¦= 1 TO 8
456;	PRINT IchnZ, RmCy(jZ)j
457;	NEXT
458;	PRINT ZchnZ,
459;	PRINT ZchnZ, ConcInitType
460;	CLOSE chnZ
461;	IF HfsZ THEN SvMasterFile
462;	END IF
B-28

-------
Program Documentation
\ind\graph.asc
Version 2.0
IAQPC
Is '$INCLUDE: *\qb4\level0.pub'
2: *$INCLUDE: *\qb4\levell.pub•
3: '$INCLUDE: * \qb4\windowp.pub *
4: '$INCLUDE: "\qb4\graphp.pub *
5: '$INCLUDE: *\qb4\level2.pub*
6: * $INCLUDE: »\qb4\menup.pub'
7s *$INCLUDE: *\ind\iaqsubp.pub'
8: '$INCLUDE: *\ind\iaqcommn.pub'
9:
10: DECLARE FUNCTION AvgConcVal! (kZ)
11: DECLARE FUNCTION ColorofI {12}
12: DECLARE FUNCTION ConcVal! (kl, ml)
13: DECLARE FUNCTION LiaConcl (kZ>
14: DECLARE FUNCTION M&xTime! (lssttl, nttZ)
15:
16: DECLARE SUB CenterofRoom (rnl, z, y)
17: DECLARE, SUB DefWindows ()
18:	DECLARE SUB DrawArrow (xb, yb, le, ye, icX)
19:	DECLARE SUB DrawAverages (iX)
20:	DECLARE SUB DrawCycles ()
21:	DECLARE SUB DrawDoorFlows (rnX, xl, y!)
22:	DECLARE SUB DrawDoors (rnZ, x, y)
23:	DECLARE SUB DrawDupCycles ()
24:	DECLARE SUB DrawFloorPlan ()
25:	DECLARE SUB DrawFlows {)
26:	DECLARE SUB DrawHallDoor 
-------
Program
51
52
53
54
55
56
57
58:
59:
60:
61:
62 "•
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73 s
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101 j
102:
103:
Documentation	Version 2.0	IAQFC
DECLARE SUB GraphLogHistory {)
DECLARE SUB GraphMenu ()
DECLARE SUB GraphRooms (}
COMMON SHARED /indgrnph/ buZ, btZ, xOZ, Aspct, xf, maxt
COMMON SHARED /indgrsph/ InhtZ, yl, plZ, ywnZ, mrZ, npolZ, mZ, tZ
COMMON SHARED /indgraph/ wpO AS SCRNPAI, wp AS SCRNPAR, wp2 AS
SCRNPAR
SUB CenterofRoonx (rnZ, x,
IF ml - NrZ + 1 THEN
y - .95 * ywnZ / buZ
7)
-	xOZ) /
-	1 THIN
Aspct
0 THEN x
« 2 THEN
buZ
x - (-80
ELSEIF FpZ
y ¦ .5 *
IF rnZ >
ELSEIF FpZ
IF rnZ <= NrZ / 2 THEN
y - .5 * Aspct
x - CrnZ - .5)
ELSE
y - 1.5 * Aspct
x * NrZ - rnZ + .5
END IF
ELSEIF FpZ *» 3 THEN
IF ml - 0 THEN
y «= 1.5 * Aspct
x - (NrZ I 4)
ELSEIF rnZ <¦ NrZ / 2 THEN
y - .5 * Aspct
x - mZ - . 5
ELSE
y «= 2.5 * Aspct
x - (NrZ
END IF
ELSEIF FpZ -
IF rnZ > 0
y ¦ .5 *
x = (rnZ
ELSE
1.5 * Aspct
NrZ I 21
END IF
ELSEIF FpZ - 5 THEN
IF rnZ - 0 THEN
y s 1.5 * ASpCt
x = (NrZ - 2) / 4
ELSEIF rnZ <= (NrZ -
y = .5 * Aspct
x - (rnZ - .5)
ELSEIF rnZ - (NrZ -
y = 1.5 * Aspct
x = (rnZ - 1 - .5)
ELSEIF rnZ <- NrZ
(rnZ - .5) ELSE x = .5
rnZ + .5)
4 THEN
THEN
Aspct
- .5)
y
X
2} / 2 THEN
2) / 2+1 THEN
1 THEN
B-30

-------
Program Documentation	Version 2.0
104:	y - 2.5 * Aspct
105s	x - (Nrl - 1 - rnZ + .5)
106:	ELSE
107s	y = 1.5 * Aspct
108s	x = .5
109s	END IF
110s	ELSEIF FpZ - 6 THEN
111:	IF rnZ » 0 THEN
112:	y ¦ 1.5 * Aspct
113:	x - 3
114s	ELSEIF rnZ <¦ 6 THIN
115:	y - .5 * Aspct
116:	* - (rnZ - .5)
117:	ELSEIF ml <- 9 THEN
118:	y ¦ ((rnZ - 6) + .5} * Aspct
119:	x ¦ (6 - .5)
120:	ELSEIF raZ <- 15 THEN
121:	y * 4.5 * Aspct
122:	x - (15 - rnZ + -5)
123:	ILSEIF raZ <- 18 THIN
124t	y - (19 - rnZ + .5) * Aspct
1.25 j	z m • 5
126:	ELSE
127s	y - 2.5 * Aspct
126:	x » 3
129:	END IF
130:	END IF
131:	x - xOZ / buZ + x
132:	END SUB
133:
134:	FUNCTION Colorof (iZ)
135:	IF il > 2 THEN Colorof - 6 + iZ ELSE Colorof = 1 + iZ
136s	IF GRAPH - 1 THEN Colorof - 1
137:	END FUNCTION
138:
139:	SUB DefWindows
140:	ofsZ - 79 \ ((npolZ + 1) \ 2)
141;	wlZ ¦ ofsZ - 1
142:	IF npolZ <¦ 2 THEN
143:	w&Z - 0
144:	ELSEIF npolZ <= 4 THEN
145:	wmZ - 1
146:	ILSEIF npolZ <- 6 THEN
147:	waZ «= 2
148:	END IF
149:	FOE iZ ¦ 0 TO wmZ
150:	jZ « 2 * iZ
151:	lbZ = ofsZ * iZ + IZ
152:	DEFINEWINDOW j2 + 1, 0, lbZ, (MAXLINES - 2) / 2, lbZ + vlZ
15, 0
153:	DEFINEWINDOW jZ + 2, (MAXLINES - 2) / 2 + 1, lbZ. MAXLINES
lbZ + wlZ, 15, 0
154:	NEXT
155:	END SUB
B-31

-------
Program Documentation	Version 2.0	IAQPC
156:
157:	SUB DrawArrow (xb, yb, xe, ye, icZ)
158:	IF xb <> xe OR yb <> ye THEN LINE (xb, yb)-(xe, ye), icl
159:	IF xb > xe THEN
160:	DRAW "E3 D6 H3*
161:	ELSEIF xb < xe THEN
162:	DRAW *H3 D6 E3"
163:	ELSEIF yb > ye THEN
164:	DRAW "E3 L6 F3"
165:	ELSEIF yb < ye THEN
166:	DRAW "F3 L6 E3"
167:	END IF
168i	END SUB
169:
170:	SUB DrawAverages (tZ)
171:	dy ¦ Aspct * buZ
172:	scaleratio ¦ dy
173: dw - 1.3
174: dlx - buZ / (6 * dw)
175:	rmnZ « 0
176:	IF FpZ - 1 OR FpZ - 2 THEN rami - 1
177:	FOR iZ - rxrmZ TO NrZ + 1
178:	REM room 0 is stored in the file, no matter the floor plan
179:	IF (rumZ - 1 AND iZ « 1 AND tZ > 0) THEN
180:	FOR kZ - 1 TO npolZ
181:	GET #tZ, , C
182:	NEXT
183:	END IF
184:	CenterofRoom iZ, x, y
185:	tx = x * buZ
186:	ty = ywnZ - y * buZ
187:	FOR kZ - 1 TO npolZ
188:	fac ¦ LimConc(kZ)
189:	IF fac - 0 THEN EXIT FOR
190:	IF tZ - 0 THEN
131:	d = ConcVaKkZ, iZ) / fac
192:	ELSE
193:	GET £tZ, , d
194i	d-d / fac
195:	END IF
196:	r - scaleratio * d
197:	rx » tx + (kZ - 3.75) * dw * dlx
198:	ry » ty - .5 * dy
199:	LINE (rx, ry)-(rx + dlx, ry + r), 8 + kZ, BF
200:	LINE (rx, ry)-(rx + dlx, ry + r), 8, B
201:	NEXT
202:	NEXT
203:	IF GRAPH = 1 THEN LINE (tx - .5 * buZ, ty - .5 * dy)-(tx + ,5 *
buZ, ty + .5 * dy), 1, B
204;	END SUB
205:
206:	SUB DrawCycles
207:	8 - 1200 / 24
208:	x « ABS(AlignTime) * s
B-32

-------
Program Documentation	Version 2.0	IAQPC
209:	dZ - ywnZ / 20
210:	LINE (x, 0)-(x, ywnZ), 7, , SH3030
211:	FOE iZ - 0 TO 24
212:	jZ = s * iZ
213:	LINE (jZ, 0)-(jZ, ymZ), 8, , &H3030
214:	NEXT
215:	FOR iZ - 1 TO 8
216;	jZ - (8 - iZ) * yvn1 / 8
217:	IF GRAPH > 1 THEN LINE (0, jZ)-(1200, jZ), 8
218:	PSET (0, jZ), Colorof(iZ)
219:	LINE -(x, jZ), Colorof(iZ)
220:	IF Cycles(iZ) > 0 THEN LINE -(x. jZ + dZ), Colorof(iZ)
221:	IF iZ <= 4 THEN z « s * ABS(Cycles(iZ)) / 60
222:	IF iZ >- 5 THEN z - 8 * ABS(Cycles(iZ))
223s	xl * x + z
224:	CO VHILE xl <¦ 1200 + z
225s	IF Cycles(iZ) > 0 THEN
226:	LINE -(xl, jZ + dZ), Colorof(iZ)
227:	LINE -(xl, jX), Colorof(iZ)
2281	xl » xl + z
229;	LINE -(xl, jZ), Colorof(iZ)
230:	LINE -(xl, jZ + dZ), Colorof(iZ)
231:	xl - xl + z
232:	ELSE
233:	LINE -(xl, jZ), Colorof(iZ)
234:	LINE -(xl, jZ + dZ), Colorof(iZ)
235:	xl - xl + z
236:	LINE -(xl, jZ + dZJ, Colorof(iZ)
237:	LINE -(xl, jZ), Colorof(iZ)
238:	xl - xl + z
239:	END IF
240;	LOOP
241:	NEXT
242:	END SUB
243:
244s	SUB DrawDoorFlows (ml, x, y)
245:	icZ - 9
246:	scaleratio * 16!
247;	r - scaleratio * RmFlcrw(rnZ, 3) / (xf / 51)
248;	by ¦ Aspct * buZ
249;	tx ¦ x * buZ
250:	ty ¦ ywnZ - y * buZ
251; IF FpZ - 1 AND ABS(r) > .01 THEN
252:	tx - tx + .5 * buZ
253;	DrawArrow tx + r, ty, tx - r, ty, icZ
254; ELSEIF FpZ - 2 AND ABS(r) > .01 THEN
255 s	IF mZ < NrZ / 2 THEN
256;	tx - tx + .5 * buZ
2S7:	DrawArrow tx ~ r, ty, tx - r, ty, icZ
258:	ELSEIF rnZ ¦ NrZ / 2 THIN
259;	r = r * Aspct
260:	ty - ty - .5 * by
261;	DrawArrow tx, ty - r, tx, ty + r, icZ
262;	ELSEIF ruZ < NrZ THEN
B-33

-------
Program Documentation	Version 2.0
263s	tx = tx - ,5 * buZ
264:	DrawArrow tx - r, ty, tx + r, ty, ic2
265:	ELSE
266:	r ¦ r * Aspct
267:	ty • ty + .5 * by
268s	DrawArrow tx, ty + r, tx, ty - r, icZ
269:	END ZF
270:	ELSEIF FpZ = 3 AND ABS(r) > .01 THEN
271:	IF ml = 0 THEN
272:	ELSEIF rnZ <= NrZ / 2 THEN
273s	tx - tx + .5 * buZ
274s	DrawArrow tx + r, ty, tx - r, ty, icZ
275s	ELSE
276s	tx ¦ tx - .5 * buZ
277s	DrawArrow tx - r, ty, tx + r, ty, icZ
278s	END IF
279s	ELSEIF FpZ - 4 AND ABS(r) > .01 THEN
280 s	IF rnZ > 0 AND mZ <¦ NrZ THEN
281:	tx - tx + .5 * buZ
282:	DrawArrow tx + r, ty, tx - r, ty, icZ
283 s	END IF
284j	ELSEIF FpZ - 5 AND ABS(r) > .01 THEN
285:	IF rnZ - 0 THEN
286:	ELSEIF nil <- (NrZ - 2) / 2 - 1 THEN
287s	tx - tx + .5 * buZ
288;	DrawArrow tx + r, ty, tx - r, ty, icZ
289:	ELSEIF rnZ <- (NrZ - 2) / 2+1 THEN
290s	r - r * Aspct
291s	ty - ty - .5 * by
292:	DrawArrow tx, ty - r, tx, ty + r, icZ
293:	ELSEIF mZ <- NrZ - 2 THEN
294:	tx - tx - .5 * buZ
295:	DrawArrow tx - r, ty, tx + r, ty, icZ
296s	ELSEIF rnZ <- NrZ THEN
297:	r = r * Aspct
298:	ty - ty + .5 * by
299:	DrawArrow tx, ty + r, tx, ty - r, icZ
300:	END IF
301;	ELSEIF FpZ - 6 AND ABS(r) > .01 THEN
302:	IF raZ =¦ 0 THEN
303:	ELSEIF rnZ <= 5 THEN
304:	tx ¦ tx + .5 * buZ
305s	DrawArrow tx + r, ty, tx - r, ty, icZ
306:	ELSEIF mZ <= 9 THEN
307;	r - r * Aspct
308:	ty - ty - .5 * by
309:	DrawArrow tx, ty - r, tx, ty + r, icZ
310s	ELSEIF rnZ <¦ 14 THEN
311:	tx - tx - .5 * buZ
312:	DrawArrow tx - r, ty, tx + r, ty, icZ
313:	ELSEIF rnZ <= 18 THEN
314:	r ¦ r * Aspct
315s	ty = ty + .5 * by
316:	DrawArrow tx, ty + r, tx, ty - r, icZ
B-34

-------
Program Documentation	Version 2,0	IAQPC
317:	END IF
318i	END IF
319i	END SUB
320:
321;	SUB DrswDoors {ml, x, yj
322:	scaleratio ¦ 16!
323:	r - .5 * scaleratio * Aspct * InterCon{rnZ, 3) / 251
324s	dy ¦ Aspct * buZ
325s	tx - x * buZ
326:	ty «= ywnZ - y * buZ
327:	IF FpZ = 1 AND r > 0 THEN
328:	tx = tx + .5 * buZ
329:	ELSEIF FpZ - 2 AND r > 0 THEN
330:	IF ml < NrZ I 2 THEN
331:	tx - tx + .5 * buZ
332:	ELSEZF rnZ • NrZ / 2 THEN
333.	ty - ty - .5 ~ dy
334:	ELSEIF rnZ < NrZ THEN
335:	tx - tx - .5 * buZ
336:	ELSE
337:	ty • ty + .5 * dy
338:	END IF
339:	ELSEIF FpZ - 3 AND r > 0 THEN
340:	IF nil - 0 THEN
341:	EXIT SOT
342:	ELSEIF rnZ <- NrZ / 2 THEN
343:	tx ¦ tx + .5 * buZ
344:	ELSE
345:	tx - tx - .5 * buZ
346:	END IF
347:	ELSEIF FpZ - 4 AND r > 0 THEN
348:	IF rnZ > 0 AND rnZ <¦ NrZ THEN
349:	tx - tx + .5 * buZ
350:	END IF
351:	ELSEIF FpZ - 5 AND r > 0 THEN
352:	IF rnZ ¦ 0 THEN
353:	EXIT SUB
354:	ELSEIF rnZ <- (NrZ - 2) / 2 - 1 THEN
355:	tx ¦ tx + .5 * buZ
356:	ELSEIF rnZ <- (NrZ - 2) / 2 + 1 THEN
357:	ty - ty - .5 * dy
358:	ELSEIF rnZ <= NrZ - 2 THEN
359:	tx = tx - .5 * buZ
360:	ELSEIF rnZ <- NrZ THEN
361:	ty - ty + .5 * dy
362:	END IF
363:	ELSEIF FpZ - 6 AND r > 0 THEN
364:	IF mZ - 0 THEN
365:	EXIT SOT
366:	ELSEIF rnZ <- 5 THEN
367:	tx * tx + .5 * buZ
368:	ELSEIF raZ <¦ 9 THEN
369:	ty ¦ ty - .5 * dy
370:	ELSEIF rnZ <= 14 THEN
B-35

-------
Program Documentation	Version 2.0
371:	tx « tx - .5 * buX
372:	ILSEIF rnZ <- 18 THIN
373:	ty = ty + .5 * dy
374:	ELSE
375:	EXIT SUB
376:	END IF
377s	ELSE
378s	EXIT SUB
379s	END IF
380:	LINE (tx - scaleratio, ty - r)-(tx + scaleratio, ty + r), 9,
381:	END SUB
382:
383:	SUB DrawDupCycles
384:	S - 1200 / (7 * 24)
385:	dl - yvnZ { 20
386:	FOR iZ - 0 TO 7
387:	jZ - 1200 / 7 * iZ
388s	LINE (jZ, 0)-(jZ, ywnZ), 8, , S.H3030
389i	NEXT
390i	IF GRAPH > 1 THEN
391:	FOR iZ - 1 TO 8
392:	jZ - (8 - iZ) * ywnZ / 8
393s	LINE (0, jZ)-(1200, jZ), 8
394:	NEXT
395:	END IF
396:	FOE dayZ - 0 TO 7
397:	xO - 1200 / 7 * dayZ
398:	x ¦ ABS(AlignTime) * s + xO
399:	LINE (x, 0)-{x, ywnZ), 15, , SH3030
400:	NEXT
401:	FOR iZ - 1 TO 8
402:	jZ « (8 - iZ) * ywnZ / 8
403:	FOR dayZ « 0 TO 6
404:	xO ¦ 1200 / 7 * dayZ
405:	x2 - xO + 1200 / 7
406:	x = ABS(AlignTime) * s + xO
407:	PSET (xO, jZ). Colorof(iZ)
408:	LINE -(x, jZ>. Colorof(iZ)
409:	IF Cycles(iZ) > 0 THEN LINE -(x, jZ + dZ), Colorof(iZ)
410:	IF iZ <- 4 THEN z = B * ABS(Cycles(iZ)) / 60
411i	IF iZ >« 5 THEN z - s * ABS(Cycles(iZ))
412:	xl - RMIN(x + z, x2)
413:	DO WHILE xl <= xl
414:	IF Cycles(iZ) > 0 THEN
415:	LINE -(xl," jZ + dZ), Colorof (iZ)
416:	LINE -(xl, jZ), Colorof(iZ)
417:	xl - RMIN(xl + z, x2)
418:	LINE -(xl, jZ), Colorof(iZ)
419:	IF xl = x2 THEN EXIT DO
420:	LINE -(xl, jZ + dZ), Colorof(iZ)
421:	xl * RMIN(xl + z, x2)
422:	ELSE
423:	LINE -(xl, jZ), Colorof(iZ)
424:	IF xl = x2 THEN EXIT DO
B-36

-------
Program Documentation	Version 2.0	IAQPC
425:	LINE -(xl, jZ + dZ), Colorof(iZ)
426s	xl = RMIN(xl + z, x2)
427s	LINE -(xl, jZ + dZ), Colorof(iZ)
428s	LINE -(xl, jZ), Colorof(iZ)
429s	xl ¦ RMIN
-------
Program Documentation	Version 2.0
477:	LINE (xOZ + btZ. ywnZ - baZ)-(xZ - btZ, ywnZ - baZ), icZ
478: ELSEIF FpZ •= 3 THEN
479s	FOR iZ * 1 TO NrZ / 2 - 1
480j	LINE (xOZ + iZ * buZ, jvnZ - yZ + btZ)-(xOZ + iZ * buZ, ywnZ
- 2 * baZ), icZ
481:	LINE (xOZ + iZ * buZ, jvnZ - baZ)-(xOZ + iZ * buZ, yvnZ -
btZ), icZ
482:	NEXT
483:	LINE (xOZ + btZ, ywnZ - 2 * baZ)-(xZ - btZ, ywnZ - 2 * baZ),
icZ
484:	LINE (xOZ + btZ, ywnZ - baZ)-(xZ - btZ, ywnZ - baZ), icZ
485: ELSEIF FpZ - 4 THEN
486:	FOR iZ m 1 TO NrZ - 1
487:	LINE (xOZ + iZ * buZ, ywnZ - baZ)-(xOZ + iZ * buZ, ywnZ -
bt>Z) f icZ
488:	NEXT
489:	LINE (xOZ + btZ, ywnZ - baZ)-(xZ - btZ, ywnZ - baZ), icZ
490: ELSEIF FpZ = 5 THEN
491:	mZ - (NrZ - 2) / 2 - 1
492:	LINE (xOZ + buZ, ywnZ - btZ)-(xOZ + buZ, ywnZ - yZ + btZ), icZ
493:	LINE (xOZ + ml * buZ, ywnZ - btZ)-(xOZ + raZ * buZ, ywiZ - yZ +
btZ), icZ
494:	FOR iZ - 2 TO mZ - 1
495s	LINE (xOZ + iZ * buZ, ywnZ - baZ)-(xOZ + iZ * buZ, ywnZ -
btZ), icZ
496s	LINE (xOZ + iZ * buZ, yvnZ - 2 * baZ)-(xOZ + iZ * buZ, yvnZ
-	yZ + btZ)» icZ
497: NEXT
498;	LINE (xOZ + btZ, ywnZ - 2 * baZ)-(xZ - btZ, ywnZ - 2 * baZ),
icZ
499:	LINE (xOZ + btZ, ywnZ - baZ)-(xX - btZ, ywnZ - baZ), icZ
500: ELSEIF FpZ - 6 THEN
501:	ml «= 5
502:	LINE 
-------
Program Documentation	Version 2.0	IAQFC
516s	END SUB
517s
518s	SUB DrawFlows
519s	xf ¦ ROUND(VolFlcwr / Nrl, 5)
520s	scaleratio ¦ 1000 / 80
521s	dy = 10
522:	nnnZ = 0
523 5	IF FpZ ¦ 1 08 FpZ - 2 THEN nnnZ = 1
524$	FOR il « nnnZ TO NrZ
5	t JT i i Z , 3C ,
526:	r ¦ scaleratio * ImFlowCiZ, 1) / xf
527:	tx «¦ x * buZ
528:	ty ¦ ywnZ - (y + .1) * buZ
529:	DrawArrow tx - r, ty, tx + r, ty, 10
530:	r • scaleratio * RmFlow(iZ, 6) / xf
531:	ty - ywnZ - (y - .1) * buZ
532s	DrawArrow tx - r, ty, tx + r, ty, 14
533:	DrawWindowFlow il, x, y
534:	DrawDoorFlows iZ, x, y
535s	DrawHallFlow iZ, x, y
536:	NEXT
537:	END SOT
538 s
539:	SUB DrawHallDoor (ml, x, y)
540:	scaleratio ¦ 161
541:	r - .5 * scaleratio * Aspct * InterCon(rnZ, 5} / 251
542s	dy - Aspct * buZ
543s	tx - x * buZ
544s	ty - ywnZ - y * buZ
545s	IF FpZ - 3 AMD r > 0 THEN
546s	IF rnZ - 0 THEN
547:	EXIT SUB
548:	ELSEIF raZ <- NrZ / 2 THEN
549:	ty s ty • .5 * dy
550s	ELSE
551:	ty « ty + .5 * dy
552:	END IF
553s	ELSEIF FpZ » 4 AND r > 0 THIN
554s	IF rnZ > 0 AND znZ <- NrZ THEN
555s	ty = ty - .5 * dy
556 s	END IF
557s	ELSEIF FpZ - 5 AND r > 0 THEN
558:	IF raZ ¦ 0 THEN
559 s	EXIT SUB
560s	ELSEIF rnZ <- (NrZ - 2) / 2-1 THEN
561:	ty - ty - .5 * dy
562s	ELSEIF rnZ <- (NrZ - 2) / 2+1 THEN
563:	tx ¦ tx - ,5 * buZ
564:	ELSEIF ml <= NrZ - 2 THEN
565:	ty = ty + ,5 * dy
566:	ELSEIF mZ <= NrZ TIEN
567:	tx ¦ tx + .5 * buZ
568:	END IF
569:	ELSEIF FpZ = 6 AND r > 0 THEN
B-39

-------
Program
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
Documentation
IF rnl - 0 THEN
EXIT SUB
ELSE1F rnZ <= 5
ty • ty -
Version 2.0
IAQFC
THEN
* dy
ELSEIF ml <= 9 THEN
tx
tx
bul
ELSEIF rnZ <= 14 THEN
ty = ty + .5 * dy
ELSEIF rnl <= 18 THEN
tx ¦ tx + .5 * buZ
ELSE
ty ¦ ty + .5 * dy
END IF
ELSE
EXIT SUB
END IF
LINE (tx - scaleratio, ty - r)-(tx + scaleratio, ty + r), 9, BF
END SUB
SUB DrawHallFlow (rnl, x, y)
icZ - 9
scaleratio - 161
r * scaleratio * RmFlowCrnf, 5) / (xf / 5J)
dy » 10
by « Aspct * buZ
tx « x * buZ
ty » ywnX - y * buZ
IF FpZ « 3 AND ABSfr) > .05 THEN
r - r * Aspct
IF rnZ - 0 THEN
ELSEIF rnZ <¦ NrZ / 2 THEN
ty - ty - .5 * by
DrawArrow tx, ty -
ELSE
ty = ty + .5 * by
DrawArrow tx, ty + r, tx,
END IF
ELSEIF FpZ - 4 AND ABS(r) > .05 TIEN
IF rnZ > 0 AND rnZ <« NrZ THEN
r » r * Aspct
ty s ty - .5 * by
DrawArrow tx, ty - r,
END IF
ELSEIF FpZ - 5 AND ABS(r) > .05 THEN
IF rnl = 0 THEN
ELSEIF rnZ <¦ (NrZ -
r - r * Aspct
ty ¦ ty - .5 * by
DrawArrow tx, ty -
ELSEIF rnZ <» (NrZ -
tx = tx - .5 * buZ
DrawArrow tx - r, ty, tx + r, ty, icZ
ELSEIF rnZ <= NrZ - 1 THEN
r m r * Aspct
tx, ty + r, icZ
ty
icZ
tx, ty r, icZ
2) / 2
1 THEN
r,
2)
tx,
/ 2
ty + r, icZ
+ 1 THEN
B- 40

-------
Program Documentation	Version 2.0	1AQPC
624s	ty » ty + .5 * by
625i	DrawArrow tx, ty + r, tx, ty - r, icZ
626s	ELSEIF rnZ <= NrZ THEN
627i	tx • tx + .5 * buZ
628:	DrawArrow tx + r, ty, tx - r, ty, icZ
629:	END IF
630s	ELSEIF FpZ - 6 AND ABS(r) > .05 THIN
631s	IF rnZ ¦ 0 THEN
632s	ELSEIF rnZ <« 5 THEN
633s	r ¦ r * Aspct
634s	ty = ty - .5 * by
635s	DrawArrow tx, ty - r, tx, ty + r, icZ
636s	ELSEIF rnZ <- 9 THEN
637:	tx - tx - .5 * buZ
638i	DrawArrow tx - r, ty, tx + r, ty, icZ
639:	ELSEIF rnZ <- 14 THEN
640s	r ¦ r * Aspct
641s	ty ¦ ty + .5 * by
642:	DrawArrow tx, ty + r, tx, ty - r, icZ
643s	ELSEIF rnZ <- 18 THEN
644s	tx ¦ tx + .5 * buZ
645s	DrawArrow tx + r, ty, tx - r, ty, icZ
646:	ELSE
647s	r - r * Aspct
648s	ty ¦ ty + .5 * by
649:	DrawArrow tx, ty + r, tx, ty - r, icZ
650:	END IF
651:	END IF
652s END SUB
653:
654: SUB DrawHistVindows (x AS INTEGER, y AS INTEGER)
655s	DefWindows
656:	FOR iZ - 1 TO npolZ
657:	.SELECTW iZ
658:	STDWINDOW
659:	DRAWCTICS x / 4, -1
660:	SETAXIS -1, -1
661!	DRAVXAXIS
662:	DRAWYTICS y, 0
663:	DRAWYAXIS
664:	DRAVYGRID y, 0
665:	IF GRAPH - 1 THIN cZ - 0 ELSE cZ = 8 + iZ
666:	LINE (0, 800)-(1000, 800), cZ, , &H7171
667:	IF GRAPH > 1 THEN rZ - HWIN - 1 ELSE rZ - HWIN
668:	CENTXT rZ, "Poll* + STR$(iZ)
669:	IF GRAPH > 1 THEN rZ - rZ - 1
670:	PRNT rZ, (100 * WIN) / 1200, "O*
671:	n$ » LTRIM$(RTRIM$ (STR$(maxt)))
672:	PRNT rZ, WIN - LEN(n$) - ((100 * WIN - 100) / 1200) + 1, n$
673:	IZ - .167 * HWIN
674:	IF GRAPH > 1 THEN IZ - IZ - 1
675:	PRNT IZ, 4, LTRIHS(STR$(LimConc(iZ)))
676:	NEXT
677: END SOT
B-41

-------
Program	Documentation Version 2.0	IAQPC
i78s
679:	.SUB DrawLegendl
680:	SETSTDWINDOW 0, 80, 80, 0, yl, yl
681:	STDWINDOW
682:	LINE (9, 0)-{U, InhtZ), 9, IF
683:	PENT plZ, 14, "« 25 ft* Door*
684:	SETACCENT 0, 0
685:	GENCIICLI 30, .5 * InhtZ, .5, 10, BsZ
686s	GENCIRCLE 32, .5 * InhtZ, .5, 14, BsZ
687s	PENT plZ, 34, .5 ft2 HVAC Vents*
688:	LINE (55, 0)-(57, InhtZ), 12, BF
689:	PRNT plZ, 60, *» 4 ft* Window"
690:	END SUB
691:
692:	SUB DrawLegend2
693:	SETSTDWINDOW 0, 80, 80, 0, yl, yl
694:	STDWINDOW
695s	DrawArrow 9, 4, 11, 4, 9
696s	PRNT plZ, 14, ¦- " + STR$(x£ 15)+' cfm Doors*
697:	DrawArrow 30, 6, 32, 6, 10
698:	DrawArrow 30, 3, 32, 3, 14
699s	PRNT plZ, 34, + STR$(xf) + • cfm HVAC"
700:	DrawArrow 55, 4, 57, 4, 12
701:	PINT plZ, 60, + STR$(xf / 10) + * cfm Window"
702:	END SUB
703:
704:	SUB DrawLegendS
705s	PRNT 1, 2, "HVAC
706:	SETSTDWINDOW 0, 80, 80, 0, yl, yl
707:	STDWINDOW
70S:	FOR iZ = 1 TO npolZ
709s	jZ - 12 * (iZ -15+9
710s	LINE (jZ, 0)-(jZ + 1, 8), iZ + 8, BF
711:	PRNT pit, jZ + 3, Pol • + RIGHTS(STR$(iZ), 1)
712s	NEXT
713 s	END SUB
714s
715:	SUB DrawLegend4
716:	SETSTDWINDOW 2, 160, 160, 0, 5 * (InhtZ), 5 * (InhtZ)
717:	STDWINDOW
718:	PRNT 1, 27, "12 3 4 5 6 7 8"
719:	PRNT 1, 2, "HVAC"
720:	FOR iZ - 1 TO 8
721:	jZ = 49 + 4 * iZ
722:	LINE (jZ, 3.3 * lnhtZ)-(jZ + 1, 4 * InhtZ), Colorof(iZ), BF
723:	NEXT
724:	PRNT 2, 44, "» Sources"
725:	FOR iZ - 1 TO 4
726:	jZ - 49 + 4 * iZ
727:	LINE (jZ, 2.3 * lnhtZ)-(jZ + 1, 3 * InhtZ), Colorof(iZ), BF
728:	NEXT
729:	PRNT 3, 44, •- Sinks'
730:	FOR iZ - 1 TO 2
731;	jZ = 49 + 4 * iZ
B-42

-------
Program Documentation Version 2.
0


732
LINE (jZ, 1.3 * InhtZ) - (j Z + 1.
2 *
InhtZ), Colorof(iZ)
BF
733
NEXT



734
PRNT 4, 44, * = Cleaners"



735
FOR iZ = 1 TO 8



736
jZ - 49 + 4 * iZ



737
LINE (jZ, .3 * InhtZ)-(jZ + 1,
InhtZ), Colorof(iZ), BF

738
NEXT



739
PINT 5, 44, •- Cycles"



740
END SUB



741




742
SUB DrawLegendS (swZ)



743
SETSTDWINDOW 0, 1200, 1200, 0, 9,
9


744s STDVTNDOW



745
LINE (0, 5)-(1200, 5), 7



746
LINE (0, 0)-(0, 9), 15



747
LINE (1200, 0)-(1200, 9), 15



748
IF swZ • 0 THEN CENTXT 1, "24 Hours* ELSE CENTXT 1, "7 Days"
749
END SUB



750 ?



751s SUB DrawLoeations



752: dy * buZ * Aspct



753
dz - .06 * buZ



754
rmnZ - 0



755
IF GRAPH - 1 THEN bZ - 0 ELSE bZ
- 8


756
IF FpZ - 1 OR FpZ - 2 THEN rmnZ - 1


757
FOR iZ - rmnZ TO NrZ + 1



758
CenterofRoom iZ, x, y



759
tx - (x - .5) * buZ



760
ty ¦ ywnZ - y * buZ



761
FOR jZ - 1 TO 8



762
zx-tx+.l*jZ* buZ



763
IF TSTBIT(RmSr(jZ), iZ) THEN
cZ =
Colorof(jZ) ELSE cZ
= bZ
764
LINE (zx, ty + .25 * dy)-(zx
+ dz,
ty + .4 * dy), cZ,
BF
765
NEXT



766
FOR jZ - 1 TO 4



767s zx « tx + .1 * j Z * buZ



768
IF TSTBIT(RfflSk(jZ), iZ) THEN
cZ -
Colorof(jZ) ELSE cZ
= bZ
769: LINE (zx, ty + ,05 * dy)-(zx
+ dz,
ty + .2 * dy), cZ,
BF
770
NEXT



771
FOR jZ - 1 TO 2



772
zx - tx + .1 * JZ * buZ



773
IF TSTBIT(RmCn(jZ), iZ) THEN
cZ «
Colorof(jZ) ELSE cZ
¦ bZ
774
LINE (zx, ty - .05 * dy)-(zx
+ dz,
ty - .2 * dy), cZ,
BF
775: NEXT



776
FOR jZ = 1 TO 8



777
zx-tx+.l*JZ* buZ



778: IF TSTBIT(RmCy(j Z), 11) THEN
cZ =
Colorof(jZ) ELSE cZ
- bZ
779: LINE (zx, ty - .25 * dy)-(zx
+ dz,
ty - .4 * dy), cZ,
BF
780: NEXT



781
NEXT



782
IF GRAPH = 1 THEN LINE (tx, ty -
.5 *
dy)-(tx + buZ, ty +
.5 *

dy), 1, B



783
END SUB



784




IAQPC
B-43

-------
Program
785:
786:
787:
788;
789:
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
8071
808
809
810
811
812
813
814
815
816
817
818
819
820
821
Documentation	Version 2,0
SUB DrawLogHistWindows (x AS INTEGER, y AS INTEGER)
DefWindows
FOR iZ - 1 TO npolZ
SELECTV iX
IAQPC
STDVTNDOW
DRAWXTICS i
SETAXES -1,
DRAWXAXIS
DRAWLYfICS y,
DBAWYAXIS
DRAWLYGRID y,
IX - 1000 I y
IF GRAPH - 1
I 4,
-1
-1,
0, -1
* 3
THEN cZ
- 0 ELSE cX = 8 + iZ
WIN - 100) / 1200) + 1, n$
LINE (0, 1Z)-(1000, IZ), cZ, , &H7171
IF GRAPH > 1 THEN rZ - HWIN - 1 ELSE rZ - HWIN
CENTXT rZ, "Poll' + STRS(il)
IF GRAPH >1 THEN rZ - rZ - 1
PRNT rZ, (100 * WIN) / 1200, *0"
n$ - LTRIMS(RTRIMS(STR$(maxt)))
PRNT rZ, WIN - LEN(n$) - ((100 *
IZ - (1000 - 1Z) / 1200 * HWIN
IF GRAPH > 1 THEN 1Z » IZ - 1
PRNT IZ, 4, LTRIM$(STR$(LimConc(iZ)))
NEXT
END SUB
SUB DrawOpenings
scsleratio - .5 * 1000 / 80
ronX - 0
IF FpZ - 1 OR FpZ - 2 THEN ami - 1
FOR iZ - rranZ TO NrZ
CenterofRoom iX, x, y
r * scaleratio * SQR(InterCon(iZ, 1) / .5)
ys ¦ ywnZ - y * buZ
IF r > 0 THEN GINCIRCLE ((x - .1) * buZ), ys, r, 10, BsZ
r - scaleratio * SQR(InterCon(iZ,
IF r > 0 THEN GENCIRCLE ((x + .1)
14, BsZ
DrawWindow iZ, x, y
DrawDoors iZ, x, y
DrawHallDoor iZ, x, y
NEXT
END SUB
*	buZ), ys
6) / .5)
*	buZ), (ywnZ
buZ), r,
SUB DrawWindow (rnZ, x, y)
dy - Aspct * buZ
scaleratio - 161
r = .5 * scaleratio * Aspct * InterConfrnZ, 2)
tx * x * buZ
ty *= ywnZ - y * buZ
IF FpZ = 1 AND r > 0 THEN
ty =» ty + .5 * dy
ELSEIF FpZ - 2 AND r > 0 THEN
IF ml <- NrZ / 2 THEN
/ 4!
B-44

-------
Program Documentation	Version 2.0	IAQPC
838;	ty ¦ ty + .S * dy
839!	ELSE
840s	ty * ty - .5 * dy
841i	END IF
842! ELSEIF Fpl = 3 AND r > 0 THEN
843:	IF rill - 0 THEN
844i	tx « (-NrX / 4 + x) * buZ
845s	ELSEIF ml <= NrZ / 2 THEN
846;	ty « ty + .5 * dy
847;	ELSE
848:	ty - ty - .5 * dy
849j	END IF
850: ELSEIF FpZ - 4 AND r > 0 THEN
851s	IF rnZ = 0 THEN
852i	ty ¦ ty - .5 * dy
853:	ELSE
854:	ty - ty + .5 * dy
855:	END IF
856i ELSEIF Fpl - 5 AND r > 0 THEN
857i	IF rnZ - 0 THEN
858i	EXIT SOT
859:	ELSEIF nil <« (NrZ - 2) / 2 THEN
860s	ty - ty + .5 * dy
861:	ELSEIF rnZ - (NrZ - 2} / 2 + 1 THEN
862:	tx - tx + .5 * buZ
863:	ELSEIF rnZ <- NrZ - 1 THEN
864:	ty » ty - .5 * dy
865:	ELSE
866:	tx ¦ tx - ,5 * bul
867:	END IF
868: ELSEIF FpZ - 6 AND r > 0 THEN
869:	IF rnZ - 0 THEN
870;	EXIT SUB
871:	ELSEIF mZ <- 6 THEN
872:	ty - ty + .5 * dy
873:	ELSEIF rnl <- 9 THEN
874:	tx ¦ tx + .5 * buZ
875:	ELSEIF rnl <- 15 THEN
876:	ty - ty - .5 * dy
877:	ELSEIF rnl <= 18 THEN
878:	tx - tx - .5 * buZ
879:	ELSE
880:	EXIT SUB
881s	END IF
882: ELSE
883s ^ EXIT SUB
884 s " END IF
885s LINE (tx - sc&leratio, ty - r)-(tx + scaleratio, ty + r), 12, BF
886s END SUB
887;
888.- SUB DrawWindowFlow (rnZ, x, j)
889: icZ =12
890: scaleratio = 161
891:	r ¦ scaleratio * Aspct * RmFlow(rnZ, 2) / (xf / 101)
1-45

-------
Program Documentation	Version 2.0
892s	dy = 10
893s	tr = x * buZ
894s	ty = yvnZ - y * buZ
895:	baZ = buZ * Aspct
896:	IF FpZ - 1 AN© ABS(r) > 0 THEN
897:	ty - ty + .5 * dy
898:	DrawArrow tx, ty + r, tx, ty - r, icZ
899:	ELSEIF FpZ = 2 AND ABS(r) > 0 THEN
900j	IF rnZ <= NrZ / 2 THEN
901:	ty - ywnZ
902:	DrawArrow tx, ty + r, tx, ty - r, icZ
903i	ELSE
904:	ty » ywnZ - 2 * baZ
905:	DrawArrow tx, ty - r, tx, ty + r, icf
906;	END IF
907s	ELSEIF FpZ - 3 AND ASS(r) > 0 THEN
908:	IF rnZ - 0 THEN
909:	ty » ywnZ - 2 * baZ
910:	r ¦ r / Aspct
911:	DrawArrow tx, ty ™ r, tx, ty r, icZ
912:	ELSEIF rnZ <- NrZ / 2 THIN
913:	ty ¦ ywnZ
914s	DrawArrow tx, ty + r, tx, ty - r, icZ
915:	ELSE
916:	ty « ywnl - 3 * baZ
917:	DrawArrow tx, ty - r, tx, ty + r, icZ
918:	END IF
919:	ELSEIF FpZ - 4 AND ABS(r) > 0 THEN
920:	IF mZ - 0 THEN
921:	ty - ywnZ - 2 * baZ
922:	DrawArrow tx, ty - r, tx, ty + r, icZ
923:	ELSE
924:	¦ ty - ywnZ
925:	DrawArrow tx, ty + r, tx, ty - r, icZ
926:	END IF
927:	ELSEIF FpZ - 5 AND ABS(r) > 0 THEN
928:	IF rnZ - 0 THEN
929s	ELSEIF rnZ <- (NrZ - 2) / 2 THEN
930:	ty * ywnZ
931:	QrawArrow tx, ty + r, tx, ty - r, icZ
932:	ELSEIF rnZ - (NrZ - 2) / 2 + 1 THEN
933:	r - r I Aspct
934:	tx ¦ tx + .5 * buZ
935;	ty - ywnZ - 1.5 * baZ
936:	DrawArrow tx + r, ty, tx - r, ty, icZ
937:	ELSEIF rnZ <= NrZ - 1 THEN
938:	ty - ywnZ - 3 * baZ
939:	DrawArrow tx, ty - r, tx, ty + r, icZ
940:	ELSE
941:	r = r / Aspct
942:	tx ¦ tx - .5 * buZ
943:	ty = ywnZ - 1.5 * baZ
944:	DrawArrow tx - r, ty, tx + r, ty, icZ
945:	END IF
B-46

-------
Program Documentation	Version 2-0
946:	ELSEIF FpZ - 6 AND ABS(r) > 0 THEN
947:	IF rnZ = 0 THEN
948:	ELSEIF rnZ <= 6 THEN
949:	ty = jnml
950:	DrawArrow tx, ty + r, tx, ty - r, icZ
951:	ELSEIF rnZ <- 9 THEN
952;	r ¦ r / Aspct
953:	tx ¦ tx + .5 * but
954:	ty « ywnZ - (raZ - 6 + .5} * baZ
955:	DrawArrow tx + rt ty, tx - r, ty, icZ
956:	ELSEIF ml <- 15 THEN
957:	ty ¦ yvnZ - 5 * baZ
958:	DrawArrow tx, ty - r, tx, ty + r, icZ
959:,	ELSEIF rnZ <- 18 THEN
960:	r - r / Aspct
961:	tx - tx - .5 * buZ
962:	ty ¦ yvnZ - (18 - rnZ +• 1.5) * baZ
963:	DrawArrow tx - r, ty, tx + r, ty, icZ
964:	END IF
965:	END IF
966:	END SUB
967:
968:	SUB FloorGraphSetup
969;	ywnZ - 1000
970:	SETSTDWINDOW -200, 1200, 1000, -550, 1100, (ywnZ)
971:	STDWINDOW
972:	Aspct -1.6
973:	DrawFloorFlan
974:	IF GRAPH > 1 THEN
975:	rmnZ ¦ 0
976:	IF FpZ - 1 01 FpZ - 2 THIN nrtnZ - 1
977s	FOR iZ - rmnZ TO NrZ
978:	CenterofRoom iZ, x, y
979:	cZ - ((x - .3} * buZ + 200) * WIN / 1400
980:	rZ - ((y - .5) * buZ + 100) * HWIN / 1650
981:	FRNT rZ, CZ, LTRIM$(STR$(iZ))
982:	NEXT
983:	END IF
984:	ml - MAXLINES - 88 / InhtZ + 2
985:	IF GRAPH - 3 THEN nZ - mZ - 1 ELSE nZ » mZ
986:	DEFINEWINDOW 2, nZ, 0, mZ, 79, 15, 0
987:	SELECTW 1
988:	END SUB
989:
990:	SUB GraphAverage
991:	CENTXT 1, 'RELATIVE CONCENTRATIONS*
992:	FloorGraphSetup
993:	DrawAverages 0
994:	SELECTW 2
995:	DrawLegend3
996:	mZ ¦ mZ + 2
997:	DEFINEWINDOW 3, mZ, 0, mZ, 79, 15, 0
998:	SELECTW 3
999:	FRNT 1, 2, "Limit"
B-47

-------
Program Documentation	Version 2.0	IAQFC
1000s	IF Initialized! THIN
1001:	FOR iX « 1 TO npoll
1002:	jZ - 12 * Ci2 - 1) + 9
1003s	PRNT 1, jf + 4, STR$(LimConc(iX))
1004s	NEXT
1005	s	END IF
1006	J	SELECTW 1
1007;	PAX 0
1008s	END SUB
1009 s
1010;	SUB GraphAverageClose
1011s	GraphicsRestore wp, wpO, wp2
1012 s	END SUB
1013:
1014:	SUB GraphAverageHiat
1015s	OpenTmpFile tX, Dpath$ + MasterFiIe$ + ".tap"
1016:	IF tZ - 0 THIN EXIT SUB
1017s	GetLastTime tZ, mrZ, npoXZ, lastt
1018:	mast ¦ MaxTime(lastt, nttZ)
1019:	recsizei - 4 * ((mrZ + 3) * npoll + 1)
1020:	nrecsX - (LOF(tX) - 4) \ recsizei
1021:	CENTXT 1, "RELATIVE CONCENTRATIONS*
1022:	FloorGraphSetup
1023s	SELECTW 2
1024s	DrawLegend3
1025:	ml - mX + 2
1026:	DEFINEWINDOW 3, mX, 0, mZ, 79, 15, 0
1027:	SELECTW 3
1028s	PRNT 1, 2, 'Limit*
1029s	IF InitializedZ THEN
1030s	FOR iX « 1 TO npolZ
1031s	jZ « 12 ~ (iZ - 1) + 9
1032:	PRNT 1, jZ + 4, STR$(LimConc(iX))
1033:	NEXT
1034s	END IF
1035:	SELECTW 1
1036:	yvnZ - 1000
1037:	SETSTDWINDOW -200, 1200, 1000, -550, 1100, (yvnZ)
1038:	STDWINDOW
1039:	Aspct ¦ 1.6
1040:	FOR rZ ¦ 1 TO nrecsX
1041:	startrecS ¦ 5 + (rZ - 1) * recsizeS
1042:	SEEK #tZ, startrecfc
1043:	GST #tZ, , time
1044:	PRNT 1, 55, "at": PRINT USING * ###.#"; time
1045s	DrawAverages tZ
1046:	a$ - IMKIY$: IF a$ - CHR$(27) THEN GOTO quickexit2
1047:	NEXT
1048:	SELECTW 0
1049s	PAK 0
1050s
1051:	quicke*it2i
1052:	CLOSE tZ
1053:	END SUB
B-48

-------
Program Documentation	Version 2.0	IAQFC
1054:
1055:	SUB GraphAveragelnit
1056:	Graphicslnit wp, wpO, wp2
1057:	CENTXT 1, "RELATIVE CONCENTRATIONS *
1058:	FloorGraphSetup
1059 :	SELECTW 2
1060:	DrawLegend3
1061:	ml » ml + 2
1062i	DEFINEWINDOW 3, ml, 0, ml. 79, 15, 0
1063 s	SELECTW 3
1064t	PINT 1, 2, "Limit*
1065:	IF Initialized! THEN
1066s	FOR if - 1 TO npolX
1067:	jZ - 12 * (iZ - 1) + 9
1068:	PRNT 1, jZ + 4, STR$(LimConc(iZ))
1069:	NEXT
1070:	END IF
1071:	SELECTW 1
1072:	ywnZ » 1000
1073:	SETSTDWINDOW -200, 1200, 1000, -550, 1100, (yvnZ)
1074:	STDWINDOW
1075:	Aspct ¦ 1.6
1076s	END SUB
1077:
1078:	SUB GraphCycles (swZ)
1079:	IF GRAPH ¦ 3 THEN
1080.*	ybmZ - -390
1081:	lsZ ¦ 5
1082:	loZ - 4
1083:	ELSEIF GRAPH * 2 THEN
1084:	ybmZ ¦ -700
1085:	lsZ - 3
1086:	loZ - 2
1087:	ELSE
1088;	ybmZ - -450
1089:	lsZ - 2
1090:	loZ - 1
1091:	END IF
1092:	CENTXT 1. "SOURCE CYCLES"
1093;	ywnZ - 1000
1094:	SETSTDWINDOW 0. 1200, 1200, (ybmZ), 1100, (yvnZ)
1095:	STDWINDOW
1096:	IF swZ « 0 01 AUgnTiae < 0 THEN DrawCycles ELSE DrawDupCycles
1097:	FOR iZ - 1 TO 8
1098s	PRNT lsZ * iZ + loZ, 1, STR$(iZ)
1099:	NEXT
1100s	mZ «¦ MAXLINES -88 / InhtZ + 2
1101s	DEFINEWINDOW 2, mZ, 0, mZ, 79, 15, 0
1102s	SELECTW 2
1103:	DrawLegendS swZ
1104:	SELECTW 1
1105;	PAK 0
1106 s	END SUB
1107:
B-49

-------
Program Documentation	Version 2.0	IAQPC
1108; SUB GraphFlows
1109:	CENTXT 1, "ROOM FLOWS*
1110s	FloorGraphSetup
1111 s	DrawFlows
1112s	SELECTW 2
1113 s	DrawLegend2
1114s	SELECTW 1
1115;	PAK 0
1116s	END SUB
1117s
1118s	SUB GraphHistory
1119s OpenTmpFile tZ, Dpath$ + MasterFileS + ". tmp"
1120s	IF tZ ¦ 0 THIN EXIT SUB
1121s	GetLastTime tZ, mrZ, npolZ, lastt
1122s	mast * M&xTime(lastt, nttZ)
1123s	DIM xp(npolZ), yp(npolX)
1124s SETSTDWINDOW -100, 1100, 1000, -190, 1010, 1000
1125s	Dr awBistWindows nttZ, 5
1126s	SELECTW 1
1127s	CENTXT 2, "Room* + STR$(SdrZJ
1128s	recsizei « 4 * ((mrZ + 3) * npolZ +1}
1129s	nrecsl - (LOF(tX) - 4) \ recsizeS
1130s	rad - ((npolZ + 1) \ 2) * 10
1131s	IF mast I PrntTime > 3 * 1000 / rad THEN
1132:	SETACCENT 0, 0
1133:	ELSE
1134s	SETACCENT -1, 0
1135:	END IF
1136:	FOR rZ - 1 TO nreesZ
1137:	startrecS - 5 + (rZ - 1) * recsizefc
1138:	SEEK #tZ, startrecS
1139s	GET #tX, , time
1140 s	tin = 1000 * time / maxt
1141:	rnZ » SdrZ
1142s	rooaoffset& - 4 + 4 * (apolZ * rnZ)
1143:	SEEK #tZ, startreci + roomoffsetfc
1144 s	FOR iZ » 1 TO npolZ
1145s	GET #tZ, , c
1146s	c « 800 * c I LimConc(iZ)
1147s	SELECTW iZ
1148:	FULLCIRCLE ta, c, rad, 8 + iZ
1149:	NEXT
1150:	ml - mrZ + 1
1151s	roomoffset& - 4 + 4 * (npol2 * rnZ)
1152;	SEEK #tZ, startrec& + roomoffset*
1153:	FOR iZ - 1 TO npolZ
1154:	GET ftZ, , c
1155:	c ¦ 800 * c I LimConc(iZ)
1156s	SELECTW iZ
1157:	IF rZ = 1 THEN
1158;	PSET (ta, c), 8 + iZ
1159:	xp(iZ) = ta
1160:	yp(iZ) * c
1161:	ELSE
B-50

-------
Program Documentation	Version 2.0	XAQPC
1162:	LINE (xp(iZ), yp(iZ))-(tm, c), 8 + iZ
1163s	xp(iZ) ¦ tm
1164!	yp(iX) - c
1165:	END IF
1166!	NEXT
1167:	a§ - IMKEY$: IF a$ - GHR$<27) THEN GOTO quickexit
1168:	NEXT
1169s	SELECTV 0
1170s	PAK 0
1171i
1172i	quickexits
1173:	CLOSE tZ
1174:	END SUB
1175:
1176:	SUB GraphicsDispatch (ipZ)
1177:	IF GrZ - 0 THEN EXIT SUB
1178:	RIDIM bZ(25 *4+3)
117S:	SAVESCREEN 0, 76, 24, 79, bZO
1180:	Graphicslnit wp, wpO, wp2
1181:	IF ipZ - 1 THEN GraphRooms
1182:	IF ipZ - 2 THEN GraphFlows
1183:	IF ipZ - 3 THEN GraphLocations
1184:	IF ipZ - 4 THEN GraphCycles 0
1185:	IF ipZ - S THEN GraphCycles 1
1186:	IF ipl « 6 THEN GraphAverage
1187:	IF ipZ • 7 THEN GraphAverageHist
1188:	IF ipZ - 8 THEN GraphHistory
1189:	IF ipl - 9 THEN GraphLogHistory
1190:	GraphicsRestore wp, wpO, wp2
1191*	RESTORESCREEN 0, 76, bZ(>
1192:	ERASE bZ
1193:	END SUB
1194:
1195:	SUB Graphicslnit (wp AS SCRNPAR, wpO AS SCRNPAR, wp2 AS SCRNPAR)
1196:	SAVEPAR 0, wpO
1197:	SAVEPAR 1, wp
1198:	SAVEPAR 2, wp2
1199:	COLGRAPH
1200:	InhtZ ¦ 8
1201:	pll » 1
1202:	IF GRAPH - 3 THEN
1203:	IZ - 60
1204:	SETLINES IZ
1205:	IF IZ - 25 THEN
1206s	CALL SETGRAPHTO(2)
1207:	COLGRAPH
1208:	ELSE
1209:	yl ¦ 2 * InhtZ
1210:	plZ ¦ 2
1211:	END IF
1212:	END IF
1213:	IF GRAPH « 2 THEN
1214s	IZ - 43
1215:	SETLINES IZ
B-51

-------
Program	Documentation Version 2.0	IAQPC
1216:	IF 12 - 25 THEN
1217:	CALL SETGRAPHTO(l)
1218:	BWGRAPH
1219i	END IF
1220:	yl - lnhtl
1221:	END IF
1222:	IF GRAPH - 1 THEN
1223:	InhtZ - 16
1224:	yl - InhtZ
1225:	END IF
1226:	xl - SCREENMODE
1227:	DEFINEWINDOW 0, MAXLINES, 0, MAXLINES, HAXCOL, 15, 0
1228:	DEFINEWINDOW 1, 0, 0, MAXLINES, HAXCOL, 15, 0
1229:	SELECTW 1
1230s	IF BsZ = 0 THIN WHITEFALETTE ELSE KPALETTE -1, 0
1231:	npolZ ¦ CNTBITS(In)
1232s	END SUB
1233:
1234:	SUB GraphicsRestore (wp AS SCRNPAR, wpO AS SCRNPAR, wp2 AS
SCRNPAR)
1235:	SETSCREEN 0
1236:	SETLINES 25
1237:	RESTOREPAR 0, wpO
1238:	RESTOREPAR 1, wp
1239:	RESTOREPAR 2, wp2
1240:	IF NOT BsZ THEN WHITEPALETTE
1241:	SELECTW 1
1242:	CLW 1
1243:	END SUB
1244:
1245:	SUB GraphLocations
1246s	CENTXT 1, "LOCATION of SOURCES, SINKS, and CLEANERS"
1247:	FloorGraphSetup
1248:	DrawLocations
1249:	DEFINEWINDOW 2, mZ, 0, mZ + 4, 79, 15, 0
1250:	SELECTW 2
1251:	DravLegend4
1252:	SELECTW 1
1253:	IF GRAPH < 2 THEN CHIRP 1: PAUSE 0, "* ELSE PAK 0
1254:	END SUB
125S:
1256:	SUB GraphLogHistory
1257:	OpenTmpPile tZ, Dpath$ + MasterFile$ + *,tmp"
1258:	IF tZ - 0 THEN EXIT SUB
1259:	GetLastTime tZ, orZ, npolZ, lastt
1260:	maxt - MaxTime(lastt, nttZ)
1261:	DIM xp(npolZ), yp(npolZ)
1262:	SETSTDWINDOW -100, 1100, 1000, -200, 1000, 1000
1263:	DrawLogHistWindows nttZ, 5
1264:	SELECTW 1
1265:	CENTXT 2, 'Room" + STR$(Sdr2)
1266:	recsizeS = 4 * ((orZ + 3) * npolZ +1)
1267:	nrecsZ ¦ (LOF(tZ) - 4) \ recsizefc
1268:	rad = ((npolZ + 1) \ 2) * 10
B-52

-------
Program Documentation	Version 2.0
1269j	IF maxt / PrntTime > 3 * 1000 / rad THEN
1270:	SETACCENT 0, 0
1271:	ELSE
1272:	SETACCENT -1, 0
1273:	END IF
1274.-	FOR rZ - 1 TO nrecsl
1275:	startrecS ¦ 5 + (rZ - 1) * recsizeS
1276:	SEEK ItZ, startrec&
1277:	GET ItZ, , time
1278:	tm = 1000 * time / maxt
1279:	rnZ - SdrZ
1280:	roomoffset& - 4 + 4 * (npolZ * mZ)
1281:	SEEK #tZ, startrecS: + roomoffset&
1282:	FOR iZ - 1 TO npolZ
1283s	GET #tZ, , c
1284:	fac - LimConc(iZ)
1285:	c ¦ LG10(!MAX(c, .001 * fac) / fac)
1286:	c - 200 * c + 600
1287:	SELECTV iZ
1288:	FULLCIRCLE tm, c, rad, 8 + iZ
1289:	NEXT
1290:	rnZ ¦ mrZ + 1
1291:	roomoffseti - 4 4- 4 * (npolZ * mZ)
1292:	SEEK ItZ, startrecS + roomoffset&
1293:	FOR iZ - 1 TO npolZ
1294:	GET ItZ, , c
1295:	fac = LimConc(iZ)
1296:	c = LG10(RMAX(c, .001 * fac) / fac)
1297:	c ¦ 200 * c + 600
1298:	SELECTW iZ
1299:	IF rZ » 1 THEN
1300:	PSET (tm, c), 8 + iZ
1301:	xp(iZ) = tm
1302:	yp(iZ) - c
1303:	ELSE
1304:	LINE (xp(iZ), yp(iZ)}-
-------
Program Documentation	Version 2.0	IAQPC
1323:
TextS
=
"Building Floor Plan"
1324:
Text$

TextS
+
".Flows for Room/HVAC"
1325:
Text?
-
TextS
+
",In-Room Locations"
1326:
Text$
=
TextS
+
",Day Cycles "
1327;
Text$
_
Text$
+
".Week Cycles"
1328:
TextS
as
TextS
+
".Room Pollutants Now"
1329:
TextS
=
TextS
+
*,Pollutant History (All)"
1330:
TextS
m
TextS
+
".Time Room Pollutant"
1331:
TextS
=
TextS
Hh
",Log-plot Time Pollutant*
1332:
Text$
=
TextS
+
".Select Room for Display"
1333:
TextS
=
TextS
+
",.Quit to Prior Menu *
1334:	OPMEN Title?, TextS, StdBot$, ipl, Key$
1335:	IF Key? = CHR$(27) OR ipZ = 12 THEN EXIT DO
1336:	IF KeyS = CHR$(13) AND ipl = 10 THEN
1337;	PUSHW MIDLINE - 3, MIDSCRN - 20, MIDLINE, MIDSCRN + 18,
MPAL(O), MPAL(l)
1338:	SETFRAME FALSI
1339:	FRAMEWINDOW CURRENTWINDOW
1340:	SHADOWINDOW CURRENTWINDOW, "R"
1341:	CENTXT 1, "Present display room # is * + STR$(SdrZ)
1342:	PRNT 2, 2, "Enter a new Room for Display: *
1343:	q$ = SINPUT(qS)
1344:	IF q$ <> "" THIN SdrZ = VAL(q$): q$ - ""
1345:	SdrZ = IMIN(NrZ, IMAX(0, SdrZ))
1346:	POPW
1347s	ELSEIF Key$ = CHR$(13) AND ipZ < 10 THEN
1348:	Title$ « * "
1349:	TextS =
1350s	GraphicsDispatch ipZ
1351s	SETLEVEL 2
1352;	END IF
1353:	LOOP
1354:	END SUB
1355:
1356:	SUB GraphRooms
1357:	CENTXT 1, "FLOOR PLAN and OPENINGS*
1358:	FloorGraphSetup
1359:	DrawOpenings
1360:	IF FpZ <= 2 THEN nZ = 1 ELSE nZ » 0
1361:	PRNT 3, 3, "Volume"
1362:	FOR iZ = nZ TO NrZ
1363:	IF MAXLINES > 2 * (NrZ + 1 - nZ) + 5 THEN jZ=2*iZ+5
ELSE jZ = iZ + 5
1364:	PRNT jZ, 1, RIGHTS(* " + STR$(iZ), 2)
1365:	PRNTF jZ, 4, (Vol(iZ)), "######"
1366:	NEXT
1367:	SELECTW 2
1368:	DrawLegendl
1369s	SELECTW 1
1370:	PAK 0
1371:	END SUB
1372:
1373:	FUNCTION MaxTime (lastt, nttZ)
1374:	IF lastt > 48 THEN
B-54

-------
Program	Documentation Version 2,0
1375:	nttZ = lastt I 12
1376s	maxt = 12 * nttZ
1377;	ELSEIF lastt > 12 THIN
1378i	nttZ = ROUND((lastt), 2)
1379s	maxt = nttZ
1380s	ELSE
1381:	nttZ = ROUND((lastt +1), 1)
1382;	maxt = nttl
1383s	END IF
1384:	MaxTime ¦ maxt
1385:	END FUNCTION
B-55

-------
Program Documentation	Version 2.0
\ind\basicd.asc
IAQPC
lJ
' SINCLUDEj
2;
" SINCLUDE:
3;
* $INCLUDE:
4:
'SINCLUDE:
5;
'SINCLUDE:
6:
'SINCLUDE:
7:
'SINCLUDE:
8s
'SINCLUDE:
9s

10 s
lis
12 s
13:
14:
15:
16	$
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
»\qb4\level0.pub *
*\qb4\levell.pub'
'\qb4\windowp.pub"
'\qb4\minicalp.pub *
*\qb4\level2.pub'
'\qb4\menup.pub *
'\ind\iaqsubp.pub'
*\ind\iaqcommn.pub*
DECLARE FUNCTION AllowableRoomsZ (Fpl, nZ)
DECLARE FUNCTION Press I (if)
DECLARE FUNCTION RnChangeZ CkZ, ml, NrZ)
DECLARE SUB Balance ()
DECLARE SUB Balancelnit ()
DECLARE SUB BasicDesign ()
DECLARE SUB BasicFloorPlans (FpZ)
DECLARE SUB BuildingStat ()
DECLARE SUB CopyDown (iZ, jl)
DECLARE SUB CopyUp (iZ, jZ)
DECLARE SUB DisplayFlows ()
DECLARE SUB ExpandedFloorPlan (FpZ, NrZ)
DECLARE SUB Floorplan (FpZ, NrZ)
DECLARE SUB GraphicsDispatch (iZ)
DECLARE SUB HSched ()
DECLARE SUB InRoom ()
DECLARE SUB InterConMenu (rnZJ
DECLARE SUB Interconnections (FpZ, NrZ, mZ)
DECLARE SUB InterConSet (}
DECLARE SUB LdBasicDesignFile (}
DECLARE SUB LdHVACFile ()
DECLARE SUB LdMasterFile ()
DECLARE SUB LoadBasicDesign ()
DECLARE SUB LoadHVAC ()
DECLARE SUB PrntFlows (hZ)
DECLARE SUB RoomDes (Vol(), MixFac())
DECLARE SUB RoomNumbers (FpZ, NrZ)
DECLARE SUB SaveBasicDesign ()
DECLARE SUB SaveHVAC ()
DECLARE SUB SvMasterFile ()
CONST MaxRooms >= 20, B15 = "	"
END
FUNCTION AllowableRoomsZ (FpZ,
mZ = 0
IF FpZ = 1 THEN mZ = IMAX(2,
IF FpZ = 2 THEN mZ = IMAX(4,
IF FpZ = 3 THEN mZ - IHAX(4,
IF FpZ = 4 THEN mZ = IMAX(2,
IF FpZ - 5 THEN mZ - IMAX(8,
nZ5
IMIN(MaxRooms,
IMIN(MaxRooms,
IMIN(MaxRooms,
IMIN(MaxRooms,
IMIN (MaxRooms,
nZ))
(nZ \ 2) * 2))
(nZ \ 2) * 2))
nZ)5
(nZ \ 2) * 2))
B-56

-------
Program	Documentation Version 2.0
53s	IF FpZ = 6 THEN mZ = 19
54 s	AllowableRooms = mZ
55s	END FUNCTION
56 s
57s	SUB BasicDesign
58s	STATIC ipZ, rnl
59:	DIM wp AS SCRNPAR
60s	SAVEPAR 1, wp
61s	DEFINEWINDOW 3, II, 0, 24, 42, MPAL(l), MPAL(O)
62:	DEFINEWINDOW 2, 0, 0, 10, 43, MPAL(l), MPAL(O)
63s	DEFINEWINDOW 1, 0, wp.MAXCOL - 32, 24, wp.MAXCOL, MPAL(l), MPAL(
0)
64s	SELECTW 1
65:	elZ « 12
66:	scZ = MIDSCRN - 10
67:	srZ = MIDLINE - elZ / 2 - 2
68:	SETCOL SCZ
69:	TitleS = 'Basic Building,Design"
70:	TextS « "Floor Flan Selection,Number of Rooms"
71:	TextS = TextS + ".Room Number,Volume (ft3),Interconnections"
72:	TextS = TextS + *,Upward Room# Copy ,Downward Room# Copy
«F4>"
73:	TextS = TextS + ",Building Statistics,Load Building Design"
74:	TextS = TextS + ",Save Building Design,.Quit to Main Menu "
75:	BotS « "Use cursor keys to select option."
76:	BotS = BotS + ".Use  to activate option."
77:	Bot$ = BotS + ",Use " + CHR$<26) + "/" + CHR$(27) + " to change
room number."
78:	GITROW Title$, TextS, Bot$
79:	SETROW srZ
80:	IF rnZ < 0 THEN ml ¦ 1
81:
82:	BasicDesignO:
83:	IF FpZ <> 0 THIN
84:	CLW 2
85:	SELECTW 2
86s	CENTXT 1, "Expanded Floor Plan" + STR$(FpZ)
87:	SETCURSOR 3, 1
88:	ExpandedFloorPlan FpZ, NrZ
89s	END IF
90:
91:	BasicDesignl:
92:	IF FpZ <> 0 THEN
93:	SELECTW 3
94:	SETCURSOR 0, 0
95:	Interconnections FpZ, NrZ, rnZ
96:	SELECTW 1
97:	END IF
98:
99:	BasicDesign2:
100:	DO
101:	PUTROW
102:	MCOLOR 1, 0
103s	PRNT srZ, scZ + 20, STR$(FpZ)
B-57

-------
Program Documentation	Version 2.0	IAQPC
104:	PRNT srZ + 1, scZ + 20, STR$(NrX) + " "
105:	PRNT srl + 2, scZ + 20, STR$(rnZ} + * "
106:	PRNT srZ + 3, scZ + 20, STR$(Vol(rnZ)} + SPACE${4)
107s	MCOLOR 3, 0
108;	Key$ = MENU(elZ, srZ, scZ, ipZ, kZ, "FNRVIUDBLS Q")
109:	IF KeyS - CHR$(27) OR (Key$ = CHR$(13> AND ipZ - elZ) THEN
EXIT DO
110:	IF RnChange(kZ, rnZ, NrZ) THEN GOTO BasicDesignl
111:	IF kZ - 68 TIEN GraphicsDispatch 1: SETLEVEL 2: GOTO
BssicDesignO
112:	IF ipZ = 4 THEN
113:	IF kZ = 67 THEN
114:	PRNT srZ + ipZ - 1, scZ + 10, "New Value: "
115:	VolCrnZ) = MINICALC
116:	CLL srZ + ipZ - 1, scZ + 10, scZ + 25
117:	kZ = 0
118:	KeyS = " "
119:	ELSEIF kZ « 61 THEN
120:	FOR JZ = rnZ + 1 TO NrZ
121:	Vol(jZ) = Vol(mZ)
122:	NEXT
123:	ELSEIF kZ = 62 THEN
124:	FOR jZ = 1 TO mZ - 1
125:	Vol(jZ) = Vol(mZ)
126:	NEXT
127:	END IF
128:	END IF
129:	IF kZ « 67 THEN x# - MINICALC
130:	IF VALIDNUM(Key$) AND ipZ < 5 THEN
131:	x$ =» Key$
132:	Key$ - CHR$(13)
133:	ELSE
134:	xZ - 0
135:	x$ = *"
136:	END IF
137:	IF Key$ - CHR$(13) THEN
138:	IF ipZ - 1 AND *$«="" THEN
139:	SELECTV 2
140:	SETCURSOR 2, 4
141;	BasicFloorPlans FpZ
142:	InterConSet
143:	IF FpZ <> 0 THEN NrZ = AllowableEooms(FpZ, 0)
144:	SELECTW 1
145:	GOTO BasicDesignO
146:	ELSEIF ipZ - 1 AND x$ <> "" THEN
147:	xZ = VAL(X$)
148:	ELSEIF ipZ < 5 THEN
149:	PRNT srZ + ipZ - 1, scZ + 10, "New Value: "
150:	x$ = SINPUT(xS)
151:	CLL srZ + ipZ - 1, scZ + 10, scZ + 25
152:	IF x$ - "" THEN GOTO BasicDesign2
153:	xZ = VAL(x$)
154:	END IF
155:	IF ipZ = 1 AND (xZ > 0 AND xZ < 7) THEN
B-58

-------
Program Documentation	Version 2.0	IAQPC
156s	FpZ * xl
157j	InterConSet
158s	NrZ = AllowableRooms(Fpl, NrZ)
159s	GOTO BasicDesignO
160s	END IF
161:	IF ipZ = 2 THIN NrZ « AllowableRooms(FpZ, xZ)s GOTO
BasicDesignO
162:	IF ipZ - 3 THIN rnZ = IHAX(0, IMIN(NrZ» xZ)): GOTO
BasicDesignl
163s	IF ipZ = 4 THIN Vol(rnZ) ¦ xZ
164:	IF ipZ = 5 THIN SELEGTW 3: InterConMenu rnZ: GOTO
BasicDesignl
165;	IF ipZ - 6 THIN CopyUp rnZ, 0
166:	IF ipZ ¦ 7 THEN CopyDoim rnZ, 0
167s	IF ipZ = 8 THEN BuildingStat
168:	IF ipZ = 9 THIN LoadBasicDesigns GOTO BasicDesignO
169:	IF ipZ = 10 THEN SaveBasicDesigns GOTO BasicDesignO
170:	END IF
171:	LOOP
172:	CLOSEWINDOW 2
173:	CLOSEWINDOW 3
174s	SlipCatch wp
175:	END SUB
176s
177s	SUB BasicFloorPlans (nZ)
178s	xZ = CSRLIN - 1: yZ = POS(O) - 1
179s	PUSHW xZ, yZ, xZ + 16, yZ + 50, 0, 7
180:	HEADER CURRENTWINDOW, ("Basic Floor Plans*}
181:	FOR iZ = 1 TO 3
182:	FOR jZ = 0 TO 1
183:	fZ = 3 * jZ + iZ
184:	PENT 2 + 6 * jZ, -15 + 16 * iZ, STR$(fZ)
185:	SETCURSOR 2 + 6 * jZ, -14 + 16 * iZ
186:	Floorplan fZ, AllowableRooms(fZ, 0)
187:	NEXT
188:	NEXT
189:	DO
190:	a$ = PAUSESTR(16, " or select a design for the problem: "
)
191:	IF a$ = CHR$(27) THEN EXIT DO
192:	PRNT CSRLNW, POSW, a$
193:	nZ = VAL(a$)
194:	IF nZ >= 1 AND nZ <= 6 THEN EXIT DO
195:	CHIRP 2
196:	LOOP
197:	POPW
198:	END SUB
199:
200:	DEFINT I
201:	SUB BuildingStat
202:	PUSHV 0, 7, NrZ + 4, 69, 0, 7
203:	HEADER 1, "Building Statistics"
204:	IF FpZ > 2 THEN hZ - 0 ELSE hZ - 1
205:	il = 3
B-59

-------
Program
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220?
221 i
222:
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
Documentation
Version 2.0
IAQFC
12 «
il
+ 5
i3 «
i2
O
Hi
i4 «
i3
+ 7
i5 »
i4
+ 12
i6 «
i5
+ 7
i7 =
i6
+ 7
18 =
i7
+ 7
PRNT
1.
2, "Room*
PRNT
1,
12, "Volume"
PRNT
1,
i3 - 2, "HVAC!
PRNT
1,
i4, "Ret Walls
PRNT
1,
i5, "Out"
PRNT
1,
16, "Nxt Rm"
PRNT
1.
i7, "Pr Rm*
PRNT
1.
i8, "Hall"
Tv -
0

Tow ¦¦
= 0

THI =
= 0

THR ¦
= 0

FOR
i .
hZ TO NrZ
In'
ipl = i + 2 - hZ
fv - Tv + Vol(i)
Til « THI + InterCon(i, 1)
Tow « Tow + lnterCon(i, 2)
+ InterCon(i, 6)
STR$(i)
THR — THR
PRNT ipl,	il,
PRUT ipl,	i2,
PRNT ipl,	i3,
PRNT ipl,	i4,
PRNT ipl,	i5,
PRNT ipl,	i6,
PRNT ipl,	i7,
PRNT ipl,	i8,
STR$(Vol(i)>
STR$(Inte rCon(i,	1))
STR$(InterCon(i,	6))
STR$(InterCon(i,	2))
STR$(InterCon(i,	3))
STR$(InterCon(i,	4))
STR$ CInte rCon(i,	5)5
NEXT
ipl = ipl
PRNT ipl,
PRNT ipl,
PRNT ipl,
PRNT ipl,
PRNT ipl,
PAK 0
POPW
END SUB
+ 1
2,
12,
13,
14,
15,
•Total*
STR$(Tv)
STRS(THI)
STR$(THR)
STRS(Tow)
DEFSNG I
SUB Copy Down (rnZ. swZ)
'if swZ=Q then copy all. if swl<>0 then copy only wall swZ,
'with swZ"7 corresponding to Vol
IF swZ THEN
IF swZ = 7 THEN
FOR iZ = 1 TO rnZ - 1
Vol(iZ) - Vol(rnZ)
NEXT
B-60

-------
Program Documentation	Version 2.0	IAQPC
260:	ELSE
261:	FOR iZ = 1 TO rnZ - 1
262:	InterConUZ, swZ> - InterCon(rnZ, swZ)
263:	IF swZ = 3 AND iZ < NrZ THEN
264:	InterCon(iZ + 1, 4) = InterCon(iZ, 3)
265s	ELSEIF swZ - 4 AND iZ > 1 THEN
266:	InterCon(iZ - 1, 3) - InterCon(iZ, 4)
267:	END IF
268:	NEXT
269;	END IF
270:	ELSE
271:	FOE jZ - 1 TO 7
272:	CopyDovn mZ» jZ
273:	NEXT
274:	END IF
275:	END SUB
276:
277:	SUB CopyUp (rnZ, swZ)
278:	'if swZ=0 then copy all
279:	'if swZ<>0 then copy only wall swZ, with swZ=7 corresponding
280:	* to Vol. do not copy to NrZ, which is the hall
281:	IF swZ THEN
282:	IF swZ = 7 THEN
283:	FOR iZ = mZ + 1 TO NrZ
284:	Vol(iZ) - Vol(rnZ)
285:	NEXT
286:	ELSE
287-.	FOR iZ = rnZ + 1 TO NrZ
288:	InterCon(iZ, swZ) = InterCon(rnZ, swZ)
289:	IF swZ - 3 AND iZ < NrZ THEN
290:	InterCon(iZ +1, 4) - InterCon(iZ, 3)
291:	ELSEIF swZ - 4 AND iZ > 1 THEN
292:	InterCon(iZ - 1, 3) = InterCon(iZ, 4}
293:	END IF
294:	NEXT
295:	END IF
296 s	ELSE
297:	FOR j2 = 1 TO 7
298:	CopyUp rnZ, jZ
299:	NEXT
300:	END IF
301:	END SUB
302:
303:	SUB DisplayFlows
304:	IF FpZ > 2 THEN hZ - 0 ELSE hZ - 1
305:	IF NrZ - 20 AND FpZ > 2 THEN blnZ = 24 ELSE blnZ = NrZ + 5 - hZ
306:	PUSHW 0, 2, blnZ, 73, 0, 7
307:	PratFlows (hZ)
308:	POPV
309:	END SUB
310:
311:	SUB ExpandedFloorPlan (FpZ, NrZ)
312:	xZ = CSRLNW
313:	yZ = P0SV
1-61

-------
Program Documentation	Version 2.0	IAQPC
314:	SETCURSOR xZ - 1. yZ - 1
315:	Floorplan FpZ, NrZ
316:	IF FpZ - 1 THEN SETCURSOR xZ + 2, yZ
317:	IF FpZ - 2 OR FpZ - 4 THEN SETCURSOR xZ + 3, yZ
318:	IF FpZ » 3 THEN SETCURSOR xZ + 2, yZ + NrZ + 2
319:	IF FpZ » 5 THEN SETCURSOR xZ + 2, yZ + NrZ
320j	IF FpZ = 6 THEN SETCURSOR xZ + 1, yZ + IS
321:	RoomNumbers FpZ, NrZ
322i	END SUB
323:
324i	SOT Floorplan (FpZ, NrZ)
325:	xX - NrZ
326:	yZ - 0
327:	iZ - CSRLIN + 1: jZ « POS(O)
328:	LOCATE iZ - 2, jZ + 1
329:	SELECT CASE FpZ
330:	CASE 1
331:	zl ~ xZ - 1
332:	PRINT 'Shotgun*
333:	LOCATE iZ - 1, jZ
334:	PRINT STR$(NrZ) + * rooms"
335:	LOCATE iZ. jZ
336:	PRINT "5=" + REPEAT<"=?=", z*} + "f" + REPEAT{"	yZ)
337:	LOCATE iX + 1, jZ
338:	PRINT "U=" + REPEAT("±=", zZ) + "M' + REPEAT(" —' ", yX)
3391	CASE 2
340:	zX » xZ \ 2 - 1
341:	PRINT "Bungalow"
342:	LOCATE iZ - 1, jZ
343:	PRINT STRS(NrZ) + " rooms"
344:	LOCATE iZ, jl
345:	PRINT "p=" + REPEAT(", zZ) + ^ » + REPEAT{*	yZ)
346:	LOCATE iZ + 1, jZ
347:	PRINT "J-* + REPEAT(*+-", zZ) + "|" + REPEAT("	yZ)
348:	LOCATE iZ + 2, jZ
349:	PRINT "B=" + REPEAT ("=t=", z Z) + "M " + REPEAT (" —' * , yZ)
350:	CASE 3
351:	zZ » xZ \ 2 - 1
352:	PRINT "Central Hall"
353:	LOCATE iZ - 1, jZ
354:	PRINT STR$(NrZ) + " rooms & hall"
355:	LOCATE iZ, jZ
356:	PRINT "r*" + REPEAT("=f=", zZ) + V + REPEAT(" ", yZ)
357:	LOCATE iZ + 1, jZ
358:	PRINT " (|-* + REPEAT("4—" f zZ) + "-(j" + REPEAT(" —' ", yZ)
359:	LOCATE iZ + 2, jZ
360:	PRINT + REPEAT (—", zX> + "fl " + REPEAT (" *, yZ)
361:	LOCATE iZ + 3, jX
362:	PRINT "tt=" + REPEAT*"±=", zZ) + «S* + REPEAT("	yZ)
363:	CASE 4
364:	zX ¦ xZ - 1
365:	PRINT "Side Hall"
366:	LOCATE iZ - 1, jZ
367:	PRINT STRS(NrZ) + " rooms & hall"
B-62

-------
Program
368;
369s
370s
371;
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
Documentation
LOCATE iZ, jZ
PRINT *f=" + REPEAT("
LOCATE iZ + 1, jZ
PRINT ¦ 1(—" + REPEAT("
LOCATE iZ + 2. jZ
PRINT ¦«-' + REPEAT("
CASE 5
zZ - xZ \ 2 - 4
PRINT "Common Hall"
LOCATE IZ - 1, jZ
PRINT STR$(NrZ) + " rooms & hall
LOCATE iZ, jZ
PRINT "fr=F=* + REPEAT ( "=f=
LOCATE iZ + 1, jZ
PRINT "I)—I-" + REPEAT<"J-
LOCATE iZ + 2, jZ
PRINT "II—I-" + REPEAT ("t-
LOCATE iZ + 3, jZ
PRINT «Ii=^" + REPEAT ("^
CASE 6
PRINT "Central Island"
LOCATE iZ - 1. jZ
PRINT STRS(NrZ) + " rooms & hall
LOCATE il, jX
PRINT "i, | , , , , ||"
LOCATE iZ + 1, j Z
PRINT " |—|—<—I—I—f—1|"
LOCATE iZ + 2, jZ
PRINT "|H ,	1 HI"
LOCATE iZ + 3, jZ
PRINT "|H 1	1 HI"
LOCATE iZ + 4, jZ
PRINT "II
Version 2.0
f=", zZ) + *=n"	+	REPEAT(" —yZ)
1-\ zZ) + *|"	+ REPEAT (" —I", yl)
, zZ) +	+	REPEAT(" yZ)
IAQPC
zZ)	+ VtT	+ REPEAT(*	—1\	yZ)
zZ)	+ "-HI"	+ REPEAT ( "	—I *,	yZ)
zZ)	+ *-H|"	+ REPEAT{"	—yZ)
zZ)	+	+ REPEAT ("	—I",	yZ)
_i—I—I—I—I—II
LOCATE iZ + 5, jZ
PRINT *!' 1 1 1 ' 1 "¦
CASE ELSE
END SELECT
END SUB
SUB HSched
CLW 1
SETLEVEL 3
Title$ m "HVAC Schedule, Each 24 Hours,Use Decimal Hours"
Text$ = "Time ON,Time OFF"
Text$ = Text$ + ".Time ON,Time OFF"
TextS « Text$ + ".Time ON,Time OFF"
TextS ¦ TextS + ".Time ON,Time OFF"
TextS = Text$ + ",,Quit "
Htimes(0) = RMIN(8I, Htimes(O))
FOR iZ = 1 TO Htimes(0)
tS = COMPOSEVAL(t$, STR$(Htimes(iZ)))
NEXT iZ
VALUHMENU 30, TitleS, TextS, t$
B-63

-------
Program Documentation	Version 2.0	IAQPC
422s	nZ » 2
423i	Htimes(0) = 0
424:	FOR iZ « 1 TO 8
425:	Htimes(iZ) « EMAX(0, RMIN(24i, VAL(DECOMPOSEVAL(t$)))}
426:	NEXT
427:	IF Htimes(2) = 0 THIN
428:	Htimes(2) = 24
429:	ELSE
430:	FOR it - 2 TO 8
431:	* » Htimes(iZ - 1)
432:	IF x »= Htimes(iZ) THEN EXIT FOR
433:	nX = iZ
434:	NEXT
435:	END IF
436:	Htimes(0) « nZ
437:	END SOT
438:
439:	SUB HVDescription
440:	STATIC ipZ
441:	DIM vp AS SCRNPAR
442:	elZ - 14
443:	SCZ - MIDSCRN - 10
444:	srZ - MIDLINE - elZ / 2
445:	DO
446:	Title$ = "HVAC SYSTEM,DESCRIPTION"
447:	Text? = "Total Flow (cfm) ¦
448:	TextS = TextS + "»Minimum Flow (cfm)"
449:	TextS =» TextS + ".Fraction Makeup Air"
450:	TextS = Text$ + ".Pressure Head (" + CHR$(34) + * H20)"
451:	TextS <= TextS + *,HVAC Flow Exponent(0.6-1)"
452:	TextS = TextS + On/Off Times,Balance Air Flows.Rebalance
Air Flows"
453s	Text$ = Text$ + ",Display Air Flows,Go to Basic Design.Load
HVAC data"
454:	TextS = TextS + ",Save HVAC data,,Quit to Main Menu "
455:	GETROW TitleS, TextS, StdBotS
456:	SETCOL SCZ
457:	CLV 1
458:	SETMOUSEVERT TRUE
459:	DO
460s	PUTROW
461i	MCOLOR 1, 0
462:	PRNT srZ + 0, scZ + 25, STRS(VolFlow) + B15
463:	PRNT srZ + 1, scZ + 25, STRS(MinFlow) + B15
464:	PRNT srZ + 2, scZ + 25, STRS(MakeUpAir) + BIS
465:	PRNT srZ + 3, scZ + 25, STRS(FanDP) + B15
466:	x ¦ ROUND(11 / FlowExp, ,01)
467:	PRNT srZ + 4, scZ + 25, STR$(x) + B15
468:	MCOLOR 3, 0
469:	Key$ - MENU(elZ, srZ, scZ, ipZ, kZ, "TMFPHOBRDGLS Q")
470:	IF Key$ - CHR$(27) OR (Key$ - CHR$(13) AND ipZ = elZ) THEN
EXIT SUB
471:	IF Key$ - CHR$(13) AND ipZ < 6 THEN
472:	PRNT srZ + ipZ - 1, scZ + 15, "New Value: *
B-64

-------
Program Documentation	Version 2.0	IAQPC
473s	x$ = SINPUT(w")
474;	PRNT srl + ipZ - 1, scZ + 15, *
475:	END IF
476:	IF Key$ = CHR$(13) AND ipZ - 9 THEN DisplayFlows: Key$ = "*
477:	IF Key$ = CHR$(13) AND ipZ >= 6 THEN
478:	TextS =
479:	Title? = *"
480:	SAVEPAR 1, wp
481:	BarCatch ipl +6, scZ, 3
482:	IF ipZ = 6 THEN HSched
483:	IF ipZ - 7 OR ipZ = 8 THEN
484:	CENTXT HWIN, "Press  to halt calculation."
485:	IF ipZ - 7 THEN
486:	Balancelnit
487:	BalancedZ = FALSE
488:	END IF
489:	Balance
490:	END IF
491:	IF ipZ = 10 THEN BasicDesign
492:	IF ipZ = 11 THEN LoadHVAC
493:	IF ipZ = 12 THEN SaveHVAC
494:	SETLEVEL 2
495:	SlipCatch wp
496:	EXIT DO
497:	END IF
498:	IF VALIDNUM(Key $) AND ipZ < 6 THEN
499:	SETCU1SOR srZ + ipZ - 2, scZ + 25
500:	x$ = SINPUT(Key$)
501:	END IF
502:	IF kZ = 67 AND ipZ < 6 THEN
503:	PRNT srZ + ipZ - 1, scZ + 10, "New Value: "
504:	x$ = STR$(MINIGALC)
505:	PRNT srZ + ipZ - 1, scZ + 10, "	"
506:	kZ = 0
507:	ELSEIF kZ = 67 THEN
508:	x = MINICALC
509:	END IF
510:	IF x$ <> ** THEN
511:	IF ipZ - 1 THEN VolFlow = RMAX(0, VAL(x$))
512:	IF ipZ = 2 THEN MinFlow = RMAX(.01 * VolFlow, VAL(x$))
513:	IF ipZ = 3 THEN MakeUpAir = VAL(x$)
514:	IF ipZ = 4 THEN FanDP = RMAX(0, VAL(x$))
515:	IF ipZ - 5 THEN FlowExp = RMAX(RMIN(1.7, 11 / VAL(x$)). 1)
516:	x$ = "«
517:	END IF
518:	IF kZ - 68 THEN GraphicsDispatch 2: SETLEVEL 2
519: ' LOOP
520: LOOP
521: SETMOUSEVERT FALSE
522: END SUB
523:
524: SUB InterConMenu (rnZ) STATIC
525: Interconl:
526: Interconnections FpZ, NrZ, rnZ
B-65

-------
Program Documentation	Version 2.0
527:	id =» 16
528:	DO
529:	MCOLOR 3, 0
530;	x$ = VALSTR(8, 3, icZ, ipZ, kZ, *	Q*5
531:	IF ipZ « 8 OR x$ = CHR$(27) THEN EXIT SUB
532:	IF kZ - 61 THEN
533;	CopyUp rnZ, ipZ
534:	x$ = ""
535;	ELSEIF kZ = 62 THEN
536;	CopyDown rnZ, ipZ
537:	x$ -
538;	END IF
539;	IF RnChange(kZ, mZ, NrZ) THEN
540:	x$ -
541;	SETCURSOR 0, 0
542:	Interconnections FpZ, NrZ, rnZ
543:	END IF
544:	IF x$ <> "" THEN
545;	InterCon(rnZ» ipZ) - VAL(x$)
546;	IF ipZ - 3 THEN
547:	IF rnZ < NrZ THEN InterCon(rnZ +1, 43 - InterCon(rnZ,
548:	IF rnZ = NrZ THEN
549;	IF FpZ < 6 THEN
550;	InterCon(l, 4) = InterCon(NrZ, 3)
551:	ELSE
552;	InterCon(l, 4) ¦ InterCon(NrZ - 1, 3)
553;	InterCon(NrZ, 4) = 0
554:	InterCon(NrZ, 3) = 0
555;	END IF
556;	END IF
557:	ELSEIF ipZ - 4 THEN
558:	IF rnZ > 1 THEN InterCon(rnZ - 1, 3) » InterCon(rnZ, 4)
559;	IF rnZ = 1 THEN
560:	IF FpZ < 6 THEN
561:	InterCon(NrZ, 4) = InterCon(l, 3)
562;	ELSE
563;	InterCon(NrZ - 1, 4) = InterCon(l, 3)
564;	InterCon(NrZ, 4) = 0
565;	InterCon(NrZ, 3) = 0
566;	END IF
567;	END IF
568:	END IF
569;	END IF
570;	SETCURSOR 0, 0
571:	Interconnections FpZ, NrZ, rnZ
572:	LOOP
573;	END SUB
574;
575;	SUB Interconnections (FpZ, NrZ, rnZ)
576:	xZ = CSRLIN: yZ » POS{0)
577:	IF rnZ - 0 THEN a$ = " Hall " ELSE a$ = "Room" + STR$(rnZ)
*
578;	NARROWFRAME xZ + 1, yZ + 2, xZ + 4, yZ + 8
579:	LOCATE xZ, yZ + 3: PRINT a$
B-66

-------
Program
580
581
582
583
584
585
586
587
588
589
590
591
592
593	s
594;
595s
596s
597:
598
599
§00
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
Documentation	Version 2.0
LOCATE xZ + 1, yZ + 3$ PRINT "Outside";
IF raX > 0 THIN
LOCATE xl + 3, yZ + lli PRINT " + ";
LOCATE xZ + 6, yl + 5s PRINT "Hall";
LOCATE xZ + 4, yZ + 1: PRINT
ELSE
LOCATE xZ + 3, yZ + 11: PRINT " ";
LOCATE xZ + 6, yZ + 5; PRINT " "j
LOCATE xZ + 4, yZ + Is PRINT " " j
END IF
jZ « yZ + 15
LOCATE xZ, jZs PRINT "Connecting Area (ft2)*;
LOCATE xZ + 2, jZ: PRINT "HVAC room inlet InterCon(rnZ, 1}
B15
LOCATE xZ + 3, jZ: PRINT "Outside wall(s) InterCon(rnZ, 2)
B15
LOCATE xZ + 4, jZ: PRINT "Next room
IAQPC
InterCon(rnZ,	3}
InterCon(rnZ,	4)
InterCon(rnZ,	5)
InterCon(rnZ,	6)
B15
LOCATE xZ + 5, jZ: PRINT "Prior room
B15
LOCATE XZ + 6, jZs PRINT "Hall
B15
LOCATE xZ + 7, j Zs PRINT "HVAC room return"
115
LOCATE xZ + 9, j Z: PRINT "Quit ";
END SUB
SUB InterConSet
IF FpZ « 1 OR FpZ = 2 THEN
FOR iZ - 1 TO 6
InterCon(0, iZ) = 0
NEXT
END IF
END SUB
SUB LoadBasicDesign
IF OpenDataFile(DpathS, BuildingFile$, "bid", 0) THEN
LdBasicDesignFile
IF MfsZ THEN SvMasterFile
END IF
END SUB
SUB LoadHVAC
IF OpenDataFile(Dpath$, HVACFile$, "live", 0) THEN
LdHVACFile
IF MfsZ THEN SvMasterFile
END IF
END SUB
DEFINT I
SUB PrntFlows (hZ)
REDIM ac(hZ TO NrZ)
FOR i = hZ TO NrZ
ac(i) = AirChanges(i, Vol(), Rmflow(>)
B-67

-------
Program Documentation	Version 2.0	IAQPC
628:	IF ac(i) > 9991 THEN ill « TRUE
629; • NEXT
630s IF ilZ THEN idZ - 60 ELSE idZ - 1
631s CENTXT 1, "Air Flows (CFM)"
632s	f$ = "#####"
633:	il = 3
634; 12 = il + 5
635: 13 = i2 + 8
636;	14 - 13 + 7
637; 15 ¦ i4 + 8
638;	16-15 + 7
639;	17 = i6 + 7
640:	18 = i7 + 7
641:	i§ =18+7
642;	ilO = i9 + 7
643:	PENT 2, 2, "Room*
644: IF ilZ THEN PRNT 2, 12, "ACh/Min" ELSE PRNT 2, 12, "ACh/Hr"
645: PRNT 2, i3, "HV_In"
646; PRNT 2, 14 - l,~"HV_Ret"
647: PRNT.2, i5 - 2, "Outside"
648; PRNT 2, i6, *Nxt_Rm"
649;	PRNT 2, 17, "Pr Rm"
650;	PRNT 2, 18, " Hall"
651;	PRNT 2, 19, "Total"
652:	PRNT 2, ilO, "Press"
653:	Tow = 0
654;	THI - 0
655;	THR - 0
656:	FOR i = hZ TO NrZ
657:	Ipl = i + 3 - hZ
658;	Tr - 0
659;	FOR jZ - 1 TO 6
660;	Tr - Tr + RmFlow(i, jZ)
661:	NEXT
662:	THI = THI + RmFlow(i, 1)
663:	Tow = Tow + RaFlowfi, 2)
664:	THR = THR + RmFlow(i, 6)
665*.	PRNT ipl, il, STR$(i)
666:	PRNTF ipl, i2, (ac(i) / idZ), "###.#"
667:	PRNTF ipl, i3. (RmFlowfi, 1)>, f$
668;	PRNTF ipl, i4, (RmFlovU. 6)5, f$
669;	PRNTF ipl, i5, (RmFlow(i, 2)), f$
670;	PRNTF ipl, i6, (RmFlow(i, 3)), f$
671;	PRNTF ipl, 17, (RmFlow(i, 4)), f$
672;	PRNTF ipl, i8, (RmFlow(i, 5)}, f$
673;	PRNTF ipl, i9, (Tr), f$
674;	PRNTF ipl, ilO, (Press(i)), "ii.it'
675:	NEXT
676: PRNT ipl + 1, 2, "Total"
677: x = 60 * VolFlov / ((NrZ + 1) * VectorAvg(0, NrZ, Vol())) / idZ
678; PRNTF ipl + 1, 12, (x), "iit.fi*
679; PRNTF ipl + 1, i3, (THI), £$
680: PRNTF ipl + 1, 14, (THR), f$
681;	PRNTF ipl + 1, 15, (Tow), f$
B-68

-------
Program Documentation	Version 2.0	IAQPC
682;	PRNTF ipl + 1, 58, (HVP), "Supply; «.##"
683:	PRNTF ipl + 2, 58, (RetP), "Return: ##.##"
684j	IF NrZ < 20 OR FpZ < 3 THEN PAK 0 ELSE CHIRP 1: PAUSE 0,
685s	END SUB
686:
687:	SUB RoomNumbers (FpZ, NrZ)
688s	ir = CSRLIN: ic =» POS(O)
689:	SELECT CASE FpZ
690:	CASE 1
691s	FOR i = 1 TO NrZ
692:	PRINT LEFT $(LTRIM$(5TR$(i) + " , 2);
693:	NEXT
694:	CASE 2
695;	FOR i - 1 TO NrZ I 2
696;	PRINT LEFT$(LTRIMS(STR$(i) + " *), 2);
697:	NEXT
698:	LOCATE ir + 1, ic
699s	FOR i = NrZ TO NrZ / 2 + 1 STEP -1
700:	PRINT LEFT$(LTRIMS(STR$(i) + " '), 2);
701s	NEXT
702:	CASE 3
703s	LOCATE ir - 1, ic
704:	FOR i = 1 TO NrZ \ 2
705:	PRINT LEFTS(LTRIM$(STR$(i) + " 2);
706:	NEXT
707:	LOCATE ir + 1, ic
708:	FOR i - NrZ TO NrZ \ 2 + 1 STEP -1
709:	PRINT LEFTS(LTRIM$(STR$(i) + " "), 2);
710:	NEXT
711:	LOCATE ir, ic + NrZ \ 2 - 2: PRINT "0"
712:	CASE 4
713:	FOR i = 1 TO NrZ
714:	PRINT LEFT$(LTRIM$(STR$(i) + • "), 2);
715:	NEXT
716:	LOCATE ir + 1, ic
717:	PRINT "0
718:	CASE 5
719:	LOCATE ir - 1, ic
720:	FOR i = 1 TO NrZ \ 2 - 1
721:	PRINT LEFTS(LTRIMS(STR$(i) + " "), 2);
722:	NEXT
723:	LOCATE ir + 1. ic
724s	FOR i = Nrl - 1 TO NrZ \ 2 + 1 STEP -1
725:	PRINT LEFT$(LTRIM$(STR$(i) + " *) , 2);
726:	NEXT
727:	LOCATE ir, ic
728:	PRINT LEFT $(LTRIM$(STR$(NrZ > + " *), 2);
729:	LOCATE ir, ic + NrZ \ 2 - 2
730:	PRINT "0
731:	LOCATE ir, ic + NrZ - 4
732:	PRINT LEFTS(LTRIMS(STR$(NrZ \ 2) + ' "), 2);
733:	CASE 6
734:	FOR i = 1 TO 6
735:	PRINT LEFTS(LTRIMS(STR$(i) + " 2);
B-69

-------
Program Documentation	Version 2.0	IAQPC
736:	NEXT
737i	LOCATE ir + 1, ic
738s	PRINT *18 7";
739i	LOCATE ir + 2, ic
740:	PRINT "17 19 8";
741:	LOCATE ir + 3, ic
742:	PRINT "16 0 9";
743:	LOCATE ir + 4, ic
744:	FOR i - 15 TO 10 STEP -1
745:	PRINT LEFTS(LTEIH$(STRS(i) + " "), 2);
746:	NEXT
747s	CASE ELSE
748:	END SELECT
749:	END SUB
750:
751:	DEFSNG I
752:	SUB SaveBasicDesign
753:	IF OpenDataFile(DpathS, BuildingFile$, "bid", 1} THEN
754:	chnX - FREEFILE
755:	OPEN DpathS + BuildingFileS + ".bid" FOR OUTPUT AS chnZ
756:	PRINT tchnZ, Fp1, Nr2
757:	FOR il - 0 TO MaxRooms
758:	PRINT /chnZ, Vol(iZ); InterCon(iZ, 1); InterCon(iZ, 2);
InterConCiZ, 3):
759:	PRINT #chnZ, InterConfiZ, 4); InterConfiZ, 5); InterCon(iZ,
63
760:	NEXT
761:	CLOSE chnZ
762i	IF MfsZ THEN SvMasterFile
763:	END IF
764:	END SUB
765:
766:	SUB SaveHVAC
767:	IF OpenDataFile(Dpath$, HVACFileS, "hvc", 1) THEN
768:	chnZ - FREEFILE
769:	OPEN DpathS + HVACFileS + ".hvc" FOR OUTPUT AS chnZ
770?	PRINT #chnX, FlowExp; VolFlow; FanDP; MakeUpAir; MinFlow;
HVPj RetP; BalancedZ
771:	FOR iZ = 0 TO MaxRooms
772:	PRINT #chnZ, RmFlow(iZ, 1)? RmFlov(iZ, 2); RmFlow(iZ, 3);
773:	PRINT #chnZ, RmFlow(iZ, 4); RmFlow(iZ, 5); RmFlow(iZ, 6)
774:	NEXT
775:	PRINT #chnZ, Htimes(0); Htimes(1); Htimes(2); Htimes(3) ;
Htimes(4);
776:	PRINT #chnZ, Htimes(5); Htimes{6): Htimes(7); Htimes(8)
777:	FOR iZ = 0 TO MaxRooms
778:	PRINT #chnZ, RmPressure(iZ)
779:	NEXT
780:	PRINT #chnZ, HVPr
781:	CLOSE chnZ
782:	IF HfsZ THEN SvMasterFile
783:	END IF
784:	END SUB
B- 70

-------
Program	Documentation Version 2.0	IAQPC
\ind\strength.asc
Is	'SINCLUDE: *\qbA\levelO.pub'
2;	'$INCLUDE: '\qb4\levell.pub1
3:	'$INCLUDE: *\qb4\windowp.pub *
4;	'$INCLUDE: *\qb4\minicalp.pub'
5:	*$INCLUDE: *\qb4\level2.pub*
6;	'$INCLUDE: '\qb4\menup.pub'
7:	* $INCLUDE: *\ind\iaqsubp.pub *
8:	'$INCLUDE: *\ind\iaqcommn.pub'
9s
10:	DECLARE SUB AirClean (acZ)
lis	DECLARE SUB AmbConc ()
12:	DECLARE SUB CyclicVar ()
13:	DECLARE SUB GraphicsDispatch (12)
14;	DECLARE SUB LdCleanerFile <3
15s	DECLARE SUB LdPolFile ()
16:	DECLARE SUB LoadCleaner ()
17;	DECLARE SUB LoadPoIlutants (3
18:	DECLARE SUB PolAvg O
19:	DECLARE SUB PolLim ()
20:	DECLARE SUB PolSetUp (Text$, t$, a()3
21:	DECLARE SUB PolSetUpB (Text$, t$, a(), nZ, swZ3
22:	DECLARE SUB PolSrc {>
23:	DECLARE SUB Fsink (swZ)
24:	DECLARE SUB SaveCleaner ()
25:	DECLARE SUB Savepollutants ()
26:	DECLARE SUB SelectCleaners (}
27:	DECLARE SUB SelectPollutant C)
28:	DECLARE SUB SetCleanerPerf (3
29:	DECLARE SUB SinkStr (nsnkZ, swZ)
30:	DECLARE SUB SrcStr (ipZ)
31:	DECLARE SUB SvMasterFile (3
32:
33 s
34:	SUB AirClean (acZ)
35:	STATIC ipZ
36:	IF acZ - 1 OR acZ = 2 OR acZ - 6 OR acZ = 7 THEN Title$ = "
Filter"
37:	IF acZ - 3 OR acZ = 8 THEN Title$ = "ESP"
38:	IF acZ = 4 THEN Titie$ = "Ionizer"
39:	IF acZ = 5 OR acZ = 9 THEN Title$ = "Dehumidifier"
40:	Title$ = Title$ + ".Efficiency,(Z3*
41s	FOR iZ ¦ 1 TO 11
42s	Text$ = Te*t$ + PolName(iZ3 +
43:	t$ - COMPOSEVAL(t$, STR$(100 * (1 - ClEff(acZ, iZ>) 3)
44:	NEXT
45:	Text$ = Text$ + ".Quit to prior menu "
46:	VALUEHENU 22, TitleS, TextS, t$
47:	FOR iZ = 1 TO 11
48:	ClEff(act. iZ3 =11 - VAL(DEC0MP0SEVAL(t$)) / 1001
49:	NEXT
50;	END SUB
51;
B-71

-------
program Documentation	Version 2.0	IAQPC
52:	SUB AmbConc
53:	STATIC ipl
54:	Title? - "Ambient, Concentrations,(mg/m3 or pC/1)"
55;	PolSetUp Text$» t$, AmbientConeO
56:	VALUEMENU 26, Title$, TextS, t$
57s	FOR iZ = 1 TO 11
58:	AmbientConc(iZ) = VAL(DICOMFOSEVAL$(t$))
59:	NEXT iZ
60:	END SUB
61:
62:	SUB CleanerMenu
63:	DIM wp AS SCRNPAR
64:	STATIC ipZ
65;	Title$ - "Air Cleaner & Sink, CHARACTERISTICS"
66:	TextS « "Choose Cleaners*
67:	TextS * TextS + ".Efficiency Levels"
68:	Te*t$ ® TextS + ".Passive Sinks"
69:	Text$ = TextS + ".Reemission from Sinks"
70:	Text$ - Text$ + ".Load Cleaner Data,Save Cleaner Data"
71:	TextS = TextS + ",,Quit to Main Menu «Esc>*
72:	DO
73:	CLW 1
74:	OPMEN Title$, TextS, StdBotS, ipZ, KeyS
75:	IF Key$ ¦ CHR$(27) OR ipZ « 8 THEN EXIT DO
76:	IF KeyS =* CHR$(13) THEN
77:	SAVEPAR 1, wp
78:	BarCatch ipZ + 8, MIDSCRN, 3
79:	IF ipZ = 1 THEN SelectCleaners
80:	IF ipZ = 2 THEN SetCleanerPerf
81:	IF ipZ = 3 THEN Psink 0
82:	IF ipZ =¦ 4 THEN Psink 1
83:	IF ipZ = 5 THEN LoadCleaner
84:	IF ipZ * 6 THEN SaveCleaner
85:	SETLEVEL 2
86:	SlipCatch wp
87:	END IF
88:	LOOP
89;	Title$ - ""
90:	TextS =
91:	END SUB
92:
93:	SUB CyclicVar
94:	SELECTW 0
95:	IF AlignTime >= 0 THEN
96:	CENTXT 1, "Negative start time signifies continuous cycling.
97:	ELSE
98:	CENTXT 1, "Positive start time signifies daily recycling.
99:	END IF
100:	SELECTW 1
101:	Title$ ¦ "On-Off Cyclic, Variation,Negative Values Allowed"
102:	FOR iZ - 1 TO 8
103:	TextS = TextS + CycleName(iZ) +
104:	NEXT
B- 72

-------
Program	Documentation Version 2.0	IAQPC
105:	IF Align!ime >= 0 THEN day$ -¦"each* ELSE day$ = "first"
106i	Text$ = Text$ + "Start time (" + day$ + * day)"
107:	TextS * TextS + ",.Quit "
108:	FOR iX - 1 TO 8
109:	tS - COMPOSEVAL(t$, STRS(Cycles(iZ)))
110:	NEXT
111:	t$ - COMPOSEVAL(t$, STR$(AlignTime))
112:	VALUEMENU 24, Title$, TextS, t$
113:	FOR il = 1 TO 8
114;	Cycles(il) - VAL(DECOMPOSEVAL(t $))
115s	IF CyclesCiX) - 0 THEN Cycles(iX) =0.1
116:	NEXT
117:	AlignTime « VAL(DECOMPOSEVAL(t$))
118;	END SUB
119?
120:	SUB LoadCleaner
121s	IF OpenDataFile(DpathS, ClFileS, *cln\ 0} THEN
122:	LdCleanerFile
123:	IF MfsZ THEN SvMasterFile
124:	END IF
125:	END SOT
126:
127:	SUB LoadPollutants
128:	IF OpenDataFile(DpathS, PolFileS, "pol", 0) THEN
129.	LdPolFile
130s	IF MfsX THIN SvMasterFile
131:	END IF
132:	END SUB
133:
134:	SUB PolAvg
135:	STATIC ipX
136:	Title? - "Pollutant, Averaging Times,(hr)*
137:	PolSetUp Texts, t$, PavgTO
138:	VALUEMENU 26, Title$, TextS, t$
139:	FOR il ¦ 1 TO 11
140:	PavgT(iZ) = VAL(DECOMPOSEVAL$(t$))
141:	NEXT
142:	END SUB
143:
144:	SUB PolLim
145:	STATIC ipX
146:	TitleS = "Pollutant, Limits,(mg/m3 or pC/1)"
147:	PolSetUp Text$, t$, Plim{)
148:	VALUEMENU 26, TitleS, TextS, t$
149:	FOR iX = 1 TO 11
150:	Plim(iX) - VAL(DECOMPOSEVALS(t$))
151:	NEXT
152:	END SUB
153:
154:	SUB PoIlut&ntMenu
155:	DIM wp AS SCRNPAR
156:	STATIC ipX
157:	TitleS = "POLLUTANT, CHARACTERISTICS*
158:	TextS = "Pollutant Choices,Generic Sources"
B-73

-------
Program Documentation	Version 2.0	IAQPC
159:	Text? ¦ Text$ + "(Averaging Periods,TLVs or Limits"
160:	Text$ = Text$ + ".Outside Concentrations'
161:	Text$ ¦ Text$ + ".Cyclic Variations*
162:	Text$ ¦ Text$ + ".Load Pollutant Data,Save Pollutant Data"
163:	TextS = fext$ + ",.Quit to Main Menu "
164:	DO
165:	CLW 1
166:	OPMEN Title$, Text$, StdBotS, ipZ, Key$
167:	IF Key$ - CHR$(27) OR ipl « 10 THEN EXIT DO
168:	IF Key$ » CHR$(13} THEN
169:	SAVSPAR 1, wp
170:	BarCatch ipZ + 7, MIDSCRN, 3
171:	IF ipZ - 1 THEN SelectPollutant
172:	IF ipZ = 2 THEN PolSrc
173:	IF ipZ ¦ 3 THEN PolAvg
174:	IF ipZ - 4 THEN PolLim
175:	IF ipl - 5 THEN AmbConc
176:	IF ipZ - 6 THEN CyclicVar
177:	IF ipZ = 7 THEN LoadPollutants
178:	IF ipZ = 8 THEN SavePollutants
179:	SETLEVEL 2
180:	SlipCatch wp
181:	END IF
182:	IF KeyS * "g" THEN GraphicsDispatch 4:SETLEVEL 2
183:	LOOP
184:	Title$ - ""
185:	Text$ - ""
186:	END SUB
187:
188:	SUB PolSetUp (TextS, t$, a())
189:	FOR iZ = 1 TO 11
190:	TextS *= Text$ + PolNaxaeCiZ)
191:	IF TSTBIT(In, iZ) THEN Text$ - Text$ + " x"
192:	TextS = TextS +
193:	t$ = COMPOSEVALCtS, STR$(a(iZ)))
194:	NEXT
195:	TextS ¦ TextS + ".Quit to prior menu "
196:	END SUB
197:
198:	SUB PolSetUpB (TextS, tS. a(), nZ, swZ)
199:	FOR iZ ¦ 1 TO 11
200:	TextS = TextS + PolName(iZ)
201:	IF swZ THEN
202:	TextS - TextS + STRINGS(4, 255)
203:	END IF
204:	IF TSTBIT(In, iZ) THEN TextS - TextS + " x"
205:	TextS - TextS +
206:	IF swZ THEN
207:	t$ = C0MP0SEVAL(t$, STR$(100 * (1! - a(nZ, iZ))))
208:	ELSE
209:	t$ - COMPOSEVALCtS, STR$(a(nZ, iZ) })
210:	END IF
211:	NEXT
212:	TextS * TextS + ".Quit to prior menu "
B-74

-------
Program Documentation
Version 2.0
IAQPC
213!	END SUB
214s
215:	SUB PolSrc
216:	DIM wp AS SCRNPAR
217:	STATIC ipX
218:	Title$ = "Generic SOURCE, DESCRIPTION, MENU"
219:	TextS - ""
220:	FOR jX ¦ 1 TO 8
221:	Text? - TextS + GenSource(jX) +
222:	NEXT
223:	Text$ - Text$ + ",Quit "
224:	DO
225:	CL¥ 1
226:	OPMEN TitleS, Text$, StdBot$, ipZ, Key$
227:	IF Key$ • CHR$(27> OR ipl ¦ 10 THEN EXIT DO
228:	IF KeyS - CHR$(13) AND ipl < 9 THEN
229;	SAVEPAR 1, wp
230;	BarCatch ipZ + 7, MIDSCRN, 4
231:	SrcStr ipZ
232:	SETLEVEL 3
233:	SlipCatch up
234:	END IF
235:	LOOP
236:	END SUB
237:
238:	SUB Psink (swX)
239:	DIM wp AS SCRNPAR
240:	STATIC ipZ
241:	IF swX ¦ 0 THEN TitleS » "Passive Sink, Efficiencies"
242:	IF swZ ¦ 1 THEN TitleS = "Passive Sink, Reemission Rates"
243s	TextS = "Horizontal (Type 1), Vertical (Type 2)"
244s	Text? = TextS + ".Furniture (Type 35,People (Type 43,.Quit

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
LOOP
END SUB
SUB SaveCleaner
DO
IF OpenDataFile(DpathS, ClFile$, "cln", 1) THEN
chnX = FREEFILE
OPEN DpathS + ClFile$ + ".cln" FOR OUTPUT AS chnX
PRINT IchnZ, cn
FOR jZ = 1 TO 9
CLW 1
OPMEN TitleS, TextS, StdBot$, ipX, Key$
IF KeyS - CHR$(27) OR ipX = 6 THEN EXIT DO
IF KeyS = CHR$(13) THEN
SlipCatch wp
END IF
SAVEPAR 1, wp
BarCatch ipX + 9, MIDSCRN, 4
SinkStr ipX, swZ
SETLEVEL 3
FOR iX = 1 TO 11
B-75

-------
Program Documentation	Version 2.0	IAQPC
266:	PRINT #chnZ, ClEff(j 2, iZ);
267s	NEXT
268s	PRINT #chnl,
269:	NEXT
270:	FOR iZ = 1 TO k
271:	FOR JZ - 1 TO 11
272:	PRINT /chnZ, Sink(iZ, jZ); SinkTc(iZ, jZ);
273:	NEXT
274:	PRINT #chnZ,
275:	NEXT
276:	CLOSE chnZ
277:	IF MfsZ THEN SvMasterFile
278 *	EI^D jy
279:	END SUB
280:
281:	SUB SavePollutants
282;	IFjDpenDataFile(DpathS, PolFile$, "pol", 1} THEN
283:	ChnZ - FREEFILE
284:	OPEN Dpath$ + PolFileS + ".pol" FOR OUTPUT AS chnZ
285;	PRINT #chnZ, In
286:	FOR il ¦ 1 TO 8
287:	FOR jZ = 1 TO 11
288;	PRINT IchnZ, GenericSrc(iZ, jZ);
289:	NEXT
290:	PRINT #chtnZ,
291:	NEXT
292:	FOR iZ = 1 TO 11
293:	PRINT IchnZ, PavgT(iZ);
294:	NEXT
295:	PRINT IchnZ,
296:	FOR iZ = 1 TO 11
297:	PRINT IchnZ, Plim(iZ);
298:	NEXT
299 s	PRINT /chnZ,
300:	FOR iZ = 1 TO 11
301:	PRINT IchnZ, AmbientConc(iZ);
302:	NEXT
303:	PRINT #chnZ,
304:	FOR iZ - 1 TO 8
305:	PRINT IchnZ, Cycles(iZ);
306;	NEXT
307:	PRINT #chnZ,
308t	PRINT IchnZ, AlignTime
309:	CLOSE chnZ
310:	IF MfsZ THEN SvMasterFile
311:	END IF
312:	END SUB
313:
314:	SUB SelectCleaners
315:	ell * 12
316;	TitleS ¦ "Cleaner, Selection,Choose Up To 2 Room and 2 HVAC"
317;	FOR iZ ¦ 1 TO 9
318;	Text$ ¦ Text$ + ClName(iZ)
319:	IF'iZ ¦ 5 THEN Text$ ¦> Text$ +
B-76

-------
Program Documentation	Version 2.0
320:	Text$ = Text$ + *,"
321:	NEXT
322:	Text$ = Text$ + ".Quit to prior menu «Esc>"
323:	SETCOL 24
324:	GETROW fitle$, Text$, *•
325:	TOGGLEBOT
326:	PUTROW
327:	DO
328:	t$ - ""
329:	FOR jZ = 1 TO 9
330:	PselS = CHR$(255)
331:	IF TSTBIf(cn, jl) THEN Psel$ = "x"
332:	IF jl = 5 THEN Psel$ « PselS + \"
333:	t$ = COMFOSIVAL(t$, PselS)
334:	NEXT jl
335:	GETVAL t$
336:	MCOLOt 3, 0
337:	PUTVAL
338:	TOGGLEMEN ipZ, plusZ
339:	IF ipZ - 0 OR ipZ - elZ THEN EXIT DO
340:	IF ipZ < 6 THEN
341:	IF TSTBIT(cn, ipZ) THEN
342:	CLRSITOF cn. ipZ
343:	ELSEIF CNTBITS(cn AND &H1F) < 2 THEN
344:	SETBITOF cn, ipZ
345:	ELSE
346:	MaxOf 2
347:	END IF
348:	ELSEIF ipZ > 6 THEN
349:	IF TSTBITCcn, ipZ - 1) THEN
350:	CLRBITOF cn, ipZ - 1
351:	ELSEIF CNTBITS(cn AND &H1E0) < 2 THEN
352:	SETBITOF cn, ipZ - 1
353:	ELSE
354:	MaxOf 2
355:	END IF
356:	END IF
357:	LOOP
358:	SETCOL MIDSCRN
359:	END SUB
360:
361:	SUB SelectPollutant
362:	elZ » 13
363:	TitleS = "POLLUTANT ,SELECTION,Choose Up To 6"
364:	FOR iZ = 1 TO 11
365:	TextS = Text$ + PolName(iZ) +
366:	NEXT
367:	Text$ = Text$ + ",Quit "
368:	SETCOL 30
369:	GETROW TitleS, TextS,
370:	TOGGLEBOT
371:	PUTROW
372:	DO
373:	t$ -
B- 77

-------
Program Documentation	Version 2.0	IAQPC
374s	FOR jl = 1 TO 11
375:	Psel$ = CHR$(255)
376;	IF TSTBIT(In, jZ) THEN Psel$ - "x"
377:	t$ = COMPOSEVAL(t$, Psel$)
378:	NEXT jZ
379:	GETVAL t$
380:	MCOLOR 3, 0
381:	PUTVAL
382:	TOGGLEMEN ipZ, plus!
383:	IF ipZ - 0 OR ipZ - elZ THEN EXIT DO
384:	IF CNTBITS(In) < 6 THEN
385:	XOR1ITOF In, ipZ
386:	ELSE
387:	IF TSTBIT(In, ipZ) THEN CLRBITOF In, ipZ ELSE MaxOf 6
388:	END IF
389:	LOOP
390:	SETCOL MIDSCRN
391:	END SUB
392:
393:	SUB SetCleanerPerf
394:	STATIC ipZ
395 s	DIM wp AS SCRNFAR
396:	Title? = "Efficiency, Levels"
397:	FOR iZ = 1 TO 9
398:	Text$ - Text$ + ClName(iZ)
399:	IF TSTBIT(cn, iZ) THEN Text$ - Text$ + " x"
400:	Text$ * Text$ +
401:	NEXT
402:	Text$ = Text$ + ".Quit to prior menu "
403:	DO
404:	CLW 1
405:	OPMEN Title$, Text$, StdBot$, ipZ, Key$
406:	IF Key$ « CHR$(27) OR ipZ « 11 THEN EXIT DO
407:	IF KeyS - CHR$(13) THEN
408:	SAVEPAR 1, wp
409:	BarCatch ipZ + 7, MIDSCRN, 4
410:	AirClean ipZ
411:	SETLEVEL 3
412:	SlipCatch wp
413:	END IF
414:	LOOP
415:	END SUB
416:
417:	SUB SinkStr (nsnkZ, swZ)
418: STATIC ipZ
419:	IF swZ - 0 THEN
420:	Title$ - "Type" + STR$(nsnkZ) + " Efficiency,In 0.1 Hour (Z5"
421:	PolSetUpB Text$, t$, Sink(), nsnkZ, -1
422: ELSEIF swZ - 1 THEN
423:	TitleS = "Type" + STR$(nsnkZ) + " Rate,In 0.1 Hour (Z)"
424:	PolSetUpB Text$, t$, SinkTc(), nsnkZ, 0
425:	END IF
426:	VALUEMENU 22, Title$, Text$, t$
427:	FOR iZ = 1 TO 11
B-78

-------
Program Documentation	Version 2.0	IAQPC
428:	IF swZ = 0 THEN Sink(nsnkZ, iZ) = 11 - VAL(DECOMPOSEVAL$(t$))
/ 1001
429:	IF swZ - 1 THEN SinkTc(nsnkZ, iZ) - VAL(DECOMPOSEVAL$(t$)) /
100
430: NEXT
431: END SUB
432:
433: SUB SrcStr (nsrZ)
434: Title$ <¦> "Each " + GenSource(nsrZ) + ", Produces*
435: Title$ = TitleS + ",In 0.1 Hour"
436: PolSetUpB Text$, t$, GenericSrc(), nsrZ, 0
437: VALUEHENU 20, Title$, Teit$, t$
438: FOR iZ » 1 TO 11
439:	GenericSrc(nsrZ, il) = VAL(DECOMPOSEVAL$(t$))
440: NEXT iZ
441: END SUB
B-79

-------
Program Documentation
\ind\balance.asc
Version 2.0
IAQPC
1:	•$INCLUDE: '\qb4\level0.pub'
2:	1 $INCLUDE: '\qb4\level1.pub'
3	s	"$INCLUDE : ' \qb4\windowp.pub'
4	¦	'$INCLUDE: »\qb4\level2.pub'
5:	'$INCLUDE: '\qb4\menup.pub *
6:	'$INCLUDE: 'iaqsubp.pub'
7:	*$INCLUDE: 'iaqcommn.pub'
8:
9:	DECLARE FUNCTION ArrayTotal (rnZ. IC())
10s	DECLARE FUNCTION HallPressureAvg (}
Us	DECLARE FUNCTION IntegralFlow (swl, x)
12;	DECLARE FUNCTION Press 1 (il)
13:	DECLARE FUNCTION PressureAvg (iZ)
14:	DECLARE FUNCTION SQRP (xl)
15:	DECLARE FUNCTION TotalArea! (swZ, ICI())
16:
17i	DECLARE SUB Balance (}
18:	DECLARE SUB Balancelnit ()
19:	DECLARE SUB DisplayBalance (x(), Tol)
20:	DECLARE SUB HallFlows ()
21:	DECLARE SUB RoomFlows ()
22:
23:	'$DYNAMIC
24:
25:	DIM SHARED TotalRoomFlow(l)
26:	DIM SHARED a AS STRING * 41
27:
28:	REM $STATIC
29:	FUNCTION ArrayTotal (rnZ, IC())
30:	FOR iZ » 1 TO 6
31:	ta » ta + IC(rtiZ, iZ)
32:	NEXT
33:	ArrayTotal = ta
34:	END FUNCTION
35:
36:	SUB Balance
37:	Tol - .005 * VolFlow / NrZ
38:	wr * .02
39:	wh - wr / (2 * NrZ)
40:	IF SdZ - 0 THEN CENTXT MIDLINE, "Balancing..."
41:	FOR jZ = 1 TO 1000
42:	RoomFlows
43;	IF FpZ > 2 THEN
44:	HallFlows
45:	z « TotalRoomFlow(O)
46:	y » IntegralFlow(-1, z)
47:	RaiPressure(O) = HallPressureAvg
48:	RmPressure(0) = RmPressure<0) - wh * (z - 2 * y)
49:	END IF
50:	FOR iZ - 1 TO NrZ
51:	'x - TotalRoomFlow(iZ) + .5 * AvgTF
52:	RmPressure(iZ) « PressureAvg(iZ)
B-80

-------
Program Documentation	Version 2.0	IAQPC
53;	NEXT
54:
55t	IF FpZ > 2 THEN lmZ = 0 ELSE lmZ = 1
56i	HVFlow = 0
57s	RetFlow = 0
58s	FOR il = lmZ TO NrZ
59s	HVFlow = HVFlow + EmFlow(iZ, 1)
60s	RetFlow = RetFlow - RmFlow(iI, 6)
61s	NEXT
62 s
63s	RetPr = RetPr - wr A FlowExp * ((1 - MakeUpAir) * VolFlow -
RetFlow)
64;	HVPr ¦ HVPr + wr * FlowExp * (VolFlow - HVFlow)
65;
66:	IF SdZ > 0 THEN DisplayBalance TotalRoomFlow(), Tol
67;	IF MaxVector(0, NrZ, TotalRoomFlow(), Tol) THEN BalancedZ «
TRUE; GOTO FinishedBsl
68:	IF IMKEYS = CHR$(27) THEN EXIT FOR
69s	NEXT
70;	BalancedZ = FALSE
71:
72;	FinishedBal;
73;	Dp ® (HVPr - RetPr)
74;	HVP = FailDP * HVPr / Dp
75;	RetP = FanDP * RetPr / Dp
76;	END SUB
77;
78:	SUB Balancelnit
79:	REDIM TotalRoomFlow(0 TO NrZ)
80:	z = IntegralFlow(0, 0)
81;	RmPr = (HakeUpAir * VolFlow / TotalArea(2, InterConO)) "
FlowExp
82:	RetPr = RmPr - ((1 - MakeUpAir) * VolFlow / TotalArea(6,
InterConO)) " FlowExp
83;	HVPr = RmPr + (VolFlow / TotalArea(1, InterConO)) " FlowExp
84;	FOR iZ = 0 TO NrZ
85:	RmPressure(iZ) = RmPr
86:	NEXT
87s	END SUB
88 s
89s	SUB DisplayBalance (x(), Tol)
90;	STATIC itZ
91s	IF FpZ > 2 THEN hZ = 0 ELSE hZ = 1
92:	Ltol = Tol
93;	FOR iZ - hZ TO NrZ
94:	z ¦ ABS(x(iZ))
95:	IF z » Ltol * 10 THEN
96:	Ltol = z / 10
97s	IF iZ <> itZ THEN FRNT itZ + 2, 58, "
98s	itZ = iZ
99s	END IF
100;	NEXT
101:	IF Ltol > Tol THEN
102:	MCOLOR 2, 0
B-81

-------
Program Documentation	Version 2.0	IAQPC
103s	CENTXT 1, "Rough Balancing"
104!	PRNT 1, 60, *cfm"
105:	ELSE
106:	MCOLOR 1, 0
107:	CENTXT 1, " Fine Balancing"
108:	PRNT 1, 60, " "
109:	END IF
110:	FRNTF itZ + 2, 58, (Ltol * 10), "####.##"
Ill;	a - "|(" + SPACES (17) + *1 I* + SPACES (17) + " |("
112!	FOE iZ - hi TO NrZ
113:	xZ - IMIN(41, IMAXfa., CINT(21 + (2 * x(iZ) / Ltol))))
114s	t$ - MID$(a, xZ, 1)
115!	MID$(a, *Z, 1) - *~"
116:	PRUT iZ + 2, 16, a
117:	PRNTF iZ + 2, 10, (iZ), "##"
118!	MID$(a, xl, 1) - t$
119s	NEXT
120:	END SUB
121:
122:	SUB HallFlows
123:	RmFlow(0, 1) = SQRPCHVPr - SmPressure(0)) * lnterCon(0, 1)
124:	RmFlow(0, 2) = SQRP(0! - RmPressure(O)) * InterCon(0, 2)
125:	RmFlow(0, 3) = 0
126:	RmFlow(0, 4) * 0
127:	FOR iZ * 1 TO NrZ
128:	ta = ta + RmFlcw(iZ, 5)
129:	NEXT
130:	RaFlow(0, 5) - -ta
131:	RmFlow(0, 6) - SQRP(RetPr - RmPressure(O)) * InterCon(0, 6)
132:	TotalRoomFlow(O) - ArrayTotal(0, RmFlowO)
133:	END SUB
134:
135:	FUNCTION HallPressureAvg
136s	IF FlowExp » 1 THEN mZ = 1 ELSE mZ » 4
137:	Pr - RmPressure(0)
138:	FOR kZ ¦ 1 TO mZ
139:	z =» InterCon(0, 1)
140s	xp = xp + SQRP(HVPr - Pr) * z
141:	xa = xa + z
142 ,*
143:	z - InterCon(0, 2)
144s	xp = xp + SQRP(0 - Pr) * z
145:	xa = xa + z
146:
147:	FOR iZ = 1 TO NrZ
148:	z - InterCon(iZ, 5)
149:	xp - xp + SQRP(!mPressure(iZ) - Pr) * z
150:	xa * xa + z
151:	NEXT
152:
153:	z = InterCon{0, 6)
154:	xp = xp + SQRPCRetPr - Pr) * z
155:	xa = xa + z
156:
B-82

-------
Program Documentation	Version 2.0	IAQPC
157s	IF xa <> 01 THEN Pr = Pr + xp / xa ELSE Pr = Pr + 0
158:	xp ¦ 0
159:	xa = 0
160:	NEXT
161:	HallPressureAvg = Pr
162:	END FUNCTION
163 s
164:	FUNCTION IntegralFlow (swZ, x) STATIC
165s	IF swZ THEN
166:	t = t + X
167:	ELSE
168:	t ¦ 0
169:	END IF
1.70:	IntegralFlow = t
171:	END FUNCTION
172:
173:	FUNCTION Press (iZ)
174:	IF HVPr <> 0 THEN Press = RmPressure(iZ) * HVP / HVFr ELSE
Press = 0
175s	END FUNCTION
176:
177i	FUNCTION PressureAvg (iZ)
178:	IF FpZ <> 6 THIN
179:	IF iZ = NrZ THEN kpZ - 1 ELSE kpZ - iZ + 1
180:	IF iZ ¦ 1 THEN kmZ » NrZ ELSE kmZ - iZ - 1
181t	ELSE
182:	IF iZ - NrZ - 1 THEN kpZ = 1 ELSE kpZ = iZ + 1
183:	IF iZ - 1 THEN kmZ - NrZ - 1 ELSE km! - iZ - 1
184:	END IF
185:	IF FlowExp = 1 THEN mZ = 1 ELSE aZ » 4
186:	Pr ¦ RmPressure(iZ)
187:	FOR kZ - 1 TO mZ
188:	z = InterCon(iZ, 1)
189:	xp = xp + SQRP(HVPr - Pr) * z
190:	xa = xa + z
191:
192:	z - InterCon(iZ, 2)
193:	xp » xp + SQRP(0 - Pr) * z
194:	xa = xa + z
195:
196:	IF NOT (
-------
Program Documentation	Version 2,0	IAQPC
210:	z - InterCon(iZ, 6)
211:	xp = xp + SQRP(Ret?r - Pr) * z
212:	xa - xa + z
213:
214:	IF xa <> 0! THEN Fr - Pr + xp / xa ELSE Pr = Pr + 0
215:	xp ¦ 0
216:	xa - 0
217;	NEXT
218:	PressureAvg = Pr
219:	END FUNCTION
220:
221:	SUB RoomFlows
222:	FOR 12 = 1 TO NrZ
223:	RmFlow(iZ, 1) = SQRPCHVPr - RmPressure(iZ)) * InterCon(iI, 1)
224:	RmFlow(iZ, 2) = SQRP(0I - RmPressure
-------
Program
Is
2:
3s
4!
5!
6:
7:
8;
9:
10:
Hi
12s
13 8
14:
15?
16 ;
17;
18 s
191
20 s
21:
22s
23s
24 s
25;
26:
27:
28:
29s
30s
31s
32 s
33s
34 s
35;
36:
37;
38;
39;
40;
41:
42:
43;
44;
45:
46;
47:
48:
49;
50;
51;
Documenta tion
\ind\calc.asc
Version 2.0
IAQPC
*	SINCLTOE
*	$INCLUDE
*	$INCLUDE
'$INCLUDE
•$INCLUDE
'$INCLUDE
•$INCLUDE
'\qb4\level0.pub'
*\qb4\levell.pub *
'\qb4\vindowp.pub'
*\qb4\level2.pub'
1\qb4\menup.pub'
* iaqsubp.pub"
' iaqconum. pub *
DECLARE FUNCTION AvgConcVal1 (kl)
DECLARE FUNCTION ConcVal! (kZf rnZ)
DECLARE FUNCTION CycleOnZ (tl, rnZ)
DECLARE FUNCTION LimConc! (kZ)
DECLARE FUNCTION VentFlowl (t!)
DECLARE SUB CalcConc (TOJ, Tff)
DECLARE SUB Calclnit ()
DECLARE SUB CalcFolAvglnit ()
DECLARE SUB CalcRmTotSk 
DECLARE SUB DrawAverages (iZ)
DECLARE SUB Gaxis ()
DECLARE SUB GraphAverageClose ()
DECLARE SUB GraphAveragelnit ()
DECLARE SUB Grph (kZ, t)
DECLARE SUB Grphlnit (t)
DECLARE SUB GrphShift ()
DECLARE SUB HVACcalc ()
DECLARE SUB HallCalc ()
DECLARE SUB MasterCalcInit ()
DECLARE SUB OutConc {)
DECLARE SUB PrntConc C)
DECLARE SUB PrtProcess ()
DECLARE SUB RoomCalc ()
COMMON SHARED	/indcalc/ NrlZ, npolZ, tm, prt, v, intt, hZ, wdZ,
yoZ
COMMON SHARED	/indcalc/ xoZ, cntZ, RmcyclesSr, rt, dt, lastt
COMMON SHARED	/indcalc/ runinit AS INTEGER
'$DYNAMIC
DIM SHARED c(l, 1), vf(1, 1), tc(l), Amb(l), qin(l)
DIM SHARED hvfrac(1), sr(l, 1), sk(l, 1), t(1), TavgConc(6)
DIM SHARED pload(l, 1), cycper(l), oZ(l), skptr(l, 1) AS INTEGER
•reserve the variables here; REDIM them in Calclnit
REM $STATIC
FUNCTION AvgConcVal (kZ)
AvgConcVal = TavgConc(kZ)
B-85

-------
Program Documentation	Version 2.0	IAQPC
52:	END FUNCTION
53 s
54s	SUB CalcConc (TO, ff)
55;	dt = StepTime
56:	rt = dt / .1
57:
58:	*c is cone in room at last time step
59:	'cycle through the calculations until the next stopping time
is reached
60s
61:	tin » TO
62:	DO WHILE tm <= Tf
63:	' set sources on for each room according to their schedules
64;	FOR iZ = 0 TO NrlZ
65:	oZ(iZ) - CycleOn(tm, iZ)
661	NEXT
67:
68:	' determine the HVAC normal or minimum flow
69:	v = VentFlow(tm)
70s
71s	'get the hv concentration first and average it as
representative
72:	'of the building as a whole
73 s
74:	HVACcalc
75:
77:	'get the hall concentration by summing all the room
78:	'contributions. zi is the hall response factor.
79:	'		:					—		
80s
81:	IF FpZ > 2 THEN HallCalc
82:
83s	»	..	—		—		
84s	'get the room concentrations; for each room, go through all
the
85:	'pollutants
86s	'				 	 	 				___		
87s
88:	RoomCalc
89:
90:	"	—									
91:	* check for printing, graphing, or interruptions
92:	*	—					—				
93:
94s	tm » tm + dt
95:	CheckTime x$
96:	IF IMKEYS » CHR$(27) OR x$ = CHR$(27) THEN EXIT DO
97:	LOOP
98:	Tf = tm
B-86

-------
Program Documentation Version 2.0

99:
END SUB

100!


101
SUB CalcFirstlnit

102
npolZ ¦ CNTBITS(in)

103
NrlZ = NrZ + 1

104


105
'this dimension the arrays as soon as the program is entered
106


10?
REDIM vf (0 TO NrZ, 1 TO 6)

108
REDIM tc(0 TO NrZ)

109
REDIM oZ(0 TO NrlZ)

110:
REDIM qin(0 TO NrlZ), hvfrac(0 TO NrZ)

111;
REDIM c(l TO npolZ, 0 TO NrlZ)

112;
REDIM sr(l TO npolZ, 0 TO NrlZ)

113
REDIM sk(l TO npolZ, 0 TO NrlZ)

114
REDIM skptrd TO npolZ, 0 TO NrlZ) AS INTEGER

115
REDIM pload(l TO npolZ, 0 TO NrlZ)

116
REDIM Amb(l TO npolZ)

117
REDIM tCl TO npolZ), TavgConc(l TO npolZ)

118
REDIM cycperd TO 8)

119
END SUB

120


121
SUB Calclnit

122
npolZ « CNTBITS(in)

123
NrlZ - NrZ + 1

124
prt - 0

125
intt = 0

126


127
'tc() is the room time constant in hours

128
'qin() is the total flow into a room, used for
constant (cfm)
the decay
129


130
IF UB0UND(vf, 1) <> NrZ THEN

131
REDIM vf(0 TO NrZ, 1 TO 6)

132
REDIM tc(0 TO NrZ)

133
REDIM oZ(0 TO NrlZ)

134
END IF

135
IF UBOUND{c, 1) <> npolZ OR UB0UND(c, 2) <> NrlZ
THEN
136
REDIM c(l TO npolZ, 0 TO NrlZ)

137
REDIM sr(1 TO npolZ, 0 TO NrlZ)

138
REDIM sk(l TO npolZ, 0 TO NrlZ)

139
REDIM skptr(1 TO npolZ, 0 TO NrlZ) AS INTEGER

140
REDIM pload(l TO npolZ, 0 TO NrlZ)

141
REDIM Amb(1 TO npolZ)

142
REDIM t(l TO npolZ). TavgConc(l TO npolZ)

143
END IF

144
REDIM qin(0 TO NrlZ), hvfrac(0 TO NrZ)

145
REDIM cycperd TO 8)

146


147
initialized - TRUE

148


149
FOR iZ - 0 TO NrZ

150
FOR jZ = 1 TO 5

151
z = RmFlow(iZ, jZ)

1-87

-------
Program Documentation	Version 2.0	IAQPC
152:	IF x > 0 THEN
153:	qin(it) = qin(iZ) + x
154:	END IF
155i	NEXT
156:	tc(iZ) - qin(iZ) * 60 / Vol(iZ)
157 s	FOR jZ - 1 TO 5
158:	IF qin(iZ) <> 0 THIN
159:	vf(iZ, jZ) = RmFlow(iZ, jZ) / qin(iZ)
160s	ELSEIF FpZ>2 THEN
161;	SELECTW 0
162:	FEINT "Warnings no flow into room *; iZ;
163;	DELAY 50
164;	CIM 0
165 s	SELECTW 1
166:	END IF
167:	NEXT
168:	qhv - qhv - RmFlow(iZ, 6)
169:	NEXT
170:	vf(0, 5) = -vf(0, 5)
171:	FOE iZ = 0 TO NrZ
172s	hvfrac(iZ) = -RmFlowJiZ, 6) / qhv
173:	NEXT
174:	ERASE qin
175:	FOE iZ - 1 TO 4
176:	cycper(iZ) - ABS(Cycles(iZ)) / 60
177:	NEXT
178:	FOR iZ - 5 TO i
179:	cycper(iZ) = ABS(Cycles(iZ))
180:	NEXT
181s	END SUB
182:
183:	SUB CalcPolAvglnit
184:	mZ = 1
185:	FOR kZ - 1 TO npolZ
186:	TavgConc(kZ) - c(kZ, NrlZ)
187:	FOR jZ = mZ TO 11
188:	IF TSTBITtin, jZ) THEN
189:	IF PavgT(jZ) < .1 THEN x * .1 ELSE x » PavgT(jZ)
190:	mZ = jZ + 1
191:	EXIT FOR
192:	END IF
193:	NEXT
194:	t(kZ) = x / 2.94
195:	NEXT
196:	END SUB
197 s
198:	SUB CalcRmTotSk (jZ, kZ)
199:	FOR iZ = 0 TO NrlZ
200:	sk(jZ, iZ) = 1
201:	FOR IZ = 1 TO 4:"passive sinks
202:	IF TSTBIT(RmSk(IZ), iZ) THEN
203:	sk (j Z, iZ) *» sk(jZ, iZ) * S ink (1Z, kZ)
204:	skptrfjZ, iZ) = 256 * kZ + IZ
205:	END IF
B-88

-------
Program Documentation	Version 2.0	IAQPC
206i	NEXT
207;	FOR 12 = 1 TO 2;'cleaners
208s	IF TSTBIT(RmCn(lZ), iZ) THEN
209s	IF iZ < NrlZ THEN
210:	FOR mZ - 1 TO 5
211:	IF TSTBIT(Cn, mZ) THEN
212:	sk(j Z, iZ) - sk(jZ, iZ) * ClEff{mZ, kZ)
213:	END IF
214i	NEXT
215 s	ELSE
216s	FOR iZ - 6 TO 9
217:	IF TSTBIT(Cn, mZ) THEN
218:	sk(jZ, iZ) - sk(jZ, iZ) * ClEff(mZ, kZ)
219:	END IF
220:	NEXT
221:	END IF
222:	END IF
223:	NEXT
224: NEXT
225 s END SUB
226:
227: SUB CalcRmTotSrc (jZ, kZ)
228: FOR iZ = 0 TO NrlZ
229:	sr(jZ, iZ) = 0
230:	FOR IZ = 1 TO 8:»generics
231:	IF TSTBIT(RmSr(IZ), iZ) THEN
232s	sr(JZ, IZ) = srCjZ, iZ) + GenericSrc(IZ, kZ) * 101
233f	END IF
234:	NEXT
235:	srCjZ, iZ) ¦ sr(jZ» iZ) / (Vol(iZ) * .02837)
236: NEXT
237: END SUB
238:
239: SUB CheckTime (x$)
240: x$ = ""
241: prt = prt + dt
242: intt = intt + dt
243: IF prt >= PrntTime THEN PrtProcess
244: IF IntrptAt > 0 AND intt >« IntrptAt THEN
245i	intt = intt - IntrptAt
246:	x$ - PAUSESTR(0, "Interrupted at" + STR$(INT{tm)))
247:	CLL HVIN, 0, 0
248: END IF
249: END SUB
250:
251: SUB ConeInit (icZ)
252:	*c() is the concentration in each room, with c(NrZ+l) being
253:	'the concentration is the HVAC system
254:	'if icZ=Q then only the sources/sinks are set up, not the
concentrations
255:	"Rmcyclesli has a bit set for a room if any cyclic behavior is
in the
256:	'room; otherwise, the room sources, etc., will be considered
on all the
B-89

-------
Frogram
257;
258
259
260
Documentation
* time.
Version 2.0
IAQPC
279;
280:
281;
282:
283:
284:
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
IF NOT (initialized) THEN EXIT SOT
261:
j Z = 1


262:
FOE kZ ¦ 1 TO 11


263:
IF TSTBIT(in, kZ) THEN


264:
Amb(jZ) = AmbientConc(kZ)

265 s
CaicRmTotSrc jZ, kZ


266:
CalcRmTotSk jZ, kZ


267:
jZ - jZ + 1


268:
END IF


269:
NEXT


270:
Imcyclesi = 0


271:
FOR kZ - 1 TO npolZ


272:
FOR iZ » 0 TO NrZ


273:
IF icZ ¦ 1 THEN c(kZ,
iZ)
= 0
274:
IF icZ = 2 THEN c(kZ,
iZ)
¦ Amb(kZ)
275:
IF icZ = 3 THEN c(kZ,
iZ)
- c(kZ, NrlZ)
276:
IF icZ = 4 THEN c(kZ,
iZ)
¦ sr(kZ, iZ) * sk(kZ, iZ)
277:
FOR jZ - 1 TO 8


278;
IF TSTBIT(RmCy(j Z),
iZ)
THEN SETBITOF Rmcyclesi, iZ:
EXIT
FOR
NEXT
NEXT
IF icZ i
IF icZ «
IF icZ =
,02837)
. 1 THIN c(kZ, NrZ	+ 1)
: 2 THEN c(kZ, NrZ	+ 1)
¦ 4 THEN c(kZ, NrZ	+ 1)
* 8k{kZ, NrlZ)
= 0
• Amb(kZ)
= sr(kZ, NrlZ)
/ (VolFlow * 6 *
NEXT
END SUB
FUNCTION ConcVal (kZ, rnZ)
ConcVal = c(kX, rnZ)
END FUNCTION
FUNCTION CycleOnZ (t, rnZ)
•first, check to see whether cyclic behavior is present.
IF TSTBIT(RmcyclesSt, rnZ) THEN
CyZ =» 0
"second, check whether aligntime has been passed
IF AlignTime >= 0 THEN teff = RMOD(t, 24) ELSE teff - t
IF teff >= ABS(AlignTime) THEN
'third, determine whether cycle is in on or off state
CyZ - 1
teff ¦ teff - ABS(AlignTime)
FOE iZ = 1 TO 4
IF TSTBIT(RmCy(iZ), rnZ) THEN
j m 2 * cycper(iZ)
IF RM0D(teff, j) >= cycper(iZ) AND Cycles(iZ) > 0 THEN
CyZ ¦ 0
B-90

-------
Program Documentation	Version 2.0	IAQPC
309i	EXIT FOR
310:	ELSEIF RM0D(teff, j) < ABS(cycper(iZ)) AND Cycles(iZ) <
0 THEN
311¦	CyZ - 0
312j	EXIT FOR
313:	END IF
314s	END IF
315:	NEXT
316:	IF CyZ = 1 THEN
317:	FOE iZ = 5 TO 8
318;	IF TSTBIT(lmCy(if3» rn2) THEN
319:	j - 2 * cycper(iX)
320:	IF RMODfteff, j) >- cycper(iZ) AND Cycles(iZ) > 0 THIN
321:	CyZ = 0
322:	EXIT FOR
323:	ELSEIF RMOD(teff. j) < ABS(cycper(iZ)) AND Cycles(iZ)
< 0 THEN
324;	CyZ = 0
325:	EXIT FOR
326;	END IF
327;	END IF
328:	NEXT
329:	END IF
330s	END IF
331: ELSE
332:	CyZ = 1
333: END IF
334: CycleOn = CyZ
335: END FUNCTION
336:
337: SUB Gaxis
338: IF tin < 48 THEN
339:	PRNT yoZ, xoZ, *-f"
340:	PRNT yoZ, xoZ + 1, REPEATS(" wdZ \ 4 - 1) + " -p
341:	PRNT yoZ. POSV, REPEATS(" vdZ \ 4 - 1) + " + "
342: END IF
343: FOR iZ = 1 TO hZ
344:	PRNT iZ + yoZ, xoZ, CHR$<179>
345: NEXT
346: PRNT hZ + yoZ, XOZ, CHR$<192}
347; PRNT hZ + yoZ, POSW, STRINGS(wdZ, 196}
348: END SUB
349:
350; SUB Grph (kZ, t)
351: MCOLOR kZ + 1, -1
352: fac = LixnConc(kZ)
353: IF SdrZ = NrZ + 1 THIN
354;	d = AvgConcVal(kZ) / fac * 2 * hZ
355: ELSE
356:	d = ConcVal(kZ, SdrZ) / fac * 2 * hZ
357: END IF
358: jZ = 2 * (yoZ + hZ - 1)
359: jZ - IMAX(2 * yoZ, jZ - d)
360: iZ - IMIN(xoZ + t, xoZ + wdZ)
B-91

-------
Program Documentation	Version 2.0	IAQPC
361:	SETPOINT jZ, iZ
362:	MCOLOR 15, -1
363:	END SUB
364:
365:	SUB Grphlnit (t)
366:	cntZ - INT(RMOD(t, 241))
367i	SdrZ - IMIN(SdrZ, NrZ + 1)
368:	COLOR MPAL(15)
369:	IF SdrZ = 0 THEN
370:	r$ - "Hall"
371:	ELSEIF SdrZ > NrZ THEN
372:	r$ = "HVAC System"
373:	ELSE
374:	r$ - "Room" + STRS(SdrZ)
375:	END IF
376:	r$ - "Concentrations vs Time in " + r$ + " at "
377:	CENTXT 1, r$
378:	yoZ = 3
379:	xoZ = 8
380:	hZ = 20
381:	wdZ = 48
382:	Gaxis
383:	PRNT yoZ + hZ + 1, 28, "Time (48 hr)"
384:	PRNT yoZ + hZ / 2, 1, "Cone"
385:	PRNT yoZ +¦ hZ / 2 + 1, 1, "Ratio"
386:	npolZ - CNTBITS(in)
387:	FOR kZ = 1 TO npolZ
388:	COLOR HPAL(fcZ + 1)
389:	SETPOINT 2 * (yoZ + kZ), xoZ + wdZ + 5
390:	COLOR MPAL(15)
391:	PRNT yoZ + kZ, xoZ + wdZ + 7, STR$(kZ)
392:	NEXT
393:	END SUB
394:
395:	SUB GrphShift
396:	cntZ - cntZ + 1
397:	IF (cntZ MOD 2) = 0 THEN PRNT yoZ, xoZ + wdZ + 1,
398:	IF (cntZ MOD 24) = 0 THEN PRNT yoZ, xoZ + wdZ +1, "+"
399:	REDIM BsZ(2 * hZ * (wdZ + 2))
400:	SAVESCREEN yoZ - 1, xoZ + 1, yoZ + hZ - 2, xoZ + wdZ + 2, BsZ(3
401:	RESTORESCREEN yoZ - 1, xoZ, BsZ()
402:	END SUB
403:
404:	SUB HallCale
405:	z - tc(0) * v
406:	zi «= EXP(-z * dt)
407:	FOR kZ = I TO npolZ
408:	Ac = 0
409:	Ac - Ac + c(kZ, NrlZ) * vf(0, 1)
410:	IF vf(0, 2) > 0 THEN
411:	Ac - AC + Amb(kZ) * vf(0, 2)
412:	END IF
413:	x - 0
414:	FOR iZ = 1 TO NrZ
8-92

-------
Program Documentation	Version 2.0	IAQPC
415:	IF vf(il, 5) < 0 THEN
416:	x = x - c(kZ, iZ) * EmFlovCiX, 5) / RmFlow(0, 5)
417:	END IF
418:	NEXT
419:	Ac = Ac + x
420:	Ac - (Ac * z + oZ(0) * sr(kZ, 0)) / z
421:
422:	eta - 101 * (1 - sk(kZ, 0))
423:	Ac»Ac*z/(z+ eta)
424:
425:	Ac = Ac + (c(kX, 0) - Ac) * zi ~ ((z + eta) / z)
426:
427:	klZ = skptr(kZ, 0)
428s	IF klZ <> 0 THIN
429:	1Z - klZ \ 256
430:	jZ - klZ AND 255
431:	cr - 1 - Sink(jZ, 1Z) ~ rt
432:	Id = pload(kZ, 0) + Ac * cr
433s	emr - SinkTc(jZ, 1Z)
434s	IF rt > 1 THEN emr = emr * (1 - emr ~ rt) / (1 - emr)
435s	Ac ¦ (Ac * z + Id * emr) / z
436s	pload(kZ, 0) = Id * (1 - emr)
437s	END IF
438s	c(kZ, 0) = Ac
439:	NEXT
440:	END SUB
441.-
442:	SUB HVACcalc
443:	FOR kZ - 1 TO npolZ
444:	x = 0
445:	FOR iZ « 0 TO NrZ
446:	x « x + c(kZ, iZ) * hvfrac(iZ)
447:	NEXT
448:
449s		—			-	-	-	
450:	» this is at the HVAC return
451:	* now mix in the ambient air and HVAC sources/filters
452:	»-	— —	-	——		
453:
454:	x = x + oZ(NrlZ) * sr(kZ, NrlZ)
455:	x = x * sk(kZ, NrlZ)
456:	TavgConc(kZ) = (TavgConc(kZ) * (t(kZ) - dt) + x * dt) / t(kZ)
457i	IF MakeUpAir > 0 THEN
458:	c(kZ, NrlZ) » (1 - MakeUpAir) * x + MakeUpAir * Amb(kZ)
459:	ELSE
460:	C(kZ, NrlZ) = x
461:	END IF
462:	NEXT
463:	END SUB
464:
465:	FUNCTION LimConc (kZ)
466:	mZ = 0
467:	FOR jZ = 1 TO 11
468:	IF TSTBIT(in, j Z) THEN
B-93

-------
Program Documentation	Version 2.0	IAQPC
469:	mZ « ml + 1
470:	IF mZ = kZ THIN EXIT FOE
471 *	END IF
472s	NEXT
473s	IF jZ < 12 THEN LimConc - Plim(jZ) ELSE LimConc - -1
474:	END FUNCTION
475s
476:	SUB MasterCalcInit
477s	IF IBM < 2 THIN CENTXT MIDSCRW, "Calculating..."
478s	tm « 0
479:	Calclnit
480s	Conclnit ConcInitType
481s	CalcPolAvglnit
482:	lastt ¦ 47
483:	IF FsdZ THEN
484:	CLOSE OutchZ
485:	f$ ¦ Dpath$ + MasterFile$ + ".tmp"
436:	IF EXISTFILE(fS) THEN KILL f$
487:	OutchZ = FREEFILE
488:	OPEN f$ FOR UNARY AS /OutchZ
489:	PUT /OutchZ, , NrZ
490:	PUT /OutchZ, , npolZ
491:	OutConc
492s	CLOSE /OutchZ
493:	END IF
494:	runinit = TRUE
495:	END SUB
496:
497:	SUB MasterCalcRun (TO, Tf)
498••	IF NOT (runinit) THEN MasterCalcInit
499:	IF FsdZ THEN
500:	f$ - Dpath$ + MasterFile$ + ".tmp"
501:	OutchZ = FREEFILE
502:	OPEN f$ FOR BINARY AS #OutchZ
503:	SEEK OutchZ, LOF(OutchZ) + 1
504:	END IF
505:	IF SdZ = 0 THEN CENTXT MIDLINE, "Calculating ... "
506:	IF SdZ - 2 THEN Grphlnit TO
507:	IF SdZ = 3 THEN GraphAveragelnit
508:
509:	REM set up source/sinks/cleaners/cycles each time without
510:	REM changing the concentrations
511:
512:	Conclnit 0
513:	CalcConc TO, Tf
514:
515:	IF SdZ = 3 THEN GraphAverageClose
516:	IF FsdZ THEN CLOSE /OutchZ
517:	END SUB
518:
519:	SUB OutConc
520:	PUT /OutchZ, , tm
521:	FOR iZ = 0 TO NrlZ
522:	FOR kZ ¦ 1 TO npolZ
B-94

-------
Program Documentation	Version 2.0	IAQPC
523:	PUT #OutchZ, , c(kZ, iZ)
524:	NEXT
525:	NEXT
526:	FOR kZ = 1 TO npolZ
527:	PUT lOutchZ, , TavgConc(kZ)
528:	NEXT
529:	END SUB
530;
531:	SUB PrntConc
532:	fl$ = «##,##*>—•
533:	f2$ = "ttt.it* *
534:	PRNT 1, 14, "Concentrations at time"
535:	P1NTF 1, POSV + 2, (tin), "###.#"
536:	IF v - 1 THEN a$ - "Normal Flow " ELSE a$ - "Minimum Flow"
537:	PRNT 1, POSW + 5, a$
538:	FOR iZ - 0 TO NrlZ
539:	FOR kZ - 1 TO npolZ
540:	IF iZ - 0 THEN PRNT iZ + 2, kZ * 10 + 4, STR$(kZ)
541:	PRNT iZ + 3, 1. STR$(iZ)
542:	x - c(kZ, iZ)
543i	IF * > 9,999 OR x < .003 THEN f$ - fl$ ELSE f$ = £2$
544:	PRNTF iZ + 3, kZ * 10, (x), f$
545:	NEXT
546:	NEXT
547:	PRNT NrlZ + 4, 1, "Avg:"
548:	FOR kZ = 1 TO npolZ
549:	x ¦ TavgConc(kZ)
550;	IF x > 9.999 OR x < .003 THEN f$ = fl$ ELSE f$ = f2$
551:	PRNTF NrlZ + 4, kZ * 10, (x), f$
552:	NEXT
553 s	END SUB
554:
555:	SUB PrtProcess
556:	prt = prt - PrntTime
557:	IF SdZ « 1 THEN
558:	PrntConc
559:	ELSEIF SdZ - 2 THEN
560:	FOR kZ = 1 TO npolZ
561:	Grph kZ, tm
562:	NEXT
563:	DO WHILE tm > lastt + 1
564:	GrphShift
565:	lastt = lastt + 1
566:	LOOP
567:	PRNT 1, xoZ + wdZ + 4, " ": PRINT USING "###.#" j tm;
560:	ELSEIF SdZ = 3 THEN
569:	PRNT 1, 55, "at"; PRINT USING - ###.#"; tm
570:	DrawAverages 0
571:	END IF
572;	IF FsdZ THEN OutConc
573:	END SUB
574:
575;	SUB RoomCalc
576:	FOR iZ = 1 TO NrZ
B-95

-------
Program Documentation	Version 2,0	IAQPC
577:	z = tcfiZ) * v
578s	zi = IXPC-z * dt)
579s	FOR kZ <® 1 TO npolZ
580 i	Ac - 0
581:	Ac - Ac + c(kZ, NrlZ) * vf(iZ, 1)
582:	IF vf(il, 2) > 0 THEN
583:	Ac * Ac + Amb(kZ) * vf(iZ, 2)
584:	END IF
585:	IF vf(iZ, 3) > 0 THEN
586:	IF iZ = NrZ THEN x - c(kZ, 1) ELSE x - c(kZ, iZ + 1)
587:	Ac - Ac + x * vf(iZ, 3)
588:	END IF
589:	IF vf(iZ, 4) > 0 THEN
590:	IF iZ = 1 THEN x = c(kZ, Nrl) ELSE x - c(kZ, if' - 1)
591:	Ac * Ac + X * vf(iZ, 4)
592:	END IF
593:	IF vf(iZ, 5) > 0 THEN
594:	Ac * Ac + c(kZ, 0) * vf(iZ, 5)
595:	END IF
596:
597:	* add room sources
598:	Ac = (Ac + z + of(iX) * sr(kZ» iZ)J / z
599:
600:
601:	' sink the results
602:	eta = 101 * {1 - sk(kZ, iZ))
603:	Ac = Ac * z / (z + eta)
604:
605:	Ac = Ac +  0 THEN
610:	IZ - klZ \ 256
611:	jZ = klZ AND 255
612:	cr - 1 - Sxnk(jZ, IZ) rt
613:	Id = pload(kZ, iZ) + Ac * cr
614:	emr ¦* SinkTc(jZ, IZ) * CI - emr " rt) / (1 - emr)
615:	Ac = (Ac * z + Id * emr) / z
616:	pload(kZ, iZ) = Id * (1 - emr)
617:	END IF
618:	c(kz, iZ) = Ac
619:	NEXT
620:	NEXT
621:	END SUB
622:
623:	FUNCTION VentFlow (t)
624:	IF Htimes(1) - 0 AND Htimes(2) - 24 THEN VentFlow - 1: EXIT
FUNCTION
625:	dlt - RMOD(t, 24)
626:	VentFlow ¦ MinFlow / VolFlow
627:	FOR iZ - 1 TO Htimes(0) STEP 2
628:	IF dlt > Htimes(iZ) AND dlt <= Htimes(iZ + 1) THEN
629:	VentFlow = 1
B- 96

-------
Program Documentation	Version 2.0	IAQPC
630:	EXIT FUNCTION
631:	END IF
632i NEXT
633: END FUNCTION
B-97

-------
Program Documentation.	Version 2,0
\ind\iaqmenus.asc
IAQPG
1:	'SINCLUDE
2:	*$INCLUDE
3s	'$INCLUDE
4•	»SINCLUDE
5:	'$INCLUDE
6:	*$INCLUDE
7:	•SINCLUDE
8s	'SINCLUDE
•\qb4\level0.pub'
•\qb4\levell.pub'
'\qb4\windowp.pub'
*\qb4\minicalp.pub'
*\qb4\level2.pub'
'\qb4\menup.pub'
"iaqsubp.pub"
'iaqcommn.pub *
9s
10: DECLARE FUNCTION DirectEntry$ ()
11: DECLARE FUNCTION RnChangeZ (kZ, ml, NrZ)
12:
13: DECLARE SUB AirClean (iZ)
14: DECLARE SUB BasicDesign ()
15: DECLARE SUB CalcConc (TO, Tf)
16: DECLARE SUB CalcConfig (}
17: DECLARE SUB Calclnit ()
18: DECLARE SUB Conclnit (icZ)
19: DECLARE SUB CalePolAvglnit ()
20: DECLARE SUB CleanerMenu ()
21: DECLARE SUB DisplayInDat ()
22: DECLARE SUB GraphMenu ()
23: DECLARE SUB EditMaster ()
24: DECLARE SUB EditNotes ()
25: DECLARE SUB FileShow {)
26: DECLARE SUB HVDescription ()
27: DECLARE SUB Iaqconfig ()
28s DECLARE SUB Inrm ()
29: DECLARE SUB LdBasicDesignFile ()
30: DECLARE SUB LdCleanerFile ()
31: DECLARE SUB LdHVACFile ()
32: DECLARE SUB LdltiRmFile C)
33: DECLARE SUB LdMasterFile ()
34: DECLARE SUB LdPolFile ()
35: DECLARE SUB LoadlaqConfig (GrZ, Dpath$, MasterFileSaveZ,
BeginMainMenuZ)
36: DECLARE SUB LoadMaster ()
37: DECLARE SUB MasterCalcInit ()
38: DECLARE SUB MasterCalcRun (TO, Tf)
39: DECLARE SUB OperatingMenu ()
40: DECLARE SUB OutRes O
41: DECLARE SUB PollutantMenu ()
42: DECLARE SUB SavelaqConfig (GrZ, DpathS, MfsZ, BMMZ, WrZ, BsZ,
NtbrZ, NtKeyZ)
43: DECLARE SUB SaveMaster ()
44: DECLARE SUB SvMasterFile ()
45:
46: CONST On$ = "OnO", Off$ = "Off *
47:
48: DIM SHARED namefileZ
49:
50: * SDYNAMIC
B-98

-------
Program
51:
52:
53:
54:
55;
56:
57 s
58:
59:
60s
61«
62:
63;
64:
65 s
66:
67s
681
69:
70;
71s
72:
73:
74s
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103:
Documentation	Version 2.0
DIM SHARED pn(l TO 11) AS STRING * 18
DIM SHARED cln(l TO 9) AS STRING * 24
DIM SHARED gn(l TO 8) AS STRING * 16
END
REM StpTme values for CalcConfig
DATA 0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0
ISM PrtTme values for CalcConfig
DATA 0.1,0.2,0.4,0.5,1.0,2.0,3.0,4.0,6.0,12.0
REM RnDur values for CalcConfig
DATA 1,2,3,4,5,6,7,14,21,28,31,42,62
REM SSTATIC
FUNCTION AirChanges (ml, Vol (), RmFlov())
FOR iZ = 1 TO 6
y = RmFlow(rnZ, iZ)
IF y > 0 THEN x = x + y
NEXT
AirChanges « x * 601 / Vol(rnZ)
END FUNCTION
SUB BarCatch (rowZ, colZ, levelZ)
REDIM tZ(2003
PRNTA rowZ, colZ, MPAL(l) * 16, 3
SAVESCREEN 0, colZ - 1, MAXLINES, colZ + 1, tZ()
RESTORESCREEN 0, 81 - 4 * (levelZ - 1), tZ()
COLOR 7, 0
cZ = 81 - 4 * (levelZ - 1)
FOR iZ = 1 TO MAXLINES
PRNT iZ, cZ, "|•
NEXT
IZ = levelZ
SETLEVEL IZ
DEFINEVTNDOV 1, 0, 0, MAXLINES, 79 - 4 * (levelZ - 1), MPAL(l),
MFAL(0)
SELECTV 1
SETCOL MIDSCRN
ERASE tZ
END SUB
SUB CalcConfig
REDIM StpTme(0 TO 9), PrtTme(0 TO 9), RnDur(0 TO 12)
RESTORE
FOR iZ = 0 TO 9
READ StpTme(iZ)
IF StepTime ¦ StpTme(iZ) THEN StptrZ = iZ
NEXT
FOR iZ - 0 TO 9
IAQPC
B-99

-------
Program Documentation	Version 2.0
104:	READ PrtTme(iZ)
10S:	IF PrntTime = PrtTme(iZ) THEN PrtptrZ - iZ
106:	NEXT
107:	FOR il = 0 TO 12
108:	READ RnDur(iZ)
109:	IF RunDuration - RnDur(iZ) THIN RnDuptrZ - iZ
110:	NEXT
111:	STATIC ipsZ
112:	IF PrntTime < StepTime THEN PrntTime = StepTime
113:	IF RunDuration < 1 THEN RunDuration = 1; RnDuptrZ = 0
114:	ell - 11
115:	srZ = 8
116:	set ® 30
117:
118:	IaqMenusO:
119:	TitleS ¦ "Runtime, Configuration, OPTIONS*
120:	Text$ - 'Time Calc Step (hr),Print Step Chr)"
121:	Text$ •= Text$ + ".Duration of Run (day)*
122:	Text$ ¦» Text$ + ".Interrupt every (hr)*
123:	Text$ ¦ Text$ + Calculation Displays"
124:	Text$ = TextS + ",Room Number for Plot"
125:	Text$ = Text$ + ".File Storage of Results"
126:	Text$ = TextS + ".Load Configuration"
127:	Text$ = TextS + ".Save Configuration"
128:	Text$ = TextS + "..Quit to Main Menu Q3"
129:	SETC0L SCZ
130:	GETROW Title$, Text$, "*
131:	TOGGLEBOT
132:	SETROW srZ
133:	DO
134:	PUTROV
135;	t$ » STR$(StepTime) + "." + STR$(PrntTime) +
136:	t$ = t$ + STR$(RunDuration) + + STR$(IntrptAt) +
137:	IF SdZ = 1 THEN
138:	a$ = "Print"
139:	ELSEIF SdZ = 2 THEN
140:	a$ = "Plot" + CHR$(255)
141:	ELSEIF SdZ = 3 THEN
142:	a$ « "Graph"
143:	ELSE
144:	a$ - Off$ + STRINGS(2.255)
145:	END IF
146;	t$ - t$ + aS + + STR$(SdrZ) + "."
147:	IF FsdZ THEN a$ - 0n$ ELSE a$ - OffS
148:	t$ = t$ + a$
149:	GETVAL t$
150:	MCOLOR 3. 0
151:	PUTVAL
152:	ipZ = ipsZ
153:	TOGGLEMEN ipZ, plusZ
154:	IF ipZ = 0 OR ipZ - elZ THEN EXIT DO
155:	ipsZ = ipZ
156:	IF ipZ = 1 THEN
157:	IF plusZ THEN
B-100

-------
Program Documentation	Version 2.0	IAQPC
158:	StptrZ = (StptrZ + 1) MOD 10
159;	ELSE
160:	StptrZ = (StptrZ + 9) MOD 10
161:	END IF
162:	StepTime = StpTme(StptrZ)
163:	IF PrntTime < StepTime THEN PrntTime = StepTime
164:	ELSEIF ipZ = 2 THEN
165:	IF plusZ THEN
166!	PrtptrZ = (PrtptrZ + 1) MOD 10
167:	ELSE
168:	PrtptrZ = (PrtptrZ + 9) MOD 10
169s	END IF
170?	PrntTime = PrtTme(PrtptrZ)
171s	IF PrntTime < StepTime THEN PrntTime = StepTime
172:	ELSEIF ipZ = 3 THEN
173:	IF plus Z THEN
174:	RnDuptrZ « (RnDuptrZ + 1) MOD 13
175:	ELSE
176:	RnDuptrZ = (RnDuptrZ + 12) MOD 13
177:	END IF
178:	RunDuration = RnDur(RnDuptrZ)
179:	ELSEIF ipZ « 4 THEN
180:	IF plusZ THEN
181s	IntrptAt = (IntrptAt + 1) MOD 13
182:	ELSE
18 3 •	Ijnt rp t^^t (12 ^ Int rpt^^t) ^^0^3 13
184:	END IF
185:	ELSEIF ipZ - 5 THEN
186:	IF GrZ THEN rZ - 4 ELSE rZ = 3
187:	IF plusZ THEN
188:	SdZ = (SdZ + 1) MOD rZ
189s	ELSE
190:	SdZ - (SdZ + rZ - 1) MOD rZ
191:	END IF
192:	ELSEIF ipZ - 6 THEN
193:	IF plusZ THEN
194:	SdrZ - (SdrZ + 1) MOD (NrZ + 2)
195:	ELSE
196:	SdrZ = (SdrZ + NrZ + 1) MOD (NrZ + 2)
197:	END IF
198:	ELSEIF ipZ - 7 THEN
199:	IF FsdZ THEN FsdZ = FALSE ELSE FsdZ = TRUE
200:	IF NOT (FsdZ) THEN CLOSE OutchZ
201:	ELSEIF ipZ - 8 THEN
202:	LdMasterFile
203:	ELSEIF ipZ - 9 THEN
204:	SvMasterFile
205:	END IF
206:	LOOP
207:	ERASE StpTme, PrtTme, RnDur
208: END SUB
209:
210: FUNCTION ClName$ (iZ)
211s	IF namefileZ THEN
B-101

-------
Program	Documentation Version 2.0
212.;	ClName - cln(iX)
213 *	ELSE
214:	IF iX = 1 THEN t$ = "Room Filter (Particles)"
215s	IF iX « 2 THEN t$ = "Room Filter (VOC)"
216:	IF iX = 3 THEN t$ - "Room ESP (Elct Air Clnr)"
217:	IF iX =5 4 THEN t$ = "Room Air Ionizer"
218:	IF iX•= 5 THEN t$ - "Room Dehumidifier"
219:	IF iX ¦ 6 THEN t$ = "HVAC Filter (Particles)"
220:	IF iX = 7 THEN t$ - "HVAC Filter (VOC)"
221:	IF iX = 8 THEN t$ = "HVAC ESP (Elct Air Clnr)"
222:	IF iX = 9 THEN t$ = "HVAC Dehumidifier"
223:	ClName$ - t$ + SPACE?(24 - LEN(t$))
224:	END IF
225:	END FUNCTION
226:
227:	FUNCTION CycleNameS (iX)
228:	IF iX <= 4 THEN tS = "Minutes On & Off t"
229s	IF iX >= 5 THEN t$ = "Hours On & Off ±"
230:	CycleName = t$
231:	END FUNCTION
232;
233:	FUNCTION DirectEntry$
234:	f$ = SPACES(12)
235:
236s	GETNAMEF SSEG(f$). SADD(f$), flenX
237:	f$ = SPACES(12 - flenX) + LEFTS(fS, flenX)
238:
239:	GETSIZEF loX, hiX
240:	IF loX < 0 THEN hiX = hiX + 1
241:	sz& - hiX * 65536# + loX
242:	sz$ • STR$(siS)
243:	f$ - f$ + SPACES(7 - LEN(sz$)) + sz$
244:
245:	GETDATEF moX, daX, yrX
246:	da$ = RIGHTS("00" + LTRIMS(STR$(daX)), 2)
247:	dt$ - STR$(moX) + + da$ + + RIGHTS(STR$(yrX), 2)
248:	f$ = f$ + SPACES(10 - LEN(dt$)) + dt$
249:
250:	GETTIMEF hrX, mnX, scX
251:	mn$ = RIGHTS("00" + LTRIM$(STR$(mnX)), 2)
252:	ti$ = STRS(hrX) + •:" + mn$
253:	f$ - f$ + SPACES(7 - LEN(ti$)) + ti$
254:
255:	DirectEntry = fS
256:	END FUNCTION
257:
258:	SUE DisplayFiles (DpathS, Ext$)
259:	IF LTRIMS(DpathS) <> "" THEN f$ = UCASES(Dpath$) ELSE f$
CURRENT DIRECTORY"
260:	CENTXT 1, "Files in " + f$
261:	f$ = DpathS +"*."+ Ext$
262:	IF EXISTFILE(f$) THEN
263:	FileShow
264:	ELSE
B-102

-------
Program Documentation	Version 2.0	IAQPC
265s	FileAlert
266:	END IF
267:	END SUB
268 s
269:	SUB EditMaster
270:	STATIC ipl
271:	wZ = GUMINTWINDOW
272:	CLV wZ
273:	ell ¦ 12
274:	cl = 4
275:	rl - 1
276:	MC0L0E 1, 0
277:	CENTXT rZ, "Master File " + MasterFileS
278:	PENT rl + 2, cZ, "Building File " + UCASES(BuildingFile$)
279:	PINT rZ + 3, cl, "HVAC System " + UCASES(HVACFileS)
280:	PENT rZ + 4, eZ, "Pollutant File * + UCASES(PolFile$)
281s	PENT rZ + 5, cZ, "Cleaner File " + UCASE$(ClFile$)
282:	PENT rZ + 6, cZ, "In-room File " + UCASE$(InFile$)
283:	FOE iZ = 1 TO 4
284:	t$ - SPACES(76)
285:	LSET t$ - Note(iZ)
286:	PENT rZ + 7 + iZ, cZ, t$
287:	NEXT
288:	PENT rZ + 13, cZ, "Quit to Preliminary Menu "
289:	LOCATE HWIN - 8, 1
290:	EditNotes
291:	DO
292:	IF ipZ < 7 THEN SETBAELEN 22 ELSE SETBAELEN WIN - cZ
293:	Key$ = MENU(elZ, rZ + 2, cZ, ipZ, kZ, SPACE$(elZ - 1} + "Q")
294:	IF KeyS = CHE$(27) OE ipZ = elZ THEN EXIT DO
295:	IF ipZ > 6 THEN
296:	t$ - MID$(LINES(wZ. CSELNW) , cZ)
297:	IF Key$ <> CHE$(13) THEN
298:	MID$(t$, 1, 1) = Key$
299:	ptrZ = 1
300:	ELSE
301:	ptrZ = 0
302:	END IF
303:	SETCUESOE rZ + ipZ, cZ - 1
304:	EDITLINE t$, ptrZ
305:	Note(ipZ - 6) = SPACES(77)
306:	LSET Note(ipZ - 6) = LTRIMS(t$)
307:	ELSE
308:	SETCUESOE rZ + ipZ, cZ + 12
309;	IF Key$ - CHE$(13) THEN Key$ = ""
310:	t$ ¦ NAMES(KeyS)
311:	IF t$ <> "" THEN CLL CSELNV, POSW + LEN(t$) + 2, 0
312:	IF ipZ - 1 THEN
313:	IF t$ <> "" THEN BuildingFileS = t$
314:	ELSEIF ipZ = 2 THEN
315:	IF t$ <> "" THEN HVACFileS = t$
316:	ELSEIF ipZ = 3 THEN
317:	IF t$ <> "" THEN PolFileS = t$
318:	ELSEIF ipZ = 4 THEN
B-103

-------
Program Documentation	Version 2,0	IAQPC
319s	IF t$ <> •" THEN ClFile$ - t$
320:	ELSEIF ipZ - 5 THIN
321i	IF t$ <> "" THEN InFile$ = t$
322:	END IF
323:	END IF
324s	LOOP
325:	END SUB
326:
327:	SUB EditNotes
328:	MCOLOR 2, 0
329:	PRINT "The following keys are effective when editing the note
lines:"
330:	PRINT
331:	PRINT " - accept the note as is,  - restore
original note."
332:	PRINT " - delete at the cursor.	
backspace and delete."
333:	PRINT " - move to start of note.  - move to
end of note."
334:	PRINT " - delete whole note.	 - delete
to end of note."
335:	PRINT * - toggle insert mode (initially off)."
336:	PRINT "Cursor keys - move left/right;
337:	MCOLOR 1, 0
338:	END SUB
339:
340s	SUB FileAlert
341:	CENTXT MIDLINE, "Path or File not found."
342:	CHIRP 2
343:	DELAY 100
344i	END SUB
345s
346s	SUB FileNameWindow (Hdr$, Dpath$, Ext$, File$, a$)
347:	SETFRAME FALSE
348:	DIM i AS SCRNPAR, ipl AS SCRNPAR
349:	wZ = CURRENTWINDOW
350:	SAVEPAR wZ, i
351:	SAVEPAR wZ + 1, ipl
352:	DEFINEWINDOW wZ, 0, 0, 20, i.MAXCOL, MPAL(3), MPAL(0)
353:	DEFINEWINDOW wZ + 1, 21, 0, 24, i.MAXCOL, MPAL(0), MPAL(7)
354:	FRAMEWINDOW wZ + 1
355:	HEADER wZ + 1, Hdr$
356:	SELECTW wZ
357:	DisplayFiles Dpath$, Ext$
358i	SELECTW wZ + 1
359:	FRNT 1, 5, "Current filename is " + UCASE$(File$) + Accept -
 | Abort - "
360:	PRNT 2, 10, "Enter the filename (less extension): *
361:	a$ ¦ UCASE$(NAMES(""))
362:	CLOSEWINDOW wZ
363:	CLOSEWINDOW wZ + 1
364:	RESTOREPAR wZ + 1, ipl
365:	RESTOREPAR wZ. i
366:	SELECTW wZ
B-104

-------
Program Documentation
Version 2.0
IAQFC
367:	END SUB
368:
369s	SUB FileShow
3701	IZ = WIN \ 2 - 1
371:	f$ - DirectEntry
372:	flenZ = LEN(f$)
373:	rl = 2
374:	cZ = 1
375:	PRNT rZ, cZ, f$
376:	DO
377:	IF NOT {FINDNEXTF) THEN EXIT DO
378:	rZ = rZ + 1
379s	f$ - DirectEntry
380s	PRNT rZ, cZ, f$
381s	IF rZ - HWTN - 1 THEN
382s	IF cZ - 1 AND flenZ <- 1Z THIN
383s	cZ = 1Z + 1
384s	rZ ¦ 1
385:	ELSE
386s	x$ = PAUSESTR(0, "Press  to Quit; any other key to
continue")
387
388
389
390
391
392
393
394
395
396
IF x$ = CHR$(27) THEN EXIT DO
rZ = 1
cZ = 1
END IF
END IF
LOOP
END SUB
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
FUNCTION GenCopy$
GenCopy$ ¦ ".Upward Room# Copy ,Downward Room# Copy ,
Quit to Prior Menu *
END FUNCTION
FUNCTION GenSink$ (iZ)
IF iZ * 1 THEN t$ -	"Horizontal	{Type 1)
IF iZ - 2 THEN t$ -	"Vertical	(Type 2)
IF iZ = 3 THEN t$ =	"Furniture	(Type 3)
IF iZ = 4 THEN t$ =	"People	(Type 4)
GenSink = t$
END FUNCTION
FUNCTION GenSource$ (iZ)
IF namefileZ THEN
GenSource ¦ gn(iZ)
ELSE
IF iZ - 1 THEN t$ = "Cigarette"
IF iZ - 2 THEN t$ = "People"
IF iZ = 3 THEN t$ = "Kerosene Heater"
IF iZ = 4 THEN t$ = "Gas Range"
IF iZ = 5 THEN t$ = "Moth Crystals"
IF iZ = 6 THEN t$ = "Floor Wax"
IF iZ = 7 THEN t$ = "Rock Slab"
IF iZ = 8 THEN t$ = "Other"
B-105

-------
Program Documentation	Version 2.0	IAQPC
419; "	GenSource = t$
420 s	END IF
421j	END FUNCTION
422 j
423:	SUB GetLastTime (tl, mrZ, mpolZ, lastt)
424:	filesizefc ¦ LOF(t23
425s	GIT #tZ, , mrZ
426s	GET #tZ, , mpolZ
427s	recsizeS = 4 * ((mrl + 3) * mpolZ + 1)
428:	nrecsZ » (filesize& - 4) \ recsizeS
429:	SEEK tZ, (5 + (nrecsZ - 1) * recsizei)
430:	GET #tZ, , lastt
431s	SEEK #tZ, 5
432s	END SUB
4331
434:	SUB laqconfig
435;	STATIC ipZ
436s	GETCONFIG WrZ, BsZ, NtbrZ, NtKeyZ
437s	LoadlaqConfig GrZ, Dpath$, HfsZ, BMMZ
438s	CLW 1
439:	elZ = 12
440s	srl = 4
441:	scZ - 30
442:	Title? = "Configuration Options"
443:	Text® ¦ "Wraparound,Color Enable,Bar/Blink Cursor,Key Letter
Enable"
444:	TextS = TextS + ",Graphics Display,Master File Update,Opening
Menu"
445:	Text$ « TextS + ".Data Files Path,Load Configuration"
446:	TextS «= TextS + ",Save Configuration,.Quit "
447:	SETCOL scZ
448:	GETRQW TitleS, Text$, ""
449:	TOGGLEBOT
450:	PUTROW
451:	DO
452:	IF WrZ THEN Wr$ - 0n$ ELSE VrS - OffS
453:	IF BsZ THEN Bs$ = OnS ELSE Bs$ - OffS
454:	IF NtbrZ THEN Nb$ = "Blink* ELSE Nb$ = "BarQ]"
455:	IF NtKeyZ THEN k$ = 0ff$ ELSE k$ - On$
456:	IF GrZ THEN Gr$ = OnS ELSE Gr$ - Off$
457:	IF MfsZ THEN Ms$ = 0n$ ELSE Ms$ = OffS
458:	IF BMMZ THEN Bm$ = "Main/TTTTTT]" ELSE Bm$ - "Preliminary"
459:	t$ = Wr$ + + Bs$ + + Nb$ + + k$ +
460:	t$ = tS + GrS + + Ms$ + + Bm$ + + DpathS
461:	GETVAL t$
462s	MCOLOR 3, 0
463:	PUTVAL
464:	TOGGLEMEN ipZ, plusZ
465s	IF ipZ = 0 OR ipZ = elZ THEN
466:	EXIT DO
467:	ELSEIF ipZ = 1 THEN
468:	IF WrZ THEN WrI = FALSE ELSE WrZ « TRUE
469:	LDCONFIG WrZ, BsZ, NtbrZ, NtKeyZ
470:	ELSEIF ipZ = 2 THEN
B-106

-------
Program Documentation	Version 2,0	IAQPC
471:	IF BsZ THEN SsZ - FALSE ELSE BsZ = TRUE AND (MONITOR <> 0)
472s	LDCONFIG WrZ, BsZ, NtbrZ, NtKeyZ
473s	PUTROW
474:	ELSEIF ipZ = 3 THEN
475:	IF NtbrZ THEN NtbrZ = FALSE ELSE NtbrZ = TRUE
476:	LDCONFIG WrZ, BsZ, NtbrZ, NtKeyZ
477:	ELSEIF ipZ = 4 THIN
478:	IF NtKeyZ THEN NtKeyZ = FALSE ELSE NtKeyZ ¦ TRUE
479:	LDCONFIG WrZ, BsZ, NtbrZ, NtKeyZ
480:	ELSEIF ipZ - 5 THEN
481:	IF GrZ THEN GrZ - FALSE ELSE GrZ = TRUE
482;	ELSEIF ipZ = 6 THEN
483:	IF MfsZ THEN MfsZ = FALSE ELSE MfsZ = TRUE
484:	ELSEIF ipZ - 7 THEN
485:	IF BMMZ THEN BMMZ - FALSE ELSE BMMZ - TRUE
486:	ELSEIF ipZ « 8 THEN
487:	PUSHW srZ + 12, 15, srZ + 15, 65, 0, 1
488:	FRAMEWINDOW 1
489:	HEADER 1, "Data Files Path"
490:	CENTXT 1, "If you desire a blank path, enter it as
491:	PRNT 2, 3, "Data path (ending with	x$ = SINPUT$("")
492:	POPW
493:	IF x$ <> "* AND x$ <> CHR$(27> THEN
494:	z$ = LTRIM$(RTRIM$(x$))
495:	IF X$ » THEN x$ - ""
496:	DpathS = x$
497:	CLL srZ + 7, scZ + 20, 79
498:	END IF
499:	ELSEIF ipZ - 9 THEN
500:	GETCONFIG WrZ, BsZ, NtbrZ, NtKeyZ
501:	LoadlaqConfig GrZ, Dpath$, MfsZ, BMMZ
502:	CLL srZ + 4, scZ + 20, 0
503:	ELSEIF ipZ - 10 THEN
504:	SavelaqConfig GrZ, Dpath$, MfsZ, BMMZ, WrZ, BsZ, NtbrZ,
NtKeyZ
505:	END IF
506:	LOOP
507:	SETCOL MIDSCRN
508: END SUB
509:
510: SUB LoadlaqConfig (GrZ, Dpath$, MasterFileSaveZ, BeginMainMenuZ)
511: fZ = FREEFILE
512: fS - "menu.cnf"
513: IF EXISTFILE(fS) THEN
514:	OPEN f$ FOR INPUT AS fZ
515:	FOR iZ - 1 TO 6
516:	LINE INPUT #£I, t$
517:	NEXT
518:	INPUT #fZ, t$
519:	GrZ ¦ VAL(t$)
520:	INPUT #fZ, t$
521:	DpathS - t$
522:	INPUT /fZ, t$
523:	MasterFileSaveZ = VAL(t$)
B-107

-------
Program Documentation	Version 2.0	IAQPC
524s	INPUT IfX. t$
525:	Beg inHa inMenu Z = VAL(t$)
526s	CLOSE fZ
527s	ELSE
528i	GrZ - GRAPH
529s	Dpath$ - ""
530s	HfsZ - TRUE
531:	BMMZ - FALSE
532:	WrZ ¦ FALSI
533:	BsZ - TRUE
534;	NtbrZ = TRUE
535:	NtKeyZ » FALSE
536:	END IF
537:	END SUB
538:
539j	SUB LoadMasfcer
540:	IF OpenDataFile(Dpath$, MasterFile$, "msf, 0) THEN
541:	LdMasterFile
542:	a$ = Dpath$ + BuildingFileS + ".bid"
543:	IF EXISTFILE(a$) THEN LdBasicDesignFile
544:	a$ = Dpath$ + HVACFileS + ".hvc"
545:	IF EXISTFILE(aS) THEN LdHVACFile
546:	a$ = DpathS + PolFileS + *.pol*
547:	IF EXISTFILE(aS) THIN LdPolFile
548:	a$ = DpathS + ClFile$ + "-cln"
549:	IF EXISTFILE(a$) THEN LdCleanerFile
550:	a$ = Dpath$ + InFile$ + *.inr"
551:	IF EXISTFILE(a$) THEN LdlnRmFile
552:	END IF
553:	END SUB
554:
555:	SUB MainMenu
556:	ipZ = 1
557:	DO
558;	SETCALC0RNER 4, 4
559:	CLW CURRENTWINDOW
560:	Title$ = "Indoor Air Quality, Simulator,Preliminary Menu 2.0"
561:	TextS « "Main Menu,Load Master File,Save Master File*
562:	Text$ ¦= Text$ + ".Annotate Master File,.Reconfigure Program,"
563:	TextS • Text$ + "Temporary Exit to DOS,,Exit to DOS"
564:	OPMEN TitleS, Text$, StdBotS, ipZ, Key$
565:	IF Key$ - CHR$(13) THEN
566:	Title$ - ""
567:	Text$ = ""
568:	IF ipZ « 1 THEN OperatingMenu
569:	IF ipZ = 2 THEN LoadMaster
570:	IF ipZ - 3 THIN SaveMaster
571:	IF ipZ - 4 THEN
572:	SETLEVEL 2
573:	EditMaster
574:	SETLEVEL 1
575:	ELSEIF ipZ = 6 THEN
576:	SITLEVEL 2
577:	Iaqconfig
B-108

-------
Program Documentation	Version 2.0	IAQPC
578:	SITLEVEL 1
579:	ELSEIF ipZ = 7 THEN
580:	CLSW
581:	CENTXT 1, "Type EXIT to return to this program"
582:	SHELL
583:	CLSW
584:	SETLEVEL 1
585:	END IF
586:	IF ipZ = 9 THEN EXIT DO
587:	END IF
588:	LOOP
589:	END SUB
590:
591:	SUB MaxOf (iZ)
592 s	SELECTV 0
593:	CENTXT 1, "Maximum of" + STR$(iZ)
594:	CHIRP 2
595:	CLV 0
596:	SELECTV 1
597:	END SUB
598;
599:	FUNCTION MaxVectorZ (ilZ, iuZ, r(), Tol)
600:	MaxVector - TRUE
601:	FOR iZ = ilZ TO iuZ
602:	IF ASS(rCiZ)) > Tol THEN MaxVector - FALSE: EXIT FUNCTION
603:	NEXT
604:	END FUNCTION
605:
606:	FUNCTION OpenDataFileZ (Dpath$, File$, Ext$, wZ)
607:	OpenDataFile = FALSE
608:	IF wZ THEN
609:	FileNameWindov "SAVE", Dpath$, Ext$, File$, a$
610:	ELSE
611:	FileNameVindow "LOAD", Dpath$, Ext$, File$, a$
612:	END IF
613:	IF a$ = CHR$(27) THEN EXIT FUNCTION
614;	IF a$ <> *" THEN FileS = a$
615:	IF wZ AND LEFTS(File$, 1) = "I* THEN MID$(File$, 1, 1) =
616:	a$ = Dpath$ + File$ + + Ext$
617:	IF wZ OR EXISTFILE(a$) THEN
618:	OpenDataFile = TRUE
619:	ELSE
620;	FileAlert
621:	END IF
622:	END FUNCTION
623;
624:	SUB OpenTmpFile (tZ, f$)
625:	tZ = FREEFILE
626:	IF NOT (EXISTFILE(f$)) THEN
627;	tZ = 0
628;	CENTXT MIDLINE. "Run File not found. Store results while
calculating.*
629:	CHIRP 2
630:	DELAY 100
B-109

-------
Program Documentation	Version 2.0	IAQPC
631.-	- EXIT SUB
632i	END IF
633:	OPEN f$ FOR BINARY AS ItZ
634i	END SUB
635:
636:	SUB Ope rat ingMenu
637s	DIM wp AS SCRNPAR
538i	STATIC ipX
639s	IF ipZ - 0 THEN ipZ = 6
640 .*	DO
641:	CLW CURRENTVINDOW
642.*	Title? • "Indoor Air Quality, Simulator,Main Menu*
643s	TextS ¦ "Basic Building Design.HVAC System Description*
644:	Texts = TextS + ".Pollutant Characteristics,Air Cleaners &
Sinks *
645:	TextS = Text$ + ",In-Room Locations"
646:	TextS * TextS + ".Runtime Configuration"
647:	Text$ = TextS + ".Start Simulator,Continue Simulation"
648s	TextS ¦ TextS + *,Graphical Output,Output Results"
649s	TextS » TextS + ",,Quit to Prior Menu "
650:	OPMEN Title$, TextS, StdBotS, ipZ, KeyS
651:	IF KeyS = CH1S{27) OR ipZ - 12 THEN EXIT DO
652:	IF KeyS - *h" THEN LOCATE 1, 1: PRINT FRE{""*). FRE(-l), FRE{-
2): DELAY 100
653:	IF KeyS = CHR$(13) THEN
654:	TitleS = ""
655:	TextS = "«
656:	SAVEPAR 1. wp
657:	1Z = 2
658:	rZ =¦ ipZ + 6
659:	BarCatch rZ, MIDSCRN, IX
660:	IF ipZ = 1 THEN BasicDesign
661:	IF ipZ = 2 THEN HVDescription
662:	IF ipZ = 3 THEN PollutantMenu
663:	IF ipZ = 4 THEN CleanerMenu
664:	IF ipZ « 5 THEN Inrm
665:	IF ipX = 6 THEN CalcConfig
666:	IF ipZ = 7 THEN
667:	TO = 0
668 i	Tf =» 24 * RunDuration
669:	MasterCalcInit
670:	MasterCalcRun TO, Tf
671:	END IF
672:	IF ipZ = 8 THEN
673:	TO - Tf
674:	Tf ¦ 24 * RunDuration
675:	MasterCalcRun TO, Tf
676:	END IF
677:	IF ipZ = 9 AND GrZ THEN GraphMenu
678:	IF ipZ = 10 THEN Outles
679:	SETLEVEL 1
680:	SlipCatch wp
681:	END IF
682:	LOOP
B-110

-------
Program
683:
684:
68S:
686
700:
701	s
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729:
730:
731
732
733
734
735
Documentation
END SUB
FUNCTION PolNameS  AND (2
1))). IZ)
PRNT rZ + iZ, POSW, SPACES(IZ + 4 - POSW)
NEXT
END SUB
FUNCTION SHOD (x, y)
nZ - FIX(x I y)
RMOD ¦ x - nZ * y
END FUNCTION
FUNCTION RnChangeZ (kZ, rnZ, NrZ)
RnChange = FALSE
IF kZ = 75 OR kZ = 77 THEN
IF kZ - 77 THEN
rnZ = rnZ + 1
IF rnZ > NrZ THEN rnZ - 0
ELSE
rnZ = rnZ - 1
IF rnZ < 0 THEN rnZ - NrZ
END IF
kZ - 0
RnChange = TRUE
END IF
(NrZ + 2)
B-lll

-------
Program Documentation	Version 2.0	IAQPC
736:	END FUNCTION
737:
738:	SUB SavelaqConfig (GrZ, DpathS, MfsZ, BMMZ, WrZ, BsZ, NtbrZ,
NtKeyZ)
739:	DIM t$(6)
740:	fZ » FREEPILE
741:	OPEN "menu.cnf" FOE INPUT AS fZ
742:	FOR jZ » 1 TO 6
743:	LIRE INPUT #£Z, t$(jZ)
744:	NEXT
745:	CLOSE fZ
746:	OPEN "menu.cnf" FOR OUTPUT AS fZ
747:	WRITE #fZ, VrZ, BsZ, NtbrZ, NtKeyZ
748:	FOR jl - 2 TO 6
749:	PRINT #fZ. t$(jX)
750:	NEXT
751:	WRITE #fZ, GrZ, Dpath$, MfsZ, BMMZ
752:	CLOSE fZ
753:	ERASE t$
754:	END SUB
755:
756:	SUB SaveMaster
757:	IF OpenDataFile(DpathS, MasterFileS, "mst", 1) THEN
758:	SvMasterFile
759:	END IF
760:	END SUB
761:
762:	SUB SlipCatch (vp AS SCRNPAR)
763:	RE5T0REPAR 1, wp
764:	SELECTW 1
765:	SETCOL MIDSCRN
766:	END SUB
767:
768:	FUNCTION StdBot$
769:	StdBot = "Use the arrow keys to position the cursor.,Use
 to select the option."
770:	END FUNCTION
771:
772:	SUB UselAQMenu
773:	REDIM pn(l TO 11) AS STRING * 18
774:	REDIM cln(l TO 9) AS STRING * 24
775:	REDIM gn(l TO 8) AS STRING * 16
776:	IF EXISTFILE("names.cnf") THEN
777:	iZ = FREEFILE
778:	OPEN "names.cnf" FOR INPUT AS #iZ
779:	FOR jZ - 1 TO 11
780:	INPUT #iZ, pn(jZ)
781:	NEXT
782:	FOR jZ - 1 TO 9
783:	INPUT 412, cln(jZ)
784:	NEXT
785:	FOR jZ = 1 TO 8
786:	INPUT #iX, gn(jZ)
787:	NEXT
B-112

-------
Program	Documentation Version 2.0	IAQPC
788:	namefileZ = TRUE
739i	ELSE
790;	namefilel ¦ FALSE
791:	END IF
792:	CLOSE iZ
793:	END SUB
794:
795:	FUNCTION VectorAvg (ill, iuZ, r())
796:	FOR iZ = ilZ TO iuZ
797:	tv = tv + r(iZ)
798:	NEXT
799:	VectorAvg = tv / (iuZ - ilZ - 1}
800:	END FUNCTION
B-113

-------
Program Documentation
\ind\output.asc
Version 2.0
IAQPC
1: '$INCLUDE: '\qb4\level0.pub'
2: '$INCLUDE! *\qb4\levell.pub'
3: '$INCLUDE: '\qb4\windowp.pub'
4: '$INCLUDE: '\qb4\minicalp.pub»
5: 1 $INCLUDEi '\qb4\level2.pub'
6: 'SINCLUDE: '\qb4\menup.pub *
7! '$INCLUDE: * iaqsubp.pub'
3: '$INCLUDE: 'iaqcommn.pub'
9:
10:
II:
12
13
14:
15:
16:
17:
18:
19:
20;
21s
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33 :
34:
35:
36:
37: DIM SHARED b$, p$
38:
39: COMMON SHARED /indcalc/ NrlZ, npolZ, tm, prt, v
40:
41: END
42:
43: SUB DisplaylnDat
44: *$ = * "
45: y$ » "Press any key to continue or  to quit."
46:
47:	" Device! = 1 file, 2 = comm port
48:	* 3 printer, 4 SCRN
49: IF DeviceI - 4 AND GRAPH > 1 THEN
50:
51:	WIDTH , 43
52:	DEFINEW1ND0W 1, 0. 0, 42, 79, MPAL(4), MPAL(0)
DECLARE
FUNCTION ConcVal (kl, 12)
DECLARE
FUNCTION AvgConcVal (kZ)
DECLARE
SUB
DisplaylnDat ()
DECLARE
SUB
Inpagel ^5
DECLARE
SUB
Inpage2 (}
DECLARE
SUB
InpageS ()
DECLARE
SUB
Inpage4 ()
DECLARE
SUB
InpageS C5
DECLARE
SUB
Inpagefi ()
DECLARE
SUB
Inpage? f)
DECLARE
SUB
InpageS (5
DECLARE
SUB
LoadHistory {)
DECLARE
SUB
OutputConc ()
DECLARE
SUB
OutputFlovs ()
DECLARE
SUB
PI (}
DECLARE
SUB
Pageheader (iZ)
DECLARE
SUB
PollHist ()
DECLARE
SUB
PolSetUpB (Text$, t$, a I (), nZ, swZ)
DECLARE
SUB
PrintCh (%)
DECLARE
SUB
PrntConc ()
DECLARE
SUB
PrntFlows (hi)
DECLARE
SUB
PrtChConc ()
DECLARE
SUB
PrtChFlows (hZ)
DECLARE
SUB
SetOutDev (DeviceZ)
DECLARE
SUB
StoreHistory ()
B-114

-------
Program Document&t,ion
Version 2.0
IAQPC
53
54
55
56
57
58
59
60
61
62
63
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
SETLEVEL 3
SELECTW 1
CLW 1
egaZ ¦ TRUE
tip I ® 4
ELSE
egal = FALSI
npZ = 8
END IF
IF Device! <> 4 THEN npZ
FOR pgZ » 1 TO npl
64 s
Pageheader
pgz
65s
IF npZ -
4
THEN
66;
IF pgZ
m
1
THEN Inpagel: Inpage2
67s
IF Pg2
=
2
THEN InpageS: Inpage4
68 s
IF pgZ
=
3
THEN InpageS: Inpage6
69s
IF pgZ
-
4
THEN Inpage7: InpageS
70s
ELSE



71:
IF pgZ
a
2
AND NrZ > IS THEN LOCATE 1, 1
72:
IF pgZ
=
1
THEN Inpagel
73:
IF pgZ
SB
2
THEN Inpage2
74:
IF pgZ
=
3
THEN Inpage3
75:
IF pgZ
=
4
THEN Inpage4
76:
IF pgZ
«
5
THEN InpageS
77:
IF pgZ
SB
6
THEN Inpage6
78:
IF pgZ
sa
7
THEN Inpage7
79:
IF pgZ
as
8
THEN Inpage8
80:
END IF



81:
IF DeviceZ
=
4 THEN
IF pgZ <> 2 OR npl - 4 THEN
x$ = PAUSESTRfO, yS)
ELSE
IF NrZ < 20 THEN
x$ = PAUSESTRCO, y$)
ELSE
x$ = PAUSESTR(0, ¦")
END IF
END IF
IF x$ = CHR$(27) THEN EXIT FOR
CLW 1
ELSE
PRINT #2
END IF
IF DeviceZ
NEXT
IF egaZ THEN WIDTH
END SOT
PRINT #2, : PRINT #2, : PRINT #2,
3 THEN PRINT #2, CHR$(12)
25
SUB Inpagel
PI
PRINT #2, SPC{28); "GENERAL"
b$ - SPACE?(5)
PI
PRINT #2, bS; "Master File Name;
MasterFileS
B-115

-------
Program Documentation
Version 2.0
10?
PI



108
, PRINT
#2, b$;
"Building File Name:
"; BuildingFileS
109
PI



110
PRINT
#2, b$;
"HVAC System File Name:
•; HVACFileS
111
PI



112
PRINT
#2, b$;
"Pollutant File Name:
«; PolFile$
113
PI



114
PRINT
#2, b$;
"Air Cleaner File Name;
ClFile$
115
PI



116
PRINT
#2, b$;
"In-room File Name:
InFile$
117
PI



118
PRINT
#2,


119
PI



120
PRINT
42, "Notes:"

121
FOR il = 1 TO
4

122
123
124
125
126
127
128
129
130
131
132
133
134
135
151:
152:
153:
154:
155:
PI
PRINT #2. h$i RTRIM$(Note(iZ))
NEXT
PI
PRINT #21
PI
PRINT 42,
END SUB
SUB Inpage2
IF Nrl < 18 THEN PI: PRINT #2,
D y """* w J> Avm y I » J
PI
PRINT #2, b$; "BUILDING STATISTICS (areas in ft2)	Floor
Plan"; Fpl
IF Nrl < 18 THEN Pis PRINT #2,
PI
PRINT #2, b$; " Room Volume HVAC:In Ret Walls: Out Nxt
Rm Pr Rm Hall"
Tv - 0
Tow = 0
THI = 0
THR - 0
IF Fpl > 2 THEN hZ - 0 ELSE hi = 1
FOR i = hi TO Nrl
Tv = Tv + Vol(i)
IP11T -- fOT -fc. Tt* *• a	/ i 1 \
mi. e inx t interuoru jl)
Tow « Tow + InterCon(i, 2)
THR » THR + InterConfi, 6)
PI
PRINT #2, USING "&### ###/# t*.§* 44.ft	44.44 4
4.44 44.44 44.44'j b$; i; Vol(i), InterCon(i, 1), InterCon(i
, 6), InterCon(i, 2), InterCon(i, 3), InterCon(i, 4), InterCon{i,
5)
NEXT
PI
PRINT #2, USING "STotal 44444 ##.## ##.##	##.##"; b$
; Tv; THI; THR; Tow;
END SUB
B-116

-------
Program	Documentation Version 2.0	IAQPC
156 s
157:	SUB Inpage3
158:	PI
159:	PRINT #2, SPC(28); "HVAC SYSTEM"
160:	PI
161s	PRINT #2,
162:	b$ = SPACES(10)
163:	PI
164:	PRINT #2, b$j "Total Flows	"; s PRINT #2, USING "#####
VolFlow; "cfm"
165:	PI
166;	PRINT #2, b$; "Minimum Flows	•; : PRINT #2, USING "#####
6"; MinFlow; "cfm"
167:	PI
168s	PRINT #2, b$j "Makeup Air Fractions"; s PRINT #2, USING "#####.#
I": MakeUpAir
169;	PI
170;	PRINT #2, b$; "Pressure Head:	: PRINT #2, USING "#####
: FanDP; "in. H20"
171:	PI
172;	PRINT #2, b$; "Flow Exponent;	s PRINT #2, USING "###/#
S"; FlowExp
173;	PI
174;	PRINT #2,
175;	PI
176;	PRINT #2, b$; "HVAC System Schedule (24 hour clock)": PRINT #2,
177;	FOR iZ - 1 TO 7 STEP 2
178:	IF iZ > 2 AND Htimes(iZ) < Htimes(iZ - 1) THEN EXIT FOR
179:	PI
180:	PRINT /2, b$; " ON at	Htimes(iZ)
181s	PI
182;	PRINT #2, b$; " OFF at *; Htimes(iZ + 1)
183;	NEXT iZ
184;	PI
185s	PRINT #2,
186;	PI
187:	PRINT #2,
188	s	END SUB
189	s
190;	SUB Inpage4
191s	PI
192;	PRINT #2, SPC(17); "POLLUTANTS	Selected"
193;	PI
194;	PRINT #2,
195:	b$ - SPACE$(10)
196;	FOR iZ - 1 TO 11
197s	Psel$ - " "
198:	IF TSTBIT(In, iZ) THEN Psel$ = "x«
199:	PI
200s	PRINT 92, USING b$; iZ> PolName(iZ), Psel$
201s	NEXT
202;	PI
203:	PRINT #2,
204:	END SUB
B-117

-------
Program
205
206
207
208
209
210
211
212
213
214
215
216:
217;
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232
233
234
235
236
237
238:
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
Documentation
Version 2.0
IAQPC
'Generation Rates (mg or pCi in .1 hr)
SUB InpageS
PI
PRINT #2, SPC(18)
PI
PRINT #2,
PI
PRINT #2, "SOURCES"; SPC(25); "Pollutants"
PI
PRINT #2, SPC(17);
FOR iX - 1 TO 11
PRINT #2, USING "##	iX;
NEXT iZ
PRINT #2,
PI
PRINT #2, SPC(16);
FOR iX = 1 TO 11
Psel$ = " "
IF TSTSITfln, iX) THEN Psel$ « "x"
PRINT #2. USING " & "; Psel$;
NEXT iX
PRINT #2,
PI
PRINT #2,
FOR jX - 1 TO 8
FOR IX - 1 TO 11
IF IX - 1 THEN PI: PRINT #2, USING "\
GenSourceCj X);
PrintCh GenericSrc(jX, IX)
NEXT
PRINT #2,
NEXT
PI
PRINT #2,
PI
PRINT #2,
END SUB
SUB Inpagefi
PI
PRINT #2, SPC(18); "Efficiency in 0.1 Hour (Z)
PI
PRINT #2,
PI
PRINT #2, "SINKS"; SPC(27); "Pollutants"
PI
PRINT #2, SPC(17);
FOR iX = 1 TO 11
PRINT #2, USING 'ft
NEXT iX
PRINT #2,
PI
PRINT #2, SPC(16);
FOR iX = 1 TO 11
V;
iX;
B-118

-------
Program
258	s
259	s
260	s
261;
262;
263;
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281;
282:
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301:
302:
303:
304:
305;
306:
307:
308:
3091
310;
311:
Documentation	Version 2.0
PselS = " "
IF TSTBIT(In, it) THEN Psel$ = "x"
PRINT #2, USING " & *; Psel$;
NEXT iZ
PRINT #2.
PI
PRINT 42,
FOR jZ - 1 TO 4
PI
IF jl = 1 THIN PRINT #2, USING
IF jZ " 2 THEN PRINT #2, USING "\
IF jZ = 3 THEN PRINT #2, USING "\
IF jZ = 4 THEN PRINT #2, USING "\
FOR 1Z = 1 TO 11
IAQPC
\"i
\";
\";
\";
"Horizontal*
"Vertical '
"Furniture '
"People '
eff ¦ 100 * (1 - Sink(jX, 1Z)}
PrintCh eff
NEXT
PRINT #2,
NEXT
PI
PRINT #2,
PI
PRINT #2, SPC(18); "Reemission Rates (Z collected in 0.1 hr)*
PI
PRINT #2,
FOR jZ = 1 TO 4
PI
IF jZ = 1 THEN PRINT #2, USING "\	\"; "Horizontal'
IF jZ - 2 THEN PRINT #2, USING "\	\"; "Vertical "
IF jZ = 3 THEN PRINT #2, USING "\	\"; "Furniture '
IF jZ = 4 THEN PRINT #2, USING "\	\"; "People
FOR 1Z = 1 TO 11
PrintCh SinkTc(jZ, IZ)
NEXT
PRINT #2,
NEXT
END SUB
SUB Inpage7
PI
PRINT #2, SPC(33); "Pollutants'
PI
PRINT #2, SPC(19>}
FOR iZ ¦ 1 TO 11
USING
iZ;
PRINT 42, USING *44
NEXT iZ
PRINT 42,
PI
PRINT 42, SPC(18);
FOR iZ = 1 TO 11
PselS = " »
IF TSTBIT(In, iZ) THEN Psel$ -
PRINT 42, USING • t •; Psel$;
B-119

-------
Program Documentation	Version 2-0	IAQPC
312
NEXT il
313
¦ PRINT #2,
314
PI
315
PRINT #2,
316

317
PI
318
PRINT #2, USING "\ \"; "AVGING TIME (hr)";
319
FOR 1Z - 1 TO 11
320
IF PavgT(lZ) < 100 THEN PRINT #2, USING " ##.#"; PavgT(lZ);
321
IF PavgT(lZ) >= 100 THEN PRINT #2, USING " ####"; PavgT(lZ)
322
NEXT
323
PRINT #2,
324
PI
325
PRINT #2,
326
PI
327s PRINT #2, USING "\ \"; "LIMIT (mg/m3)";
328s FOR 11 = 1 TO 11
329
IF Plixn(lZ) < 100 THEN PRINT #2. USING " Plim{lZ5 ;
330
IF Plim(lZ) >= 100 THEN PRINT #2, USING " ####"; Plim(lZ);
331
NEXT
332
PRINT #2,
333
PI
334
PRINT #2,
335
PI
336
PRINT #2, USING "\ \"; "AMBIENT CONG";
337
FOR IZ = 1 TO 11
338
PrintCh AmbientConc(IZ)
339
NEXT
340
PRINT #2,
341
PI
342
PRINT #2, USING *&"; "mg/m3 or pCi/1"
343
PI
344
PRINT n.
345
PI
346
PRINT #2,
347
END SUB
348

349
SUB InpageS
350
PI
351
PRINT #2, SPC(18); "EFFICIENCY in 0.1 Hour 
-------
Program Documentation	Version 2.0	IAQPC
366s	IF TSTBIT(In, 125 THEN Psel$ = "x"
367:	PRINT #2, USING " & "j Psel$;
368:	NEXT
369:	PRINT #2,
370:	PI
371:	PRINT #2, " Room"
372:	FOR jZ = 1 TO 9
373:	PI
374:	Psel$ = " "
375:	IF TSTBIT(Cn, jZ) THEN Psel$ - "**
376:	IF jZ - 1 THEN PRINT #2, USING "\	\"; 'Particle
Filter" + Psel$;
377:	IF jZ = 2 OR jZ = 7 THEN PRINT #2, USING "\	\"; *
VOC Filter	* + Psel$;
378:	IF jZ = 3 OR jZ = 8 THIN PRINT #2, USING «\	\"; "
ESP	" + Psel$;
379:	IF jZ = 4 THEN PRINT #2, USING "\	\"; "Air
Ionizer " + Psel$;
380:	IF jZ » 5 OR jZ = 9 THEN PRINT #2, USING "\	\"; "
Dehumidifier " + Psel$;
381:	IF jZ = 6 THEN
382:	PRINT #2,
383:	PI
384:	PRINT #2, ' HVAC"
385:	PI
386:	PRINT #2, USING *\	\»i "Particle Filter" +
PselS{
387:	END IF
388:	FOR 1Z = 1 TO 11
389:	eff = 100 * (1 - ClEff(jZ, 1Z>)
390:	PrintCh eff
391:	NEXT
392:	PRINT #2,
393:	NEXT
394:	PI
395:	PRINT #2,
396s	END SUB
397:
398:	SUB LoadHistory
399:	FileNameWindow "LOAD", Dpath$, "hst", b$, a$
400:	IF a$ = CHR$(27) THEN EXIT SUB
401:	IF a$ <> *" THEN b$ = a$
402:	IF b$ <> *" THEN
403:	a$ = DpathS + b$ + ".hst"
404:	END IF
405:	IF EXISTFILE(aS) THEN
406:	CENTXT MIDLINE, "Loading..."
407:	COPY a$, Dpath$ + HasterFileS + *.tmp"
408:	ELSE
409:	FileAlert
410:	END IF
411:	END SUB
412:
413:	SUB OutputConc
B-121

-------
Program Documentation	Version 2.0	IAQPC
414:	IF DeviceZ = 4 THIN
415;	PrntConc
416:	PAK 0
417:	ELSE
418:	PrtChConc
419:	END IP
420:	END SUB
421:
422:	SUB OutputFlows
423:	IF Fp1 > 2 THEN hZ = 0 ELSE hZ = 1
424:	IF DeviceZ = 4 THEN
425:	PrntFlows hZ
426 s	ELSE
427s	PrtChFlows hZ
428:	END IF
429:	END SUB
430:
431:	SUB OutRes
432:	DIM wp AS SCRNPA1
433:	STATIC ipZ
434:	TextS = "Input Values,Flowrates.Concentrations.Pollutant
History*
435:	Text$ - Text$ + ",Load History,Store History"
436:	Text$ - TextS + ".Output Channel*
437:	TextS - Text$ + ",.Quit to Main Menu <£sc>"
438s	DO
439:	CLW 1
440:	OPMEN "OUTPUT MENU*, TextS, StdBot$, ipZ, Key$
441}	IF Keys = CHR$(27) OR ipZ ¦ 9 THEN EXIT SUB
442:	IF Key$ = CHR$(13> THEN
443:	IF ipZ < 5 THEN
444:	IF DeviceZ = 0 THEN
445:	SetOutDev DeviceZ
446;	SETCOL MIDSCRN
447:	IF DeviceZ = 0 THEN EXIT SUB
448:	END IF
449:	SAVEPAR 1, wp
450:	CLW 1
451:	IF DeviceZ <> 4 THIN
452:	CENTXT MIDLINE. "Printing..."
453:	END IF
454:	IF DeviceZ = 3 THEN
455:	p$ = PREAL
456:	WIDTH #2, 132
457:	ELSE
458:	p$ ¦ ""
459:	WIDTH #2, 80
460:	END IF
461:	IF ipZ - 1 THEN DisplayInDat
462:	IF ipZ - 2 THEN OutputFlows
463:	IF ipZ = 3 THEN OutputConc
464:	IF ipZ = 4 THEN PollHist
465:	SlipCatch wp
466:	END IF
B-122

-------
Program Documentation	Version 2.0	IAQPC
467:	IF ipZ - 5 THEN LoadHistory
468:	IF ipZ = 6 THEN StoreHistory
469:	IF ipZ = 7 THEN
470:	SAVEPAR 1, vp
471:	BarCatch, ipZ + 9, HIDSCRN, 3
472:	OUTDEV 2, DeviceZ
473:	SlipCatch wp
474:	CLW 1
475:	END IF
476	:	END IF
477	s	SETLEVEL 2
478:	LOOP
479s	END SU1
480:
481:	SUB Pageheader (il)
482:	IF DeviceZ = 4 THEN aS = "=" ELSE a$ = "="
483:	PI
484:	PRINT i2, "INPUT DATA"5 SPC(54); "Page" + STR$(iZ)
485:	PI
486:	PRINT #2, STRINGS(70, a$)
487:	END SUB
488:
489:	SUB PI
490:	IF p$ <> "* THEN PRINT #2, p$;
491:	END SUB
492:
493:	SUB PollHist
494:	OpenTmpFile tZ, Dpath$ + HasterFile$ + ".tmp"
495:	IF tl ¦ 0 THIN EXIT SUB
496:	GET #tZ, k NrZ
497:	GET #tZ, , npolZ
498:	DO WHILE NOT (EOF(tZ))
499:	GET #tZ, , t
500:	IF EOF(tZ) THEN EXIT DO
501:	t - ROUND{t, .05)
502:	PI
503:	PRINT #2, "Time: "it;" "
504:	FOR iZ = 0 TO NrZ + 1
505:	PI
506:	PRINT #2, USING "## iZ;
507:	FOR kZ ¦ 1 TO npolZ
508:	GET #tZ, , c
509:	PRINT #2, USING " I#-####""""; c;
510:	NEXT
511:	PRINT #2,
512:	NEXT
513:	PI
514:	PRINT #2, "Avg:";
515:	FOR kZ = 1 TO npolZ
516:	GET ItZ, , a
517:	PRINT #2, USING * ##.####—~"; a;
518:	NEXT
519:	PRINT #2,
520:	IF DeviceZ = 4 THEN
B-123

-------
Program Documentation	Version 2.0
521:	DELAY 50
522:	LOCATE 1, X
523	s	ELSE
524	:	PI
525:	PRINT #2,
526s	END IF
527s	a$ = IMK£Y$: IF a$ - CHR$<27) THEN EXIT DO
520:	LOOP
529:	CLOSE tl
530:	CLOSE #2
531:	IF Devicel = 4 THEN PAK 0
532:	Device! = 0
533:	END SUB
534:
535:	SUB PrintCh (x)
536:	IF * < .001 THEN
537:	PRINT #2. USING "fc"; *
538:	ELSEIF x « .1 THEN
539:	PRINT #2, USING " .##1"; x;
540:	ELSEIF X < 10 THEN
541:	PRINT #2, USING '##.##"; x;
542:	ELSEIF x < 100 THEN
543:	PRINT /2, USING "/##.#"; Xj
544:	ELSEIF X < 10000 THEN
545:	PRINT #2, USING *#####"; xj
546:	ELSEIF x < 100000 THEN
547:	PRINT #2, USING "#####"; x;
548:	ELSEIF x >« 100000 THEN
549:	PRINT #2, USING	z;
550:	END IF
551:	END SUB
552:
553;	SUB PrtChConc
554:	fl$ - "
555:	f2$ - * ###.### "
556:	PI
557:	PRINT #2, SPACES(14); "Concentrations at time";
558:	PRINT #2, USING " ###.#"; tai;
559:	IF v ¦ 1 THEN a$ = "Normal Flow " ELSE a$ » "Minimum Flow*
560:	PRINT #2, SPACE$(5); a$
561:	PI
562:	PRINT #2, " " ;
563:	FOR kZ = 1 TO npolZ
564:	PRINT #2, SPACES(8>; LEFTS(LTRIM$(STR$(kZ) + ' 2);
565:	NEXT
566:	PRINT #2,
567:	FOR it = 0 TO NrlZ
568:	PI
569:	PRINT #2, LEFTS(LTRIM$(STR$(it) + " "), 4);
570:	FOR kZ - 1 TO npolZ
571:	x = ConcVal(kZ, if)
572:	IF X > 9.999 OR x < .003 THEN f$ = fl$ ELSE f$ = f2$
573:	PRINT #2, USING f$; X;
574:	NEXT
B-124

-------
Program Documentation	Version 2.0	IAQPC
575:	PRINT #2,
576:	NEXT
577:	PI
578s	PRINT #2, "Avg:";
579s	FOR kZ - 1 TO npolZ
580s x = AvgConeVal(kZ)
581s	IF x > 9.999 OR x < .003 THEN f$ - fl$ ELSE f$ = f2$
582:	FEINT #2, USING f$; x;
583:	NEXT
584:	PRINT #2,
585:	END SUB
586;
587:	DEFINT I
588:	SUB PrtChFIows (hi)
589:	t$ • "Air Flows (CFM)"
590:	PI
591:	PRINT #2, SPACES(36 - LEN(t$) / 2)j t$
592:	f$ - "#####"
593:	il = 3
594s	i2 « 3
595 s	i3 <= 3
596:	i4 = 2
597s	i5 = 7
598s	16 = 2
599s	i7 = 2
600:	18 = 2
601s	19 = 2
602s	PI
603s	PRINT #2, " Room ACh/Hr HV_In HV_Ret Outside Nxt_!m
Pr_Rm Hall Total*
604:	Tow - 0
605:	TBI = 0
606:	THR = 0
607:	FOR i - hZ TO NrZ
608:	ipl = i + 3 - hZ
609:	Tr = 0
610:	FOR jZ = 1 TO 6
611:	Tr ¦ Tr + RmFlow(i, jZ)
612:	NEXT
613:	THI ¦ THI + RmFlow(i, 1)
614:	Tow ¦ Tow + RmFlcrw(i, 2)
615:	THR - THR + RmFlow(i. 6)
616:	PI
617:	PRINT #2, SPACES(il); RIGHTS(" " + STRS(i), 2);
618:	PRINT #2, SPACES(12)? : PRINT #2, USING "###.#•; AirChanges(i,
Vol() , RmFlowO ) ;
619:	PRINT #2, SPACE$(i3>; : PUNT #2, USING f$; RmFlow(i, 1);
620:	PRINT #2, SPACE$(i4>; : PRINT #2, USING £$; RmFlow(i, 6);
621:	PRINT §2, SPACE$(i5); : PRINT 42, USING £$i RinFlow(i, 2);
622:	PRINT #2, SPACE$(i6); : PRINT #2, USING f$; RmFlow(i, 3);
623:	PRINT #2, SPACES(i7); : PRINT #2, USING f$; RmFlow(i, 4);
624:	PRINT #2, SPACES(i8)i J PRINT #2, USING f$j RfflFlow(if 5);
625:	PRINT #2, SPACES(i9); : PRINT #2, USING f$; Tr
626:	NEXT
B-125

-------
Program Documentation	Version 2.0	IAQPC
627;
PI

628:
PRINT #2, SPACES(il -
1); "Total";
629 i
x = 60 * MakeUpAir *
VolFlow / ((NrZ + 1 - hZ) * VectorAvg(hZ

NrZ, Vol(5)5

630:
PRINT #2, SPACE$(12 -
2)j : PRINT #2, USING "###.##"; x;
631:
PRINT #2, SPACES(i3 -
1); : PRINT 42, USING £$; THIj
632:
PRINT #2, SPACES(i4);
: PRINT #2, USING f$; THR;
633:
PRINT #2, SPACES(15)i
: PRINT #2, USING f$; Tow
634:
PI

635:
PRINT #2, SPACES{il -
1)i : PRINT #2, USING "Supply Pressure

HVPj

636:
PRINT #2, SPACES(10);
: PRINT iZ, USING "Return Pressure = ##

RetP

637:
PI

638:
PRINT #2,

639:
END SOT

6401


641:
DEFSNG I

642:
SUB SetOutDev (Device!)

643:
PUSHW 6, 6, 20, 38, MPAL(2), MPAL(O)
644:
SETFRAME TRUE

645:
FRAMEWINDOW CURRENTWINDOW
646:
SHADOWINDOW CURRENTWINDOW, "R"
647:
OUTDEV 2, Device!

648:
POPW

649:
SETFRAHE FALSE

650:
END SUB

651:


652:
SUB StoreHistory

653:
FileNameWindow "STORE
Dpath$, "hst", b$, a$
654:
IF a$ - CHR$(27) THEN
EXIT SUB
655;
IF a$ <> "" THEN b$ -
a$
656:
IF b$ <> "" THEN

657:
a$ - DpathS + b$ +
".hst*
658:
CINTXT MIDLINE, "Storing..."
659:
COPY DpathS + MasterFileS + ".trap", a$
660:
ELSE

661:
FileAlert

662:
END IF

663:
END SUB

1-126

-------
INDEX
AIRCHANGES, A-4
AIRCLEAN, A-4
ALLOWABLEROOMSZ, A-4
AMBCONC, A-4
ARRAYIOTAL, A-5
Assumptions, 7, n
AVGCONCVAL, A-5
BALANCE, A-l, A-5, A-6, A-9, A-13, A-28, A-32, A-34, A-41, A-46, A-49,
A-53, A-55, B-80
BALANCEINIT, A-6
BARCATCH, A-6
BASICD, A-l, A-4, A-6, A-7, A-ll, A-12, A-14, A-21, A-22, A-28, A-29,
A-34, A-38, A-47, A-50, B-56
BASICDESIGN, A-6
BASICFLOQRPLANS, A-6
BUILD1NGSTAT, A-7
CALC, A-l, A-5, A-7, A-8, A-9, A-10, A-ll, A-12, A-22, A-27, A-28, A-29,
A-37, A-40, A-42, A-46, A-47, A-49, A-55, B-85
CALCCONC, A-7
CALCCONFIG, A-7
CALCFIRSTINIT, A-7
CALCINIT, A-8
CALCPOLAVGINIT, A-8
CALCRMTOTSK, A-8
CALCRHTOTSRC, A-8
CENTEROFROOM, A-9
CHANNELTOTAL, A-9
CHECKTIHE, A-9
CLEANERMENU, A-9
CLNAME5, A-10
COLOROF, A-10
CCMMANDHELP, A-10
COMMANDLINEPROC, A-10
Concentration Algorithm, 7
CONCINIT, A-ll
CONCVAL, A-ll
COPYALLRM, A-ll
COPYBOWN, A-ll
COPYRM, A-12
COPYUP, A-12
CYCLENAMES, A-12
CYCLEONI, A-12
CYCLICVAR, A-13
Index-1

-------
INDEX
DEFWINDOWS, A-13
DIRECTENIRYS, A-13
DISPLAYBALANCE, A-13
DISPLAYFILES, A-14
DISPLAYFLOVS, A-14
DISPLAYINDAT, A-14
DRAWARROW, A-
DRAWAVERAGES, A-15
DRAVCYCLES, A-15
DRAWDOORFLOWS, A-15
DRAWDOORS, A-15
DRAWDIIPCYCLES, A-16
DRAWFLOORPLAN, A-16
DRAWFLOWS, A-16
DRAWHALLDOOR. A-16
DRAWHALLFLOW, A-17
DRAWHISTWINDOWS, A-l?
DRAWLEGEND1, A-17
DRAWLEGEND2, A-17
DRAWLEGEND3, A-18
DRAVLEGEND4, A-18
DRAWLEGEND5, A-18
DRAWLOCATIONS, A-18
DRAWLOGHISTWINDOWS, A-19
DRAWOPENINGS, A-19
DRAWWINDOW, A-19
DRAWWINDOWFLOW, A-19
EDITMASTER, A-20
EDITNOTES, A-20
EQ$, A-20
EQD$, A-20
ERRMSG, A-21
EXPANDEDFLOORPLAN, A-21
Extra keystroke, A-l
FILEALERT, A-21
FILENAMEWINDOW, A-21
FILESHOW, A-22
FLOORGRAPHSETUP, A-22
FLOQRPLAN, A-22
Flow Balancing Algorithm, A-ll
Flow exponent, A-ll
GAXIS, A-22
GENCOPYS, A-23
Index-2

-------
GENSINK$, A-23
GENSDITRCE$, A-23
INDEX
GETLASTTIME, A-23
GRAPH, A-2, A-9, A-10, A-13, A-14, A-15, A-16, A-17, A-18, A-19, A-22,
A-24, A-25, A-26, A-27, A-41, B-29
GRAPEAVERAGE, A-24
GRAPHAVERAGECLOSE, A-24
GRAPHAVERAGEHIST, A-24
GRAPHAVERAGEINIT, A-24
GRAPHCYCLES, A-25
GRAPHFLOWS, A-25
GRAPHHISTORY, A-25
GRAPHICSD1SPATCH, A-25
GRAPHICSINIT, A-26
GRAPHICSRESTORE, A-26
GRAPHLOCATIONS, A-26
GRAPHLOGHISfORY, A-26
GRAPHMENU, A-27
GRAPHROOMS, A-27
GRPH, A-27
GRPHINIT, A-27
GRPHSHIFT, A-28
in, A-l
HALLCALC, A-28
HALLFLOWS, A-28
HALLPRESSUREAVG, A-28
Hardware Requirements, 3
HSCHED, A-29
HVACCALC, A-29
HVDESCRIPTION, A-29
IAQCOMMN, 8-10
1AQCONFIG, A-29
XAQLOGO, A—30
1AQHAIN, A-l, A-10, A-21, A-30, A-35, A-36, A-39, A-49, A-52, A-54, B-
IAQMENUS, A-2, A-4, A-6, A-7, A-10, A-12, A-13, A-14, A-20, A-21, A-22
A-23, A-29, A-39, A-40, A-41, A-42, A-45, A-48, A-49, A-51,
A-53, A-54, A-55, B-98
IAQPC, A-l, A-20, A-30, A-36, A-37, B-2
IAQSUBP, B-9
IHHDAT, A-30
INPAGE1,	A-30
INPAGE2,	A-30
INPAGE3,	A-31
INPAGE4,	A-31
Index-3

-------
INDEX
INFAGES,	A-31
1NFAGE6,	A-31
INF AGE 7,	A-3 2
INFAGES,	A-32
INBM, A-32
IN1MAISCLEAN, A-32
INRMCYCLES, A-33
INRMINITCONC, A-33
INSMSINK5, A-33
INRMSOURCE, A-33
INROOM, A-2, A-ll, A-12, A-32, A-33, A-48, A-51, B-20
INTEG8ALFLOW, A-34
INTERCONMENU, A-34
INTERCONNlCfIONS, A-34
INTERCONSET, A-34
LDBASICDESIGNFILE, A-35
LDCLEANERFILE, A-35
LDHVACFILE, A-35
LDIN1HFILE, A-35
LDMASTERFILE, A-36
LDPOLFILE, A-36
LETTERA, A-36
LETTERC, A-36
LETTERI, A-3?
LETTERP,	A-37
LETTERQ,	A-37
LIMCONC,	A-37
LOABBASICDESIGN, A-38
LOADCLEANER, A-38
LOADHISTORY, A-38
LOADHVAC, A-38
LOADIAQCONFIG, A-39
LOADINBM, A-39
LQADMASTER, A-39
LOADPOLLUTANTS, A-39
/M, A-l
MAINMENU, A-40
HASTERCALCINIT, A-40
MASTERCALCRUN, A-40
MAXOF, A-40
MAXTIHE, A-41
MAXVECTORX, A-41
Index-4

-------
INDEX
MODIFYCONFIG, A-41
Modules, 3, A-l
OFINDATAFILIZ, A-41
OPENMENTJSCREEN, A-42
OPENTMPFILE, A-42
OPERATINGMENU, A-42
OUTCONC, A-42
OUTPUT, A-2, A-14, A-30. A-31, A-32, A-38, A-43, A-44, A-46, A-47,
A-53, A-54, B-114
OUTPUTCONC, A-43
OUTPUTFLOWS, A-43
OUTRES, A-43
PAGEHEADER, A-43
Philosphy and Background, 2
PL, A-44
POLAVG, A-44
POLLHIST, A-44
POLLIM, A-44
POLLUTANTMENU, A-45
POLNAMES, A-45
POLSETUP, A-45
POLSETUPB, A-45
POLSRC, A-46
PRESSUREAVG, A-46
PRINTCH, A-46
PRNTCONC, A-46
PRNTFLOWS, A-47
Program Listing, B-l
Program Maintenance, A-l
Programing Language, 2
PRTCHCONC, A-47
PRTCHFLOWS, A-47
PRTPROCESS, A-47
PSINK, A-48
QuickBASIC 4.0, 2
RMDIS, A-48
RMOD, A-48
RMS TAT, A-48
RNCHAKGE2, A-49
ROOMCALC, A-49
ROOMDAT, A-49
ROOMFLOWS, A-49
Index-5

-------
ROOMNUMBERS, A-50
INDEX
SAVEBASICDESIGN, A-50
SAVECLEANER, A-50
SAVEHVAC, A-50
SAVEIAQC0NFIG, A-51
SAVEINRM, A-51
SAVEMASTER, A-51
SAVEPOLLUTANTS, A-51
SELECTCLEANERS, A-52
SELECTPOLLIITANT, A-52
SETCLEANERPERF, A-52
SETDEFAULTS. A-52
SETOUTDEV, A-53
SINKSTR, A-53
SLIPCATCH, A-53
SQRP, A-53
SRCSTR, A-54
STDBOT$, A-54
STQRIHISTORY, A-54
STRENGTH, A-2, A-4, A-9, A-13, A-38, A-39, A-44, A-45, A-46, A-48, A-50,
A-51, A-52, A-53, A-54, B-71
SVMASTERF1LE, A-54
TOTALAREA, A-55
Units, 3
USI1AQMENU, A-55
VECTORAVG, A-55
VENTFLOV, A-55
Index-6

-------