示例#1
0
VSCVideoSetting::VSCVideoSetting(QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);

	astring strExportPath = "ve";

	gFactory->GetDefaultHWAccel(m_bHWAccel);

	gFactory->GetExportPath(strExportPath);

	

	if (m_bHWAccel  == 1)
	{
	        ui.hwaccel->setChecked(true);
	}else
	{
		ui.hwaccel->setChecked(false);
	}

	ui.fileLoc->setText(strExportPath.c_str());

	connect( this->ui.pushButtonApply, SIGNAL( clicked() ), this, SLOT(applyConfig()));
	connect( this->ui.pushButtonDir, SIGNAL( clicked() ), this, SLOT(dirSelect()));
}
示例#2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    viewer = new PicManager(this);
    setCentralWidget(viewer);
    viewer->installEventFilter(this);

    wasMaximized = false;
    slideInterval = 4000;
    slideTimer = new QTimer(this);
    slideTimer->setInterval(slideInterval);
    //! if file numbers is 0 or 1, stop timer???......................
    connect(slideTimer, SIGNAL(timeout()), viewer, SLOT(nextPic()));

    connect(viewer, SIGNAL(imageChanged(QString)), SLOT(imageChanged(QString)));

    initContextMenu();
    initButtomBar();
    initSwitchFrame();

    registerAllFunction();

    resize(Config::WindowFitSize);
    QRect rect = QApplication::desktop()->availableGeometry();
    QPoint pos = QPoint((rect.width() - Config::WindowFitSize.width()) / 2 + rect.left(),
                        (rect.height() - Config::WindowFitSize.height()) / 2 + rect.top());
    move(pos);  // show this window in the center of Desktop
    readSettings();
    Config::insertConfigWatcher(this, SLOT(applyConfig()));

    imageChanged();
    setWindowIcon(QIcon(":/appIcon"));
    setAcceptDrops(true);   //! !!
}
示例#3
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QCoreApplication::setOrganizationName("Gedial");
    QCoreApplication::setOrganizationDomain("gedial.com");
    QCoreApplication::setApplicationName("Subtivals");
    a.setQuitOnLastWindowClosed(true);
    SubtitlesForm f;
    MainWindow w;
    QObject::connect(&w, SIGNAL(eventStart(Event*)), &f, SLOT(addEvent(Event*)));
    QObject::connect(&w, SIGNAL(eventEnd(Event*)), &f, SLOT(remEvent(Event*)));
    QObject::connect(&w, SIGNAL(configChanged()), &f, SLOT(applyConfig()));
    QObject::connect(&w, SIGNAL(toggleHide(bool)), &f, SLOT(toggleHide(bool)));
    f.show();
    w.show();
    // If more than one arg and last arg is a file, open it
    if( argc > 1)
    {
        QFileInfo fileInfo(argv[argc - 1]);
        if (fileInfo.exists() && fileInfo.isReadable())
        {
           w.openFile(fileInfo.absoluteFilePath());
        }

    }
    return a.exec();
}
示例#4
0
文件: config.c 项目: andrmuel/r0ket
int readConfig(void){
    FIL file;            /* File object */
    UINT readbytes;
    UINT allread;
    int res;

    res=f_open(&file, CONFFILE, FA_OPEN_EXISTING|FA_READ);
    if(res){
        return 1;
    };

    CONF_ITER{
        res = f_read(&file, &the_config[i].value, sizeof(uint8_t), &readbytes);
        allread+=readbytes;
        if(GLOBAL(version) != CFGVER){
            GLOBAL(version) =CFGVER;
            return 1;
        };
        if(res || GLOBAL(version) != CFGVER)
            return 1;
    };


    res=f_close(&file);
    if(res){
        return 1;
    };

    applyConfig();
    return 0;
}
void in_received_handler(DictionaryIterator *received, void *context) {
	bool somethingChanged = false;
		
	Tuple *dateorder = dict_find(received, CONFIG_KEY_DATEORDER);
	Tuple *weekday = dict_find(received, CONFIG_KEY_WEEKDAY);
	Tuple *lang = dict_find(received, CONFIG_KEY_LANG);
	Tuple *stripes = dict_find(received, CONFIG_KEY_STRIPES);
	
	if (dateorder && weekday && lang && stripes) {
		APP_LOG(APP_LOG_LEVEL_DEBUG, "Received config (dateorder=%d, weekday=%d, lang=%d, stripes=%d)",
				(int)dateorder->value->int32, (int)weekday->value->int32, (int)lang->value->int32,
				(int)stripes->value->int32);
		
		somethingChanged |= checkAndSaveInt(&USDate, dateorder->value->int32, CONFIG_KEY_DATEORDER);
		somethingChanged |= checkAndSaveInt(&showWeekday, weekday->value->int32, CONFIG_KEY_WEEKDAY);
		somethingChanged |= checkAndSaveInt(&curLang, lang->value->int32, CONFIG_KEY_LANG);
		stripedDigitsChanged |= checkAndSaveInt(&stripedDigits, stripes->value->int32, CONFIG_KEY_STRIPES);
				
		if (somethingChanged) {
			applyConfig();
		} else if (stripedDigitsChanged) {
			stripedDigitsChanged = false;
			redrawAllSlots();
		}
	}
}
void ConfigDialogImpl::slotOk()
{
    applyConfig();
    writeConfig();
    emit(newSettings());
    delete ui;
}
示例#7
0
SpellCheckConfigDialog::SpellCheckConfigDialog(SpellCheck *spellcheck, QWidget *parent)
    : KDialog(parent)
{
    ui = new SpellCheckConfig(spellcheck, this);
    connect(this, SIGNAL(okClicked()), ui, SLOT(applyConfig()));
    setMainWidget(ui);
    setCaption(i18n("Configure Spell Check"));
}
void Exporter::postConstructor()
{

    createTree();

    applyConfig();

}
示例#9
0
VSCLicense::VSCLicense(QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	UpdateUI();
	connect( this->ui.pushButtonApply, SIGNAL( clicked() ), this, SLOT(applyConfig()));

}
示例#10
0
static GtkWidget *
thermal_constructor(LXPanel *panel, config_setting_t *settings)
{
    thermal *th;
    GtkWidget *p;
    const char *tmp;

    ENTER;
    th = g_new0(thermal, 1);
    th->panel = panel;
    th->settings = settings;

    p = gtk_event_box_new();
    lxpanel_plugin_set_data(p, th, thermal_destructor);
    gtk_widget_set_has_window(p, FALSE);
    gtk_container_set_border_width( GTK_CONTAINER(p), 2 );

    th->namew = gtk_label_new("ww");
    gtk_container_add(GTK_CONTAINER(p), th->namew);

    th->tip = g_string_new(NULL);

    /* By default, use automatic, that is, "not custom" temperature levels. If
     * we were using custom levels, they would be 0°C at startup, so we would
     * display in warning colors by default. */
    th->not_custom_levels = TRUE;

    if (config_setting_lookup_string(settings, "NormalColor", &tmp))
        th->str_cl_normal = g_strdup(tmp);
    if (config_setting_lookup_string(settings, "Warning1Color", &tmp))
        th->str_cl_warning1 = g_strdup(tmp);
    if (config_setting_lookup_string(settings, "Warning2Color", &tmp))
        th->str_cl_warning2 = g_strdup(tmp);
    config_setting_lookup_int(settings, "AutomaticSensor", &th->auto_sensor);
    /* backward compatibility for wrong variable */
    config_setting_lookup_int(settings, "CustomLevels", &th->not_custom_levels);
    config_setting_lookup_int(settings, "AutomaticLevels", &th->not_custom_levels);
    if (config_setting_lookup_string(settings, "Sensor", &tmp))
        th->sensor = g_strdup(tmp);
    config_setting_lookup_int(settings, "Warning1Temp", &th->warning1);
    config_setting_lookup_int(settings, "Warning2Temp", &th->warning2);

    if(!th->str_cl_normal)
        th->str_cl_normal = g_strdup("#00ff00");
    if(!th->str_cl_warning1)
        th->str_cl_warning1 = g_strdup("#fff000");
    if(!th->str_cl_warning2)
        th->str_cl_warning2 = g_strdup("#ff0000");

    applyConfig(p);

    gtk_widget_show(th->namew);

    update_display(th);
    th->timer = g_timeout_add_seconds(3, (GSourceFunc) update_display_timeout, (gpointer)th);

    RET(p);
}
示例#11
0
void VSCCameraAdd::SetupConnections()
{
	connect( this->ui.radioButtonFile, SIGNAL( clicked() ), this, SLOT(radioButtonClicked()));
	connect( this->ui.radioButtonRtsp, SIGNAL( clicked() ), this, SLOT(radioButtonClicked()));
	connect( this->ui.radioButtonOnvif, SIGNAL( clicked() ), this, SLOT(radioButtonClicked()));
	connect( this->ui.pushButtonApply, SIGNAL( clicked() ), this, SLOT(applyConfig()));
	connect( this->ui.pushButtonFile, SIGNAL( clicked() ), this, SLOT(fileSelect()));

}
示例#12
0
SubtitlesForm::SubtitlesForm(QWidget *parent) :
        QWidget(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint ),
    ui(new Ui::SubtitlesForm),
    m_maxEvents(2),
    m_visible(true)
{
    ui->setupUi(this);
    applyConfig();
}
示例#13
0
VSCLanguage::VSCLanguage(ClientFactory &pFactory, QWidget *parent)
	: QWidget(parent), m_pFactory(pFactory)
{
	ui.setupUi(this);

	m_pFactory.GetLang(m_nLang);
	connect( this->ui.pushButtonApply, SIGNAL( clicked() ), this, SLOT(applyConfig()));
	SetupValue();
}
示例#14
0
OMX_ERRORTYPE FmTxNmfMpc::configureMain(void) {
    OMX_ERRORTYPE error(OMX_ErrorNone);

    FmTx *proxy = static_cast<FmTx *>(&mENSComponent);
    error =  applyConfig((OMX_INDEXTYPE )OMX_IndexConfigAudioPower, proxy->getPowerConfig());
    if(error != OMX_ErrorNone){
        return error;
    }
    return AudioRendererAb8500NmfMpc::configureMain();
}
示例#15
0
文件: startup.c 项目: skreuzer/ptpd
/**
 * Signal handler for HUP which tells us to swap the log file
 * and reload configuration file if specified
 *
 * @param sig
 */
