Giter VIP home page Giter VIP logo

Comments (14)

maxime-esa avatar maxime-esa commented on July 30, 2024

In Python2, you can do:

import opengeode

and then:

ast = opengeode.parse ([set of .pr files])

From there you can find the SDL Process like this:

   root_ast = ast[0]
   proc = root_ast.processes[0]

All the AST is described in ogAST.py

There are many possibilities - in addition to looking into the model. You can render it in a window and interact, by e.g. highlightning symbols. That's what is done by the SDL simulator prototype.

Let me know if you need help.

from opengeode.

taheruddin avatar taheruddin commented on July 30, 2024

Thanks for the reply. Also, I need to modify the AST (such as add state, input, transition) and write back to the file. Would you please give some direction on How to do this?

from opengeode.

maxime-esa avatar maxime-esa commented on July 30, 2024

The best is to look at ogAST.py. You can create new nodes, and add them to the tree..
This is what ogParser.py is doing when parsing the output of ANTLR. You can check this one as well.

Then to write back to a .pr, you have to look at the Save function in opengeode.py.

from opengeode.

taheruddin avatar taheruddin commented on July 30, 2024

Thanks for the direction. By reading ogParser.py I am trying to know how to add a node. But, failed. Would you please give a trivial example of adding two states and a transition between these states. Something like below -

s0 = ogAST.Start()
s1 = ogAST.State('S1')
inp = ogAST.Input('press')
s2 = ogAST.State('S2')
root_ast.processes[0].add([s0, s1, imp, s2])
opengeode.save()

Big thanks in advance.

from opengeode.

maxime-esa avatar maxime-esa commented on July 30, 2024

Are you trying to create a model from scratch or add some elements to an existing model ?

from opengeode.

taheruddin avatar taheruddin commented on July 30, 2024

My aim is to create a model from scratch, but easy my work, I am creating a project in TASTE first, then I work in data-view and interface-view to get an almost blank model OpenGEODE. Then I am trying to get the handle on the blank model and edit it (add states, transitions).

from opengeode.

maxime-esa avatar maxime-esa commented on July 30, 2024

In that case the easiest is to generate the SDL model in text form and to let OG parse it (using the "parse" API). This will be much easier than trying to add nodes using the AST.

from opengeode.

dondublon avatar dondublon commented on July 30, 2024

It seems, opengeode module still support only Python 2?

from opengeode.

maxime-esa avatar maxime-esa commented on July 30, 2024

@dondublon : No, I ported opengeode to Python3. This is the current baseline, the Python2 code is not is the master branch anymore.

from opengeode.

dondublon avatar dondublon commented on July 30, 2024

@maxime-esa Thank you for the answer.
Could I ask about the installation process? Maybe, here is not the appropriate branch.
opengeode requires antlr3. I installed antlr4 successfully, but failed antlr3. The error:

 File "C:\Users\s2400244\AppData\Local\Temp\pip-install-rx7p4qmy\antlr3-python-runtime\setup.py", line 49
        except OSError, exc:
                      ^
    SyntaxError: invalid syntax

This is Python2 syntax, that is why I suspected that opendeoge is for Python2.

from opengeode.

maxime-esa avatar maxime-esa commented on July 30, 2024

The installation of dependencies should be done automatically if you do:

 make full-install

(In a Debian-based Linux)

from opengeode.

dondublon avatar dondublon commented on July 30, 2024

But I'm on Windows.

from opengeode.

maxime-esa avatar maxime-esa commented on July 30, 2024

To be honest, I have never tried to run the Python3 version on Windows.
In the past (Python2 version) I made a build for Windows, using dependencies I had found here: https://www.lfd.uci.edu/~gohlke/pythonlibs/

However I can see that the antlr3 runtime for Python3 is not there, neither is Pyside2... I would not know how to find them. Any help welcome. If you find out I will update the documentation.

from opengeode.

dondublon avatar dondublon commented on July 30, 2024

The antlr3 proclaimed for Python3 is actually for Python2. I fixed it manually, it was a real quest. Firstly I downloaded .gz from PyPi, and at last I had to replace one file from Github (antlr3 repository).
The last obstacle I've faced is installing pygraphviz. So, I drop this direction and switched to another modelling tool, a experiment, too.

from opengeode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.