void ZWaveController::start(string command_line){ ZWaveController::running = true; InitializeCriticalSection(&g_criticalSection); Config config = Config::LoadConfig(command_line); Logger::Initialize(config.GetConfig("log_dir"), config.GetConfig("logfile_prefix"), ".log"); API::Initialize(config); ZWaveController::Initialize(config); }
void ZWaveController::Initialize(Config &config){ ZWaveController::homeId = 0; ZWaveController::initial_node_queries_complete = false; ZWaveController::init_failed = false; ZWaveController::config = config; // Create the OpenZWave Manager. // The first argument is the path to the config files (where the manufacturer_specific.xml file is located // The second argument is the path for saved Z-Wave network state and the log file. If you leave it NULL // the log file will appear in the program's working directory. string zwave_manufacturer_xml_dir = ZWaveController::config.GetConfig("zwave_manufacturer_xml_dir"); string data_dir = ZWaveController::config.GetConfig("data_dir"); Options::Create(zwave_manufacturer_xml_dir, data_dir, ""); Options::Get()->AddOptionInt("SaveLogLevel", LogLevel_Debug); Options::Get()->AddOptionInt("QueueLogLevel", LogLevel_Debug); Options::Get()->AddOptionInt("DumpTrigger", LogLevel_Debug); Options::Get()->AddOptionInt("PollInterval", 500); Options::Get()->AddOptionBool("IntervalBetweenPolls", true); Options::Get()->AddOptionBool("ValidateValueChanges", true); Options::Get()->Lock(); Manager::Create(); // Add a callback handler to the manager. The second argument is a context that // is passed to the OnNotification method. If the OnNotification is a method of // a class, the context would usually be a pointer to that class object, to // avoid the need for the notification handler to be a static. Manager::Get()->AddWatcher(OnNotification, new ZWaveController()); // Add a Z-Wave Driver // Modify this line to set the correct serial port for your PC interface. string port = "\\\\.\\COM"; string com_port = config.GetConfig("controller_com_port"); port += com_port; Manager::Get()->AddDriver(port); }