void
do_signal_sighup(RunTimeOpts * rtOpts, PtpClock * ptpClock)
{



	NOTIFY("SIGHUP received\n");

#ifdef RUNTIME_DEBUG
	if(rtOpts->transport == UDP_IPV4 && rtOpts->ipMode != IPMODE_UNICAST) {
		DBG("SIGHUP - running an ipv4 multicast based mode, re-sending IGMP joins\n");
		netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);
	}
#endif /* RUNTIME_DEBUG */


	/* if we don't have a config file specified, we're done - just reopen log files*/
	if(strlen(rtOpts->configFile) !=  0) {

	    dictionary* tmpConfig = dictionary_new(0);

	    /* Try reloading the config file */
	    NOTIFY("Reloading configuration file: %s\n",rtOpts->configFile);

            if(!loadConfigFile(&tmpConfig, rtOpts)) {

		    dictionary_del(&tmpConfig);

	    } else {
		    dictionary_merge(rtOpts->cliConfig, tmpConfig, 1, 1, "from command line");
		    applyConfig(tmpConfig, rtOpts, ptpClock);
		    dictionary_del(&tmpConfig);

	    }

	}

	/* tell the service it can perform any HUP-triggered actions */
	ptpClock->timingService.reloadRequested = TRUE;

	if(rtOpts->recordLog.logEnabled ||
	    rtOpts->eventLog.logEnabled ||
	    (rtOpts->statisticsLog.logEnabled))
		INFO("Reopening log files\n");

	restartLogging(rtOpts);

	if(rtOpts->statisticsLog.logEnabled)
		ptpClock->resetStatisticsLog = TRUE;


}
示例#16
0
void KStars::readConfig() {
    //Load config file values into Options object
    Options::self()->readConfig();

    applyConfig();

    //Reset date, if one was stored
    if ( data()->StoredDate.isValid() ) {
        data()->changeDateTime( data()->geo()->LTtoUT( data()->StoredDate ) );
        data()->StoredDate = KDateTime(); //invalidate StoredDate
    }

    map()->forceUpdate();
}
void KalmanOwt::initialize(const double device_time, const double localTimeSecs) {
  x_.setZero();
  x_[0] = localTimeSecs - device_time;

  P_.setZero();
  P_(0,0) = config.sigmaInitOffset * config.sigmaInitOffset;
  P_(1,1) = config.sigmaInitSkew * config.sigmaInitSkew;

  applyConfig();

  H_.setZero();
  H_(0,0) = 1;

  lastUpdateDeviceTime_ = device_time;
  isInitialized_ = true;
}
示例#18
0
Workbench::Workbench(QWidget *parent) :
    QWidget(parent), currentModeWidget(0)
{

    setMinimumSize(500, 300);
    setWindowTitle(tr("Workbench"));
    setFocusPolicy(Qt::WheelFocus);
    QApplication::setActiveWindow(this);
    raise();






    QHBoxLayout *mainLayout = new QHBoxLayout();


    QWidget *mainZone = new QWidget;
    zoneLayout = new QVBoxLayout;
    mainZone->setLayout(zoneLayout);



    commonToolBar = new QToolBar();
    commonToolBar->setOrientation(Qt::Vertical);


    this->resetCommonToolBar();

    mainLayout->addWidget(commonToolBar);
    mainLayout->addWidget(mainZone);

    mainLayout->setMargin(1);
    mainLayout->setSpacing(1);
    mainLayout->setContentsMargins(1,1,1,1);

    setLayout(mainLayout);


    show();



    applyConfig();

}
示例#19
0
文件: Arc_2.0.c 项目: linuxq/Arc_2.0
void in_received_handler(DictionaryIterator *received, void *context) {
	bool somethingChanged = false;

	Tuple *dateorder = dict_find(received, CONFIG_KEY_DATEORDER);
	Tuple *lang = dict_find(received, CONFIG_KEY_LANG);
	Tuple *light = dict_find(received, CONFIG_KEY_BACKLIGHT);
	
	if (dateorder && lang && light) {
		somethingChanged |= checkAndSaveInt(&USDate, dateorder->value->int32, CONFIG_KEY_DATEORDER);
		somethingChanged |= checkAndSaveInt(&curLang, lang->value->int32, CONFIG_KEY_LANG);
		somethingChanged |= checkAndSaveInt(&backlight, light->value->int32, CONFIG_KEY_BACKLIGHT);
		
		logVariables("ReceiveHandler");
		
		if (somethingChanged) {
			applyConfig();
		}
	}
}
示例#20
0
int
main(int argc, char **argv)
{
    if ((!parseArgs(argc, argv)) || (!getDisplay(argc, argv)))
        exit(-1);
    settings.locale.value = setlocale(LC_ALL, settings.locale.value);
    settings.locale.src = FROM_SERVER;
    VMSG1(7, "locale is %s\n", settings.locale.value);
    if (dpy)
        getServerValues();
    if (settings.config.value && (!applyConfig(settings.config.value)))
        exit(-3);
    if (!applyRules())
        exit(-4);
    if (!applyComponentNames())
        exit(-5);
    if (dpy)
        XCloseDisplay(dpy);
    exit(0);
}
示例#21
0
文件: setxkbmap.c 项目: aosm/X11apps
int
main(int argc, char **argv)
{
    if ((!parseArgs(argc, argv)) || (!getDisplay(argc, argv)))
        exit(-1);
    svValue[LOCALE_NDX] = setlocale(LC_ALL, svValue[LOCALE_NDX]);
    svSrc[LOCALE_NDX] = FROM_SERVER;
    VMSG1(7, "locale is %s\n", svValue[LOCALE_NDX]);
    if (dpy)
        getServerValues();
    if (svValue[CONFIG_NDX] && (!applyConfig(svValue[CONFIG_NDX])))
        exit(-3);
    if (!applyRules())
        exit(-4);
    if (!applyComponentNames())
        exit(-5);
    if (dpy)
        XCloseDisplay(dpy);
    exit(0);
}
void in_received_handler(DictionaryIterator *received, void *context) {
	bool somethingChanged = false;
	
	Tuple *dateorder = dict_find(received, CONFIG_KEY_DATEORDER);
	Tuple *weekday = dict_find(received, CONFIG_KEY_WEEKDAY);
	Tuple *lang = dict_find(received, CONFIG_KEY_LANG);
	
	if (dateorder && weekday && lang) {
		somethingChanged |= checkAndSaveInt(&USDate, dateorder->value->int32, CONFIG_KEY_DATEORDER);
		somethingChanged |= checkAndSaveInt(&showWeekday, weekday->value->int32, CONFIG_KEY_WEEKDAY);
		somethingChanged |= checkAndSaveInt(&curLang, lang->value->int32, CONFIG_KEY_LANG);
		
		snprintf(buffer, 256, "Received config (dateorder=%d, weekday=%d, lang=%d)", USDate, showWeekday, curLang);
		APP_LOG(APP_LOG_LEVEL_DEBUG, buffer);
		
		if (somethingChanged) {
			applyConfig();
		}
	}
}
示例#23
0
void TextZone::createContent()
{
    //    sounds = new Sounds(this);


    this->setAttribute(Qt::WA_KeyCompression, true);

    textDocument = new MainTextDocument(this);

    createActions();
    setContextMenuPolicy(Qt::DefaultContextMenu);
    connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(charFormat(QTextCharFormat)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChangedSlot()));

    setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);


    applyConfig();
}
DialogPreference::DialogPreference(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogPreference)
{
    ui->setupUi(this);
    cnf = new QSettings("Q-Uma","quma-skripsi",this);
    initAll();
    ui->listWidget->setViewMode(QListView::IconMode);
    ui->listWidget->setIconSize(QSize(75,75));
    ui->listWidget->setCurrentRow(0);
    ui->stackedWidget->setCurrentIndex(0);
    ui->listWidget->setAcceptDrops(false);
    curCat = 0;

    // bahasa
    ui->label_25->hide();
    ui->cbLang->hide();


    //Main Connection
    connect(ui->listWidget,SIGNAL(currentRowChanged(int)),
            ui->stackedWidget,SLOT(setCurrentIndex(int)));
    connect(ui->pbApply,SIGNAL(clicked()),this,SLOT(applyConfig()));
    connect(ui->pbClose,SIGNAL(clicked()),this,SLOT(closeDialog()));

    // Page General
    // Page Category
    connect(ui->cbCategory,SIGNAL(currentIndexChanged(int)),
            this,SLOT(changeCategory()));
    connect(ui->pbBrowseCatSaveDir,SIGNAL(clicked()),
            this,SLOT(browseCategorySaveDir()));
    connect(ui->leFilesType,SIGNAL(editingFinished()),
            this,SLOT(leType()));
    connect(ui->leCategorySaveDir,SIGNAL(editingFinished()),
            this,SLOT(leSaveDir()));

    setWindowTitle(tr("Preference"));
    setWindowIcon(QIcon(":/icon/menu/image/icon/Gear Alt.png"));
}
示例#25
0
void decodeThemeCode(char *code) {
#ifdef PBL_COLOR
  int i;

  for (i=0; i<6; i++) {
    color[COLOR_THEME_CUSTOM][i] = (GColor8){.argb=(uint8_t)hexStringToByte(code + 2*i)};
  }
#else
  // Do nothing on APLITE
#endif
}

