Giter Site home page Giter Site logo

knot-thing-simulator's Introduction

knot-modbus-simulator

KNoT Modbus Simulator is part of the KNoT project. It aims to provide an industry protocol simulator by creating a tcp server instance so that KNoT Things can be described and tested by KNoT ecosystem.

Check out our currently supported protocols.

Pre-requisites

Setup

In order to use this project it's necessary to install its dependencies and add the pre-commit hooks, to simplify this process a Makefile was used. Since not all users may like the idea of using a makefile in a python project, this README was separated in two sections: the first explaining how to build and run the project with the Makefile and the second without it.

Installation and usage with the Makefile

Pre-requisites

Installation

First, change your current working directory to the project's root directory and bootstrap the project:

# change current working directory
$ cd <path/to/knot-thing-simulator>

# install project dependencies
$ make bootstrap

Usage

In order to run the main script simply use the make run command.

Manual installation and usage

Installation

First, change your current working directory to the project's root and then setup up a new Python virtual environment:

# change current working directory
$ cd <path/to/knot-thing-simulator>

# setup a new python virtual environment
$ python -m venv venv

Now, activate the newly create virtual so that dependencies are installed there and not to your global Python installation:

# activate virtual environment
$ source venv/bin/activate

Now, install the project's dependencies with the following command:

# install project's dependencies
$ pip install -r requirements.txt

note: in order to leave the virtual environment you created for the project, use the deactivate command (from anywhere).

Finally, prepare the project's custom pre-commit hooks:

# copy the custom hook to the .git folder
$ cp hooks/pre-commit .git/hooks/pre-commit

# install the pre-commit hooks
$ pre-commit install

Usage

From the root dir run:

sudo env PYTHONPATH=. python <file>

Docker Installation and Usage

Pre-requisites

To install the project's Docker installation pre-requisites, please follow the instructions in the link below:

Note: if you're using a Linux system, please take a look at Docker's post-installation steps for Linux!

Building and running

Once you have all pre-requisites installed, change your current working directory to the project's root:

# change current working directory
$ cd <path/to/knot-thing-simulator>
Development

In order to build the Docker development image, use the command below:

# build docker image from Dockerfile-dev
$ docker build . --file Dockerfile-dev --tag knot-thing-simulator:dev

Finally, run the development container with the following command:

# start the container and clean up upon exit.
$ docker run --rm --publish 502:502 --volume `pwd`:/usr/src/app --tty --interactive knot-thing-simulator:dev

Note: the --volume flag binds and mounts pwd (your current working directory) to the container's /usr/src/app directory. This means that the changes you make outside the container will be reflected inside (and vice-versa). You may use your IDE to make code modifications, additions, deletions and so on, and these changes will be persisted both in and outside the container.

Production

In order to build the Docker production image, use the command below:

# build docker image from Dockerfile
$ docker build . --file Dockerfile --tag knot-thing-simulator

Finally, run the production container with the following command:

# start the container and clean up upon exit.
$ docker run --rm --publish 502:502 --volume `pwd`:/usr/src/app --tty --interactive knot-thing-simulator

Configure the simulator

The simulator provides an easy configuration template (config/config.json). In order to create a data server model of industrial things you need to follow the config template, where the fields are explained bellow:

  • id: Specifies the data-server id to be modeled, id > 0.
  • register_data: Represents a non-discrete (non-binary) data-block.
    • Each register_data has the following fields:
      • address: Identifies data inside the data-block related to non-discrete block.
      • value: List of values with little-endian representation in Hexa-decimal.
  • digital_data: Represents a discrete (binary) data-block.
    • Each digital_data has the following fields:
      • address: Identifies data inside the data-block related to discrete block.
      • value: List of values with little-endian representation in binary.

Supported Protocols

  • Modbus

License

All KNoT Simulator files are under LGPL v2.1 license, you can check COPYING file for details.

knot-thing-simulator's People

Contributors

agms-cesar avatar

Stargazers

Leonardo Castelo Branco de Melo avatar

Watchers

Claudio Takahasi avatar James Cloos avatar Tiago Barros avatar Vitor Casadei avatar Benedito Alberto Macedo avatar Rodrigo Perazzo avatar  avatar Eric Perazzo avatar Paulo Serra Filho avatar  avatar João Neto avatar Thiago Aquino avatar Luis Felipe 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.