コード例 #1
0
ファイル: nfd.cpp プロジェクト: named-data/NFD
void
Nfd::initialize()
{
  configureLogging();

  m_forwarder = make_unique<Forwarder>();

  FaceTable& faceTable = m_forwarder->getFaceTable();
  faceTable.addReserved(face::makeNullFace(), face::FACEID_NULL);
  faceTable.addReserved(face::makeNullFace(FaceUri("contentstore://")), face::FACEID_CONTENT_STORE);
  m_faceSystem = make_unique<face::FaceSystem>(faceTable, m_netmon);

  initializeManagement();

  PrivilegeHelper::drop();

  m_netmon->onNetworkStateChanged.connect([this] {
      // delay stages, so if multiple events are triggered in short sequence,
      // only one auto-detection procedure is triggered
      m_reloadConfigEvent = getScheduler().schedule(5_s,
        [this] {
          NFD_LOG_INFO("Network change detected, reloading face section of the config file...");
          this->reloadConfigFileFaceSection();
        });
    });
}
コード例 #2
0
ファイル: main.cpp プロジェクト: moschulze/lighter
int main(int argv, char* argc[]) {
    START_EASYLOGGINGPP(argv, argc);
    configureLogging();

    char* configPath = (char *) "./config.json";
    LOG(INFO) << "Loading configuration from " << configPath;
    ConfigurationLoader* configLoader = new ConfigurationLoader();
    Configuration* config = configLoader->loadFromFile(configPath);
    VLOG(9) << "Configuration values:" << std::endl << config->toString();

    kernel = new Kernel(config);
    signal(SIGINT, signalHandler);
    kernel->boot();

    return 0;
}
コード例 #3
0
ファイル: nfd.cpp プロジェクト: named-data/NFD
void
Nfd::reloadConfigFile()
{
  configureLogging();

  ConfigFile config(&ignoreRibAndLogSections);
  general::setConfigFile(config);

  TablesConfigSection tablesConfig(*m_forwarder);
  tablesConfig.setConfigFile(config);

  m_authenticator->setConfigFile(config);
  m_faceSystem->setConfigFile(config);

  if (!m_configFile.empty()) {
    config.parse(m_configFile, false);
  }
  else {
    config.parse(m_configSection, false, INTERNAL_CONFIG);
  }
}
コード例 #4
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    configureLogging();

    INFO_LOG("============================================ CRASH REPORTER BEGIN =============================================");
    INFO_LOG(QString("%1 Crash Reporter Version %2 BuildID %3").arg(udg::ApplicationNameString).arg(udg::StarviewerVersionString).arg(udg::StarviewerBuildID));

    int returnValue;
    // Seguint les recomanacions de la documentació de Qt, guardem la llista d'arguments en una variable, ja que aquesta operació és costosa
    // http://doc.trolltech.com/4.7/qcoreapplication.html#arguments
    QStringList commandLineArgumentsList = app.arguments();
    if (commandLineArgumentsList.size() != 3)
    {
        returnValue = false;
    }
    else
    {
        app.setOrganizationName(udg::OrganizationNameString);
        app.setOrganizationDomain(udg::OrganizationDomainString);
        app.setApplicationName(udg::ApplicationNameString);

        udg::CoreSettings coreSettings;
        coreSettings.init();

        initializeTranslations(app);

        udg::QCrashReporter reporter(commandLineArgumentsList);
        reporter.show();

        returnValue = app.exec();
    }

    INFO_LOG(QString("%1 Crash Reporter Version %2 BuildID %3, returnValue %4").arg(udg::ApplicationNameString).arg(udg::StarviewerVersionString)
             .arg(udg::StarviewerBuildID).arg(returnValue));
    INFO_LOG("============================================= CRASH REPORTER END ==============================================");

    return returnValue;
}
コード例 #5
0
ファイル: loggingconfig.cpp プロジェクト: Fuitad/mapcrafter
void LoggingConfig::configureLogging(const fs::path& logging_config) {
	if (logging_config.empty()) {
		LOG(WARNING) << "Unable to find a global logging configuration file!";
		return;
	}

	LoggingConfig config;
	ValidationMap validation = config.parse(logging_config.string());
	if (!validation.isEmpty()) {
		if (validation.isCritical())
			LOG(FATAL) << "Unable to parse global logging configuration file:";
		else
			LOG(WARNING) << "There is a problem parsing the global logging configuration file:";
		validation.log();
	}
	if (validation.isCritical())
		return;

	auto log_sections = config.getLogSections();
	for (auto it = log_sections.begin(); it != log_sections.end(); ++it)
		it->configureLogging();
}
コード例 #6
0
void AbstractGeneratorConfig::initialize(AbstractConfiguration& appConfig)
{
    // add the application config as a read-only layer
    this->addWriteable(&appConfig, 0, true);

    // set partitioning and sizing parameters
    if (!hasProperty("application.scaling-factor"))
    {
        setDouble("application.scaling-factor", getDouble("common.defaults.scaling-factor", 1.0));
    }

    setInt("common.partitioning.number-of-chunks", getInt("application.node-count", 1));
    setInt("common.partitioning.chunks-id", getInt("application.node-id", 0));

    // configure directory structure
    setString("application.job-dir", format("%s/%s", getString("application.output-base"), getString("application.job-id")));
    setString("application.output-dir", format("%s/node%03d", getString("application.job-dir"), getInt("common.partitioning.chunks-id")));
    setString("application.log-path", format("%s/log/node%03d.log", getString("application.job-dir"), getInt("common.partitioning.chunks-id")));

    // expose some application.* parameters unter generator.ENV.*
    setString("generator.ENV.config-dir", getString("application.config-dir"));
    setString("generator.ENV.output-dir", getString("application.output-dir"));

    configureLogging();

    _logger.information("Loading generator configuration");

    configurePartitioning();
    configureFunctions();
    configureSets();

    if (hasProperty("common.master.seed"))
    {
        // initialize the master random stream (otherwise - use the default master seed)
        _masterPRNG.seed(RandomStream::Seed(getString("common.master.seed")));
    }
}
コード例 #7
0
	bool FalconCLIBase::parseOptions(int argc, char** argv)
	{
		try
		{
			po::store(po::parse_command_line(argc, argv, m_progOptions), m_varMap);
			po::notify(m_varMap);
		}
		catch(...)
		{
			std::cout << "Invalid Arguments. Please try again." << std::endl << std::endl;
			outputProgramOptions();
			return false;
		}
		
		if (m_varMap.count("help")) {
			outputProgramOptions();
			return false;
		}

#ifdef ENABLE_LOGGING
		std::string logPattern(TTCC_CONVERSION_PATTERN);
		log4cxx::LevelPtr logLevel = log4cxx::Level::toLevel("FATAL");

		if(m_varMap.count("debug_level"))
		{
			logLevel = log4cxx::Level::toLevel(m_varMap["debug_level"].as<std::string>());
		}

		configureLogging(logPattern, logLevel);
#endif
		
		m_falconDevice->setFalconFirmware<FalconFirmwareNovintSDK>();
		
		//First off, see if we have a communication method
		if(m_varMap.count("libftdi") && m_varMap.count("ftd2xx"))
		{
			std::cout << "Error: can only use one comm method. Choose either libftdi or ftd2xx, depending on which is available." << std::endl;
			return false;
		}
		
		//This is an either/or choice, since we have problems with static linking and ftd2xx. Prefer libusb1, then libftdi. Thanks for the static linking against old libusb binaries, FTDI!

#if defined(LIBUSB)
		else if (m_varMap.count("libusb"))
		{
			std::cout << "Setting up libusb device" << std::endl;
			m_falconDevice->setFalconComm<FalconCommLibUSB>();
		}
#endif
#if defined(LIBFTDI)
		else if (m_varMap.count("libftdi"))
		{
			std::cout << "Setting up libftdi device" << std::endl;
			m_falconDevice->setFalconComm<FalconCommLibFTDI>();
		}
#elif defined(LIBFTD2XX)
		else if (m_varMap.count("ftd2xx"))
		{
			std::cout << "Setting up ftd2xx device" << std::endl;
			m_falconDevice->setFalconComm<FalconCommFTD2XX>();
		}
#endif
        else
		{
            std::cout << "No communication method selected." << std::endl;
			outputProgramOptions();
            return false;
        }


		//Device count check
		if(m_varMap.count("device_count"))
		{
			int8_t count;
			m_falconDevice->getDeviceCount(count);
			std::cout << "Connected Device Count: " << (int)count << std::endl;
			return false;
		}		
		else if(m_varMap.count("device_index"))
		{
			if(!m_falconDevice->open(m_varMap["device_index"].as<int>()))
			{
				std::cout << "Cannot open falcon device index " << m_varMap["device_index"].as<int>() << " - Lib Error Code: " << m_falconDevice->getErrorCode() << " Device Error Code: " << m_falconDevice->getFalconComm()->getDeviceErrorCode() << std::endl;
				return false;
			}
		}
		else
		{
			std::cout << "No device index specified to open, cannot continue (--help for options)" << std::endl;
			return false;			
		}

		//There's only one kind of firmware right now, so automatically set that.
		m_falconDevice->setFalconFirmware<FalconFirmwareNovintSDK>();
		//See if we have firmware
		bool firmware_loaded = m_falconDevice->isFirmwareLoaded();	 
		if((m_varMap.count("firmware") || m_varMap.count("test_firmware") || m_varMap.count("nvent_firmware")) && (m_varMap.count("force_firmware") || !firmware_loaded))
		{
			std::cout << "Loading firmware" << std::endl;
			if(m_varMap.count("nvent_firmware"))
			{
				for(int i = 0; i < 10; ++i)
				{
					if(!m_falconDevice->getFalconFirmware()->loadFirmware(m_varMap.count("skip_checksum") > 0, NOVINT_FALCON_NVENT_FIRMWARE_SIZE, const_cast<uint8_t*>(NOVINT_FALCON_NVENT_FIRMWARE)))
					{
						std::cout << "Could not load firmware" << std::endl;
					}
					else
					{
						std::cout <<"Firmware loaded" << std::endl;
						break;
					}
				}
			}
			else if(m_varMap.count("test_firmware"))
			{
				for(int i = 0; i < 10; ++i)
				{
					if(!m_falconDevice->getFalconFirmware()->loadFirmware(m_varMap.count("skip_checksum") > 0, NOVINT_FALCON_TEST_FIRMWARE_SIZE, const_cast<uint8_t*>(NOVINT_FALCON_TEST_FIRMWARE)))
					{
						std::cout << "Could not load firmware" << std::endl;
					}
					else
					{
						std::cout <<"Firmware loaded" << std::endl;
						break;
					}
				}
			}
			else if(m_varMap.count("firmware"))
			{
				//Check for existence of firmware file
				std::string firmware_file = m_varMap["firmware"].as<std::string>();
				if(!m_falconDevice->setFirmwareFile(firmware_file))
				{
					std::cout << "Cannot find firmware file - " << firmware_file << std::endl;
					return false;
				}
				if(!m_falconDevice->loadFirmware(10, m_varMap.count("skip_checksum") > 0))
				{
					std::cout << "Cannot load firmware to device" << std::endl;
					std::cout << "Error Code: " << m_falconDevice->getErrorCode() << std::endl;
					if(m_falconDevice->getErrorCode() == 2000)
					{
						std::cout << "Device Error Code: " << m_falconDevice->getFalconComm()->getDeviceErrorCode() << std::endl;
					}
					return false;
				}
			}
		}
		else if(!firmware_loaded)
		{
			std::cout << "No firmware loaded to device, and no firmware specified to load (--nvent_firmware, --test_firmware, etc...). Cannot continue" << std::endl;
			return false;
		}
		else
		{
			return true;
		}
		if(!m_falconDevice->isFirmwareLoaded())
		{
			std::cout << "No firmware loaded to device, cannot continue" << std::endl;
			return false;
		}
		
		return true;
	}
