WISE-PaaS/SRP Services

From ESS-WIKI
Revision as of 08:44, 16 January 2017 by Rison.yeh (talk | contribs)
Jump to: navigation, search

OVERVIEW

RTENOTITLE

  • API Management

Adopt Azure API Management/Open-source (WSO2) to integrate various SRP services API.

  • Common Service APIs/Lib

Basic Account/Device/Group/Role operation APIs, including Add/Edit/Delete/Search/Advance Search WISE-PaaS administration information (Product Support, version, capability…etc.)

  • Custom/SRP Service

RMM/IMM/OTA/SCADA self-service APIs

  • Common Data Workers

Including device basic information and sensor data from broker. (Common MQTT Topic) For structure info (device Info) store into PostgreSQL For non-structure (sensor Info) store into MongoDB/DocumentDB/...etc.

  • Custom/SRP Data Workers

Process RMM/IMM/OTA/SCADA self-MQTT topic message and store into self-database (RMM/IMM/OTASCADA DB)

  • Message Broker (RabbitMQ)

Adopt RabbitMQ as default cluster broker, and plugin MQTT as communication protocol.

  • Device Agent

Define common MQTT topic handshake message and custom/SRP topic format.

  • Database (SQL/NoSQL)

PostgreSQL as default relation database and including Common/RMM /SCADA/IMM/etc. MongoDB/DoucmentDB for sensor information collect.

COMMON DATABASE SCHEME

Concept & Design Rules

  • Device belong to multi-groups or not to any group.
  • Each account have non or multi-groups.
  • Each group must belong to someone account.
  • Group of group (1-3 Levels)
  • Each account must belong to someone role.

RTENOTITLE

Common Database Scheme

RTENOTITLE

Common Database Table Details

Table Account

RTENOTITLE

Table Role

RTENOTITLE

Table Group

RTENOTITLE

Table Device

RTENOTITLE

Non-Structure Data (MongoDB/DocumentDB)

  • Default Collections
  • Event
    • WISE-PaaS platform event message
    • Format
                        {         "product": "RMM",        
                                  "type": "DEVICE",        
                                  "subtype": "DEVICE_DISCONNECTED",        
                                  "severity": "ERROR",        
                                  "message": "DEVICE_DISCONNECTED",        
                                  "extMsg": <JSONObject>,        
                                  "device_id": 2,        
                                  "device_name": "AC09",        
                                  "account_id": 2,        
                                   "account_name": "admin",        
                                   "ts": ISODate('2016-11-29T05:13:46.759Z') }
  • Handler (Plugin)
    • Handler (Plugin) report data (source data)
  • Capability
    • Handler capability structure
  • Heartbeat
    • WISE-PaaS device’s keepalive mechanism, ensure device connection state.


  • Sensor Collections (Dynamic generate and transfer to key/value)
  • SUSIControl
  • HDDMonitor
  • Modbus
  • SenHub
  • IoTGW

RTENOTITLE

API MANAGEMENT (RESTFUL APIS)

Common REST APIs

  • Device APIs
  • /wise-paas/common/device
    • <POST>    –   Add Device
  • /wise-paas/common/device/<id>
    • <PUT>      –   Edit Device
    • <DELETE>        –    Delete Device
    • <GET>      –    Get device, account, group information.
  • /wise-paas/common/device/advSearch
    • <POST>    –   Advanced search by each field.
  • Group APIs
  • /wise-paas/common/group
    • <POST>    –   Add Group
  • /wise-paas/common/group/<id>
    • <PUT>      –   Edit Group
    • <DELETE>        –    Delete Group
    • <GET>      –    Get group, account information
  • /wise-paas/common/group/advSearch
    • <POST>    –   Advanced search by each field.
  • Account APIs
  • /wise-paas/common/account
    • <POST>    –   Add Account
  • /wise-paas/common/account/<id>
    • <PUT>      –   Edit Account
    • <DELETE>        –    Delete Account
    • <GET>      –    Get account and group information
  • /wise-paas/common/account/advSearch
    • <POST>    –   Advanced search by each field.
  • /wise-paas/common/account/login
    • <POST>    –   Account login, verify the password, and return access token.
  • Role APIs
  • /wise-paas/common/role
    • <POST>    –   Add Role
  • /wise-paas/common/role/<id>
    • <PUT>      –   Edit Role
    • <DELETE>        –    Delete Role
    • <GET>      –    Get role information
  • /wise-paas/common/role/advSearch

<POST>    –   Advanced search by each field.

  • Data Management APIs
  • /wise-paas/common/data/history/<id>/<beginTS>/<endTS>/<handler>/<sensorId>
    • <GET>      –   Get row data, based on device Id, time range, handler and sensor Id.
  • /wise-paas/common/data/realtime/<id>/<beginTS>/<endTS>/<handler>/<sensorId>
    • <GET>      –   Get real-time device data, based on device Id, time range, handler and sensor Id.
  • /wise-paas/common/data/set/<id>
    • <POST>    –   Set device data to target device.
  • /wise-paas/common/data/sensorId/<id>/<handler>
    • <GET>      –   Get sensor Id, based on device Id and handler.
  • /wise-paas/common/data/startReport
    • <POST>    –   Set device start to report data.
  • /wise-paas/common/data/stopReport

