Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VILLASnode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Schroeder
VILLASnode
Commits
2fc07818
Commit
2fc07818
authored
3 years ago
by
Manuel Pitz
Browse files
Options
Downloads
Patches
Plain Diff
formats: add specific json format for edgeFlex
parent
1509939a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/villas/formats/json_edgeflex.hpp
+40
-0
40 additions, 0 deletions
include/villas/formats/json_edgeflex.hpp
lib/formats/CMakeLists.txt
+1
-0
1 addition, 0 deletions
lib/formats/CMakeLists.txt
lib/formats/json_edgeflex.cpp
+62
-0
62 additions, 0 deletions
lib/formats/json_edgeflex.cpp
with
103 additions
and
0 deletions
include/villas/formats/json_edgeflex.hpp
0 → 100644
+
40
−
0
View file @
2fc07818
/** JSON serializtion for edgeFlex project.
*
* @author Manuel Pitz <manuel.pitz@eonerc.rwth-aachen.de>
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#pragma once
#include
<villas/formats/json.hpp>
namespace
villas
{
namespace
node
{
class
JsonEdgeflexFormat
:
public
JsonFormat
{
protected:
int
packSample
(
json_t
**
j
,
const
struct
sample
*
smp
);
public:
using
JsonFormat
::
JsonFormat
;
};
}
/* namespace node */
}
/* namespace villas */
This diff is collapsed.
Click to expand it.
lib/formats/CMakeLists.txt
+
1
−
0
View file @
2fc07818
...
...
@@ -62,6 +62,7 @@ endif()
list
(
APPEND FORMAT_SRC
column.cpp
iotagent_ul.cpp
json_edgeflex.cpp
json_kafka.cpp
json_reserve.cpp
json.cpp
...
...
This diff is collapsed.
Click to expand it.
lib/formats/json_edgeflex.cpp
0 → 100644
+
62
−
0
View file @
2fc07818
/** JSON serializtion for edgeFlex project.
*
* @author Manuel Pitz <manuel.pitz@eonerc.rwth-aachen.de>
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include
<cstring>
#include
<villas/timing.h>
#include
<villas/formats/json_edgeflex.hpp>
using
namespace
villas
::
node
;
int
JsonEdgeflexFormat
::
packSample
(
json_t
**
json_smp
,
const
struct
sample
*
smp
)
{
json_error_t
err
;
json_t
*
json_value
;
json_t
*
json_created
=
nullptr
;
if
(
smp
->
flags
&
(
int
)
SampleFlags
::
HAS_TS_ORIGIN
)
json_created
=
json_integer
(
time_to_double
(
&
smp
->
ts
.
origin
)
*
1e3
);
struct
signal
*
sig
=
(
struct
signal
*
)
vlist_at_safe
(
smp
->
signals
,
0
);
if
(
!
sig
)
return
-
1
;
json_value
=
json_pack_ex
(
&
err
,
0
,
"{ s: f }"
,
"value"
,
smp
->
data
[
0
].
f
);
if
(
json_created
)
json_object_set_new
(
json_value
,
"created"
,
json_created
);
if
(
json_value
==
nullptr
)
return
-
1
;
*
json_smp
=
json_value
;
return
0
;
}
static
char
n
[]
=
"json.edgeflex"
;
static
char
d
[]
=
"EdgeFlex JSON format"
;
static
FormatPlugin
<
JsonEdgeflexFormat
,
n
,
d
,
(
int
)
SampleFlags
::
HAS_TS_ORIGIN
|
(
int
)
SampleFlags
::
HAS_SEQUENCE
|
(
int
)
SampleFlags
::
HAS_DATA
>
p
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment