This repository was archived by the owner on Jan 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.cpp
More file actions
135 lines (120 loc) · 2.41 KB
/
Copy pathplugin.cpp
File metadata and controls
135 lines (120 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* FogLAMP south plugin.
*
* Copyright (c) 2018 Dianomic Systems
*
* Released under the Apache 2.0 Licence
*
* Author: Mark Riddoch
*/
#include <csv.h>
#include <plugin_api.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string>
#include <logger.h>
#include <plugin_exception.h>
#include <config_category.h>
#include <version.h>
using namespace std;
#define PLUGIN_NAME "Csv"
const char *default_config = QUOTE({
"plugin" : {
"description" : PLUGIN_NAME,
"type" : "string",
"default" : PLUGIN_NAME,
"readonly" : "true"
},
"asset" : {
"description" : "Asset name",
"type" : "string",
"default" : "Vibration",
"order": "1",
"displayName": "Asset Name"
},
"datapoint" : {
"description" : "Datapoint name/prefix",
"type" : "string",
"default" : "ch",
"order": "2",
"displayName": "Datapoint"
},
"multicolumn" : {
"description" : "Multiple Column CSV file",
"type" : "boolean",
"default" : "false",
"order": "3",
"displayName": "Multi-Column"
},
"file" : {
"description" : "Name of the file to read",
"type" : "string",
"default" : "",
"order": "4",
"displayName": "Path Of File"
}
});
/**
* The Csv plugin interface
*/
extern "C" {
/**
* The plugin information structure
*/
static PLUGIN_INFORMATION info = {
PLUGIN_NAME, // Name
VERSION, // Version
0, // Flags
PLUGIN_TYPE_SOUTH, // Type
"1.0.0", // Interface version
default_config // Default configuration
};
/**
* Return the information about this plugin
*/
PLUGIN_INFORMATION *plugin_info()
{
return &info;
}
/**
* Initialise the plugin, called to get the plugin handle
*/
PLUGIN_HANDLE plugin_init(ConfigCategory *config)
{
Csv *csv = new Csv();
csv->configure(config);
return (PLUGIN_HANDLE)csv;
}
/**
* Start the Async handling for the plugin
*/
void plugin_start(PLUGIN_HANDLE *handle)
{
}
/**
* Poll for a plugin reading
*/
Reading plugin_poll(PLUGIN_HANDLE *handle)
{
Csv *csv = (Csv *)handle;
return csv->nextValue();
}
/**
* Reconfigure the plugin
*/
void plugin_reconfigure(PLUGIN_HANDLE *handle, string& newConfig)
{
ConfigCategory config("csv", newConfig);
Csv *csv = (Csv *)*handle;
csv->configure(&config);
}
/**
* Shutdown the plugin
*/
void plugin_shutdown(PLUGIN_HANDLE *handle)
{
Csv *csv = (Csv *)handle;
delete csv;
}
};