Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

Re: Stand alone version of Cormas Model

New Message Reply Date view Thread view Subject view Author view

Subject: Re: Stand alone version of Cormas Model
From: Jean-François LEFEVRE (jflefevre@oxiane.com)
Date: Fri May 14 2010 - 18:45:51 CEST

Hi Deborah (and all readers),

I'm in contact with Mathias and he tells me about this forum and your
problem.
I'm the guy who help Mathias last year to bring the role playing game
"MottePiquet" to a deployed application at Oceanopolis.

I will try to explain you why it's difficult to make a Stand alone
application with Cormas and how it can be possible.

Before, you must understand some concepts :

1/ Deploying application with Smalltalk was traditionnaly a painfull process
since it consists to remove the "dev tools" parts of the Smalltalk image.
   Some tools was developed and the RuntimePackager is the one delivered
with VisualWorks

2/ The documentation delivered with VisualWorks contains some usefull
informations about this step in the application lifecycle
    With VisualWorks, you have two main possibilities for packaging your
application :

    a) build a stripped monolithic image containing your application
    b) build a minimal image and arrange you to load your application at
runtime, usually done by packaging your application in one or more parcels

    Obviously, you can mixte between these two extrems : building a runtime
image containing some stable part of your application and package
    the other part in parcels.

    In the following, I choose the simplest scenario : building a monolithic
stand-alone image

3/ Deploying a VisualWorks application can be a complex and painfull
process, depending of 3 things :

     - your knowledge about VisualWorks
       I assume that, as Mathias, your job is not to understand the
complexity of VW but you use it as a nice tool for your researchs

     - the level of the desired completion for this process
       Keep in mind that VisualWorks comes from a time where memory was a
big problem. In 1995, a "standard" pc for a user
       under Windows 3.1 had 4Mb and VisualWorks was a very big application
for these systems. Actually, VisualWorks is relatively small
       comparing to others applications.
       Many of the RuntimePackager options exists for gaining a chance to
eliminate useless objets, classes and methods but its rarely
       usefull now comparing to the pain.

     - your application
       Some applications are very simple to package, some others use some
facilities from VisualWorks and particularly from the dev environment.
       Unfortunately, Cormas is in this category.
       Depending of what you expect to deploy, you will encounter some
problems. The loading and initialization steps of a Cormas model is a
       source of problem. If you can eliminate this steps, it will be more
simple to deploy your Cormas application.

Now, I will explain the steps for building a runtime image with the Conway
model loaded and ready to run.
I assume you have already installed VisualWorks (I use the 7.6nc),
downloaded cormas and the Conway model in the proper directory.

1/ load cormas in a fresh new image (loading the cormas parcel)

2/ load the Conway model

3/ initialize your model (Open Simulation Interface, Visualization Space,
load env, choose the methods for init and control,
   choose the pov in the visualization space, ...)

   at this step your Cormas application is ready to run.
   The goal is to open the runtime image with these steps already done so
the user will press directly the step button.

4/ press F12 (its a shortcut for accessing to the VisualWorks Launcher which
was closed)

5/ Load the RuntimePackager parcel

6/ Unfortunately, there is a bug in the 7.6 runtime packager. If you use
this version, you have to apply a patch (Res94469).
   Search on the web for "Res94469", you will find the file Res94469.zip
containing the patch.
   Unzip this file and load Res94469.st in the image

7/ Fix a problem in the method Cormas class>cormasPath
    cormasPath
    "Returns a Filename corresponding to the path of Cormas directory.
    Ex: a FATFilename('d:\vw7nc\cormas')"

    ^ObjectMemory imageDirectory " JFL : this can work in runtime, the old
code expect an access to source file "
     "^SourceFileManager default targetFile logicalName asFilename
directory"

At this step, it can be usefull to save the image (save as ... conway.im by
exemple)

8/ We can now start the process of stripping the image.
    Open the Runtime Packager (from the Tools menu).
    You will be guided from multiple optional steps. You can skip a step
using the buton [Next >>] or do the step using [Do this step]

     Overview : click on [Next >>]
     Clean up image : its recommanded to start the process in a fresh image,
after loading your code so you have nothing to clean. [Next >>]
     Set common options : this step is important for our context. click [Do
this step].
             you have now six sub-steps
             - Basics : since we leave the applicative window already open,
there is nothing to do here (you can change the name "runtime")
             - Details : some of these options are very important.
                       [ ] Remove compiler classes : you can check this box
unless you expect to load some source code (.st, not parcels)
                       [ ] Skip default scan for unreferenced items : you
should check this box (we don't want trying to suppress any useless object)
             - other boxes are probably not important for you
     Platforms : you can uncheck some of them if you don't want of
multi-platform system
     Exceptions : nothing to do here
     Parcels : nothing to do here
     Stripping : this is the second very important panel for you
                 [ ] Remove system organization : you should uncheck this
box since the "Init window needs access to the categories of methods
                 [ ] Remove unreferenced globals : you should uncheck this
box since we don't want the system remove any useless class
                 the others boxes have probably no interest for you
      Specify classes and methods to keep : since we don't search for
unreferenced object, we have nothing to do : [Next >>]
      Scan for unreferenced items : we don't want any automatic search [Next
>>]
      Review kept classes and methods : no interest [Next >>]
      Save runtime loadable parcels : since we choosed a monolithic image,
there is no parcel to save [Next >>]
      Test application : as said a friend : "testing is doubting" :-) [Next
>>]
      Set runtime memory parameters : you probably don"t need (and want) to
enter in this optimisation section [Next >>]
      Strip and save image : your Grail is after this button. click, confirm
and wait.

You should obtain a runtime.im you can run.

Note : if you miss the init step of your model and pov in the visualization
(or if you change your pov), you can encounter
a second problem with Cormas.
The method Legend>prepareLegend: aClass pov: aPovName use explicitly the
source code of method. It's typically some
thing a runtime application should not do.
I don't understand all the goal for this method. I think it can be modified
as following :

Replace the line :
    aText := (aClass compiledMethodAt: aPovName asSymbol) getSource.""

by :
    "aText := (aClass compiledMethodAt: aPovName asSymbol) getSource."
    aText := (aClass sourceCodeAt: aPovName asSymbol). "JFL : obtain
decompiled code if no source available"

Unfortunately, this decompilation need some aspects of the compiler so you
should not remove it in the "Set common options" step

In conclusion :
There are many difficulties you can encounter when you want to package your
application.
Some comes from the process but you can easily bypass these useless steps
since the memory is usually no longer an issue
Some other come from Cormas itself since it seems not designed with
deployment issue in mind but we can easily work around
these constraints.
And finally, some others come from what you want to deploy exactly.
Deploying a monolithic, stand alone image is the simplest scenario.
Some others, like the one I used for MottePiquet is more complex but have
some big interests.

I hope this will be helpfull for you and other Cormas users.
I just join the group and I will try to follow your community as far I can
(but I have not really a direct interest for Cormas).

Regards,
Jean-François

Dear all,
>
> Thank you so much for your prompt and helpful responses. Dr Mathias Rouan
> will be in touch next week to give me a hand, and I'll let you know how it
> goes (fingers crossed)
>
> Best
> Deb
>

-- 
Jean-François LEFEVRE
Consultant/Formateur
jflefevre@oxiane.com
www.oxiane.com

New Message Reply Date view Thread view Subject view Author view
 

Back to home