supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
suplet
json_definition.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_SUPLET_JSON_DEFINITION_H_
20
#define SRC_SUPLA_SUPLET_JSON_DEFINITION_H_
21
22
#include <stdint.h>
23
#include <supla/suplet/definition.h>
24
25
#ifndef SUPLA_SUPLET_MAX_NAME_SIZE
26
#define SUPLA_SUPLET_MAX_NAME_SIZE 48
27
#endif
28
29
#ifndef SUPLA_SUPLET_MAX_CAPTION_SIZE
30
#define SUPLA_SUPLET_MAX_CAPTION_SIZE 48
31
#endif
32
33
#ifndef SUPLA_SUPLET_MAX_PARAMETERS
34
#define SUPLA_SUPLET_MAX_PARAMETERS 16
35
#endif
36
37
#ifndef SUPLA_SUPLET_MAX_PARAMETER_KEY_SIZE
38
#define SUPLA_SUPLET_MAX_PARAMETER_KEY_SIZE 32
39
#endif
40
41
#ifndef SUPLA_SUPLET_MAX_PARAMETER_TEXT_SIZE
42
#define SUPLA_SUPLET_MAX_PARAMETER_TEXT_SIZE 64
43
#endif
44
45
namespace
Supla {
46
namespace
Suplet {
47
48
class
JsonDefinition {
49
public
:
50
JsonDefinition();
51
52
void
clear();
53
Definition
*getDefinition();
54
const
Definition
*getDefinition()
const
;
55
ChannelDefinition
*getChannel(uint8_t index);
56
ParameterDefinition
*getParameter(uint8_t index);
57
char
*getNameBuffer();
58
char
*getCaptionBuffer(uint8_t index);
59
char
*getParameterKeyBuffer(uint8_t index);
60
char
*getParameterDefaultTextBuffer(uint8_t index);
61
char
*getParameterEnumValuesBuffer(uint8_t index);
62
63
private
:
64
Definition
definition;
65
ChannelDefinition
channels[SUPLA_SUPLET_MAX_CHANNELS_PER_INSTANCE];
66
ParameterDefinition
parameters[SUPLA_SUPLET_MAX_PARAMETERS];
67
char
name[SUPLA_SUPLET_MAX_NAME_SIZE];
68
char
captions[SUPLA_SUPLET_MAX_CHANNELS_PER_INSTANCE]
69
[SUPLA_SUPLET_MAX_CAPTION_SIZE];
70
char
parameterKeys[SUPLA_SUPLET_MAX_PARAMETERS]
71
[SUPLA_SUPLET_MAX_PARAMETER_KEY_SIZE];
72
char
parameterDefaultText[SUPLA_SUPLET_MAX_PARAMETERS]
73
[SUPLA_SUPLET_MAX_PARAMETER_TEXT_SIZE];
74
char
parameterEnumValues[SUPLA_SUPLET_MAX_PARAMETERS]
75
[SUPLA_SUPLET_MAX_PARAMETER_TEXT_SIZE];
76
};
77
78
class
JsonDefinitionParser
{
79
public
:
80
static
bool
parse(
const
char
*json,
JsonDefinition
*output);
81
static
bool
parseCategory(
const
char
*value, Category *category);
82
static
bool
parseKind(
const
char
*value, Kind *kind);
83
static
bool
parseChannelKind(
const
char
*value, ChannelKind *kind);
84
static
bool
parseParameterType(
const
char
*value, ParameterType *type);
85
static
bool
parseParameterLifecycle(
const
char
*value,
86
ParameterLifecycle *lifecycle);
87
static
bool
parseDefaultFunction(
const
char
*value, int32_t *function);
88
};
89
90
}
// namespace Suplet
91
}
// namespace Supla
92
93
#endif
// SRC_SUPLA_SUPLET_JSON_DEFINITION_H_
Supla::Suplet::JsonDefinitionParser
Definition
json_definition.h:78
Supla::Suplet::JsonDefinition
Definition
json_definition.h:48
Supla::Suplet::ChannelDefinition
Definition
definition.h:101
Supla::Suplet::Definition
Definition
definition.h:138
Supla::Suplet::ParameterDefinition
Definition
definition.h:108
Generated by
1.17.0