ThingML
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:The ThingML modelling language
![ThingML](Logotype_ThingML_100317_500px.png)

The ThingML approach is composed of *i*) a **modeling language**, *ii*) a set of **tools** and *iii*) a **methodology**. The modeling language combines well-proven software modeling constructs for the design and implementation of distributed reactive systems:

- statecharts and components (aligned with the UML) communicating through asynchronous message passing
- an imperative platform-independent action language
- specific constructs targeted at IoT applications.

The ThingML language is supported by a set of tools, which include editors, transformations (e.g. export to UML) and an advanced multi-platform code generation framework, which support multiple target programming languages (C, Java, Javascript). The [methodology](https://heads-project.github.io/methodology/) documents the development processes and tools used by both the IoT service developers and the platform experts.

> ThingML is distributed under the *[Apache 2.0 licence](https://www.apache.org/licenses/LICENSE-2.0)*, and has been developed by @ffleurey and @brice-morin of the Networked Systems and Services department of SINTEF in Oslo, Norway, together with a vibrant [open-source community](https://github.com/TelluIoT/ThingML/graphs/contributors). ThingML is now owned by [Tellu](http://www.tellucloud.com/), but remains open-source.

**Issues, bug reports and feature requests should be submitted to the [issue tracker on GitHub](https://github.com/TelluIoT/ThingML/issues)**


## Installing ThingML

*This section should contain up to date information about getting the latest version of ThingML and getting started with it.*

### Versions and Distribution

The current **recommended version of ThingML is version 2.X.X**. Tagged versions are available on the [Github release page](https://github.com/TelluIoT/ThingML/releases):

* A standalone JAR which can be used from the command line: look for the most recent `*.jar` file on the releases page
* An eclipse update site to install the ThingML IDE in eclipse: look for the most revent `*.zip` on the releases page

> **Version 1.X.X** is not maintained and should not be used (maintenance was stopped in Q3 2017). Version 2.X.X introduces a complete rewrite of the parser and editors based on XText. A few syntactical changes make the ThingML programs written for version 1 not compatible with version 2. There are also a few constructs which were evaluated in version 1 and were not re-implemented in version 2 (e.g. groups, streams, etc).

### ThingML Command Line Compiler

The ThingML command line compiler is distributed as a standalone JAR. It **requires Java 8 or newer**. The latest version (`*.jar`) can be found on [the releases pages](https://github.com/TelluIoT/ThingML/releases)

The command line tool contains all the code generators and plugins which are part of this repository.

**Usage:** `java -jar ThingML2CLI.jar` will provide usage information and a list of options.

### ThingML Eclipse-Based IDE

1. Install "Eclipse IDE for Java and DSL Developers" from the [Eclipse website](https://www.eclipse.org/downloads/).
2. Download the most recent update site (`*.zip`) from [the releases pages](https://github.com/TelluIoT/ThingML/releases).
3. Launch Eclipse
4. Install the ThingML plugins from the `*.zip` file: `Help -> Install New Software... -> Add... -> Archive...` 

**Usage:** Once ThingML plugins are installed, `*.thingml` files will open with the ThingML editors. Right-click on `*.thingml` files and use `HEADS / ThingML` sub-menu to compile a ThingML file. Generated code will be put in a `thingml-gen` folder at the root of the eclipse project. Remember that only ThingML files containing a `configuration` can be compiled.

### Docker-Based Distribution

> **Warning:** Currently the image on Dockerub is not automatically updated. You should build the image from the Dockerfile to get an up-to-date version of ThingML.

If you have docker, you can use the build container with Eclipse and ThingML at the [thingmleditor repository](https://github.com/madkira/thingmleditor) or the [thingmleditor docker hub](https://hub.docker.com/r/madkira/thingmleditor/)


## Sample ThingML programs

*The goal of this section is to give a list of example which should work out of the box*

> **Note:** over the years and versions, we have collected a lot of different samples and projects made with ThingML. However most of them are not maintained and updated to work with the latest version of ThingML. This might be confusing if you are getting started.

**Examples which should be working out of the box:**

* Basic Arduino examples: [https://github.com/ffleurey/ThingMLArduinoDemo](https://github.com/ffleurey/ThingMLArduinoDemo). The "1.Basics" folder contains a set of simple ThingML/Arduino programs dealing with digital IOs.

* Multi-platform Breakout game (Arduino, Posix C, Java and Javascript): [https://github.com/ffleurey/ThingML-PongTutorial](https://github.com/ffleurey/ThingML-PongTutorial). This example demonstrate how to create platform independent components with ThingML.

* Arduino <-> Java communication (Serial): [https://github.com/ffleurey/ThingML-PressureLogger](https://github.com/ffleurey/ThingML-PressureLogger). This program shows has to create 2 ThingML programs communicating over a serial port. One program is running on an Arduino and collects sensor measurement. The other is a running as a Java program collecting the measurement from the Arduino over the USB/Serial connection and displaying curves. This example is quite minimalistic but should be easy to customize for your own sensor/needs. It shows various features of ThingML like the Serial communication plugin and the possibility of adding Maven dependencies to your ThingML programs.

* Raspberry Pi GPIOs: [https://github.com/ffleurey/ThingML-RPI-Blink](https://github.com/ffleurey/ThingML-RPI-Blink)
A couple of very simple examples showing how to blink an LED on the Raspberry Pi using either C or NodeJS.

**Example having known incompatibilities:**

> **Note:** Some old samples may be easy to fix but other may use features which have been removed from ThingML.

* Example from the `org.thingml.samples` in this repository. This folder contains many samples which were made with various versions of ThingML. It is good to explore to see different things that can be done with ThingML but it is not the place to get working samples when getting started.

* Tutorials from the HEADS project: [https://github.com/HEADS-project/training/tree/master/1.ThingML_Basics](https://github.com/HEADS-project/training/tree/master/1.ThingML_Basics). This tutorial is based on ThingML v1.0 which is no longer maintained.


## Compiling ThingML Generated Code

*The ThingML compiler generate platform specific source code in C, Java, Javascript or Go. This section give short guidelines on how the generated code should be complied and executed.*

### JAVA / Maven
---

When compiling to Java, ThingML creates a complete Maven project which is ready to build with `mvn clean install` and execute with `mvn exec:java`.

**Prerequisites:**

- Make sure you have a proper [JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html) (a JRE is not sufficient)
- Install [Maven](http://maven.apache.org/)


**Using Eclipse:**

Configure Eclipse so that it uses the JDK: `Window -> Preferences -> Java -> Installed JREs` (make sure it points to a JDK)

- Right click on `pom.xml` (in `thingml-gen/java/your-configuration`)
- `Run as -> Maven build... `
- In `Goals` type: `clean install exec:java`

> If Maven claims it cannot find a `pom.xml` file, change the base directory in the `Run as -> Maven build...` window using the `Workspace...` button, so that it points to `thingml-gen/java/your-configuration`.

### javascript for web browsers
---

Nothing special. Open the generated `index.html` file in your System Browser (ideally Chrome or Firefox)

> Do not use the default web browser embedded into Eclipse!

### Javascript for Node.JS
---

ThingML creates a standard Node.js package.

**Prerequisites:**

- NodeJS: Install [Node.JS](https://nodejs.org/en/)

**Using Eclipse:**

From this update site: `Node.JS - http://www.nodeclipse.org/updates/enide-2015/`, install `Features included in Enide Studio .Features Set` and `Nodeclipse Node.js .Features Set	1.0.2.201509250223`

- Right click on `package.json` (in `thingml-gen/nodejs/your-configuration`)
- `Run as -> npm install `
- Right click on `main.js`
- `Run as -> Node Application`

### Visualize UML Diagrams (PlantUML)
---

The files generated by the UML generator are text files which uses the PlantUML format. PlantUML will perform the layout and export the diagrams as images.

**Prerequisites:**

- Install [Graphviz](http://www.graphviz.org/Download.php)
- Install [PlantUML](http://plantuml.com/) (not needed if using the Eclipse plugin)

**Using Eclipse:**

Install PlantUML plugins in Eclipse using this update site: `http://hallvard.github.io/plantuml/`

- `Window -> Show View -> Other... -> PlantUML`

> Make sure you have Graphviz installed. It is required by the Eclipse plugin. If you have issues getting PlantUML to work, follow the instructions from http://plantuml.com/eclipse

###  Posix C
---

The generated code is a complete C project which include a Makefile.

- Open a terminal in the filder containing the generated code
- Compile with `make`
- Run with `./your-configuration`

**Prerequisites:**

- Use a C-friendly OS (such as Linux)
- Install `gcc` and `make` + the libraries you are using.

> Note: Virtual box is an option. Ubuntu on Windows 10 works fine as long as there are no graphics/hardware drivers involved.


###  Arduino C
---

- Open the generated file in the Arduino IDE
- Compile
- Upload to your board

**Prerequisites:**

- Install [Arduino IDE](https://www.arduino.cc/en/Main/Software)
- Install any Arduino libraries which you are using from your ThingML program

> For more information about how to use the Arduino IDE and Arduino boards, have a look at [the Arduino documentation](https://www.arduino.cc/en/Guide/Environment).

###  Go
---

- Open a terminal at `thingml-gen/go/your-configuration`
- To run the program directly: `go run *.go`
- To compile to an executable file: `go build *.go`

**Prerequisites:**

- Install the appropriate [Go distribution](https://golang.org/doc/install)
- Install the [Go state-machine library used by ThingML](https://github.com/SINTEF-9012/gosm) `go get github.com/SINTEF-9012/gosm`


> For more information about Go package structures, have a look at the [Go documentation](https://golang.org/doc/code.html)


### Teensy C
---

> Teensy compiler has not be tested for some time. Expect some possible issues when trying it.

**Prerequisites:**

- Install [Teensyduino IDE](https://www.pjrc.com/teensy/td_download.html)

or

- Install [cross compiled arm toochain](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads)
- Install [teensy command line loader](https://www.pjrc.com/teensy/loader_cli.html)


##  Compile ThingML from the sources

> You need Git, Maven, and a proper JDK8+

```bash
git clone https://github.com/TelluIoT/ThingML.git
cd ThingML
mvn clean install
cd language
mvn clean install
```

The command-line interface JAR (containing all you need to compile ThingML files) can be found here:

```bash
cd compilers/registry/target
java -jar compilers.registry-2.0.0-SNAPSHOT-jar-with-dependencies.jar
 --- ThingML help ---
Typical usages:
    java -jar your-jar.jar -t  -s  [-o ] [--options 

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。