4 * Created on: Dec 9, 2010
8 #ifndef DEVICECONFIG_HH_
9 #define DEVICECONFIG_HH_
18 enum EnumSummaryPeriod{PERIOD_YEARLY, PERIOD_MONTHLY, PERIOD_DAILY, PERIOD_HOURLY, PERIOD_MINUTELY, PERIOD_SECONDLY};
19 enum EnumSummaryCalculationType {SUM, DELTA, MIN, MAX, MEAN};
21 const std::string SUMMARY_PERIOD_NAMES_ARRAY[] = {"yearly", "monthly", "daily", "minutely", "secondly"};
22 const std::string CALCULATION_TYPE_NAMES_ARRAY[] = {"sum", "delta", "min", "max", "mean"};
24 #define DEVICE_CONFIG__FILE_NAME "device_cfg"
25 #define DEVICE_CONFIG__SECTION_TYPE "device"
26 #define DEVICE_CONFIG__SECTION_NAME "base_data"
27 #define DEVICE_CONFIG_VALUE_KEY__TYPE "type"
28 #define DEVICE_CONFIG_VALUE_KEY__ID "id"
29 #define DEVICE_CONFIG_VALUE_KEY__NAME "name"
31 #define DEFAULT_STORAGE_BASE_DIR "/tmp/w1data"
32 #define DATAFILE_SUFFIX ".txt"
33 #define CACHE_DIR_NAME "cache"
38 ConfigHandle(uci_context *ctx_param,
39 uci_package *pkg_param,
40 const char *short_fname_param,
41 const char *full_fname_param);
43 struct uci_context *_ctx;
44 struct uci_package *_pkg;
51 DeviceConfig(std::string device_id_param);
52 virtual ~DeviceConfig();
53 static std::string get_base_dir_name();
54 static void set_base_dir_name(std::string store_param);
55 static long get_read_interval_seconds();
56 static void set_read_interval_seconds(long seconds_param);
57 static DeviceConfig *get_device_config(std::string device_id);
58 std::string get_config_value(std::string key);
59 void set_config_value(std::string key,
61 EnumSummaryCalculationType get_summary_calculation_type();
63 static std::string store_base_dir;
64 static long read_interval_seconds;
65 std::string device_id;
66 std::string device_type;
67 ConfigHandle *uci_handle;
68 ConfigHandle *load_device_config(std::string device_id_param);
69 std::string get_dir_name(std::string device_id);
70 std::string get_file_name(std::string device_id_param);
74 #endif /* DEVICECONFIG_HH_ */