Giter Club home page Giter Club logo

modeltranslator's Introduction




Carthage compatible Carthage compatible Carthage compatible Carthage compatible Carthage compatible

MODEL TRANSLATOR


Translate XML model into Python code
Visit our website for full documentation »

View current process · Report Bug · Request Feature




TABLE OF CONTENTS

  1. About The Project
  2. Getting Started
  3. Usage
  4. Current features
  5. Roadmap
  6. Testing Schedules
  7. License
  8. Contact


About The Project

This project will assist developers in implementing custom IoT systems.

Here's why you should use this:

  • Users who want to design automata with UPPAAL but have no idea what to do with the generated XML file.
  • Users who want their modeled diagrams to run on a Rasberry Pi device.
  • Users who want to test out IoT environment with the modeling tool (UPPAAL).

(back to top)

Tools Used With (Translator)


Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

Download UPPAAL to create your model

Demo Installation

  1. Clone the repo
    git clone https://github.com/TCC2021SeniorProject/ModelTranslator.git
  2. Download XML examples
  3. Run Main.py program
     cd ./MdoelTranslator/src
    

Valid model for tranlator


+Rules for a valid execution
  1. A model must be a valid model. The validity of the model can be checked in UPPAAL software. Any invalid UPPAAL model will cause a program crash.
  2. All variables must be defined. Any unidentified variables may cause errors either while using the software (translation) or executing output (Python code).
  3. All variable declarations must be valid, according to its template.
  4. Every node must have a unique identifier. Duplicate identifiers will result in overwriting of functions.


File structure

├── data
│   ├── xml_input_file.xml
│   ├── output_file.py
├── img
├── README.md
└── src
    ├── __init__.py
    ├── main.py
    ├── objects
    │   ├── model.py
    │   ├── node.py
    │   ├── transition.py
    │   └── variable.py
    ├── parser
    │   └── XML_parser.py
    └── translator
        ├── class_gen.py
        ├── function_gen.py
        ├── model.py
        └── py_export.py

Process logic flow




(back to top)

Current Features

  • The translator can handle the below features from UPPAAL

    • Identifies Start and End node by name (This feature will be changed to tag identification)
    • Change UPPAAL XML into abstract graph structure
    • Parse given global declaration from UPPAAL to variables
  • Transition object can handle:

      • Select (name)
      • Guard (conditionals)
      • Assignment (variable update in local)
    • Locate linked node sources

    • Each UPPAAL node name is converted to the function declaration in python.

    • Each transition point is converted to a function call in python



Example of how software works


  1. When producing a model such like this in UPPAAL
  1. Suppose there is a XML file given like this
  <?xml version="1.0" encoding="utf-8"?>
  <!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
  <nta>
    <declaration>// Global declarations. 
  int status1, charge1;</declaration>
    <template>
      <name x="9" y="9">Simple</name>
      <parameter>int &amp;mode,  int &amp;battery</parameter>
      <declaration>// Place local declarations here.
  </declaration>
      <location id="id0" x="-391" y="-323">
        <name x="-408" y="-357">End</name>
      </location>
      <location id="id1" x="-603" y="-323">
        <name x="-629" y="-357">Clean</name>
      </location>
      <location id="id2" x="-731" y="-323">
        <name x="-756" y="-357">Ready</name>
      </location>
      <location id="id3" x="-952" y="-323">
        <name x="-960" y="-357">Start</name>
      </location>
      <transition>
        <source ref="id1"/>
        <target ref="id0"/>
        <label kind="guard" x="-578" y="-340">mode == 4 || battery &lt; 10</label>
        <label kind="assignment" x="-535" y="-323">mode := 4</label>
      </transition>
      <transition>
        <source ref="id2"/>
        <target ref="id1"/>
        <label kind="guard" x="-705" y="-340">mode == 3</label>
      </transition>
      <transition>
        <source ref="id3"/>
        <target ref="id2"/>
        <label kind="guard" x="-926" y="-340">mode == 1 &amp;&amp; battery &gt; 10</label>
      </transition>
    </template>
    <system>// Place template instantiations here.
  r1 = Simple(status1, charge1);

  // List one or more processes to be composed into a system.
  system r1;</system>
    <queries>
      <query>
        <formula></formula>
        <comment></comment>
      </query>
    </queries>
  </nta>
  1. After running XML_parser, this will parse crucial data into graph objects. Below the image is output lines as a result of this conversion



  1. Then the parser automatically checks all the required data such as a starting state, an end state, infinity, and connectionless transitions.



