logic

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 6 Imported by: 0

README

Logic Script

编写数据处理逻辑,入口参数为message:LinkMessage.

logic script返回message.data,可以在logic中编辑data部分数据

function execute(message:LinkMessage);

message定义


message = {
    "applicationID": "1",
    "applicationName": "app_test",
    "deviceID": "1001",
    "deviceName": "tbs001",
    "data": {
        "humidity": 45
    }
};

event函数定义

function event(target, properties) {
    // dummy
    console.log(target, properties);
}

Logic script接口 (Demo)

function execute(message) return message.data

// 
function execute(message){
    humidity = message.data["humidity"];
    if (humidity < 5) {
        
        var target = {
             "applicationID": "",
             "deviceID": ""
         };
        var properties = {
            "state": "1"
        };
        // 控制另外一个设备
        event(target, properties);
        if (message.data) {
            return message.data;
        } else {
            return {};
        }
    }
}

Documentation

Index

Constants

View Source
const Tpl = `
// object -> byte array
function execute(message){
	if (message.data) {
		return message.data;
	} else {
		return {};
	}
}
`

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageLogicHandler

type MessageLogicHandler interface {
	OnData(msg model.LinkMessage) model.LinkMessage
}

收到业务数据后执行

func New

func New(logicScript string) MessageLogicHandler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL