4 * Created on: Dec 9, 2010
8 #ifndef DEVICECONFIG_HH_
9 #define DEVICECONFIG_HH_
19 enum EnumSummaryPeriod{PERIOD_YEARLY, PERIOD_MONTHLY, PERIOD_DAILY, PERIOD_HOURLY, PERIOD_MINUTELY, PERIOD_SECONDLY};
20 enum EnumSummaryCalculationType {SUM, DELTA, MIN, MAX, MEAN};
22 const std::string SUMMARY_PERIOD_NAMES_ARRAY[] = {"yearly", "monthly", "daily", "minutely", "secondly"};
23 const std::string CALCULATION_TYPE_NAMES_ARRAY[] = {"sum", "delta", "min", "max", "mean"};
25 #define DEVICE_CONFIG__FILE_NAME "device_cfg"
26 #define DEVICE_CONFIG__SECTION_TYPE "device"
27 #define DEVICE_CONFIG__SECTION_NAME "base_data"
28 #define DEVICE_CONFIG_VALUE_KEY__TYPE "type"
29 #define DEVICE_CONFIG_VALUE_KEY__ID "id"
30 #define DEVICE_CONFIG_VALUE_KEY__NAME "name"
32 #define DEFAULT_STORAGE_BASE_DIR "/tmp/w1data"
33 #define DATAFILE_SUFFIX ".txt"
34 #define CACHE_DIR_NAME "cache"
39 ConfigHandle(uci_context *ctx_param, uci_package *pkg_param);
41 struct uci_context *_ctx;
42 struct uci_package *_pkg;
47 DeviceConfig(std::string device_id_param);
48 virtual ~DeviceConfig();
49 static std::string get_base_dir_name();
50 static void set_base_dir_name(std::string store_param);
51 static DeviceConfig *get_device_config(std::string device_id);
52 std::string get_config_value(std::string key);
53 void set_config_value(std::string key,
55 bool save_immediately);
56 EnumSummaryCalculationType get_summary_calculation_type();
58 static std::string store_base_dir;
59 std::string device_id;
60 std::string device_type;
61 ConfigHandle *uci_handle;
62 ConfigHandle *load_device_config(std::string device_id_param);
63 std::string get_dir_name(std::string device_id);
64 std::string get_file_name(std::string device_id_param);
68 #endif /* DEVICECONFIG_HH_ */