コード例 #8
0
ファイル: main.cpp プロジェクト: hitzi/emeocv
int main(int argc, char **argv) {
    int opt;
    ImageInput* pImageInput = 0;
    int inputCount = 0;
    std::string outputDir;
    std::string logLevel = "ERROR";
    char cmd = 0;
    int cmdCount = 0;

    while ((opt = getopt(argc, argv, "i:c:ltaws:o:v:h")) != -1) {
        switch (opt) {
            case 'i':
                pImageInput = new DirectoryInput(Directory(optarg, ".png"));
                inputCount++;
                break;
            case 'c':
                pImageInput = new CameraInput(atoi(optarg));
                inputCount++;
                break;
            case 'l':
            case 't':
            case 'a':
            case 'w':
                cmd = opt;
                cmdCount++;
                break;
            case 'o':
                cmd = opt;
                cmdCount++;
                outputDir = optarg;
                break;
            case 's':
                delay = atoi(optarg);
                break;
            case 'v':
                logLevel = optarg;
                break;
            case 'h':
            default:
                usage(argv[0]);
                exit(EXIT_FAILURE);
                break;
        }
    }
    if (inputCount != 1) {
        std::cerr << "*** You should specify exactly one camera or input directory!\n\n";
        usage(argv[0]);
        exit(EXIT_FAILURE);
    }
    if (cmdCount != 1) {
        std::cerr << "*** You should specify exactly one operation!\n\n";
        usage(argv[0]);
        exit(EXIT_FAILURE);
    }

    configureLogging(logLevel, cmd == 'a');

    switch (cmd) {
        case 'o':
            pImageInput->setOutputDir(outputDir);
            capture(pImageInput);
            break;
        case 'l':
            learnOcr(pImageInput);
            break;
        case 't':
            testOcr(pImageInput);
            break;
        case 'a':
            adjustCamera(pImageInput);
            break;
        case 'w':
            writeData(pImageInput);
            break;
    }

    delete pImageInput;
    exit(EXIT_SUCCESS);
}