void in_dropped_handler(AppMessageResult reason, void *context) {
}

void in_received_handler(DictionaryIterator *received, void *context) {
  bool somethingChanged = false;
  bool digitShapesHaveToBeSwapped = false;
  bool colorThemeChanged = false;

  Tuple *dateorder = dict_find(received, CONFIG_KEY_DATEORDER);
  Tuple *weekday = dict_find(received, CONFIG_KEY_WEEKDAY);
  Tuple *battery = dict_find(received, CONFIG_KEY_BATTERY);
  Tuple *bluetooth = dict_find(received, CONFIG_KEY_BLUETOOTH);
  Tuple *invert = dict_find(received, CONFIG_KEY_INVERT);
  Tuple *lang = dict_find(received, CONFIG_KEY_LANG);
  Tuple *stripes = dict_find(received, CONFIG_KEY_STRIPES);
  Tuple *corners = dict_find(received, CONFIG_KEY_ROUNDCORNERS);
  Tuple *digits = dict_find(received, CONFIG_KEY_FULLDIGITS);
  Tuple *colorThemeTuple = dict_find(received, CONFIG_KEY_COLORTHEME);
  Tuple *themeCodeTuple = dict_find(received, CONFIG_KEY_THEMECODE);

  if (dateorder && weekday && battery && bluetooth && invert && lang && stripes && corners && digits && colorThemeTuple && themeCodeTuple) {
    somethingChanged |= checkAndSaveInt(&USDate, dateorder->value->int32, CONFIG_KEY_DATEORDER);
    somethingChanged |= checkAndSaveInt(&showWeekday, weekday->value->int32, CONFIG_KEY_WEEKDAY);
    somethingChanged |= checkAndSaveInt(&curLang, lang->value->int32, CONFIG_KEY_LANG);

    checkAndSaveInt(&batteryStatus, battery->value->int32, CONFIG_KEY_BATTERY);
    checkAndSaveInt(&bluetoothStatus, bluetooth->value->int32, CONFIG_KEY_BLUETOOTH);

    digitShapesChanged = false;
    digitShapesChanged |= checkAndSaveInt(&invertStatus, invert->value->int32, CONFIG_KEY_INVERT);

    colorThemeChanged = checkAndSaveString(themeCodeText, themeCodeTuple->value->cstring, CONFIG_KEY_THEMECODE);
    digitShapesChanged |= colorThemeChanged;

    digitShapesChanged |= checkAndSaveInt(&stripedDigits, stripes->value->int32, CONFIG_KEY_STRIPES);
    digitShapesChanged |= checkAndSaveInt(&roundCorners, corners->value->int32, CONFIG_KEY_ROUNDCORNERS);

    digitShapesHaveToBeSwapped = checkAndSaveInt(&fullDigits, digits->value->int32, CONFIG_KEY_FULLDIGITS);
    digitShapesChanged |= digitShapesHaveToBeSwapped;
    digitShapesChanged |= checkAndSaveInt(&colorTheme, colorThemeTuple->value->int32, CONFIG_KEY_COLORTHEME);

    APP_LOG(APP_LOG_LEVEL_DEBUG, "Received config:");
    APP_LOG(APP_LOG_LEVEL_DEBUG, "  dateorder=%d, weekday=%d, battery=%d, BT=%d, invert=%d, lang=%d",
            USDate, showWeekday, batteryStatus, bluetoothStatus, invertStatus, curLang);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "  stripes=%d, corners=%d, digits=%d, colorTheme=%d",
            stripedDigits, roundCorners, fullDigits, colorTheme);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "  themeCodeText=%s", themeCodeText);

    if (colorThemeChanged) {
      decodeThemeCode(themeCodeText);
    }

    if (digitShapesHaveToBeSwapped) {
      swapDigitShapes();
    }

    if (somethingChanged) {
      applyConfig();
    }

    if (digitShapesChanged) {
      digitShapesChanged = false;
      redrawAllSlots();
    }
  }
}
示例#26
0
int main(){
  pid_t pid, sid;
  int       list_s;                /*  listening socket          */
  int       conn_s;                /*  connection socket         */
  short int port = 1995;                  /*  port number               */
  struct    sockaddr_in servaddr;  /*  socket address structure  */
  int i;
  uint8_t numClients = 0;
  threadInfo* info;

  /* Fork off the parent process */
  pid = fork();
  if(pid < 0) {
    exit(EXIT_FAILURE);
  }

  /* If we got a good PID, then we can exit the parent process */
  if(pid > 0){
    exit(EXIT_SUCCESS);
  }

  umask(0);

  printf("Daemon started.  Writing all further notices to daemon log: /var/log/daemon.log\n");

  // Enable Signal Handler
  signal(SIGTERM, catch_term);

  /* Open Log File Here */
  openlog("SEASSERVER",LOG_PID,LOG_DAEMON);
  syslog(LOG_DAEMON|LOG_INFO,"Daemon Started.");

  /* Open Config File Here */
  if(!readConfig()){
    syslog(LOG_DAEMON|LOG_ERR,"Unable to Read Configuration File.  Daemon Terminated.\n");
    exit(EXIT_FAILURE);
  }

  /* Create a new SID for the child process */
  sid = setsid();
  if(sid < 0){
    syslog(LOG_DAEMON|LOG_ERR,"Unable to create a new SID for child process. Daemon Terminated.");
    exit(EXIT_FAILURE);
  }

  /* Change the current working directory */
  if((chdir("/")) < 0){
    syslog(LOG_DAEMON|LOG_ERR,"Unable to switch working directory. Daemon Terminated.");
    exit(EXIT_FAILURE);
  }

  close(STDIN_FILENO);
  close(STDOUT_FILENO);
  close(STDERR_FILENO);

  /* Setup TCP/IP Socket */
  if((list_s = socket(AF_INET, SOCK_STREAM, 0)) < 0){
      syslog(LOG_DAEMON|LOG_ERR,"Unable to create socket. Daemon Terminated.");
      exit(EXIT_FAILURE);
  }

  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port = htons(port);

#ifdef DEBUG
  syslog(LOG_DAEMON|LOG_INFO,"Opening Spectrometers.");
#endif
  // Power Cycle GPIO for USB Hub to make sure USB ports initialized correctly
  //system("echo 0 > /sys/class/gpio/gpio168/value");
  //sleep(3);
  //system("echo 1 > /sys/class/gpio/gpio168/value");
  //sleep(3);
  // Connect the USB Spectrometers
  char *serialNumbers[NUM_SPECS] = {getSerialNumber(0),getSerialNumber(1)};
  if(connectSpectrometers(serialNumbers) == CONNECT_ERR)
  {
      syslog(LOG_DAEMON|LOG_ERR,"Spectrometers could not be opened.  Daemon Exiting");
      exit(EXIT_FAILURE);
  }
#ifdef DEBUG
  syslog(LOG_DAEMON|LOG_INFO,"Spectrometers Opened.");
#endif

  applyConfig();
  logConfig();

  // Start LON Dispatch
  syslog(LOG_DAEMON|LOG_INFO,"Starting LON Connection.");
  if(startDispatch(LONPORT) == -1){
      syslog(LOG_DAEMON|LOG_ERR,"LON Not Connected!  Check serial port.");
      exit(EXIT_FAILURE);
  } else {
    syslog(LOG_DAEMON|LOG_INFO,"LON Connection Started.");
  }

  // Init Bench Config and Power Management GPIOs (See SEASPeriperalCommands.c)
  readBenchConfig();
  initPeripherals();

  // Start CTD Sink
  CTDSink* ctdSink = CTDSink::Instance();

  /*  Bind our socket addresss to the
	listening socket, and call listen()  */

  if ( bind(list_s, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ) {
    syslog(LOG_DAEMON|LOG_ERR,"Unable to bind socket. Daemon Terminated.");
    exit(EXIT_FAILURE);
  }

  if ( listen(list_s, NUM_THREADS) < 0 ) {
    syslog(LOG_DAEMON|LOG_ERR,"Unable to listen on socket. Daemon Terminated.");
    exit(EXIT_FAILURE);
  }

  for(i=0; i < NUM_THREADS; i++)
      thread_bin_available[i] = AVAILABLE;

  execMode();

  while(keep_going){
    syslog(LOG_DAEMON|LOG_INFO,"Listening for connection on port %i", port);
    /* Wait for TCP/IP Connection */
    conn_s = accept(list_s, NULL, NULL);
    if ( conn_s < 0 ) {
        syslog(LOG_DAEMON|LOG_ERR,"Unable to call accept() on socket.");
        break;
    }

    /* Spawn a POSIX Server Thread to Handle Connected Socket */
    for(i=0; i < NUM_THREADS; i++){
        if(thread_bin_available[i]){
            thread_bin_available[i] = UNAVAILABLE;
            syslog(LOG_DAEMON|LOG_INFO,"Handling new connection on port %i",port);
            numClients++;
            info = (threadInfo*)malloc(sizeof(threadInfo));
            info->socket_connection = conn_s;
            info->thread_bin_index = i;
            pthread_create(&thread_bin[i],NULL,handleConnection, (void*)info);
            break;
        }
    }

    if(i > NUM_THREADS){
        syslog(LOG_DAEMON|LOG_ERR,"Unable to create thread to handle connection.  Continuing...");
    }
    
  }
  
  if(disconnectSpectrometers() == CONNECT_OK)
    syslog(LOG_DAEMON|LOG_INFO,"Spectrometers Successfully Disconnected");
  else
    syslog(LOG_DAEMON|LOG_ERR,"Unable to Disconnect Spectrometers");

  syslog(LOG_DAEMON|LOG_INFO,"Daemon Exited Politely.");
  exit(EXIT_SUCCESS);

}
示例#27
0
/*!
 * \brief Load configuration from file.
 * \param filename [in] Read configuration file path.
 */
void TConfiguration::loadConfiguration(const char *filename) {
  /* Check filename. */
  if (filename == NULL || strlen(filename) == 0) {
    return;
  }

  /* Open file. */
  FILE *conf = fopen(filename, "r");
  if (unlikely(conf == NULL)) {
    logger->printWarnMsgWithErrno("Could not open configuration file: %s",
                                  filename);
    return;
  }

#if USE_PCRE
  TPCRERegex confRegex("^\\s*(\\S+?)\\s*=\\s*(\\S+)\\s*$", 9);
#else
  TCPPRegex confRegex("^\\s*(\\S+?)\\s*=\\s*(\\S+)\\s*$");
#endif

  /* Get string line from configure file. */
  long lineCnt = 0;
  char *lineBuff = NULL;
  size_t lineBuffLen = 0;

  /* Read line. */
  while (likely(getline(&lineBuff, &lineBuffLen, conf) > 0)) {
    lineCnt++;
    /* If this line is empty. */
    if (unlikely(strlen(lineBuff) <= RETURN_CODE_LEN)) {
      /* skip this line. */
      continue;
    }

    /* Remove comments */
    char *comment = strchr(lineBuff, '#');
    if (comment != NULL) {
      *comment = '\0';
    }

    /* Check matched pair. */
    if (confRegex.find(lineBuff)) {
      /* Key and value variables. */
      char *key = confRegex.group(1);
      char *value = confRegex.group(2);

      /* Check key name. */
      try {
        applyConfig(key, value);
      } catch (const char *errStr) {
        logger->printWarnMsg("Configuration error(key=%s, value=%s): %s", key,
                             value, errStr);
      } catch (int err) {
        errno = err;
        logger->printWarnMsgWithErrno("Configuration error(key=%s, value=%s) ",
                                      key, value);
      }

      /* Cleanup after param setting. */
      free(key);
      free(value);
    }
  }

  /* Cleanup after load file. */
  if (likely(lineBuff != NULL)) {
    free(lineBuff);
  }
  fclose(conf);

  isLoaded = true;
  firstCollected = false;
}
示例#28
0
	void GanttWidget::applyConfig ()
	{
		m_config = m_config2;
		applyConfig(m_config);
	}
示例#29
0
	void GanttWidget::onApplyButton ()
	{
		setUIValuesToConfig(m_config);
		applyConfig(m_config);
	}
示例#30
0
	RecognitionResult recognizeImage(bool verbose, imago::Settings& vars, const imago::Image& src, const std::string& config)
	{
		std::vector<RecognitionResult> results;
		
		imago::ChemicalStructureRecognizer _csr;
		imago::Molecule mol;

		for (int iter = 0; ; iter++)
		{
			bool good = false;

			vars.general.StartTime = 0;

			try
			{
				imago::Image img;

				if (iter == 0)
				{
					if (!imago::prefilterEntrypoint(vars, img, src))
						break;
				}
				else
				{
					if (!imago::applyNextPrefilter(vars, img, src))
						break;
				}

				applyConfig(verbose, vars, config);
				_csr.image2mol(vars, img, mol);

				RecognitionResult result;
				result.molecule = imago::expandSuperatoms(vars, mol);
				result.warnings = mol.getWarningsCount() + mol.getDissolvingsCount() / vars.main.DissolvingsFactor;
				
				if (vars.dynamic.CapitalHeight < vars.main.MinGoodCharactersSize &&
					!vars.general.ImageAlreadyBinarized)
				{
					result.warnings += vars.main.WarningsForTooSmallCharacters;
				}

				results.push_back(result);

				good = result.warnings <= vars.main.WarningsRecalcTreshold;				
			
				if (verbose)
					printf("Filter [%u] done, warnings: %u, good: %u.\n", vars.general.FilterIndex, result.warnings, good);
			}
			catch (std::exception &e)
			{
				if (verbose)
					printf("Filter [%u] exception '%s'.\n", vars.general.FilterIndex, e.what());

			}

			if (good)
				break;
		} // for

		RecognitionResult result;
		result.warnings = 999; // just big number to override
		// select the best one
		for (size_t u = 0; u < results.size(); u++)
		{
			if (results[u].warnings < result.warnings)
			{
				result = results[u];
			}
		}
		return result;
	}