Skip to content
Snippets Groups Projects
Commit 7888efc9 authored by marrobl's avatar marrobl
Browse files

Avanzado la vista logica

parent c8508135
Branches
No related tags found
1 merge request!1Develop
...@@ -4,11 +4,15 @@ The [4+1 model view][4+1 model view], designed by Philippe Krutchen, present a w ...@@ -4,11 +4,15 @@ The [4+1 model view][4+1 model view], designed by Philippe Krutchen, present a w
The software architecture deals with abstraction, with decomposition and composition, with style and system's esthetic. To describe a software architecture, we use a model formed by multiple views or perspectives. That model is made up of five main views: logical view, development view, process view, physical view and scenarios or user cases. The software architecture deals with abstraction, with decomposition and composition, with style and system's esthetic. To describe a software architecture, we use a model formed by multiple views or perspectives. That model is made up of five main views: logical view, development view, process view, physical view and scenarios or user cases.
## The Physical View * The Physical View: describes the mapping of the software onto the hardware and reflects its distributed aspect
## The Development view * The Development view: describes the static organization of the software in its development environment.
The development view describes the static organization of the software in its development environment. * The logical view: is the object model for the design
* The process view: captures the concurrency and synchronization aspects of the design
* The scenarios: show how the four views work together seamlessly
<!-- Falta explicar todas las vistas... igual hago una lista mejor para explicarlas por encima y ya --> <!-- Falta explicar todas las vistas... igual hago una lista mejor para explicarlas por encima y ya -->
...@@ -40,10 +44,24 @@ In [Main modules of PySD] **pysd**, **vensim2py** and **table2py** modules are p ...@@ -40,10 +44,24 @@ In [Main modules of PySD] **pysd**, **vensim2py** and **table2py** modules are p
The **pysd** module has the necessary functions to allow the user to create the translation of a Vensim model to Python. The function **read\_vensim** takes as a parameter a Vensim model in text format and converts it to an instance of the Model class, which is in the **functions** module. In the same way, **pysd** has **load** function, which can generate from a Python model to an instance of *Model* class, which can be able to execute and perform the simulation. The **load** function is used within **read\_ vensim** function. The **pysd** module has the necessary functions to allow the user to create the translation of a Vensim model to Python. The function **read\_vensim** takes as a parameter a Vensim model in text format and converts it to an instance of the Model class, which is in the **functions** module. In the same way, **pysd** has **load** function, which can generate from a Python model to an instance of *Model* class, which can be able to execute and perform the simulation. The **load** function is used within **read\_ vensim** function.
![Main modules of PySD] ![Main modules of PySD]
The table2py module has only one function, **read_tabular**. This function allows to read a Vensim model in table form (csv, tab or xlsx) and convert it into an instance of Model class. The table2py module has only one function, **read_tabular**. This function allows to read a Vensim model in table form (csv, tab or xlsx) and convert it into an instance of Model class.
In addition, **vensim2py** is represented in that diagram. In **vensim2py**, the five grammars of *PySD* are defined, with their associated classes which allows parser and get the information from a Vensim model.
The main function of the *vensim2py* module, which is also used by **read\_vensim** function of *pysd* module, is **translate\_vensim**. This function starts the translation process. The Vensim model is parsed with the first *pysd* grammar, *file\_structure\_grammar*, found within **get\_file\_sections** function. The *file\_structure\_grammar* divides the model into sections: the main section with the main code of the model and on the other hand, a section for each macro in the model. The obtained sections are passed as parameters to **translate\_section** function later.
The **get\_model\_elements**, **get\_equation\_components**, **parse\_general\_expression** and **parse\_lookup\_expression** functions have the four remaining grammars of *PySD* which are: *model\_structure\_grammar*, *component\_structure\_grammar*, *expression\_grammar* and *lookup\_grammar*, respectively. Moreover, after each of these functions, the NodeVisitor classes that are associated with each grammar are defined. These classes allow to perform and parse the parse tree.
Noteworthy is the **\_include\_common\_grammar** function which has the basic grammar rules used by all other grammars.
Due to the complexity of vensim2py, since it has the five functions in which PySD grammars and their visitor classes are defined, in [Simplified vensim2py module] it is represented without detail. These classes are: FileParser, ModelParser, ComponentParser, ExpressionParser and LookupParser. Note that these classes inherit from the NodeVisitor class, that provides an inversion-of-control framework for walking a tree and returning a new construct based on it.
![Simplified vensim2py module] ![Simplified vensim2py module]
In [Classes of pysd grammars] and [Classes of pysd grammar2] are represented the classes associated to the grammars.
![Classes of pysd grammars] ![Classes of pysd grammars]
![Classes of pysd grammars2] ![Classes of pysd grammars2]
The methods of each class are the visitor methods associated with the different grammar rules. There is not a visitor method for each rule, but there is a visitor method associated with a rule that serves to store certain information about the parsed model. Within the visitor method, that relevant information is stored in the attributes of each class, which are then returned as a result of the grammar.
![Simplified functions module] ![Simplified functions module]
![Functions module] ![Functions module]
![Functions module] ![Functions module]
![Builder module] ![Builder module]
...@@ -63,9 +81,11 @@ The table2py module has only one function, **read_tabular**. This function allow ...@@ -63,9 +81,11 @@ The table2py module has only one function, **read_tabular**. This function allow
![Process view 6] ![Process view 6]
## The physical view of PySD ## The physical view of PySD
*PySD* system is deployed on a single workstation and everything that is needed is in the same component. Therefore, capturing the physical view of PySD in a deployment diagram would not add more information about the system. *PySD* system is deployed on a single workstation and everything that is needed is in the same component. Therefore, capturing the physical view of PySD in a deployment diagram would not add more information about the system.
## Scenarios ## Scenarios
Two main scenarios can be distinguished throughout the Two main scenarios can be distinguished throughout the
*PySD* library project. The process of **translating** a model from Vensim to Python is the first scenario. The second scenario found is the **execution** of that translated model before, which allows the simulation to be carried out and allows the user to obtain the results of the Vensim model. *PySD* library project. The process of **translating** a model from Vensim to Python is the first scenario. The second scenario found is the **execution** of that translated model before, which allows the simulation to be carried out and allows the user to obtain the results of the Vensim model.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment