Merge pull request #1596 from ZhouBox/test-ft

add ft tests case for plugin
This commit is contained in:
fengzeroz
2023-10-16 10:16:51 +08:00
committed by GitHub
22 changed files with 1700 additions and 7 deletions
+4
View File
@@ -172,6 +172,10 @@ if(NOT DISABLE_UT)
add_subdirectory(tests/ut)
endif()
add_subdirectory(tests/plugins/c1)
add_subdirectory(tests/plugins/s1)
add_subdirectory(tests/plugins/sc1)
# Set sane defaults for multi-lib linux systems
include(GNUInstallDirs)
if(UNIX)
+8
View File
@@ -307,6 +307,7 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
reply(manager, header, &e);
free(cmd->so_file);
free(cmd->schema_file);
free(so_tmp_path);
break;
}
@@ -406,6 +407,7 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
reply(manager, header, &e);
break;
}
utarray_free(nodes);
}
template_each_cb_data_t data = { .plugin = cmd->plugin, .ret = false };
@@ -487,6 +489,7 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
reply(manager, header, &e);
free(cmd->so_file);
free(cmd->schema_file);
free(so_tmp_path);
break;
}
@@ -561,6 +564,7 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
free(cmd->so_file);
free(cmd->schema_file);
free(so_tmp_path);
free(schema_tmp_path);
break;
}
@@ -635,6 +639,10 @@ static int manager_loop(enum neu_event_io_type type, int fd, void *usr_data)
e.error = NEU_ERR_SUCCESS;
strcpy(header->receiver, header->sender);
reply(manager, header, &e);
free(cmd->so_file);
free(cmd->schema_file);
free(so_tmp_path);
free(schema_tmp_path);
break;
}
+15
View File
@@ -138,6 +138,21 @@ def write_tags(node, group, tag_values):
return requests.post(url=config.BASE_URL + "/api/v2/writes", headers={"Authorization": config.default_jwt}, json={"node": node, "group": group, "tags": tag_values})
def add_plugin(library_name, so_file, schema_file):
return requests.post(url=config.BASE_URL + "/api/v2/plugin", json={"library":library_name, "so_file":so_file,"schema_file":schema_file}, headers={"Authorization": config.default_jwt})
def updata_plugin(library_name, so_file, schema_file):
return requests.put(url=config.BASE_URL + "/api/v2/plugin", json={"library":library_name, "so_file":so_file,"schema_file":schema_file}, headers={"Authorization": config.default_jwt})
def del_plugin(plugin_name):
return requests.delete(url=config.BASE_URL + "/api/v2/plugin", json={"plugin":plugin_name}, headers={"Authorization": config.default_jwt})
def get_plugin():
return requests.get(url=config.BASE_URL + "/api/v2/plugin", headers={"Authorization": config.default_jwt})
def add_template(name, plugin, groups):
return requests.post(url=config.BASE_URL + "/api/v2/template", json={"name": name, "plugin": plugin, "groups": groups}, headers={"Authorization": config.default_jwt})
def del_template(name):
return requests.delete(url=config.BASE_URL + "/api/v2/template" + f"?name={name}", headers={"Authorization": config.default_jwt})
# plugin setting
+12 -7
View File
@@ -53,14 +53,19 @@ NEU_ERR_TAG_DESCRIPTION_TOO_LONG = 2208
NEU_ERR_TAG_PRECISION_INVALID = 2209
NEU_ERR_TAG_EXIST = 2210
NEU_ERR_LIBRARY_NOT_FOUND = 2301
NEU_ERR_LIBRARY_INFO_INVALID = 2302
NEU_ERR_LIBRARY_NAME_CONFLICT = 2303
NEU_ERR_LIBRARY_FAILED_TO_OPEN = 2304
NEU_ERR_LIBRARY_MODULE_INVALID = 2305
NEU_ERR_LIBRARY_SYSTEM_NOT_ALLOW_DEL = 2306
NEU_ERR_LIBRARY_NOT_FOUND = 2301
NEU_ERR_LIBRARY_INFO_INVALID = 2302
NEU_ERR_LIBRARY_NAME_CONFLICT = 2303
NEU_ERR_LIBRARY_FAILED_TO_OPEN = 2304
NEU_ERR_LIBRARY_MODULE_INVALID = 2305
NEU_ERR_LIBRARY_SYSTEM_NOT_ALLOW_DEL = 2306
NEU_ERR_LIBRARY_NOT_ALLOW_CREATE_INSTANCE = 2307
NEU_ERR_LIBRARY_ARCH_NOT_SUPPORT = 2308
NEU_ERR_LIBRARY_ARCH_NOT_SUPPORT = 2308
NEU_ERR_LIBRARY_IN_USE = 2309
NEU_ERR_LIBRARY_ADD_FAIL = 2310
NEU_ERR_LIBRARY_MODULE_ALREADY_EXIST = 2311
NEU_ERR_LIBRARY_MODULE_NOT_EXISTS = 2312
NEU_ERR_LIBRARY_MODULE_KIND_NOT_SUPPORT = 2313
NEU_ERR_LICENSE_NOT_FOUND = 2400
NEU_ERR_LICENSE_INVALID = 2401
+3
View File
@@ -0,0 +1,3 @@
import sys
sys.path.append("tests/ft")
+38
View File
@@ -0,0 +1,38 @@
{
"node_config": {
"node": "c1-a",
"params": {
"transport_mode": 0,
"connection_mode": 0,
"max_retries": 0,
"retry_interval": 0,
"interval": 20,
"host": "127.0.0.1",
"port": 502,
"timeout": 3000
}
},
"template_config": {
"name": "c1 template",
"plugin": "c1",
"groups": [
{
"name": "group1",
"interval": 2000,
"tags": [
{
"name": "tag1",
"type": 4,
"address": "1!400001",
"attribute": 1,
"precison": 1,
"decimal": 0
}
]
}
]
},
"library_c1": "libplugin-c1.so",
"library_s1": "libplugin-s1.so",
"library_sc1": "libplugin-sc1.so"
}
+282
View File
@@ -0,0 +1,282 @@
import os
import sys
import json
import base64
import neuron.api as api
from neuron.config import *
from neuron.common import *
from neuron.error import *
class TestPlugin:
with open('tests/ft/plugin/test_library_data.json') as f:
test_data = json.load(f)
test_data['so_file_c1_err']="asdf"
with open('build/tests/plugins/libplugin-c1.so', 'rb') as f:
test_data['so_file_c1'] = str(base64.b64encode(f.read()),encoding='utf-8')
with open('build/tests/plugins/libplugin-c1_2.so', 'rb') as f:
test_data['so_file_c1_2'] = str(base64.b64encode(f.read()),encoding='utf-8')
with open('build/tests/plugins/libplugin-s1.so', 'rb') as f:
test_data['so_file_s1'] = str(base64.b64encode(f.read()),encoding='utf-8')
with open('build/tests/plugins/libplugin-s1_2.so', 'rb') as f:
test_data['so_file_s1_2'] = str(base64.b64encode(f.read()),encoding='utf-8')
with open('build/tests/plugins/libplugin-sc1.so', 'rb') as f:
test_data['so_file_sc1'] = str(base64.b64encode(f.read()),encoding='utf-8')
with open('build/tests/plugins/libplugin-sc1_2.so', 'rb') as f:
test_data['so_file_sc1_2'] = str(base64.b64encode(f.read()),encoding='utf-8')
with open('build/tests/plugins/schema/c1.json', 'rb') as f:
test_data['schema_file'] = str(base64.b64encode(f.read()),encoding='utf-8')
@description(given="incorrect configuration", when="add plugin", then="fail")
def test_01_add_plugin_fail0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_c1_err']
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_MODULE_INVALID == response.json().get("error")
@description(given="incorrect configuration", when="add plugin", then="fail")
def test_02_add_plugin_fail1(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = ''
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_BODY_IS_WRONG == response.json().get("error")
@description(given="incorrect configuration", when="add plugin", then="fail")
def test_03_add_plugin_fail2(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_c1']
plugin_data['schema_file'] = ''
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_BODY_IS_WRONG == response.json().get("error")
@description(given="incorrect configuration", when="add plugin", then="fail")
def test_04_add_plugin_fail3(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_sc1']
plugin_data['so_file'] = test_data['so_file_sc1']
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_MODULE_KIND_NOT_SUPPORT == response.json().get("error")
@description(given="correct configuration", when="add plugin", then="success")
def test_05_add_plugin_success0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_c1']
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="add plugin", then="success")
def test_06_add_plugin_success1(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_s1']
plugin_data['so_file'] = test_data['so_file_s1']
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="add plugin", then="fail")
def test_04_add_plugin_fail4(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_c1']
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 409 == response.status_code
assert NEU_ERR_LIBRARY_NAME_CONFLICT == response.json().get("error")
@description(given="incorrect configuration", when="add plugin", then="fail")
def test_04_add_plugin_fail5(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = "libtest.so"
plugin_data['so_file'] = test_data['so_file_c1']
plugin_data['schema_file'] = test_data['schema_file']
response = api.add_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_MODULE_ALREADY_EXIST == response.json().get("error")
@description(given="incorrect configuration", when="update plugin", then="fail")
def test_07_update_plugin_fail0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_sc1']
plugin_data['schema_file'] = test_data['schema_file']
response = api.updata_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_MODULE_NOT_EXISTS == response.json().get("error")
@description(given="incorrect configuration", when="update plugin", then="fail")
def test_08_update_plugin_fail1(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = '123'
plugin_data['so_file'] = test_data['so_file_c1_2']
plugin_data['schema_file'] = test_data['schema_file']
response = api.updata_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 404 == response.status_code
assert NEU_ERR_LIBRARY_NOT_FOUND == response.json().get("error")
@description(given="incorrect configuration", when="update plugin", then="fail")
def test_09_update_plugin_fail2(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_c1_2']
plugin_data['schema_file'] = ''
response = api.updata_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_BODY_IS_WRONG == response.json().get("error")
@description(given="incorrect configuration", when="update plugin", then="fail")
def test_10_update_plugin_fail3(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = ''
plugin_data['schema_file'] = test_data['schema_file']
response = api.updata_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 400 == response.status_code
assert NEU_ERR_BODY_IS_WRONG == response.json().get("error")
@description(given="correct configuration", when="update plugin", then="success")
def test_11_update_plugin_success0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_s1']
plugin_data['so_file'] = test_data['so_file_s1_2']
plugin_data['schema_file'] = test_data['schema_file']
response = api.updata_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="add south node", then="success")
def test_12_add_node_success(self):
node_data = {}
node_data['name'] = 'c1-a'
node_data['plugin'] = 'c1'
response = api.add_node(node_data['name'], node_data['plugin'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="config node", then="success")
def test_13_configure_node_success(self):
test_data = TestPlugin.test_data
node_data = test_data['node_config']
response = api.node_setting(node_data['node'], node_data['params'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="update plugin", then="success")
def test_14_update_plugin_success1(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['library'] = test_data['library_c1']
plugin_data['so_file'] = test_data['so_file_c1_2']
plugin_data['schema_file'] = test_data['schema_file']
response = api.updata_plugin(library_name=plugin_data['library'],so_file=plugin_data['so_file'], schema_file=plugin_data['schema_file'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="del plugin", then="fail")
def test_15_del_plugin_fail0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['plugin'] = 'c1'
response = api.del_plugin(plugin_name=plugin_data['plugin'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_IN_USE == response.json().get("error")
@description(given="correct configuration", when="del plugin", then="fail")
def test_16_del_plugin_fail0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['plugin'] = 's1'
response = api.del_plugin(plugin_name=plugin_data['plugin'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_SYSTEM_NOT_ALLOW_DEL == response.json().get("error")
@description(given="correct configuration", when="del south node", then="success")
def test_17_del_node_success(self):
node_data = {}
node_data['name'] = 'c1-a'
response = api.del_node(node_data['name'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="add template", then="success")
def test_18_add_template_success(self):
test_data = TestPlugin.test_data
template_data = test_data['template_config']
response = api.add_template(name=template_data['name'], plugin=template_data['plugin'], groups=template_data['groups'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="del plugin", then="success")
def test_19_del_plugin_fail0(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['plugin'] = 'c1'
response = api.del_plugin(plugin_name=plugin_data['plugin'])
assert 400 == response.status_code
assert NEU_ERR_LIBRARY_IN_USE == response.json().get("error")
@description(given="correct configuration", when="del template", then="success")
def test_20_del_template_success(self):
test_data = TestPlugin.test_data
response = api.del_template(name='c1 template')
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
@description(given="correct configuration", when="del plugin", then="success")
def test_21_del_plugin_sucess(self):
test_data = TestPlugin.test_data
plugin_data = {}
plugin_data['plugin'] = 'c1'
response = api.del_plugin(plugin_name=plugin_data['plugin'])
assert 200 == response.status_code
assert NEU_ERR_SUCCESS == response.json().get("error")
+21
View File
@@ -0,0 +1,21 @@
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/tests/plugins")
set(CMAKE_BUILD_RPATH ./)
file(COPY ${CMAKE_SOURCE_DIR}/tests/plugins/c1/c1.json DESTINATION ${CMAKE_BINARY_DIR}/tests/plugins/schema/)
# v1
set(PLUGIN_NAME plugin-c1)
set(PLUGIN_SOURCES c1.c )
add_library(${PLUGIN_NAME} SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME} PRIVATE ${PLUGIN_SOURCES})
target_link_libraries(${PLUGIN_NAME} neuron-base)
# v2
set(PLUGIN_NAME_2 plugin-c1_2)
set(PLUGIN_SOURCES_2 c1_2.c )
add_library(${PLUGIN_NAME_2} SHARED)
target_include_directories(${PLUGIN_NAME_2} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME_2} PRIVATE ${PLUGIN_SOURCES_2})
target_link_libraries(${PLUGIN_NAME_2} neuron-base)
+172
View File
@@ -0,0 +1,172 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdlib.h>
#include <neuron.h>
#include "errcodes.h"
#include "c1.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin, bool load);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_tag_validator(const neu_datatag_t *tag);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
.driver.tag_validator = driver_tag_validator,
.driver.write_tags = driver_write_tags,
.driver.add_tags = NULL,
.driver.load_tags = NULL,
.driver.del_tags = NULL,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "c1",
.module_name = "c1",
.module_descr = "c1 v1",
.module_descr_zh = "c1 v1",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_CUSTOM,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
(void) plugin;
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
(void) plugin;
(void) config;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_tag_validator(const neu_datatag_t *tag)
{
(void) tag;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
(void) plugin;
(void) tag;
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
(void) plugin;
(void) group;
return 0;
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
(void) plugin;
(void) req;
(void) tag;
(void) value;
return 0;
}
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags)
{
(void) plugin;
(void) req;
(void) tags;
return 0;
}
+28
View File
@@ -0,0 +1,28 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#ifndef _NEU_M_PLUGIN_MODBUS_REQ_H_
#define _NEU_M_PLUGIN_MODBUS_REQ_H_
#include <neuron.h>
struct neu_plugin {
neu_plugin_common_t common;
};
#endif
+53
View File
@@ -0,0 +1,53 @@
{
"tag_regex": [
{
"type": 1,
"regex": ""
},
{
"type": 2,
"regex": ""
},
{
"type": 3,
"regex": ""
},
{
"type": 4,
"regex": ""
},
{
"type": 5,
"regex": ""
},
{
"type": 6,
"regex": ""
},
{
"type": 7,
"regex": ""
},
{
"type": 8,
"regex": ""
},
{
"type": 9,
"regex": ""
},
{
"type": 10,
"regex": ""
},
{
"type": 12,
"regex": ""
},
{
"type": 13,
"regex": ""
}
],
"group_interval": 1000
}
+172
View File
@@ -0,0 +1,172 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdlib.h>
#include <neuron.h>
#include "errcodes.h"
#include "c1.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin, bool load);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_tag_validator(const neu_datatag_t *tag);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
.driver.tag_validator = driver_tag_validator,
.driver.write_tags = driver_write_tags,
.driver.add_tags = NULL,
.driver.load_tags = NULL,
.driver.del_tags = NULL,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "c1",
.module_name = "c1",
.module_descr = "c1 v2",
.module_descr_zh = "c1 v2",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_CUSTOM,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
(void) plugin;
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
(void) plugin;
(void) config;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_tag_validator(const neu_datatag_t *tag)
{
(void) tag;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
(void) plugin;
(void) tag;
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
(void) plugin;
(void) group;
return 0;
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
(void) plugin;
(void) req;
(void) tag;
(void) value;
return 0;
}
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags)
{
(void) plugin;
(void) req;
(void) tags;
return 0;
}
+21
View File
@@ -0,0 +1,21 @@
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/tests/plugins")
set(CMAKE_BUILD_RPATH ./)
file(COPY ${CMAKE_SOURCE_DIR}/tests/plugins/s1/s1.json DESTINATION ${CMAKE_BINARY_DIR}/tests/plugins/schema/)
# v1
set(PLUGIN_NAME plugin-s1)
set(PLUGIN_SOURCES s1.c )
add_library(${PLUGIN_NAME} SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME} PRIVATE ${PLUGIN_SOURCES})
target_link_libraries(${PLUGIN_NAME} neuron-base)
# v2
set(PLUGIN_NAME_2 plugin-s1_2)
set(PLUGIN_SOURCES_2 s1_2.c )
add_library(${PLUGIN_NAME_2} SHARED)
target_include_directories(${PLUGIN_NAME_2} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME_2} PRIVATE ${PLUGIN_SOURCES_2})
target_link_libraries(${PLUGIN_NAME_2} neuron-base)
+172
View File
@@ -0,0 +1,172 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdlib.h>
#include <neuron.h>
#include "errcodes.h"
#include "s1.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin, bool load);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_tag_validator(const neu_datatag_t *tag);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
.driver.tag_validator = driver_tag_validator,
.driver.write_tags = driver_write_tags,
.driver.add_tags = NULL,
.driver.load_tags = NULL,
.driver.del_tags = NULL,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "s1",
.module_name = "s1",
.module_descr = "s1 v1",
.module_descr_zh = "s1 v1",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_SYSTEM,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
(void) plugin;
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
(void) plugin;
(void) config;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_tag_validator(const neu_datatag_t *tag)
{
(void) tag;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
(void) plugin;
(void) tag;
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
(void) plugin;
(void) group;
return 0;
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
(void) plugin;
(void) req;
(void) tag;
(void) value;
return 0;
}
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags)
{
(void) plugin;
(void) req;
(void) tags;
return 0;
}
+28
View File
@@ -0,0 +1,28 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#ifndef _NEU_M_PLUGIN_MODBUS_REQ_H_
#define _NEU_M_PLUGIN_MODBUS_REQ_H_
#include <neuron.h>
struct neu_plugin {
neu_plugin_common_t common;
};
#endif
+53
View File
@@ -0,0 +1,53 @@
{
"tag_regex": [
{
"type": 1,
"regex": ""
},
{
"type": 2,
"regex": ""
},
{
"type": 3,
"regex": ""
},
{
"type": 4,
"regex": ""
},
{
"type": 5,
"regex": ""
},
{
"type": 6,
"regex": ""
},
{
"type": 7,
"regex": ""
},
{
"type": 8,
"regex": ""
},
{
"type": 9,
"regex": ""
},
{
"type": 10,
"regex": ""
},
{
"type": 12,
"regex": ""
},
{
"type": 13,
"regex": ""
}
],
"group_interval": 1000
}
+172
View File
@@ -0,0 +1,172 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdlib.h>
#include <neuron.h>
#include "errcodes.h"
#include "s1.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin, bool load);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_tag_validator(const neu_datatag_t *tag);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
.driver.tag_validator = driver_tag_validator,
.driver.write_tags = driver_write_tags,
.driver.add_tags = NULL,
.driver.load_tags = NULL,
.driver.del_tags = NULL,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "s1",
.module_name = "s1",
.module_descr = "s1 v2",
.module_descr_zh = "s1 v2",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_SYSTEM,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
(void) plugin;
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
(void) plugin;
(void) config;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_tag_validator(const neu_datatag_t *tag)
{
(void) tag;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
(void) plugin;
(void) tag;
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
(void) plugin;
(void) group;
return 0;
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
(void) plugin;
(void) req;
(void) tag;
(void) value;
return 0;
}
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags)
{
(void) plugin;
(void) req;
(void) tags;
return 0;
}
+21
View File
@@ -0,0 +1,21 @@
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/tests/plugins")
set(CMAKE_BUILD_RPATH ./)
file(COPY ${CMAKE_SOURCE_DIR}/tests/plugins/sc1/sc1.json DESTINATION ${CMAKE_BINARY_DIR}/tests/plugins/schema/)
# v1
set(PLUGIN_NAME plugin-sc1)
set(PLUGIN_SOURCES sc1.c )
add_library(${PLUGIN_NAME} SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME} PRIVATE ${PLUGIN_SOURCES})
target_link_libraries(${PLUGIN_NAME} neuron-base)
# v2
set(PLUGIN_NAME_2 plugin-sc1_2)
set(PLUGIN_SOURCES_2 sc1_2.c )
add_library(${PLUGIN_NAME_2} SHARED)
target_include_directories(${PLUGIN_NAME_2} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME_2} PRIVATE ${PLUGIN_SOURCES_2})
target_link_libraries(${PLUGIN_NAME_2} neuron-base)
+172
View File
@@ -0,0 +1,172 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdlib.h>
#include <neuron.h>
#include "errcodes.h"
#include "sc1.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin, bool load);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_tag_validator(const neu_datatag_t *tag);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
.driver.tag_validator = driver_tag_validator,
.driver.write_tags = driver_write_tags,
.driver.add_tags = NULL,
.driver.load_tags = NULL,
.driver.del_tags = NULL,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "sc1",
.module_name = "sc1",
.module_descr = "sc1 v1",
.module_descr_zh = "sc1 v1",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_STATIC,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
(void) plugin;
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
(void) plugin;
(void) config;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_tag_validator(const neu_datatag_t *tag)
{
(void) tag;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
(void) plugin;
(void) tag;
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
(void) plugin;
(void) group;
return 0;
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
(void) plugin;
(void) req;
(void) tag;
(void) value;
return 0;
}
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags)
{
(void) plugin;
(void) req;
(void) tags;
return 0;
}
+28
View File
@@ -0,0 +1,28 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#ifndef _NEU_M_PLUGIN_MODBUS_REQ_H_
#define _NEU_M_PLUGIN_MODBUS_REQ_H_
#include <neuron.h>
struct neu_plugin {
neu_plugin_common_t common;
};
#endif
+53
View File
@@ -0,0 +1,53 @@
{
"tag_regex": [
{
"type": 1,
"regex": ""
},
{
"type": 2,
"regex": ""
},
{
"type": 3,
"regex": ""
},
{
"type": 4,
"regex": ""
},
{
"type": 5,
"regex": ""
},
{
"type": 6,
"regex": ""
},
{
"type": 7,
"regex": ""
},
{
"type": 8,
"regex": ""
},
{
"type": 9,
"regex": ""
},
{
"type": 10,
"regex": ""
},
{
"type": 12,
"regex": ""
},
{
"type": 13,
"regex": ""
}
],
"group_interval": 1000
}
+172
View File
@@ -0,0 +1,172 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdlib.h>
#include <neuron.h>
#include "errcodes.h"
#include "sc1.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin, bool load);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_tag_validator(const neu_datatag_t *tag);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
.driver.tag_validator = driver_tag_validator,
.driver.write_tags = driver_write_tags,
.driver.add_tags = NULL,
.driver.load_tags = NULL,
.driver.del_tags = NULL,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "sc1",
.module_name = "sc1",
.module_descr = "sc1 v2",
.module_descr_zh = "sc1 v2",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_STATIC,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
(void) plugin;
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
(void) plugin;
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
(void) plugin;
(void) config;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_tag_validator(const neu_datatag_t *tag)
{
(void) tag;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
(void) plugin;
(void) tag;
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
(void) plugin;
(void) group;
return 0;
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
(void) plugin;
(void) req;
(void) tag;
(void) value;
return 0;
}
static int driver_write_tags(neu_plugin_t *plugin, void *req, UT_array *tags)
{
(void) plugin;
(void) req;
(void) tags;
return 0;
}