home *** CD-ROM | disk | FTP | other *** search
- program Listing4-3;
-
- uses Tags, Crt, Graph, NewTags, PlotData;
-
- var
- LT100,
- FT100 : Analog;
- PSL100 : LoSwitch;
- PSH100 : HiSwitch;
- EY100 : NewPump;
- time : integer;
- SPress, PFlow, SFlow : Plot;
- GraphDriver, GraphMode : integer;
- Slice : integer;
-
- {$F+}
- function SystemPressure : real;
- begin
- SystemPressure := HtToPSI(LT100.GetValue);
- end;
- {$F-}
-
- procedure SetNewFlowRate( i : integer );
- begin
- if i > 1400 then FT100.PutValue(4000)
- else
- if i > 1000 then FT100.PutValue(500)
- else
- if i > 800 then FT100.PutValue(3000)
- else
- if i > 620 then FT100.PutValue(6600)
- else
- if i > 480 then FT100.PutValue(8600)
- else
- if i > 240 then FT100.PutValue(7000)
- else
- if i > 120 then FT100.PutValue(4000)
- else
- if i > 60 then FT100.PutValue(5000);
- end;
-
- begin
-
- GraphDriver := Detect;
- InitGraph( GraphDriver, GraphMode, '' );
- Graph.SetColor( white );
-
- Slice := GetMaxY div 6;
-
- SPress.Init( 40, 100, 1,
- 0, 1440, 1,
- 50,GetMaxX-50,0,2*Slice-20,
- 0,0,1,2,
- 'SystemPressure vs. Time', 't, min', 'psi',
- false );
- PFlow.Init( 0, 100, 100,
- 0, 1440, 1,
- 50,GetMaxX-50,2*Slice,4*Slice-20,
- 0,0,1,2,
- 'Pump Discharge Flow vs. Time', 't, min', 'gpm (x100)',
- false );
- SFlow.Init( 0,100, 100,
- 0,1440, 1,
- 50,GetMaxX-50,4*Slice,6*Slice-20,
- 0,0,1,2,
- 'System Flow vs. Time', 't, min', 'gpm (x100)',
- false);
-
- SPress.DrawHGridLine( 60 );
- SPress.DrawHGridLine( 75 );
- SPress.PlaceYAxisValue( 60 );
- SPress.PlaceYAxisValue( 75 );
-
- Quiet.On; { to shut up the Digitals }
- LT100.Init( 'LT100', 2048, 50, 250 );
- FT100.Init( 'FT100', 2048, 0, 10000 );
- PSL100.Init( 'PSL100', 60, SystemPressure );
- PSH100.Init( 'PSH100', 75, SystemPressure );
- EY100.Init( 'EY100', off, 100, 4.8e-7, @SystemPressure);
-
- for time := 0 to 1440 do
- begin
- { adjust level for water leaving tank }
- LT100.PutValue( LT100.GetValue - FlowToDeltaHt(FT100.GetValue) );
- { figure out PSL and PSH readings }
- PSL100.PutReading( SystemPressure );
- PSH100.PutReading( SystemPressure );
-
- if PSL100.GetStatus = on then
- EY100.PutStatus( ON );
- if PSH100.GetStatus = on then
- EY100.PutStatus( OFF );
- LT100.PutValue( LT100.GetValue + FlowToDeltaHt( EY100.Flow ));
-
- SPress.AddPoint( time, SystemPressure );
- PFlow.AddPoint( time, EY100.Flow );
- SFlow.AddPoint( time, FT100.GetValue );
-
- SetNewFlowRate( time );
- end;
-
- repeat until KeyPressed;
- RestoreCRTMode;
- end.
-
-