示例#1
0
int globalInit(void) {
	if (estgbconf.useFileConfig) {
		if (readFileConfig() != 0) {
			printf(
					"Warning! Failed to read config files. Checking for command line config...\n");
		}
	}
	 
	if (!checkConfig()) {
		printHelp();
		printConfig();
		printf("Configuration error. Nothing to do.\n\n");
		return 0;
	}

	if (telebot_create(&estgbconf.handle, estgbconf.token)
			!= TELEBOT_ERROR_NONE) {
		printf("Error. Telebot create failed (bad token?)\n\n");
		return 0;
	}

	if (estgbconf.proxy_addr != NULL) {
		estgbconf.ret = telebot_set_proxy(estgbconf.handle,
				estgbconf.proxy_addr, estgbconf.proxy_auth);
		if (estgbconf.ret != TELEBOT_ERROR_NONE) {
			printf("Warning! Failed to init proxy: %d \n", estgbconf.ret);
		}
	}

	return 1;
}
示例#2
0
void syncToConfigFile(void) {
   dn_error_t                    dnErr;
   INT8U                         fileBytes[sizeof(spiNetApp_configFileStruct_t)];
   spiNetApp_configFileStruct_t*  fileContents;
   dn_fs_handle_t                configFileHandle;
   
   fileContents = (spiNetApp_configFileStruct_t*)fileBytes;
   
   // prepare file content
   fileContents->period   = spiNetApp_vars.period;
   
   // open file
   configFileHandle = dn_fs_open(
      ACCELAPP_CONFIG_FILENAME,
      DN_FS_OPT_CREATE,
      sizeof(spiNetApp_configFileStruct_t),
      DN_FS_MODE_OTH_RW
   );
   ASSERT(configFileHandle >= 0);
   
   // write file
   dnErr = dn_fs_write(
      configFileHandle,
      0, // offset
      (INT8U*)fileContents,
      sizeof(spiNetApp_configFileStruct_t)
   );
   ASSERT(dnErr >= 0);
   
   // close file
   dn_fs_close(configFileHandle);
   
   // print
   printConfig();
}
示例#3
0
int parseCommandLine(int argc,
                     const char* argv[],
                     Json::Features& features,
                     std::string& path,
                     bool& parseOnly) {
  parseOnly = false;
  if (argc < 2) {
    return printUsage(argv);
  }

  int index = 1;
  if (std::string(argv[1]) == "--json-checker") {
    features = Json::Features::strictMode();
    parseOnly = true;
    ++index;
  }

  if (std::string(argv[1]) == "--json-config") {
    printConfig();
    return 3;
  }

  if (index == argc || index + 1 < argc) {
    return printUsage(argv);
  }

  path = argv[index];
  return 0;
}
示例#4
0
 void Version()
 {
     for(auto i = -128; i<=127; i++)
     {
         MsgParameter.config_getConfReplyVersion = to_string(i);
         printConfig( to_string(i) );
     }
 }
示例#5
0
文件: Main.c 项目: k2b3d/tconsrc
int main(int argc, char *argv[])
{
	pid_t 		pid ;
	int 		stat ;
	pthread_t	pthread_cancel_id, pthread_sms_id, pthread_cois_id ;	
	int			ret ;

	isDup(argv[0]) ;

	if((pid = fork()) < 0)
		return  -1;
	else    if(pid != 0)
		exit(0);

	setsid() ;

	set_signal() ;

	if (argc > 1) {
		if (argc == 3) {
			if (strcmp(argv[1], "-f") == 0) {
				strcpy(config_file_path, argv[2]);
			}
			else    {
				printf("---------------------------------\n");
				printf("-%s [-f ConfigFilePath]\n", argv[0]);
				printf("---------------------------------\n");
				}
			}
		else    {
			printf("---------------------------------\n");
			printf("-%s [-f ConfigFilePath]\n", argv[0]);
			printf("---------------------------------\n");
		}
	}
	else
		sprintf(config_file_path, "../config/TCenter.Config");

	memset(&Config, 0, sizeof(CONFIG_T)) ;
	readConfig(config_file_path, &Config) ;
	Log = openLog(argv[0], Config.LOG_FILE, LOG_MODE) ;
#ifdef _FOR_STAT_
	StatLog = openLog(argv[0], Config.STAT_LOG_PATH, LOG_MODE) ;
#endif
	printLog(HEAD, "=====[Program Start]=====\n") ;

	printConfig(&Config) ;

	pthread_mutex_init(&p_lock, NULL);
	thread_count = 0;

	Worker() ;

	exit_handler() ;
	return M_TRUE ;
}
示例#6
0
/**
 * Called from the USB-handler to set the sampling configuration
 * The sampling config is used for std reading and snooping.
 *
 * Other functions may read samples and ignore the sampling config,
 * such as functions to read the UID from a prox tag or similar.
 *
 * Values set to '0' implies no change (except for averaging)
 * @brief setSamplingConfig
 * @param sc
 */
