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, uci_package *pkg_param);
40 struct uci_context *_ctx;
41 struct uci_package *_pkg;
46 DeviceConfig(std::string device_id_param);
47 virtual ~DeviceConfig();
48 static std::string get_base_dir_name();
49 static void set_base_dir_name(std::string store_param);
50 static DeviceConfig *get_device_config(std::string device_id);
51 std::string get_cfg_value(std::string key);
52 void set_cfg_value(std::string key, std::string value);
53 EnumSummaryCalculationType get_summary_calculation_type();
55 static std::string store_base_dir;
56 std::string device_id;
57 std::string device_type;
58 ConfigHandle *uci_handle;
59 ConfigHandle *load_device_config(std::string device_id_param);
60 std::string get_dir_name(std::string device_id);
61 std::string get_file_name(std::string device_id_param);
65 #endif /* DEVICECONFIG_HH_ */