<POST>    –   Set device stop to report data.

  • NoSQL APIs
  • /wise-paas/common/noSQL/collection
    • <POST>    –   Add new collection into noSQL DB, index options…etc.
    • <Delete> –   Delete collection on noSQL DB.
  • /wise-paas/common/noSQL/collection/data
    • <POST>    –   Add data into collection
    • <PUT>      –   Replace data on collection, via conditions.
  • /wise-paas/common/noSQL/advSearch
    • <POST>    –   Advance search on collection and conditions.

Custom REST API Categories

  • RMM
  • /wise-paas/rmm/apiInfo
  • /wise-paas/rmm/dashboard
  • /wise-paas/rmm/kvm
  • /wise-paas/rmm/msgNotify
  • IMM
  • /wise-paas/imm/apiInfo
  • SCADA
  • /wise-paas/scada/apiInfo
  • OTA
  • /wise-paas/ota/apiInfo

DEVICE CONNECTIVITY

  • Adopt open source RabbitMQ on server side to support both AMQP and MQTT protocol.
  • Transportation supports MQTT, AMQP and HTTP (Websocket)
    • Define the common communication APIs for our WISE Agent, we called WISE Connector APIs
    • Implement the WISE Connector APIs with different communication protocol.
    • WISE Agent can link different communication protocol at compile time.

Wise agent arch.png

  • Supports secured connection (TLS/SSL) with anonymous and authenticated account

Message Topics

  • MQTT Topic Define
    • From Server to Agent:
      /wisepaas/<product>/<agentId>/<function>ack
  • From Agent to Server:
    /wisepaas/<product>/<agentId>/<function>req

RTENOTITLE

  • Preserved Topic for Common use
    • Agent Registration Topic:  /wisepaas/device/<agentId>/agentinfoack
    • Will Message Topic:  /wisepaas/device/<agentId>/willmessage Or /wisepaas/device/<serverId>/willmessage
    • Command Topic:  /wisepaas/device/<agentId>/agentactionreq
    • Response Topic:  /wisepaas/device/<agentId>/agentactionack
    • Report Data Topic:  /wisepaas/device/<agentId>/devinfoack
  • Custom Topic Sample
    • Custom Topic for power ON/OFF:

Server send command with topic: /wisepaas/custom/<agentId>/powerctrlreq

Agent send response with topic: /wisepaas/custom/<agentId>/powerctrlack

Handshake Sequence

  • Normal sign in and sign out sequence:

Normal sign in.png

  • Agent lost connection with will message sequence:

Agent lost conn.png

  • Server lost connection with will message sequence:

Server lost conn.png

Data Format

  • Basic JSON Format
  • JSON (JavaScript Object Notation) is a lightweight data-interchange format.
  • JSON is built on two structures:
    • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
    • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
  • JSON Forms:
  • Object: { string : value}
  • Array: [ value ]
  • Value: string
          number
          object
          array
           true
           false
           null
  • WISE-PaaS predefined string:
    • agentID: target device ID, value type is string.
    • handlerName: target device supported function block (Plugin or Handler) name, value type is string.
    • commCmd: the sub command ID in function block (Plugin or Handler), value type is unsigned integer.
  • Device Registration Format:

{

  "agentID":"0123456789012",

  "handlerName":"general",         //defined for device registration

  "commCmd":1,                          //defined for device registration

  "hostname":"PC001104",            //target device name

  "sn":"14DAE996BE04",                //target device serial number

  "mac":"14DAE996BE04",            //target device mac address

  "version":"1.0.0.0",                     //client application version

  "type":"IPC",                                //target device type

  "product":"",

  "manufacture":"",

  "account":"anonymous",             //bind target device to a specific account

  "password":"",                             //encrypt with DES and Base64

  "status":1                                     //1: registration, 0: un-registration

}

 

  • Report Data Format:

{

  “agentID”:”0123456789012”,

  “handlerName”:”custom”,

  “commCmd”:123,

  “custom_object”:{                      //User defined report data object.

    “custom_data1”:”string_value”,

    “custom_data2”:123,

    “custom_data3”:false

  }

}

  • IPSO Format (Application Framework)

DEVOPS MANAGEMENT

Continuous Integration & Continuous Delivery

Version Control

Build and Test

Release & Deploy

CUSTOM SERVICE INTEGRATION

Access Methods

Internal Messaging(ZMQ)

Java Library

Common Restful APIs

RMM/OTA/SCADA/IMM Integration

  • Scenario 1) RMM show more information about account
  • Scenario 2) OTA deploy a package for region devices

Document