void setSamplingConfig(sample_config *sc) {
	if(sc->divisor != 0) config.divisor = sc->divisor;
	if(sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample;
	if(sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
	
	config.decimation = (sc->decimation != 0) ? sc->decimation : 1;
	config.averaging = sc->averaging;
	if(config.bits_per_sample > 8)	config.bits_per_sample = 8;

	printConfig();
}
示例#7
0
文件: configfile.c 项目: elmo2k3/had
int writeConfig()
{
    FILE *config_file = fopen(had_used_config_file,"w");
    if(!config_file)
        return 0;
    g_debug("saving config file %s",had_used_config_file);

    printConfig((void*)fprintf,(void*)config_file);
    
    fclose(config_file);
    return 1;
}
示例#8
0
void CmdPin::printPort(int index, bool config)
{
    printf("GPIO %c: ", 'A' + index);
    for (int pin = 15; pin >= 0; --pin)
    {
        if (config)
        {
            printf("\n  %2i  ", pin);
            printConfig(mGpio[index], pin);
        }
        else
        {
            printValue(mGpio[index], pin);
            if ((pin % 4) == 0) printf(" ");
        }
    }
    printf("\n");
}
示例#9
0
/**
 * Main function
 *
 * @param argc Command line argument count
 * @param argv Command line argument value string array
 * @return Error code: 0 = OK, else error
 */
int main (int argc, char **argv)
{
   int result;

   scanOptions(argc, argv);
   printConfig();
   atexit(closeProtocol);
   openProtocol();

   // Additional parameters given for writing ?
   if (writeCnt > 0)
      result = writeSlave();
   else
      result = pollSlave();

   if (result == FTALK_SUCCESS)
      return (EXIT_SUCCESS);
   else
      return (EXIT_FAILURE);
}
示例#10
0
static int parseCommandLine(
    int argc, const char* argv[], Options* opts)
{
  opts->parseOnly = false;
  opts->write = &useStyledWriter;
  if (argc < 2) {
    return printUsage(argv);
  }
  int index = 1;
  if (JSONCPP_STRING(argv[index]) == "--json-checker") {
    opts->features = Json::Features::strictMode();
    opts->parseOnly = true;
    ++index;
  }
  if (JSONCPP_STRING(argv[index]) == "--json-config") {
    printConfig();
    return 3;
  }
  if (JSONCPP_STRING(argv[index]) == "--json-writer") {
    ++index;
    JSONCPP_STRING const writerName(argv[index++]);
    if (writerName == "StyledWriter") {
      opts->write = &useStyledWriter;
    } else if (writerName == "StyledStreamWriter") {
      opts->write = &useStyledStreamWriter;
    } else if (writerName == "BuiltStyledStreamWriter") {
      opts->write = &useBuiltStyledStreamWriter;
    } else {
      printf("Unknown '--json-writer %s'\n", writerName.c_str());
      return 4;
    }
  }
  if (index == argc || index + 1 < argc) {
    return printUsage(argv);
  }
  opts->path = argv[index];
  return 0;
}
示例#11
0
int main()
{
	int canDetectSensors = 0;
	
	SENSOR_DEVICE_HANDLE hDevice = 
		verboseOpenDevice(NULL);
	if(!hDevice) {
		return 0;
	}

	canDetectSensors = SensDev_canDetectSensors(hDevice);

	printf("Device can detect sensors: %d\n", canDetectSensors);

	if(canDetectSensors) {
		ExperimentConfig * newConfig;
		
		SensDev_getCurrentConfig(hDevice, &newConfig);
	
		printConfig(newConfig);
	}
	
	SensDev_close(hDevice);
}
示例#12
0
void CommHandler(void) //UART4 Interrupt handler implementation
{
    int c = GetChar();

    if (c >= 0)
    {
        //ConfigMode = 1;
        LEDon();
        //print("got char %02X\r\n", c);

        switch (c)
        {
            case 'b':
                print("rebooting into boot loader ...\r\n");
                Delay_ms(1000);
                bootloader();
                break;

            case 'c':
                debugCnt ^= 1;
                print("counter messages %s\r\n", debugCnt ? "on" : "off");
                break;

            case 'd':
                debugPrint ^= 1;
                print("debug messages %s\r\n", debugPrint ? "on" : "off");
                break;

            case 'g':
                Delay_ms(100);
                PutChar('x');

                for (int i = 0; i < CONFIGDATASIZE; i++)
                {
                    uint8_t data = configData[i];
                    PutChar(data);
                }

                break;

            case 'G':
                printConfig();
                break;

#if 0

            case 'H':
                if (CharAvailable() >= CONFIGDATASIZE)
                {
                    for (int i = 0; i < CONFIGDATASIZE; i++)
                    {
                        uint8_t data = GetChar();

                        if (data <= LARGEST_CONFIGDATA)
                        {
                            configData[i] = data;
                        }
                    }

                    configSave();
                }
                else
                {
                    UnGetChar(c); // try again in next loop
                }

                break;
#endif

            case 'h':
                for (int i = 0; i < CONFIGDATASIZE; i++)
                {
                    int data;

                    while ((data = GetChar()) < 0)
                        ;

                    if (data <= LARGEST_CONFIGDATA)
                    {
                        configData[i] = data;
                    }
                }

                configSave();
                break;

            case 'i':
                ConfigMode = 1;
                break;

            case 'j':
                ConfigMode = 0;
                break;

            case 'o':
                debugOrient ^= 1;
                print("Orientation messages %s\r\n", debugOrient ? "on" : "off");
                break;

            case 'p':
                debugPerf ^= 1;
                print("performance messages %s\r\n", debugPerf ? "on" : "off");
                break;

            case 'r':
                debugRC ^= 1;
                print("RC messages %s\r\n", debugRC ? "on" : "off");
                break;

            case 'R':
                print("rebooting...\r\n");
                Delay_ms(1000);
                reboot();
                break;

            case 's':
                debugSense ^= 1;
                print("Sensor messages %s\r\n", debugSense ? "on" : "off");
                break;

            case 'u':
            {
                extern int bDeviceState;
                printUSART("\r\nYY bDeviceState %3d  VCPConnectMode %d\r\n", bDeviceState, GetVCPConnectMode());
                break;
            }

            case '+':
                testPhase += 0.1;
                print("test phase output %5.1f\r\n", testPhase);
                break;

            case '-':
                testPhase -= 0.1;
                print("test phase output %5.1f\r\n", testPhase);
                break;

            default:
                // TODO
                break;
        }
    }
}
示例#13
0
// "config" command
dn_error_t spiNetApp_cli_config(char const* buf, INT32U len) {
   printConfig();
   return DN_ERR_NONE;
}
示例#14
0
void initConfigFile(void) {
   dn_error_t                    dnErr;
   INT8U                         fileBytes[sizeof(spiNetApp_configFileStruct_t)];
   spiNetApp_configFileStruct_t*  fileContents;
   dn_fs_handle_t                configFileHandle;
   
   fileContents = (spiNetApp_configFileStruct_t*)fileBytes;
   
   configFileHandle = dn_fs_find(ACCELAPP_CONFIG_FILENAME);
   if (configFileHandle>=0) {
      // file found: read it
      
      // open file
      configFileHandle = dn_fs_open(
         ACCELAPP_CONFIG_FILENAME,
         DN_FS_OPT_CREATE,
         sizeof(spiNetApp_configFileStruct_t),
         DN_FS_MODE_OTH_RW
      );
      ASSERT(configFileHandle >= 0);
      
      // read file
      dnErr = dn_fs_read(
         configFileHandle,
         0, // offset
         (INT8U*)fileContents,
         sizeof(spiNetApp_configFileStruct_t)
      );
      ASSERT(dnErr>=0);
      
      // store configuration read from file into module variable
      spiNetApp_vars.period  = fileContents->period;
      
      // close file
      dn_fs_close(configFileHandle);
      
      // print
      printConfig();
      
   } else {
      // file not found: create it
      
      // prepare file content
      fileContents->period   = spiNetApp_vars.period;
      
      // create file
      configFileHandle = dn_fs_open(
         ACCELAPP_CONFIG_FILENAME,
         DN_FS_OPT_CREATE,
         sizeof(spiNetApp_configFileStruct_t),
         DN_FS_MODE_SHADOW
      );
      ASSERT(configFileHandle >= 0);
      
      // write file
      dnErr = dn_fs_write(
         configFileHandle,
         0, // offset
         (INT8U*)fileContents,
         sizeof(spiNetApp_configFileStruct_t)
      );
      ASSERT(dnErr >= 0);
      
      // close file
      dn_fs_close(configFileHandle);
      
      // print
      printConfig();
   }
}
示例#15
0
// "config" command
dn_error_t spiNetApp_cli_config(INT8U* buf, INT32U len, INT8U offset) {
   printConfig();
   return DN_ERR_NONE;
}
void CommHandler(void) //UART4 Interrupt handler implementation
{
    int c = GetChar();

    if (c >= 0)
    {
        LEDon();

        switch (c)
        {
            case 'a':
                debugAutoPan ^= 1;
                print("Autopan messages %s\r\n", debugAutoPan ? "on" : "off");
                break;

            case 'b':
                print("rebooting into boot loader ...\r\n");
                Delay_ms(1000);
                bootloader();
                break;

            case 'c':
                debugCnt ^= 1;
                print("counter messages %s\r\n", debugCnt ? "on" : "off");
                break;

            case 'd':
                debugPrint ^= 1;
                print("debug messages %s\r\n", debugPrint ? "on" : "off");
                break;

            case 'g':
                Delay_ms(100);
                PutChar('x');

                for (int i = 0; i < CONFIGDATASIZE; i++)
                {
                    uint8_t data = configData[i];
                    PutChar(data);
                }

                break;

            case 'G':
                printConfig();
                break;

#if 0

            case 'H':
                if (CharAvailable() >= CONFIGDATASIZE)
                {
                    for (int i = 0; i < CONFIGDATASIZE; i++)
                    {
                        uint8_t data = GetChar();

                        if (data <= LARGEST_CONFIGDATA)
                        {
                            configData[i] = data;
                        }
                    }

                    configSave();
                }
                else
                {
                    UnGetChar(c); // try again in next loop
                }

                break;
#endif

            case 'h':
                for (int i = 0; i < CONFIGDATASIZE; i++)
                {
                    int data;

                    while ((data = GetChar()) < 0)
                        ;

                    if (data <= LARGEST_CONFIGDATA)
                    {
                        configData[i] = data;
                    }
                }

                configSave();
                break;

            case 'i':
                ConfigMode = 1;
                break;

            case 'j':
                ConfigMode = 0;
                break;

            case 'o':
                debugOrient ^= 1;
                print("Orientation messages %s\r\n", debugOrient ? "on" : "off");
                break;

            case 'O':
                debugGravityVector ^= 1;
                print("GVector messages %s\r\n", debugGravityVector ? "on" : "off");
                break;

            case 'S':
                debugSetpoints ^= 1;
                print("Setpoints messages %s\r\n", debugSetpoints ? "on" : "off");
                break;

            case 'p':
                debugPerf ^= 1;
                print("performance messages %s\r\n", debugPerf ? "on" : "off");
                break;

            case 'r':
                debugRC ^= 1;
                print("RC messages %s\r\n", debugRC ? "on" : "off");
                break;

            case 'R':
                print("rebooting...\r\n");
                Delay_ms(1000);
                reboot();
                break;

            case 's':
                debugSense ^= 1;
                print("Sensor messages %s\r\n", debugSense ? "on" : "off");
                break;

            case 'u':
            {
                extern int bDeviceState;
                printUSART("\r\nYY bDeviceState %3d  VCPConnectMode %d\r\n", bDeviceState, GetVCPConnectMode());
                break;
            }

            case 'v':
                print("Version: %s\r\n", __EV_VERSION);
                break;

            case '+':
                testPhase += 0.1;
                print("test phase output %5.1f\r\n", testPhase);
                break;

            case '-':
                testPhase -= 0.1;
                print("test phase output %5.1f\r\n", testPhase);
                break;

/*
            case '?':
                print("CLI documentation\r\n");
//                print("\t'+' test phase output increase (now %5.1f)\r\n", testPhase);
                //print("\t'-' test phase output decrease (now %5.1f)\r\n", testPhase);
                print("\t'a' autopan messages display (now %s)\r\n", debugAutoPan ? "on" : "off");
                print("\t'b' reboot into bootloader\r\n");
                print("\t'c' counter messages display (now %s)\r\n", debugCnt ? "on" : "off");
                print("\t'd' debug messages display (now %s)\r\n", debugPrint ? "on" : "off");
                print("\t'g' dump configuration (binary)\r\n");
                print("\t'G' dump configuration (hexadecimal)\r\n");
//                print("\t'h' write and save config array\r\n");
                print("\t'i' enter config mode (now %s)\r\n", ConfigMode ? "on" : "off");
                print("\t'j' leave config mode (now %s)\r\n", ConfigMode ? "on" : "off");
                print("\t'o' orientation messages display (now %s)\r\n", debugOrient ? "on" : "off");
                print("\t'p' performance messages display (now %s)\r\n", debugPerf ? "on" : "off");
                print("\t'r' RC messages display (now %s)\r\n", debugRC ? "on" : "off");
                print("\t'R' reboot\r\n");
                print("\t's' toggle sensor messages display (now %s)\r\n", debugSense ? "on" : "off");
                print("\t'u' print USB state (bDeviceState %3d  VCPConnectMode %d)\r\n", bDeviceState, GetVCPConnectMode());
                print("\t'v' print version (%s)\r\n", __EV_VERSION);
            break;

*/
            default:
                // TODO
                break;
        }
    }
}
示例#17
0
void loop() {
  if (safeMode) { // safeMode engaged, enter blocking loop wait for an OTA update
    int safeDelay=30000; // five minutes in 100ms counts
    while (safeDelay--) {
      ArduinoOTA.handle();
      delay(100);
    }
    ESP.reset(); // restart, try again
    delay(5000); // give esp time to reboot
  }

  if(wifiMulti.run() != WL_CONNECTED) { // reboot if wifi connection drops
      ESP.reset();
      delay(5000);
  }

  if (!mqtt.connected()) {
    mqttreconnect(); // check mqqt status
  }

  doTick();

  if (hasRSSI) doRSSI();
  if (hasTout) doTout();
  if (hasVout) doVout();
  if (hasIout) doIout();
  if (getRGB) doRGBout();
  if (hasSpeed) doSpeed();

  if ( (doUpdate) || (updateCnt>= 60 / ((updateRate * 20) / 1000) ) ) runUpdate(); // check for config update as requested or every 60 loops

  if (wsConcount>0) wsData();
  if (useMQTT) mqttData(); // regular update for non RGB controllers
  if (prtConfig) printConfig(); // config print was requested

  sprintf(str,"Sleeping in %u seconds.", (updateRate*20/1000));
  if ((!skipSleep) && (sleepEn)) {
    if (useMQTT) mqtt.publish(mqttpub, str);
  }

  int cnt = 30;
  if (updateRate>30) cnt=updateRate;
  while(cnt--) {
    ArduinoOTA.handle();
    if (useMQTT) mqtt.loop();

#ifndef _MINI
    httpd.handleClient();
#endif
    webSocket.loop();

    if (getTime) updateNTP(); // update time if requested by command
    if (scanI2C) i2c_scan();

    if (hasRGB) doRGB(); // rgb updates as fast as possible
    if (rgbTest) testRGB();

#ifndef _MINI

    if (doUpload) { // upload file to spiffs by command
      doUpload = false; fileSet = false;
      int stat = uploadFile(fileName, fileURL);
      sprintf(str, "Upload complete: %s %d bytes.",fileName,stat);
      if (useMQTT) mqtt.publish(mqttpub, str);
    }
#endif

    if (setPolo) {
      setPolo = false; // respond to an mqtt 'ping' of sorts
      if (useMQTT) mqtt.publish(mqttpub, "Polo");
    }

    if (doReset) { // reboot on command
      if (useMQTT) {
        mqtt.publish(mqttpub, "Rebooting!");
        mqtt.loop();
      }
      delay(50);
      ESP.reset();
      delay(5000); // allow time for reboot
    }

    if (!hasRGB) delay(20); // don't delay for rgb controller
  }

  if ((!skipSleep) && (sleepEn)) {
    if ((sleepPeriod<60) || (sleepPeriod>43200)) sleepPeriod=900; // prevent sleeping for less than 1 minute or more than 12 hours
    sprintf(myChr,"Back in %d minutes", sleepPeriod/60);
    if (useMQTT) {
      mqtt.publish(mqttpub, myChr);
      mqtt.loop();
    }

    ESP.deepSleep(1000000 * sleepPeriod, WAKE_RF_DEFAULT); // sleep for 15 min
    delay(5000); // give esp time to fall asleep

  }
  skipSleep = false;
  updateCnt++;
}
示例#18
0
void StAndroidGlue::threadEntry() {
    if(myJavaVM->AttachCurrentThread(&myThJniEnv, NULL) < 0) {
        ST_ERROR_LOG("Failed to attach working thread to Java VM");
        return;
    }

    THE_ANDROID_GLUE = this;
    StMessageBox::setCallback(msgBoxCallback);

    myConfig = AConfiguration_new();
    AConfiguration_fromAssetManager(myConfig, myActivity->assetManager);
    updateMonitors();
    printConfig();

    ALooper* aLooper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
    ALooper_addFd(aLooper, myMsgRead, LooperId_MAIN, ALOOPER_EVENT_INPUT, NULL, &myCmdPollSource);
    myLooper = aLooper;

    pthread_mutex_lock(&myMutex);
    myIsRunning = true;
    pthread_cond_broadcast(&myCond);
    pthread_mutex_unlock(&myMutex);

    // try to load stereo APIs
    /**jclass aJClass_Real3D = myThJniEnv->FindClass("com/lge/real3d/Real3D");
    if(aJClass_Real3D != NULL) {
        jmethodID aJMet_isStereoDisplayAvailable = myThJniEnv->GetStaticMethodID(aJClass_Real3D, "isStereoDisplayAvailable", "(Landroid/content/Contex;)Z");
        postMessage("com.lge.real3d.Real3D !!!");
    }

    jclass aJClass_HTC = myThJniEnv->FindClass("com/htc/view/DisplaySetting");
    if(aJClass_HTC != NULL) {
        jmethodID aJMet_isStereoDisplayAvailable = myThJniEnv->GetStaticMethodID(aJClass_HTC, "setStereoscopic3DFormat", "(Landroid/view/Surface;I)Z");
        postMessage("com.htc.view.DisplaySetting !!!");
    }

    jclass aJClass_Sharp = myThJniEnv->FindClass("jp/co/sharp/android/stereo3dlcd/SurfaceController");
    if(aJClass_Sharp != NULL) {
        jmethodID aJMet_setStereoView = myThJniEnv->GetMethodID(aJClass_Sharp, "setStereoView", "(Z)V");
        postMessage("jp.co.sharp.android.stereo3dlcd !!!");
    }*/

    createApplication();
    if(!myApp.isNull()) {
        if(!myApp->open()) {
            stError("Error: application can not be executed!");
        }
        myApp->exec();
    } else {
        stError("Error: no application to execute!");
    }
    myApp.nullify();

    // application is done but we are waiting for destroying event...
    bool isFirstWait = true;
    for(; !myToDestroy; ) {
        if(isFirstWait) {
            postExit();
            isFirstWait = false;
        }

        StAndroidPollSource* aSource = NULL;
        int aNbEvents = 0;
        ALooper_pollAll(-1, NULL, &aNbEvents, (void** )&aSource);
        if(aSource != NULL) {
            aSource->process(this, aSource);
        }
    }

    freeSavedState();
    pthread_mutex_lock(&myMutex);
    if(myInputQueue != NULL) {
        AInputQueue_detachLooper(myInputQueue);
    }
    AConfiguration_delete(myConfig);
    pthread_cond_broadcast(&myCond);
    pthread_mutex_unlock(&myMutex);

    myThJniEnv = NULL;
    StMessageBox::setCallback(NULL);
    THE_ANDROID_GLUE = NULL;

    myJavaVM->DetachCurrentThread();
}
示例#19
0
int sc_main(int argc, char ** argv){
	sc_report_handler::set_actions("/IEEE_Std_1666/deprecated", SC_DO_NOTHING);
	system("set SC_SIGNAL_WRITE_CHECK=\"DISABLE\"");

	printHeader();

	for (int i = 1; i< argc; i++)
	{
		string args = string(argv[i]);
		if (args == "-f")
		{
			i++;
			if (i<argc && argv[i][0] !='-')
				ga_configPath = string(argv[i]);
			else {
				cout << "Argument to '-f' is missing" << endl; 
				return 0;
			}
		}
		else if (args == "-e")
		{
			i++;
			if (i<argc && argv[i][0] !='-')
				ga_elfPath = string(argv[i]);
			else {
				cout << "Argument to '-e' is missing" << endl; 
				return 0;
			}
		}
		else{
			cout << args <<" Recognized option" << endl;
			return 0;
		}
	}
	
	char nirgamHomeTempStr[100];
	g_nirgamHome = rwDirInLinuxStyl(string(getcwd(nirgamHomeTempStr, 100)));
	g_configHome = getDirOfFile(ga_configPath);
	if(loadConfig(ga_configPath) == false)
		return 1;
	if(checkConfig() ==  false)
		return 1;
	printConfig(cout);

	tryDir(gc_resultHome);

	g_clkPeriod = 1/gc_simFreq;
	g_simPeriod = g_clkPeriod * gc_simNum;
	g_clock = new sc_clock("NW_CLOCK",g_clkPeriod, SC_NS);
	g_a = analyze(gc_topoFile, cout);	
	if(g_a == NULL){
		cout << "Error occurred. Exit Simulation" << endl; return 1;
	}
	g_tileNum = g_a->nodeNum;


	if (gc_simMode == 1)
		initStandardMode();
	else if (gc_simMode == 2)
		initDebugMode();
	else if (gc_simMode == 3)
		initSelfcheckMode();

	NoC noc("noc", g_a);
	noc.switch_cntrl(*g_clock);

	g_tracker = new Tracker();
	g_tracker->addProbes(noc);
	g_tracker->printRouteTables();
//////////////////////////////////////////////////////////////////////////
// soclib tile
#ifdef SL_TILE
	if (gc_tileType == 1){
		cerr << "SLNIRGAM is used for soclib IP" << endl;
		return 1;
	}
	sc_start(sc_time(0, SC_NS));
	g_resetN = false;
	sc_start(sc_time(1, SC_NS));
	g_resetN = true;
#else
	if (gc_tileType == 2){
		cerr << "NIRGAM is used for generic IP" << endl;
		return 1;
	}
#endif
//////////////////////////////////////////////////////////////////////////

	if (gc_simMode == 1)
		doStandardMode();
	else if (gc_simMode == 2)
		doDebugMode();
	else if (gc_simMode == 3)
		doSelfcheckMode();

	if (gc_simMode == 1)
		finaStandardMode();
	else if (gc_simMode == 2)
		finaDebugMode();
	else if (gc_simMode == 3)
		finaSelfcheckMode();
}
示例#20
0
int parseCmdLine(int argc, char *argv[]) {
	int j, more;

	if (argc < 3) {
		printHelp();
		return 0;
	}

	for (j = 1; j < argc; j++) {
		more = ((j + 1) < argc);
		if (!strcmp(argv[j], "--remove")) {
			estgbconf.isRemove = 1;
		} else if (!strcmp(argv[j], "--force-remove")) {
			estgbconf.isRemove = 2;
		} else if (!strcmp(argv[j], "--escape-seq")) {
			estgbconf.needUnescape = 1;
		} else if (!strcmp(argv[j], "--singleton")) {
			estgbconf.isSingleton = 1;
		} else if (!strcmp(argv[j], "--daemon")) {
			estgbconf.isDaemonize = 1;
		} else if (!strcmp(argv[j], "--mediagroup")) {
			estgbconf.isPicsMediagroup = 1;
		} else if (!strcmp(argv[j], "--repeat-send") && more) {
			estgbconf.isScan = atoi(argv[++j]);
		} else if (!strcmp(argv[j], "--time-sleep") && more) {
			estgbconf.timeRescan = atoi(argv[++j]);
		} else if (!strcmp(argv[j], "--animation")) {
			estgbconf.isAnimation = 1;
		} else if (!strcmp(argv[j], "--wildcard")) {
			estgbconf.isWildcard = 1;
		} else if (!strcmp(argv[j], "--weakconfig")) {
			estgbconf.isWeakConfig = 1;
		} else if (!strcmp(argv[j], "--sendpic") && more) {
			estgbconf.imgfile = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--sendvideo") && more) {
			estgbconf.videofile = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--sendtext") && more) {
			estgbconf.text = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--senddoc") && more) {
			estgbconf.docfile = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--sendaudio") && more) {
			estgbconf.audiofile = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--fileconfigs")) {
			estgbconf.useFileConfig = 1;
		} else if (!strcmp(argv[j], "--token") && more) {
			estgbconf.token = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--userid") && more) {
			estgbconf.user_id = atoll(argv[++j]);
		} else if (!strcmp(argv[j], "--path") && more) {
			estgbconf.path = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--comment") && more) {
			estgbconf.comment = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--proxy") && more) {
			estgbconf.proxy_addr = strdup(argv[++j]);
		} else if (!strcmp(argv[j], "--proxyauth") && more) {
			estgbconf.proxy_auth = strdup(argv[++j]);
		}

		else if (!strcmp(argv[j], "--help")) {
			printHelp();
			return 0;
		} else {
			printHelp();
			printConfig();
			printf("Unknown or not enough arguments for option '%s'.\n\n",
					argv[j]);
			return 0;
		}
	}
	return 1;
}
示例#21
0
bool CmdPin::execute(CommandInterpreter &/*interpreter*/, int argc, const CommandInterpreter::Argument *argv)
{
    bool config = false;
    bool poll = false;
    if (argv[0].value.s[3] == 'c') config = true;
    if (argv[0].value.s[3] == 'p') poll = true;
    if (argc == 1)
    {
        for (unsigned int index = 0; index < mGpioCount; ++index)
        {
            printPort(index, config);
        }
        return true;
    }
    char c = argv[1].value.s[0];
    unsigned int index = c - 'A';
    if (index > mGpioCount) index = c - 'a';
    if (index > mGpioCount)
    {
        printf("Invalid GPIO, GPIO A-%c (or a-%c) is allowed.\n", 'A' + mGpioCount - 1, 'a' + mGpioCount - 1);
        return false;
    }
    if (argv[1].value.s[1] == 0)
    {
        printPort(index, config);
    }
    else
    {
        char* end;
        unsigned int pin = strtoul(argv[1].value.s + 1, &end, 10);
        if (*end != 0 || pin > 15)
        {
            printf("Invalid index, GPIO has only 16 pins, so 0-15 is allowed.\n");
            return false;
        }
        if (argc == 2)
        {
            printf("GPIO %c%i: ", 'A' + index, pin);
            if (config)
            {
                printConfig(mGpio[index], pin);
            }
            else
            {
                uint64_t lastTime = System::instance()->ns();
                bool lastValue = mGpio[index]->get(static_cast<Gpio::Index>(pin));
                printValue(mGpio[index], pin);
                int count = 1000000;
                int change = 0;
                while (poll && count > 0 && change < 10)
                {
                    --count;
                    bool value = mGpio[index]->get(static_cast<Gpio::Index>(pin));
                    if (value != lastValue)
                    {
                        ++change;
                        uint64_t time = System::instance()->ns();
                        printf(" for %llu us, ", (time - lastTime) / 1000);
                        lastTime = time;
                        lastValue = value;
                        printValue(mGpio[index], pin);
                    }
                }
            }
            printf("\n");
        }
        else
        {
            if (config)
            {
                printf("Sorry, can't configure pins.\n");
            }
            else
            {
                if (argv[2].value.b) mGpio[index]->set(static_cast<Gpio::Index>(pin));
                else mGpio[index]->reset(static_cast<Gpio::Index>(pin));
            }
        }
    }
    return true;
}
示例#22
0
文件: Main.c 项目: k2b3d/tconsrc
int main(int argc, char *argv[])
{
	pid_t 		pid ;
	int 		stat ;
	pthread_t	pthread_ping_id;	
	int			ret ;

	isDup(argv[0]) ;

	if((pid = fork()) < 0)
		return  -1;
	else    if(pid != 0)
		exit(0);

	setsid() ;

	set_signal() ;

	if (argc > 1) {
		if (argc == 3) {
			if (strcmp(argv[1], "-f") == 0) {
				strcpy(config_file_path, argv[2]);
			}
			else    {
				printf("---------------------------------\n");
				printf("-%s [-f ConfigFilePath]\n", argv[0]);
				printf("---------------------------------\n");
				}
			}
		else    {
			printf("---------------------------------\n");
			printf("-%s [-f ConfigFilePath]\n", argv[0]);
			printf("---------------------------------\n");
		}
	}
	else
		sprintf(config_file_path, "../config/CCTVSvr.Config");

	memset(&Config, 0, sizeof(CONFIG_T)) ;
	readConfig(config_file_path, &Config) ;
	Log = openLog(argv[0], Config.LOG_FILE, LOG_MODE) ;
	printLog(HEAD, "=====[Program Start]=====\n") ;

	printConfig(&Config);

#ifdef _USEDB
	if((ret = mydbc_connect(Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_HOST, Config.DB_PORT, Config.DB_CONN_COUNT)) != DB_SUCCESS)   {
		printLog(HEAD, "DB Connection ERROR[%d]\n", ret);
		exit(0);
	}
	else    {
		printLog(HEAD, "DB Connection Success...\n");
	}
#endif

	pthread_mutex_init(&p_lock, NULL);
	thread_count = 0;

#ifdef _USEDB
	// DB PING-PONG
	if((stat = pthread_create(&pthread_ping_id, NULL, db_conn_check, (void *)NULL)) != 0) {
		printLog(HEAD, "ERR: (%s)(%d)\n", strerror(errno), errno);
		if(stat == EAGAIN) {
			printLog(HEAD, "ERR: not enough system resources to create a process for the new thread. (%d)(%d)\n", EAGAIN, stat);
		}
		exit_handler() ;
	}
#endif

	Worker();

	exit_handler() ;
	return M_TRUE ;
}
示例#23
0
void setup() {
  memset(voltsChr,0,sizeof(voltsChr));
  memset(amps0Chr,0,sizeof(amps0Chr));
  memset(amps1Chr,0,sizeof(amps1Chr));
  memset(tmpChr,0,sizeof(tmpChr));

    // if the program crashed, skip things that might make it crash
  String rebootMsg = ESP.getResetReason();
  if (rebootMsg=="Exception") safeMode=true;
  else if (rebootMsg=="Hardware Watchdog") safeMode=true;
  else if (rebootMsg=="Unknown") safeMode=true;
  else if (rebootMsg=="Software Watchdog") safeMode=true;

  if (sw1>=0) {
    pinMode(sw1, OUTPUT);
  }
  if (sw2>=0) {
    pinMode(sw2, OUTPUT);
  }
  if (sw3>=0) {
    pinMode(sw3, OUTPUT);
  }
  if (sw4>=0) {
    pinMode(sw4, OUTPUT);
  }

  // "mount" the filesystem
  bool success = SPIFFS.begin();
  if (!success) SPIFFS.format();

  if (!safeMode) fsConfig(); // read node config from FS

#ifdef _TRAILER
  wifiMulti.addAP("DXtrailer", "2317239216");
#else
  wifiMulti.addAP("Tell my WiFi I love her", "2317239216");
#endif

  int wifiConnect = 240;
  while ((wifiMulti.run() != WL_CONNECTED) && (wifiConnect-- > 0)) { // spend 2 minutes trying to connect to wifi
    // connecting to wifi
    delay(1000);
  }

  if (wifiMulti.run() != WL_CONNECTED ) { // still not connected? reboot!
    ESP.reset();
    delay(5000);
  }

  if (hasHostname) { // valid config found on FS, set network name
    WiFi.hostname(String(nodename)); // set network hostname
    ArduinoOTA.setHostname(nodename);  // OTA hostname defaults to esp8266-[ChipID]
    MDNS.begin(nodename); // set mDNS hostname
  }

  WiFi.macAddress(mac); // get esp mac address, store it in memory, build fw update url
  sprintf(macStr,"%x%x%x%x%x%x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  sprintf(theURL,"/iotfw?mac=%s", macStr);

  // request latest config from web api
  if (!safeMode) getConfig();

  // check web api for new firmware
  if (!safeMode) httpUpdater();

  // start UDP for ntp client
  udp.begin(localPort);

  updateNTP();

  setSyncProvider(getNtptime); // use NTP to get current time
  setSyncInterval(600); // refresh clock every 10 min

#ifndef _MINI
  // start the webserver
  httpd.onNotFound(handleNotFound);
  httpd.begin();
  // Add service to MDNS-SD
  MDNS.addService("http", "tcp", 80);
#endif

  // start websockets server
  webSocket.begin();
  webSocket.onEvent(webSocketEvent);

  // setup other things
  setupOTA();
  setupMQTT();

  // setup i2c if configured, basic sanity checking on configuration
  if (hasI2C && iotSDA>=0 && iotSCL>=0 && iotSDA!=iotSCL) {
    sprintf(str,"I2C enabled, using SDA=%u SCL=%u", iotSDA, iotSCL);
    mqtt.publish(mqttpub, str);

    Wire.begin(iotSDA, iotSCL); // from api config file

    //Wire.begin(12, 14); // from api config file
    i2c_scan();

    printConfig();

    if (hasRGB) setupRGB();
    if (hasIout) setupADS();
    if (hasSpeed) setupSpeed();

  }

  // OWDAT = 4;
  if (OWDAT>0) { // setup onewire if data line is using pin 1 or greater
    sprintf(str,"Onewire Data OWDAT=%u", OWDAT);
    mqtt.publish(mqttpub, str);
    oneWire.begin(OWDAT);
    if (hasTout) {
      ds18b20 = DallasTemperature(&oneWire);
      ds18b20.begin(); // start one wire temp probe
    }
    if (hasTpwr>0) {
      pinMode(hasTpwr, OUTPUT); // onewire power pin as output
      digitalWrite(hasTpwr, LOW); // ow off
    }
  }


  if (useMQTT) {
    String rebootReason = String("Last reboot cause was ") + rebootMsg;
    rebootReason.toCharArray(str, rebootReason.length()+1);
    mqtt.publish(mqttpub, str);
  }
}
示例#24
0
// TODO: Finalize config file format
// TODO: Add starting time offset, which would allow a user to specify schedules with optimal solutions - no conflicts in timing
// vs conflicts in timing, with the latter resulting in a more difficult job for a scheduler
int main(int argc, char * argv[])
{
    // Check for config file, create one if it doesn't exist
    if (fileCheck("config.cfg") == 0) {
        createDefConfig();
        puts("Default config file created");
    }

    // Load config file vals into current config
    struct config current_config;
    loadConfig(&current_config, "config.cfg");

    // Print menu to allow user to modify the current config
    int menuChoice;
    while (1) {
        printConfig(&current_config);
        puts("");
        puts("1: Save current config");
        puts("2: Load another config");
        puts("3: Reset config to default");
        puts("4: Generate test data");
        puts("5: Modify current configuration");
        printf("\n>> ");
        scanf("%d", &menuChoice);
        if (menuChoice == 4) {
            break;
        } else if (menuChoice == 1) {
            saveConfig(&current_config);
        } else if (menuChoice == 2) {
            char fname[20];
            printf("Enter a file name >> ");
            scanf("%s", fname);
            loadConfig(&current_config, fname);
        } else if (menuChoice == 3) {
            createDefConfig();
        } else if (menuChoice == 5) {
            modifyConfig(&current_config);
        }
    }
    
    // Stores total number of tasks to generate
    int numTasks = -1;
    if (argc == 2)
    {
        sscanf(argv[1], "%d", &numTasks);
    } else
    {
        printf("\nEnter number of tasks to generate >> ");
        scanf("%d", &numTasks);
    }

    // Seed the rng
    time_t now;
    time(&now);
    init_genrand((int)now);

    // Remove old data.txt, if necessary
    if (fileCheck("data.txt") == 1)
    {
        puts("\nOld test data file deleted.");
    } 

    // Open the file for writing
    FILE *fp;
    fp = fopen("data.txt", "w");

    // generate the data
    int rc = generateData(fp, numTasks, &current_config);

    fclose(fp);

    char in;
    printf("Start simulation on new test data? [Y/n] ");
    scanf(" %c", &in);
    if (in == 'Y' || in == 'y') {
        system("./sim data.txt");
    }
    return 0;
}
示例#25
0
vrpn_libusb::vrpn_libusb(const char *name, vrpn_Connection *c, std::string configFile) : vrpn_Button(name,c), vrpn_Analog(name,c)
{
    _devList = NULL;
    _dev = NULL;
    _vendorID = -1;
    _productID = -1;
    _entryNum = 0;
    _configNum = 0;
    _numConfigs = 0;
    _interfaceNum = 0;
    _numInterfaces = 0;
    _altSettingNum = 0;
    _numAltSettings = 0;
    _endpointNum = 0;
    _numEndpoints = 0;
    _address = 0;
    _packetSize = 0;
    _printPacket = false;
    _context = NULL;

    _error = false;

    num_buttons = 0;
    num_channel = 0;

    _driverPresent = false;

    if(!loadConfigFile(configFile))
    {
	_error = true;
	return;
    }

    if(libusb_init(&_context) < 0)
    {
	std::cerr << "Error libusb init." << std::endl;
	_error = true;
	return;
    }

    int devCount;

    if((devCount = libusb_get_device_list(NULL, &_devList)) < 0 )
    {
	std::cerr << "Error getting device list .." << std::endl;
	_error = true;
	return;	
    }

    if(_vendorID < 0 || _productID < 0)
    {
	std::cerr << "Error: vendorID/productID must be set." << std::endl;
	std::cerr << "Printing list of usb devices:" << std::endl;
	printDevices(_devList);
	_error = true;
	return;
    }

    bool usberror = false;

    _dev = findDevice(_devList);
    if(!_dev)
    {
	printConfig();
	std::cerr << "Error: device with vendorID/productID with given entry not found." << std::endl;
	std::cerr << "Printing list of usb devices:" << std::endl;
	printDevices(_devList);
	_error = true;
	return;
    }

    libusb_device_descriptor desc;
    if(libusb_get_device_descriptor(_dev,&desc) >= 0)
    {
	_numConfigs = (int)desc.bNumConfigurations;
	if(_configNum >= 0 && _configNum < _numConfigs)
	{
	    libusb_config_descriptor * cdesc;
	    if(libusb_get_config_descriptor(_dev,_configNum,&cdesc) >= 0)
	    {
		_numInterfaces = (int)cdesc->bNumInterfaces;
		if(_interfaceNum >= 0 && _interfaceNum < _numInterfaces)
		{
		    libusb_interface interface = cdesc->interface[_interfaceNum];
		    _numAltSettings = (int)interface.num_altsetting;
		    if(_altSettingNum >= 0 && _altSettingNum < _numAltSettings)
		    {
			libusb_interface_descriptor idesc = interface.altsetting[_altSettingNum];
			_numEndpoints = (int)idesc.bNumEndpoints;
			if(_endpointNum >= 0 && _endpointNum < _numEndpoints)
			{
			    libusb_endpoint_descriptor edesc = idesc.endpoint[_endpointNum];
			    _address = (int)edesc.bEndpointAddress;
			    _packetSize = (int)edesc.wMaxPacketSize;
			}
			else
			{
			    std::cerr << "Error: Invalid endpoint number." << std::endl;
			    usberror = true;
			}
		    }
		    else
		    {
			std::cerr << "Error: Invalid altSetting number." << std::endl;
			usberror = true;
		    }
		}
		else
		{
		    std::cerr << "Error: Invalid interface number." << std::endl;
		    usberror == true;
		}
	    }
	    else
	    {
		std::cerr << "Error: unable to get config descriptor." << std::endl;
		usberror = true;
	    }
	}
	else
	{
	    std::cerr << "Error: Invalid config number." << std::endl;
	    usberror = true;
	}
    }
    else
    {
	std::cerr << "Error: unable to get device descriptor." << std::endl;
	usberror = true;
    }

    printConfig();

    if(libusb_open(_dev, &_handle) < 0)
    {
	std::cerr << "Error opening device bus: " << libusb_get_bus_number(_dev) << " device: " << libusb_get_device_address(_dev) << std::endl;
	usberror = true;
    }

    if(usberror)
    {
	_error = true;
	return;
    }

    num_buttons = 0;
    for(int i = 0; i < _buttonGroups.size(); ++i)
    {
	num_buttons += _buttonGroups[i]->numButtons;
    }

    for(int i = 0; i < num_buttons; i++)
    {
	buttons[i] = 0;
	lastbuttons[i] = 0;
    }

    num_channel = _valuators.size();

    _packet = new unsigned char[_packetSize];
    for(int i = 0; i < _numInterfaces; i++)
    {
	if(libusb_kernel_driver_active(_handle, i) == 1)
	{
	    _driverPresent = true;

	    if(libusb_detach_kernel_driver(_handle, i) != 0)
	    {
		std::cerr << "Error detaching driver from interface " << i << std::endl;
	    }
	}
	else
	{
	    _driverPresent = false;
	}
    }

    if(libusb_claim_interface(_handle, _interfaceNum) != 0)
    {
	std::cerr << "Error: could not claim device interface." << std::endl;
	_error = true;
	return;
    }

    vrpn_gettimeofday(&_lastUpdateTime,NULL);

    _transfer = libusb_alloc_transfer(5);
    libusb_fill_interrupt_transfer(_transfer, _handle, _address, _packet, _packetSize, transCallback, (void*)this, 10000);
    libusb_submit_transfer(_transfer);

    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);

    _ti = new ThreadInit;
    _ti->context = _context;
    _ti->quit = false;
    pthread_create(&_updateThread,&attr,libusbUpdate,(void*)_ti);

    pthread_attr_destroy(&attr);

    std::cerr << "Init good." << std::endl;
}
示例#26
0
void Config::parseConfig ( char * f )
{
  FILE * filein = NULL;
  // Open configuration file
  if ( ( filein = fopen( f, "rt" ) ) == NULL )
  {
    // No configuration file is found. Print out
    // the current configuration
    cerr << "# WARNING: No configuration file " << f << ". Dumping default setting to " << f << endl;
    ofstream fileout( f );
    printConfig( fileout );
    fileout.close( );
  }
  else
  {
    int line = 0;

    while ( !feof( filein ) )
    {
      line ++;
      char buf[ 128 ];
      char * res = fgets( buf, 128, filein );
      (void)res;
      // Stop if finished
      if ( feof( filein ) )
	break;
      // Skip comments
      if ( buf[ 0 ] == '#' )
	continue;

      char tmpbuf[ 32 ];

      // GENERIC CONFIGURATION
	   if ( sscanf( buf, "incremental %d\n"                   , &incremental )                    == 1 );
      else if ( sscanf( buf, "produce_stats %d\n"                 , &produce_stats )                  == 1 );
      else if ( sscanf( buf, "print_stats %d\n"                   , &print_stats )                    == 1 );
      else if ( sscanf( buf, "print_proofs_smtlib2 %d\n"          , &print_proofs_smtlib2 )           == 1 );
      else if ( sscanf( buf, "print_proofs_dotty %d\n"            , &print_proofs_dotty )             == 1 );
      else if ( sscanf( buf, "produce_models %d\n"                , &produce_models )                 == 1 )
      {
#ifndef PRODUCE_PROOF
	if ( produce_proofs != 0 )
	  opensmt_error( "You must configure code with --enable-proof to produce proofs" );
#endif
      }
      else if ( sscanf( buf, "produce_inter %d\n"                 , &produce_inter )                  == 1 )
      {
#ifndef PRODUCE_PROOF
	if ( produce_inter != 0 )
	  opensmt_error( "You must configure code with --enable-proof to produce interpolants" );
#endif
      }
      else if ( sscanf( buf, "regular_output_channel %s\n"        , tmpbuf )                          == 1 )
	setRegularOutputChannel( tmpbuf );
      else if ( sscanf( buf, "diagnostic_output_channel %s\n"     , tmpbuf )                          == 1 )
	setDiagnosticOutputChannel( tmpbuf );                                                         
      else if ( sscanf( buf, "dump_formula %d\n"                  , &dump_formula )                   == 1 );
      else if ( sscanf( buf, "dump_log %d\n"                      , &dump_log )                       == 1 );
      else if ( sscanf( buf, "verbosity %d\n"                     , &verbosity )                      == 1 );
      else if ( sscanf( buf, "print_success %d\n"                 , &print_success )                  == 1 );
      else if ( sscanf( buf, "certification_level %d\n"           , &certification_level )            == 1 );
      else if ( sscanf( buf, "certifying_solver %s\n"             , certifying_solver )               == 1 );
      else if ( sscanf( buf, "split_equalities %d\n"              , &split_equalities )               == 1 );
      // SAT SOLVER CONFIGURATION                                                                     
      else if ( sscanf( buf, "sat_theory_propagation %d\n"        , &(sat_theory_propagation))        == 1 );
      else if ( sscanf( buf, "sat_polarity_mode %d\n"             , &(sat_polarity_mode))             == 1 );
      else if ( sscanf( buf, "sat_initial_skip_step %lf\n"        , &(sat_initial_skip_step))         == 1 );
      else if ( sscanf( buf, "sat_skip_step_factor %lf\n"         , &(sat_skip_step_factor))          == 1 );
      else if ( sscanf( buf, "sat_restart_first %d\n"             , &(sat_restart_first))             == 1 );
      else if ( sscanf( buf, "sat_restart_increment %lf\n"        , &(sat_restart_inc))               == 1 );
      else if ( sscanf( buf, "sat_use_luby_restart %d\n"          , &(sat_use_luby_restart))          == 1 );
      else if ( sscanf( buf, "sat_learn_up_to_size %d\n"          , &(sat_learn_up_to_size))          == 1 );
      else if ( sscanf( buf, "sat_temporary_learn %d\n"           , &(sat_temporary_learn))           == 1 );
      else if ( sscanf( buf, "sat_preprocess_booleans %d\n"       , &(sat_preprocess_booleans))       == 1 );
      else if ( sscanf( buf, "sat_preprocess_theory %d\n"         , &(sat_preprocess_theory))         == 1 );
      else if ( sscanf( buf, "sat_centrality %d\n"                , &(sat_centrality))                == 1 );
      else if ( sscanf( buf, "sat_trade_off %d\n"                 , &(sat_trade_off))                 == 1 );
      else if ( sscanf( buf, "sat_minimize_conflicts %d\n"        , &(sat_minimize_conflicts))        == 1 );
      else if ( sscanf( buf, "sat_dump_cnf %d\n"                  , &(sat_dump_cnf))                  == 1 );
      else if ( sscanf( buf, "sat_dump_rnd_inter %d\n"            , &(sat_dump_rnd_inter))            == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc %d\n"                  , &(sat_lazy_dtc))                  == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc_burst %d\n"            , &(sat_lazy_dtc_burst))            == 1 );
      // PROOF PRODUCTION CONFIGURATION                                                               
      else if ( sscanf( buf, "proof_reduce %d\n"                  , &(proof_reduce))                  == 1 );
      else if ( sscanf( buf, "proof_random_seed %d\n"             , &(proof_random_seed))             == 1 );
      else if ( sscanf( buf, "proof_ratio_red_solv %lf\n"         , &(proof_ratio_red_solv))          == 1 );
      else if ( sscanf( buf, "proof_red_time %lf\n"               , &(proof_red_time))                == 1 );
      else if ( sscanf( buf, "proof_num_graph_traversals %d\n"    , &(proof_num_graph_traversals))    == 1 );
      else if ( sscanf( buf, "proof_red_trans %d\n"               , &(proof_red_trans))               == 1 );
      else if ( sscanf( buf, "proof_reorder_pivots %d\n"          , &(proof_reorder_pivots))          == 1 );
      else if ( sscanf( buf, "proof_reduce_while_reordering %d\n" , &(proof_reduce_while_reordering)) == 1 );
      else if ( sscanf( buf, "proof_random_context_analysis %d\n" , &(proof_random_context_analysis)) == 1 );
      else if ( sscanf( buf, "proof_random_swap_application %d\n" , &(proof_random_swap_application)) == 1 );
      else if ( sscanf( buf, "proof_remove_mixed %d\n"            , &(proof_remove_mixed))            == 1 );
      else if ( sscanf( buf, "proof_set_inter_algo %d\n"          , &(proof_set_inter_algo))          == 1 );
      else if ( sscanf( buf, "proof_certify_inter %d\n"           , &(proof_certify_inter))           == 1 );
      // EUF SOLVER CONFIGURATION                                                                     
      else if ( sscanf( buf, "uf_disable %d\n"                    , &(uf_disable))                    == 1 );
      else if ( sscanf( buf, "uf_theory_propagation %d\n"         , &(uf_theory_propagation))         == 1 );
      // BV SOLVER CONFIGURATION                                                                            
      else if ( sscanf( buf, "bv_disable %d\n"                    , &(bv_disable))                    == 1 );
      else if ( sscanf( buf, "bv_theory_propagation %d\n"         , &(bv_theory_propagation))         == 1 );
      // DL SOLVER CONFIGURATION                                                                            
      else if ( sscanf( buf, "dl_disable %d\n"                    , &(dl_disable))                    == 1 );
      else if ( sscanf( buf, "dl_theory_propagation %d\n"         , &(dl_theory_propagation))         == 1 );
      // LRA SOLVER CONFIGURATION                                                                           
      else if ( sscanf( buf, "lra_disable %d\n"                   , &(lra_disable))                   == 1 );
      else if ( sscanf( buf, "lra_theory_propagation %d\n"        , &(lra_theory_propagation))        == 1 );
      else if ( sscanf( buf, "lra_poly_deduct_size %d\n"          , &(lra_poly_deduct_size))          == 1 );
      else if ( sscanf( buf, "lra_gaussian_elim %d\n"             , &(lra_gaussian_elim))             == 1 );
      else if ( sscanf( buf, "lra_integer_solver %d\n"            , &(lra_integer_solver))            == 1 );
      else if ( sscanf( buf, "lra_check_on_assert %d\n"           , &(lra_check_on_assert))           == 1 );
      // MCMT related options
      else if ( sscanf( buf, "node_limit %d\n"                    , &(node_limit))                    == 1 );
      else if ( sscanf( buf, "depth_limit %d\n"                   , &(depth_limit))                   == 1 );
      else if ( sscanf( buf, "verbosity %d\n"                     , &(verbosity))                     == 1 );      
      else if ( sscanf( buf, "simpl_level %d\n"                   , &(simpl_level))                   == 1 );      
      else if ( sscanf( buf, "e_simpl_level %d\n"                 , &(e_simpl_level))                 == 1 );      
      else if ( sscanf( buf, "fix_point_strategy %d\n"            , &(fix_point_strategy))            == 1 );
      else if ( sscanf( buf, "fix_point_period %d\n"              , &(fix_point_period))              == 1 );
      else if ( sscanf( buf, "check_compatible %d\n"              , &(check_compatible))              == 1 );
      else if ( sscanf( buf, "invariant_nodes %d\n"               , &(invariant_nodes))               == 1 );
      else if ( (report_tex            = (strcmp( buf, "tex\n" )                      == 0)) );
      else if ( (flex_fix_point        = (strcmp( buf, "flex_fix_point\n" )           == 0)) );
      else if ( (predicate_abstr       = (strcmp( buf, "predicate_abstr\n" )          == 0)) );
      else if ( (constant_abstr        = (strcmp( buf, "constant_abstr\n" )           == 0)) ); 
      else if ( (log                   = (strcmp( buf, "log\n" )                      == 0)) );
      else if ( (weak_fix_point        = (strcmp( buf, "weak_fix_point\n" )           == 0)) );
      else if ( (incr_fix_point        = (strcmp( buf, "incr_fix_point\n" )           == 0)) ); 
      else if ( (breadth_search        = (strcmp( buf, "breadth_search\n" )           == 0)) );
      else if ( (breadth_search        = (strcmp( buf, "depth_search\n" )             == 0)) );
      else if ( (full_inv_search       = (strcmp( buf, "full_inv_search\n" )          == 0)) );
      else if ( (parsing_tests         = (strcmp( buf, "parsing_tests\n" )            == 0)) );  
      else if ( (simplify_preimages    = (strcmp( buf, "simplify_preimages\n" )       == 0)) );  
      else if ( (report                = (strcmp( buf, "report\n" )                   == 0)) );  
      else if ( (optimization          = (strcmp( buf, "optimization\n" )             == 0)) ); 
      else if ( (iterative             = (strcmp( buf, "iterative\n" )                == 0)) ); 
      else if ( (invariant_pattern     = (strcmp( buf, "invariant_pattern\n" )        == 0)) ); 
      else if ( (classic_invariant     = (strcmp( buf, "invariant\n" )                == 0)) ); 
      else if ( (counterexample        = (strcmp( buf, "counterexample\n" )           == 0)) ); 
      else if ( (generate_invariants   = (strcmp( buf, "generate_invariants\n" )      == 0)) ); 
      else
      {
	opensmt_error2( "unrecognized option ", buf );
      }
    }

    if ( invariant_pattern || classic_invariant )
    {
      global_invariant = true;
    }

    // Close
    fclose( filein );
  }

  if ( produce_stats ) stats_out.open( ".stats.out" );
  if ( dump_log )      log_out.open( ".opensmt_log.smt2" );
}
示例#27
0
void StAndroidGlue::processCommand() {
    int8_t aCmd = -1;
    if(::read(myMsgRead, &aCmd, sizeof(aCmd)) == sizeof(aCmd)) {
        switch(aCmd) {
            case CommandId_SaveState:
                freeSavedState();
                break;
        }
    } else {
        ST_ERROR_LOG("No data on command pipe!");
        return;
    }

    // preprocessing
    switch(aCmd) {
        case CommandId_InputChanged: {
            pthread_mutex_lock(&myMutex);
            if(myInputQueue != NULL) {
                AInputQueue_detachLooper(myInputQueue);
            }
            myInputQueue = myInputQueuePending;
            if(myInputQueue != NULL) {
                AInputQueue_attachLooper(myInputQueue,
                                         myLooper, LooperId_INPUT, NULL,
                                         &myInputPollSource);
            }
            pthread_cond_broadcast(&myCond);
            pthread_mutex_unlock(&myMutex);
            break;
        }
        case CommandId_WindowChanged:
        case CommandId_WindowInit: {
            pthread_mutex_lock(&myMutex);
            myWindow = myWindowPending;
            pthread_cond_broadcast(&myCond);
            pthread_mutex_unlock(&myMutex);
            break;
        }
        case CommandId_WindowTerm: {
            pthread_cond_broadcast(&myCond);
            break;
        }
        case CommandId_Resume:
        case CommandId_Start:
        case CommandId_Pause:
        case CommandId_Stop: {
            pthread_mutex_lock(&myMutex);
            myActivityState = aCmd;
            pthread_cond_broadcast(&myCond);
            pthread_mutex_unlock(&myMutex);
            break;
        }
        case CommandId_ConfigChanged: {
            AConfiguration_fromAssetManager(myConfig, myActivity->assetManager);
            updateMonitors();
            printConfig();
            break;
        }
        case CommandId_Destroy: {
            myToDestroy = true;
            break;
        }
    }

    signals.onAppCmd(aCmd);

    // post-processing
    switch(aCmd) {
        case CommandId_WindowTerm: {
            pthread_mutex_lock(&myMutex);
            myWindow = NULL;
            pthread_cond_broadcast(&myCond);
            pthread_mutex_unlock(&myMutex);
            break;
        }
        case CommandId_WindowChanged: {
            pthread_mutex_lock(&myMutex);
            myWindowPending = NULL;
            pthread_cond_broadcast(&myCond);
            pthread_mutex_unlock(&myMutex);
            break;
        }
        case CommandId_SaveState: {
            pthread_mutex_lock(&myMutex);
            myIsStateSaved = true;
            pthread_cond_broadcast(&myCond);
            pthread_mutex_unlock(&myMutex);
            break;
        }
        case CommandId_Resume: {
            freeSavedState();
            break;
        }
    }
}
示例#28
0
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------
int 
main(int argc, char *argv[]) 
{
  extern char *optarg;
  int    optInd   = 0;
  char   optChar  = 0;  

  static struct option optLong[] = {
    { "database"   , 1 , 0           , 'D' },
    { "path"       , 1 , 0           , 'p' },
    { "time"       , 1 , 0           , 't' },
    { "expiration" , 1 , 0           , 'x' },
    { "flavor"     , 1 , 0           , 'F' },
    { "file"       , 1 , 0           , 'f' },
    { "get"        , 0 , (int *)&action ,  GetDB  },
    { "read"       , 0 , (int *)&action ,  GetDB  },
    { "set"        , 0 , (int *)&action ,  SetDB  },
    { "write"      , 0 , (int *)&action ,  SetDB  },
    { "tree"       , 0 , (int *)&action ,  PrintTree },
    { "history"    , 0 , (int *)&action ,  PrintHistory },
    { "config"     , 0 , (int *)&action ,  PrintConfig },
    { "comment"    , 1 , 0              , 'c' },
    { "verbose"    , 0 , &verboseMode   , true},
    { "quiet"      , 0 , &verboseMode   , false},
    { "dataonly"   , 0 , &dataOnlyMode  , true},
    { "debug"      , 0 , &debugMode     , true},
    { "help"       , 0 , 0              , 'h' },
    { 0, 0, 0, 0}
  };


  //   cout << indexFromString("05TB01" )  << endl;
  //   cout << indexFromString("P05TB01")  << endl;
  //   cout << indexFromString("05P1" ,kEEmcMaxSect*kEEmcMaxBox)  << endl;
  //   cout << indexFromString("E05TB",kEEmcMaxSect*kEEmcMaxBox)  << endl;
  //   cout << indexFromString("12TB13" )  << endl;
  //   cout << indexFromString("V12TB13")  << endl;
  //   cout << indexFromString("13TG"  ,kEEmcMaxSect*kEEmcMaxBox) << endl;
  //   cout << indexFromString("A13TG" ,kEEmcMaxSect*kEEmcMaxBox) << endl;
  //   exit(0);

  // arguments and init
  argv0 = strrchr(argv[0],'/');
  argv0 = ( argv0 == NULL )  ? argv[0] : ++argv0 ;

  while((optChar = getopt_long(argc,argv,"D:p:t:x:F:f:c:grswTHCdvqh",optLong,&optInd)) != EOF) {
    switch(optChar) {
    case  0  : break;
    case 'D' : dbName      = optarg;       break;
    case 'p' : dbPath      = optarg;       break;
    case 't' : dbTime      = optarg;       break;
    case 'x' : dbExpTime   = optarg;       break;
    case 'F' : dbFlavor    = optarg;       break; 
    case 'f' : dbFile      = optarg;       break; 
    case 'r' : // same as g
    case 'g' : action      = GetDB;        break;
    case 'w' : // same as s
    case 's' : action      = SetDB;        break;
    case 'T' : action      = PrintTree;    break;
    case 'H' : action      = PrintHistory; break;
    case 'C' : action      = PrintConfig;  break;
    case 'c' : dbComment   = optarg;       break;  
    case 'd' : dataOnlyMode= true;         break;
    case 'v' : verboseMode = true;         break;
    case 'q' : quietMode   = true;         break;
    case 'h' : usage(); return(0);         break;
    default  : usage("unknown option");    break;
    };
  }
  if(!dbPath  && action!=PrintConfig ) usage("database path missing");


  // 
  StDbManager    *mgr    = StDbManager::Instance();
  StDbConfigNode *dbNode = NULL;
  StDbTable      *dbTab  = NULL;
  char           *node   = NULL;
  FILE           *file   = NULL;

  mgr->setVerbose(verboseMode);
  mgr->setQuiet(quietMode);

  // sanity check 
  if( ! mgr->findDefaultServer() ) {
    fprintf(stderr,"cannot find the default DB server\n");
    return(-1);
  }

  if(dbFile) { 
    file = fopen(dbFile,(action==SetDB) ? "r" : "w");
    if(!file) { 
      fprintf(stderr,"%s: fopen '%s' failed, %s\n",argv0,dbFile,strerror(errno)); 
      return(-1); 
    }
  } else {
    file = (action==SetDB) ? stdin : stdout;
  }

  switch(action) {
  case PrintTree:
    node   = node=strsep(&dbPath,"/");
    if(node) { 
      dbNode = mgr->initConfig(dbName,node);
      if(dbNode) { 
	if(verboseMode || !quietMode) 
	  fprintf  (file,"DATABASE TREE:\n");
	fprintf  (file,"%s/\n",node);
	if(printTree(file,dbNode)<=0) {
	  fprintf  (stderr,"config %s is empty\n",node);
	}
      }
    }
    return 0;
    break;
  case PrintConfig:
    if(verboseMode || !quietMode) 
     fprintf(file,"DATABASE VERSIONS:\n");
    printConfig(file,mgr);
    return 0;
  default:
    break;
  }


  // parse database path 
  char *preNode="";
  while( (node=strsep(&dbPath,"/")) != NULL ) {
    StDbConfigNode *tn = (dbNode==NULL) ? 
      mgr->initConfig(dbName,node) : dbNode->findConfigNode(node);
    if(!tn) break; // assume the last token is a db table
    dbNode = tn;
    printf("found database node: %s\n",node);
    preNode=node;
  }

  if(!node) usage("invalid path");

  dbTab = dbNode->findTable(node);
  if(!dbTab) { fprintf(stderr,"%s: table %s not found\n",argv0,node); return (-1); }

  dprintf("found table: %s\n",node);

  int nrows=dbTab->GetNRows();
  int ndata=0;
  
  EEmcDbIOBase *dbIO = getDbIO(preNode,node,nrows);
  if(dbIO==NULL) return(-1);

  char keyLine[EEmcDbMaxDbPathLen];
  //char keyFile[EEmcDbMaxKeyLength];
  char keyBase[EEmcDbMaxKeyLength];
  time_t tUnix    =                     getTimeStamp(dbTimeFormat,dbTime);
  time_t tExpUnix = (dbExpTime!=NULL) ? getTimeStamp(dbTimeFormat,dbExpTime) : 0;

  dbTab->setFlavor(dbFlavor);
  switch(action) {
  case PrintHistory:
    printHistory(file,mgr,dbTab,dbIO); 
    return 0; 
    break;
  case SetDB:
    fgets (keyLine,EEmcDbMaxDbPathLen-1,file);
    sprintf(keyBase,EEmcDbKeyFormat,dbNode->printName(),node);
    printf("AAA=%s=\n",keyBase);
    if(strstr(keyLine,keyBase)==0 &&  strcmp(keyLine,keyToEverything) ) {
      fprintf(stderr,"signature mismatch: data file key '%s', required '%s'\n",
	      keyLine,keyBase);
      return (-1);
    }

    dbIO->setComment(dbComment);

    ndata = dbIO->read(file);
    if(ndata<=0) {
      fprintf(stderr,"%s: reading file %s failed\n",argv0,dbFile);
      return(-1);
    }
    if(nrows>1) { 
      dbTab->SetTable(dbIO->getData(),ndata, dbIO->getIndices());
    } else {
      dbTab->SetTable(dbIO->getData(),ndata);
    }
    if(tExpUnix>0) { 
      dbTab->setEndStoreTime(tExpUnix);
      fprintf(stderr,"%s: setting end time %ld\n",argv0,tExpUnix);
    }

    //mgr->setStoreTime(getTimeStamp(dbTimeFormat,dbTime));
    mgr->setStoreTime(tUnix);
    if(! mgr->storeDbTable(dbTab) ) {
      fprintf(stderr,"%s: storing table %s failed\n",argv0,node);
      return(-1);
    }
  
    break;
  case GetDB:
    mgr  ->setRequestTime(tUnix);
    if( ! mgr->fetchDbTable(dbTab) ) {
      fprintf(stderr,"%s: problem with fetch for time stamp %ld / %s",argv0,tUnix,ctime(&tUnix));
      fprintf(stderr," There is no record for this table over the time period :\n");
      fprintf(stderr," BeginDate     = %s\t",dbTab->getBeginDateTime());
      fprintf(stderr,"   EndDate     = %s\n",dbTab->getEndDateTime());
      fprintf(stderr," BeginTimeUnix = %d\t",dbTab->getBeginTime());
      fprintf(stderr,"   EndTimeUnix = %d\n",dbTab->getEndTime());
      return(-1);
    }
    if(! dbTab->GetTable() ) {
      fprintf(stderr,"no data found in table %s\n",node);
      return(-1);
    } 
    dbIO->setData(dbTab->GetTable());

    if(verboseMode || !quietMode)
    fprintf(stderr,"BNL Time Stamp Range  from: %s   to:    %s \n",
	    fmtSqlTime(dbTab->getBeginDateTime()),fmtSqlTime(dbTab->getEndDateTime()));
    if(!dataOnlyMode) {
      fprintf(file,EEmcDbKeyFormat,dbNode->printName(),node);
      fprintf(file,"\n");
    }
    ndata     = dbIO->write(file);
    dbComment = dbIO->getComment();
    if(verboseMode || !quietMode)
      fprintf(stderr,"COMMENT: %s\n",dbComment);
    break;
  default:
    break;
  } 

  if(ndata>0) {  
    dprintf("database access successful %d\n",ndata);
  } else { 
    fprintf(stderr,"%s: table %s access failed\n",argv0,node); 
  }
    

  fclose(file);
  return 0; 
} 
示例#29
0
文件: SMTConfig.C 项目: patere/dReal
void SMTConfig::parseConfig ( char * f )
{
  FILE * filein = NULL;
  // Open configuration file
  if ( ( filein = fopen( f, "rt" ) ) == NULL )
  {
    // No configuration file is found. Print out
    // the current configuration
    // cerr << "# " << endl;
    cerr << "# WARNING: No configuration file " << f << ". Dumping default setting to " << f << endl;
    ofstream fileout( f );
    printConfig( fileout );
    fileout.close( );
  }
  else
  {
    int line = 0;

    while ( !feof( filein ) )
    {
      line ++;
      char buf[ 128 ];
      char * res = fgets( buf, 128, filein );
      (void)res;
      // Stop if finished
      if ( feof( filein ) )
        break;
      // Skip comments
      if ( buf[ 0 ] == '#' )
        continue;

      char tmpbuf[ 32 ];

      // GENERIC CONFIGURATION
           if ( sscanf( buf, "incremental %d\n"              , &incremental )                   == 1 );
      else if ( sscanf( buf, "produce_stats %d\n"            , &produce_stats )                 == 1 );
      else if ( sscanf( buf, "produce_models %d\n"           , &produce_models )                == 1 );
      else if ( sscanf( buf, "produce_proofs %d\n"           , &produce_proofs )                == 1 );
      else if ( sscanf( buf, "produce_inter %d\n"            , &produce_inter )                 == 1 );
      else if ( sscanf( buf, "regular_output_channel %s\n"   , tmpbuf )                         == 1 )
        setRegularOutputChannel( tmpbuf );
      else if ( sscanf( buf, "diagnostic_output_channel %s\n", tmpbuf )                         == 1 )
        setDiagnosticOutputChannel( tmpbuf );
      else if ( sscanf( buf, "dump_formula %d\n"             , &dump_formula )                  == 1 );
      else if ( sscanf( buf, "verbosity %d\n"                , &verbosity )                     == 1 );
      else if ( sscanf( buf, "certification_level %d\n"      , &certification_level )                     == 1 );
      else if ( sscanf( buf, "certifying_solver %s\n"        , certifying_solver )                     == 1 );
      // SAT SOLVER CONFIGURATION
      else if ( sscanf( buf, "sat_theory_propagation %d\n"   , &(sat_theory_propagation))       == 1 );
      else if ( sscanf( buf, "sat_polarity_mode %d\n"        , &(sat_polarity_mode))            == 1 );
      else if ( sscanf( buf, "sat_initial_skip_step %lf\n"   , &(sat_initial_skip_step))        == 1 );
      else if ( sscanf( buf, "sat_skip_step_factor %lf\n"    , &(sat_skip_step_factor))         == 1 );
      else if ( sscanf( buf, "sat_restart_first %d\n"        , &(sat_restart_first))            == 1 );
      else if ( sscanf( buf, "sat_restart_increment %lf\n"   , &(sat_restart_inc))              == 1 );
      else if ( sscanf( buf, "sat_use_luby_restart %d\n"     , &(sat_use_luby_restart))         == 1 );
      else if ( sscanf( buf, "sat_learn_up_to_size %d\n"     , &(sat_learn_up_to_size))         == 1 );
      else if ( sscanf( buf, "sat_temporary_learn %d\n"      , &(sat_temporary_learn))          == 1 );
      else if ( sscanf( buf, "sat_preprocess_booleans %d\n"  , &(sat_preprocess_booleans))      == 1 );
      else if ( sscanf( buf, "sat_preprocess_theory %d\n"    , &(sat_preprocess_theory))        == 1 );
      else if ( sscanf( buf, "sat_centrality %d\n"           , &(sat_centrality))               == 1 );
      else if ( sscanf( buf, "sat_trade_off %d\n"            , &(sat_trade_off))                == 1 );
      else if ( sscanf( buf, "sat_minimize_conflicts %d\n"   , &(sat_minimize_conflicts))       == 1 );
      else if ( sscanf( buf, "sat_dump_cnf %d\n"             , &(sat_dump_cnf))                 == 1 );
      else if ( sscanf( buf, "sat_dump_rnd_inter %d\n"       , &(sat_dump_rnd_inter))           == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc %d\n"             , &(sat_lazy_dtc))                 == 1 );
      else if ( sscanf( buf, "sat_lazy_dtc_burst %d\n"       , &(sat_lazy_dtc_burst))           == 1 );
      // PROOF PRODUCTION CONFIGURATION
      else if ( sscanf( buf, "proof_reduce %d\n"             , &(proof_reduce))                 == 1 );
      else if ( sscanf( buf, "proof_ratio_red_solv %lf\n"    , &(proof_ratio_red_solv))         == 1 );
      else if ( sscanf( buf, "proof_red_time %lf\n"          , &(proof_red_time))               == 1 );
      else if ( sscanf( buf, "proof_red_trans %d\n"          , &(proof_red_trans))              == 1 );
      else if ( sscanf( buf, "proof_reorder_pivots %d\n"     , &(proof_reorder_pivots))         == 1 );
      else if ( sscanf( buf, "proof_remove_mixed %d\n"       , &(proof_remove_mixed))           == 1 );
      else if ( sscanf( buf, "proof_use_sym_inter %d\n"      , &(proof_use_sym_inter))          == 1 );
      else if ( sscanf( buf, "proof_certify_inter %d\n"      , &(proof_certify_inter))          == 1 );
      // EUF SOLVER CONFIGURATION
      else if ( sscanf( buf, "uf_disable %d\n"               , &(uf_disable))                   == 1 );
      else if ( sscanf( buf, "uf_theory_propagation %d\n"    , &(uf_theory_propagation))        == 1 );
      // BV SOLVER CONFIGURATION
      else if ( sscanf( buf, "bv_disable %d\n"               , &(bv_disable))                   == 1 );
      else if ( sscanf( buf, "bv_theory_propagation %d\n"    , &(bv_theory_propagation))        == 1 );
      // DL SOLVER CONFIGURATION
      else if ( sscanf( buf, "dl_disable %d\n"               , &(dl_disable))                   == 1 );
      else if ( sscanf( buf, "dl_theory_propagation %d\n"    , &(dl_theory_propagation))        == 1 );
      // LRA SOLVER CONFIGURATION
      else if ( sscanf( buf, "lra_disable %d\n"              , &(lra_disable))                  == 1 );
      else if ( sscanf( buf, "lra_theory_propagation %d\n"   , &(lra_theory_propagation))       == 1 );
      else if ( sscanf( buf, "lra_poly_deduct_size %d\n"     , &(lra_poly_deduct_size))         == 1 );
      else if ( sscanf( buf, "lra_gaussian_elim %d\n"        , &(lra_gaussian_elim))            == 1 );
      else if ( sscanf( buf, "lra_integer_solver %d\n"       , &(lra_integer_solver))           == 1 );
      else if ( sscanf( buf, "lra_check_on_assert %d\n"      , &(lra_check_on_assert))          == 1 );
      else
      {
        opensmt_error2( "unrecognized option ", buf );
      }
    }

    // Close
    fclose( filein );
  }

  if ( produce_stats )  stats_out.open( "stats.out" );
}
示例#30
0
void RangeSteering::joyCallback(const sensor_msgs::Joy::ConstPtr& j)
{
    // Special case to handle key release event...
    if (waitingForRelease)
    {
        waitingForRelease = false;
        return;
    }

    // Need to "enable" this before use of params...
    if (joyDisabled)
    {
        // Pressing R[2]
        if (j->buttons[25 + 16 + 2] == 1)
        {
            joyDisabled = false;
            waitingForRelease = true;
            ROS_INFO("UWBPOS::NANO KONTROL enabled!");
            printConfig();
        }

        // Always return...
        return;
    }
    else
    {
        // Pressing R[2]
        if (j->buttons[25 + 16 + 2] == 1)
        {
            joyDisabled = true;
            waitingForRelease = true;
            ROS_INFO("UWBPOS::NANO KONTROL disabled!");
            printConfig();
            return;
        }

        // Play
        else if (j->buttons[7] == 1)
        {
            /* When deactive, start cover. if active start dock */

            doControl = true;
            doDock = false;
            seekDockStart = false;
            radius = leftRange;
            followDirection = 1;
            state = STATE_START_FOLLOW_RADIUS;
            waitingForRelease = true;
            return;
        }
        // Stop
        else if (j->buttons[6] == 1)
        {
            stop();
            doControl = false;
            doDock = false;

            waitingForRelease = true;
        }
        // Pressing set
        else if (j->buttons[1] == 1)
        {
            ROS_INFO("Start Docking");

            seekDockStart = true;
            // doControl = false;
            // setDockPath();
            waitingForRelease = true;
        }
        else
        {
            // SLIDERS
            double jRadInc = j->axes[0];
            if (jRadInc != 0)
            {
                radiusInc = jRadInc;
                ROS_INFO("RangeSteering::radiusInc = %f", radiusInc);
            }

            double jSpeed = 2 * j->axes[1] - 1.0;
            if (jSpeed != -1.0)
            {
                speed = jSpeed;
                ROS_INFO("RangeSteering::speed = %f", speed);
            }

            double jRadius = 10 * j->axes[2];
            if (jRadius != 0)
            {
                radius = jRadius;
                ROS_INFO("RangeSteering::radius = %f", radius);
            }

            double jkpd = 2 * j->axes[3];
            if (jkpd != 0)
            {
                kpDock = jkpd;
                ROS_INFO("RangeSteering::kpDock = %f", kpDock);
            }

            //~ double jkid = 0.1*j->axes[3];
            //~ if (jkid != 0)
            //~ {
            //~ ki = jkid;
            //~ ROS_INFO("RangeSteering::ki = %f", ki);
            //~ }

            double jkdd = 20 * j->axes[4];
            if (jkdd != 0)
            {
                kdDock = jkdd;
                ROS_INFO("RangeSteering::kdDock = %f", kdDock);
            }

            double jkp = 2 * j->axes[5];
            if (jkpd != 0)
            {
                kp = jkp;
                ROS_INFO("RangeSteering::kp = %f", kp);
            }

            double jki = 0.1 * j->axes[6];
            if (jki != 0)
            {
                ki = jki;
                ROS_INFO("RangeSteering::ki = %f", ki);
            }

            double jkd = 20 * j->axes[7];
            if (jkd != 0)
            {
                kd = jkd;
                ROS_INFO("RangeSteering::kd = %f", kd);
            }

            // knob 0
            double jturn = j->axes[8 + 0];
            if (jturn != 0)
            {
                turnSpeed = jturn;
                ROS_INFO("RangeSteering::turnSpeed = %f", turnSpeed);
            }
        }
    }
}