summaryrefslogtreecommitdiff
path: root/enhanced-position-service/src/configuration.cpp
blob: 959c4aa66474a131873ac1237e4336deb427e732 (plain)
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
/**************************************************************************
* @licence app begin@
*
* SPDX-License-Identifier: MPL-2.0
*
* \ingroup EnhancedPositionService
* \author Marco Residori <marco.residori@xse.de>
*
* \copyright Copyright (C) 2014, XS Embedded GmbH
* 
* \license
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @licence end@
**************************************************************************/

#include "configuration.h"
#include "positioning-constants.h"
#include "log.h"

DLT_IMPORT_CONTEXT(gCtx);

static DBus::Variant variant_uint16(uint16_t i)
{
  DBus::Variant variant;
  DBus::MessageIter iter=variant.writer();
  iter << i;
  return variant;
}

static DBus::Variant variant_int32(int32_t i)
{
  DBus::Variant variant;
  DBus::MessageIter iter=variant.writer();
  iter << i;
  return variant;
}

static DBus::Variant variant_array_uint16(std::vector< uint16_t > i)
{
	DBus::Variant variant;
	DBus::MessageIter iter=variant.writer();
	iter << i;
	return variant;
}

static DBus::Variant variant_array_int32(std::vector< int32_t > i)
{
	DBus::Variant variant;
	DBus::MessageIter iter=variant.writer();
	iter << i;
	return variant;
}

Configuration::Configuration(DBus::Connection &connection, const char * path)
  : DBus::ObjectAdaptor(connection, path)
{
}

Configuration::~Configuration()
{
}

::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > Configuration::GetVersion()
{
  ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > Version;

  Version._1 = 3;
  Version._2 = 0;
  Version._3 = 0;
  Version._4 = std::string("05-08-2014");

  return Version;
}
    
std::map< std::string, ::DBus::Variant > Configuration::GetProperties()
{
  std::map< std::string, ::DBus::Variant > Properties;

  Properties["UpdateInterval"] = variant_int32(1000);
  Properties["SatelliteSystem"] = variant_uint16(POS_GPS);

  return Properties;
}

void Configuration::SetProperty(const std::string& name, const ::DBus::Variant& value)
{
  throw DBus::ErrorNotSupported("Method not supported yet");
}

std::map< std::string, ::DBus::Variant > Configuration::GetSupportedProperties()
{
  std::map< std::string, ::DBus::Variant > SupportedProperties;

  std::vector< int32_t > updateIntervals;
  updateIntervals.push_back(1000);

  std::vector< uint16_t > satelliteSystems;
  satelliteSystems.push_back(POS_GPS);
  satelliteSystems.push_back(POS_GLONASS);
  satelliteSystems.push_back(POS_GALILEO);
  satelliteSystems.push_back(POS_COMPASS);

  SupportedProperties["UpdateInterval"] = variant_array_int32(updateIntervals);
  SupportedProperties["SatelliteSystem"] =  variant_array_uint16(satelliteSystems);

  return SupportedProperties;
}

void Configuration::run()
{
  LOG_INFO_MSG(gCtx,"Starting Configuration dispatcher...");
}

void Configuration::shutdown()
{
  LOG_INFO_MSG(gCtx,"Shutting down Configuration dispatcher...");
}