[esp-r] Re: Perl script

Jon Hand jon at esru.strath.ac.uk
Wed Jul 28 08:21:59 BST 2010


There is perhaps a misunderstanding about how scripts drive esp-r modules.

ESP-r modules can be invoked in a text-only mode and each of the menus that
would normally be seen in the graphic mode are selected by a single character.
Essentially, if you can do a task in ESP-r manually what you want to do is
to capture the sequence of key strokes you used and embed them in a script.

These scripts are not invoking a 'method', they are navigating the interface and
driving the interface to do a specific task (which should work as long as the interface
does not change).

So first become familiar with the ESP-r interface.  It is possible to create a model
from scratch via commands and it is possible to take an existing model and
alter aspects of the model via commands.  And before going to all of that trouble
it would be useful to consider what the other options are.   

There is a so-called META file which is a somewhat compact text file that some 3rd party
software uses to pass information about building to ESP-r.

The ESP-r Developers Guide includes an API for ~hundred subroutines and lots of 
other information that might be helpful to you.

What is unclear is the big picture of what it is you are trying to do and your goals.
If you could provide an outline then it might focus the discussion.

-Jon Hand
________________________________________
From: victor bunster [victorbunster at gmail.com]
Sent: 28 July 2010 01:34
To: Aizaz Samuel
Cc: esp-r at lists.strath.ac.uk; David Garcia; Jon Hand
Subject: Re: [esp-r] Re: Perl script

Thanks for all the feedback, its helping me a lot.

I have a couple of more basic questions, I'm not used to ESP-r scripting "environment" (I come from other software with embedded scripting functionality, like ecotect or rhino). I have noticed that many of the scripts use the C:\ shell, but I have a couple of problems to advance in that path.
First, I don't know how to run the software's commands, is there any document with the methods or an API guide? for example if I want to create a zone, how do I call that method from inside the shell?
The other question regards the possibility to write longer code, for example: create a zone, then 10 windows, assign material, etc... all in one block. I think this should be done in Perl (or Python) but I don't know how to run it and connected to ESP-r methods.

Thanks again,

Victor



On Tue, Jul 27, 2010 at 8:40 PM, Aizaz Samuel <aizaz.a.samuel at strath.ac.uk<mailto:aizaz.a.samuel at strath.ac.uk>> wrote:
Some instances where scripts have been used in the past:
1. ESP-r modelling of domestic heating systems (ADEPT2 available from
sesg.strath.ac.uk<http://sesg.strath.ac.uk>) has scripts that simulate and list the results into csv
files that are readable by spreadsheet macros.
2. Simulation of test models that simulate and write out results in pdf
format. These are used for running comparison tests periodically and writing
out a nicely formatted report.
3. Running regression testing that involves subversion commands, forcheck,
compilation, simulation, results analysis and some other software testing
tasks. (Available at
https://espr.svn.cvsdude.com/esp-r/trunk/tester/scripts/)

The first two use bash and c shell scripts the last one uses perl

Regards,
--
Dr Aizaz A Samuel
Department of Mechanical Engineering
University of Strathclyde
M324 James Weir Building
75 Montrose Street
Glasgow, UK
G1 1XJ

T:+44 141 548 5765
F:+44 141 552 5105


On Tuesday 27 July 2010 10:57, David Garcia wrote:
> Normally it should be perl but other users told me that python is more
> useful,
>
> Personaly I used PERL, to start programming, I recommend you to read the
> book "Learning Perl" from Randal L.Schwartz,(O'reilly).
>
> Normally your perl file should look like this: (FOR YOUR CHANGE GEOMETRY
> SECTION)
>
> --------------------------------------------------------------
> $file = $ARGV[0];
> $largo = $ARGV[1];
> $ancho = $ARGV[2];
> $alto = $ARGV[3];
> $angulo = $ARGV[4];
> $base = $largo*$ancho;
>
> # Parse the perl sign pound (#)
> $val = "#";
>
> # open up MYFILE for writing
> open(MYFILE,">$file");
>
> #or die "Can't open up myfile: $file\n"; if we want the file to be readed!
>
> # now this line format will automatically apply to MYFILE
> format MYFILE =
> @<geometry of test_zonep defined in: ../zones/test_zonep.geo
> $val
> GEN  test_zonep  test_zonep describes a for testing in perl  # type, name,
> descr 8       6   @###.###    # vertices, surfaces, rotation angle $angulo
> @< X co-ord, Y co-ord, Z co-ord
> $val
>       0.00000     0.00000     0.00000  # vert   1
>    @###.#####     0.00000     0.00000  # vert   2
>     $largo,
>    @###.#####  @###.#####     0.00000  # vert   3
>     $largo,   $ancho
>       0.00000  @###.#####     0.00000  # vert   4
>           $ancho  .... CONTINUE
> ----------------------------------
>
> and you can invoke it in linux by type:
>
>
> ./changegeo.pl<http://changegeo.pl><http://changegeo.pl> ARGV1 ARGV2 ARGV3
>
> then for your SIMULATE option check the cookbook for runing espr in text
> mode.
>
> you can so do a for in a bash file, and then take out the value you are
> interested with "awk" (a language like perl) using this command: (FOR YOUR
> EVALUATE SECTION)
>
> awk '/Totals/ {print $2 "\n"}' prueba$i.cfg.wc_res.data > TOTAL
>
> then put your statement
>
> if Total == ValueYouWant
>
> Exit for
>
> and then voilà! :)
>
> Is a little bit rudimentary but I hope this could help you.
>
> Regards
>
> --
> David GARCIA SANCHEZ
> ------------------------------------------------------------
> Département Systèmes Énergétiques Environnement
> Ecole des Mines de Nantes
> 4, Rue Alfred Kastler
> 44300 Nantes
> France
> ------------------------------------------------------------
> Email: david.garcia-sanchez at emn.fr<mailto:david.garcia-sanchez at emn.fr><mailto:david.garcia-sanchez at emn.fr<mailto:david.garcia-sanchez at emn.fr>>
> Tel: +33 (0) 2 51 85 82 14
> Mobile: +33 (0) 6 78 15 08 09
> Fax: +33 (0) 2 51 85 82 99
> ------------------------------------------------------------




More information about the esp-r mailing list