GithubHelp home page GithubHelp logo

taka-wang / psmb Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.21 MB

Proactive service for modbusd written in Golang.

Home Page: http://taka-wang.github.io/psmb/

License: MIT License

Go 98.16% Shell 1.84%

psmb's Introduction

psmb

Docker GoDoc Go Report Card codecov

Proactive service library for modbusd


Continuous Integration

I do continuous integration and deploy docker images after git push by self-hosted drone.io server, circleci service, codecov service and dockerhub service.

CI Server Target Status
CircleCI x86 CircleCI
Travis x86 Build Status
Drone armhf Drone

Environment variables

Why environment variable? Refer to the 12 factors

  • CONF_PSMBTCP: config file path
  • EP_BACKEND: endpoint of remote service discovery server (optional)

Contracts (Interfaces)

  • IProactiveService: proactive service
  • IReaderTaskDataStore: read/poll task data store
  • IWriterTaskDataStore: write task data store
  • IHistoryDataStore: history data store
  • IFilterDataStore: filter data store
  • IConfig: config management

Golang package management

  • I adopted glide as package management system for this repository.

Worker Pool Model

Request from upstream

uml

Response from downstream

uml


Up and Running

Docker Compose

docker-compose build --pull
docker-compose up

Manually

Install libzmq (3.2.5)

wget https://github.com/zeromq/zeromq3-x/releases/download/v3.2.5/zeromq-3.2.5.tar.gz
tar xvzf zeromq-3.2.5.tar.gz
cd zeromq-3.2.5
./configure
make
sudo make install
sudo ldconfig

Build

# install glide
curl https://glide.sh/get | sh

# install dependencies
glide up

# build
cd tcp-srv
go build -o psmbtcp-srv

Deployment Diagram

uml


Unit tests

  • binary
  • types

Test cases

Binary

  • Bytes to 16-bit integer array tests
    • BytesToUInt16s in big endian order - (1/4)
    • BytesToUInt16s in little endian order - (2/4)
    • BytesToInt16s in big endian order - (3/4)
    • BytesToInt16s in little endian order - (4/4)
  • Bytes to 32-bit integer array tests
    • BytesToUInt32s in (ABCD) Big Endian order - (1/4)
    • BytesToUInt32s in (DCBA) Little Endian order - (2/4)
    • BytesToUInt32s in (BADC) Mid-Big Endian order - (3/4)
    • BytesToUInt32s in (CDAB) Mid-Little Endian order - (4/4)
    • BytesToInt32s in (ABCD) Big Endian order - (1/4)
    • BytesToInt32s in (DCBA) Little Endian order - (2/4)
    • BytesToInt32s in (BADC) Mid-Big Endian order - (3/4)
    • BytesToInt32s in (CDAB) Mid-Little Endian order - (4/4)
  • Bytes to 32-bit float array tests
    • BytesToFloat32s in (ABCD) Big Endian order - (1/4)
    • BytesToFloat32s in (DCBA) Little Endian order - (2/4)
    • BytesToFloat32s in (BADC) Mid-Big Endian order - (3/4)
    • BytesToFloat32s in (CDAB) Mid-Little Endian order - (4/4)
  • Bytes/registers utility tests
    • BitStringToUInt8s test
    • BitStringToUInt8s test - left comma
    • BitStringToUInt8s test - right comma
    • BitStringToUInt8s test - left, right comma
    • RegistersToBytes test
    • BytesToHexString test
    • DecimalStringToRegisters test
    • DecimalStringToRegisters test - left comma
    • DecimalStringToRegisters test - right comma
    • DecimalStringToRegisters test - left, right comma
    • HexStringToRegisters test
    • HexStringToRegisters test - wrong length
    • LinearScalingRegisters test
    • LinearScalingRegisters test - (0,0,0,0)
    • LinearScalingRegisters test - reverse

Types

Upstream structure test

  • One-off modbus tcp struct tests
    • mbtcp.once.read request test
    • mbtcp.once.read response test
  • get/set modbus tcp timeout struct tests
    • mbtcp.timeout.read request test
    • mbtcp.timeout.read response test
    • mbtcp.timeout.update request test
    • mbtcp.timeout.update response test
    • mbtcp.once.write request test
    • mbtcp.once.write response test

Downstream structure test

  • modbus tcp downstreamstruct tests
    • read request test
    • single read response test
    • multiple read response test
    • single write request test
    • multiple write request test
    • set timeout request test
    • get timeout response test

UML

uml


License

MIT

psmb's People

Contributors

taka-wang avatar

Watchers

James Cloos avatar  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.