(back to top)

  1. Finally, our program generates a python script file looking like below:
class TestClass:

	def __init__(self, ):
		print('Running constructor')
		self.status1 = 0
		self.charge1 = 0
		self.status2 = 0
		self.charge2 = 0
		self.status3 = 0
		self.charge3 = 0

	async def End(self):
		exit()

	async def Dock(self):
		await self.Ready()
		await self.End()

	async def Explore(self):
		if self.mode == 4 or self.battery < 10 :
			self.mode = 4
			await self.Dock()
		if self.mode == 3 :
			await self.Clean()


	async def Clean(self):
		if self.mode == 4 or self.battery < 10 :
			self.mode = 4
			await self.Dock()


	async def Ready(self):
		if self.mode == 3 :
			await self.Clean()
		if self.mode == 2 :
			await self.Explore()


	async def Idle(self):
		if self.battery > 10 and self.mode == 1 :
			await self.Ready()


	async def Start(self):
		self.mode = 1
		await self.Idle()


TestClass.Start()

Usage/Application

For more examples, please refer to the Design Documentation.

(back to top)

Roadmap

For more plans, please see the plan documentation.

Task 1 check list - Due October 16.

  • Update mark down documentation.
  • Create mock Python code output.
  • Make UPPAAL parser.
  • Program is able to traverse all the nodes through tranistion objects.
  • Program is able to identify the validity of the model.
  • Program is able to validate the node function (e.g. starting node, termination node, logic node, process node, etc)
  • Make Python code generator/converter.
  • Test simple diagram.

Task 2 check list - Due October 23.

  • Make complex diagram 1
  • Update(enhance) UPPAAL parser
  • Update(enhance) Python code generator/converter
  • Test complex diagram 1
  • Update (enhance) UPPAAL parser
  • Update (enhance) Python code generator/converter
  • Test complex diagram 1

See the open issues for a full list of proposed features (and known issues).


Testing Schedules


Case Testing Responder Due Date
Test case 1 Tony, Cameron, Cael Oct 9
Test case 2 Tony, Cameron Oct 17
Test case 3 Tony, Cameron Oct 23
Test case 4 Tony, Cameron, Cael Nov 21
Test case 7 Tony, Cael Dec 12
Test case 8 Tony, Cameron, Cael Dec 12

To view the specific testing details, click here

MCCD refers to Main Control Center Device.

  • Test case 1 (Due Oct 9): Produce code from a simple model
  • Test case 2 (Due Oct 17): Model comparatively massive size diagram
  • Test case 3 (Due Oct 23): Build infinite loops / Redundant transitions.
  • Test case 4 (Due Nov 21): Change models to python codes that MCCD accepts.
  • Test case 7 (Due Dec 12): Handling devices via web application on MCCD
  • Test case 8 (Due Dec 12): MCCD can be postponed until the device finishes its current job

(back to top)

Coding Style Convention

See the following link: Style Guide for Python Code

Follow rules for better readability: Clean Code by Robert C. Martin

Getter first, setter later for function definitions.

License

Currently, there is no license for this repo, meaning our team retains all rights to the source code and no one may reproduce, distribute, or create derivative works from our work.

This will not be permanent until the completion of the project.

(back to top)

Contact

Director

Dr. Siddhartha Bhattacharyya
Email: [email protected]

Developers

Sung-Jun Baek
Email: [email protected]
GitHub: MarcoBackman

Caelan Shoop
Email: [email protected]
GitHub: CCShoop

Cameron Wright
Email: [email protected]
GitHub: CameronWr

(back to top)

modeltranslator's People

Contributors

marcobackman avatar cameronwr avatar

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.