previous contents next
Previous: Variables Next: Some More Advanced Examples

A Simple Example

In the following we show how server commands, variable substitution and client commands can be combined in order to create a small environment which can be used for generating Enif plots automatically.

In the following header file named plotgen.sen, all necessary Enif parameters are created and grouped to the corresponding Enif system parameters with which they have to synchronize their values, and some functions are defined which can afterward be called to perform specific tasks:

new Integer Scenario
Scenario : $LoadScenario/

new String PlotConf
PlotConf : $LoadPlotConfiguration/

new Box View
View : $CurrentView/

new Click FullView
FullView : $FullView/

new Integer ExportEnlargementFactor
ExportEnlargementFactor : $ExportEnlargementFactor/

new String ExportScreenView
ExportScreenView : $ExportScreenViewToFile/

new Click PrintView
PrintView : $PrintCurrentViewNoSetup/

!function scenario SCENARIO
!begin
  !if 0 < {SCENARIO}
  Scenario[1] = {SCENARIO}
  echo Scenario %<$ScenarioNumber>%: %<$ScenarioTitle>%
!end

!function view VIEW
!begin
  !print Changing view to {VIEW} ...
  !if full == {VIEW}
    FullView = 1
  !if airport == {VIEW}
    View = -10;-3;-7;3;Airport;
  !if cbd == {VIEW}
    View = -3;-3;3;3;CBD;
  !if kildonan == {VIEW}
    View = -1.2;1.5;4.2;4.8;Kildonan corridor;
!end

!function plot CONFIGURATION
!begin
  !print Loading {CONFIGURATION} ...
  PlotConf = {CONFIGURATION}
!end

!function action
!begin
  # variable ACTION is defined outside!
  !if prompt == {ACTION}
    !prompt Continue?
  !if wait == {ACTION}
    !wait 5
  !if print == {ACTION}
  !begin
    PrintView = 1
    !print Printing view ...
  !end
!end

!function export FILENAME
!begin
  ExportScreenView = {FILENAME}
  !if export == {ACTION}
    !print Exporting view to file {FILENAME} ...
!end

The above header file does not produce itself any visible results, but it implements the five simple functions which can afterward be called by the task definition file as follows:

!call scenario scenarionumber
 
Loads the scenario with the given number into the primary network.

!call view viewname
 
Changes to the current view to one of the predefined views full, cbd, airport or kildonan.

!call plot plotconfiguration
 
Loads the specified plot configuration file.

!call action [wait|prompt|print]
 
This function represents a general processing routine that can be called to perform some action after a plot has been generated. Which action is taken by this function depends on the supplied parameter. If it's called with the parameter wait, it will wait for a few seconds before proceeding with the following commands. If it's called with the parameter prompt, it will issue a prompt message and wait for a user input before proceeding. If it's called with the parameter print, it will generate a printout of the plot. Finally, if none of these parameters is specified, no action is taken and the processing of the following commands continues.

!call export filename
 
Generates and exports an image file containing the current view. If needed the value of the parameter ExportEnlargmentFactor can be changed before calling this function, in order to change the resolution of the generated image file.

Based on the commands defined in the header file plotgen.sen it is now possible to define a specific plot generation task quite easily. E.g. the following task file volumeplots generates auto volume plots for three different views and one transit volume plot for the CBD:

!include plotgen.sen
!call scenario {SCENARIO}
!call plot autovol.e2p 
!call action
!call view cbd
!call action
!call view kildonan
!call action
!call plot transitvol.e2p 
!call view cbd
!call action

If we now call SEnC with the header and the task file, i.e.

        senc -l volumeplots

The four plots will be generated one after the other for the default scenario of the data bank. But this will be done very quickly and except for a rapidly flickering screen, not much will be seen.

We can now use variable substitution to define the scenario to be used with a command line argument of the form ``SCENARIO=...'', as well as the action to be taken for each plot with an argument ``ACTION=...''. Note that for achieving the desired results, these variable specifications should be put after the header file and before the task file.

Thus, the command

        senc -l ACTION=wait SCENARIO=1000 volumeplots

will generate the same plots as before, but this time for the specified scenario 1000, and after each plot it will pause for a few seconds to give the user a chance to look at it.

Similarly, the command

        senc -l ACTION=print SCENARIO=3000 volumeplots

will generate the four plots for scenario 3000 and send them to the default printer. Reduced versions of the four resulting printouts are shown below:

\fbox{\includegraphics[width=39mm]{plot3000autofull}} \fbox{\includegraphics[width=39mm]{plot3000autocbd}} \fbox{\includegraphics[width=39mm]{plot3000autokil}} \fbox{\includegraphics[width=39mm]{plot3000transitcbd}}

Image plot3000autofull
Image plot3000autocbd
Image plot3000autokil
Image plot3000transitcbd


previous contents next
Previous: Variables Next: Some More Advanced Examples

SEnC - A Sequential Enif Client, Heinz Spiess, May 2003