Example #1
0
/**
 * parse the set command
 */
void parseSet(char* input) {
    printf("%s\n", input);
    if (begins(input, "user ")) {
        debug("set user");
        setUser(input + 5);
        return;
    } else if (begins(input, "pass ")) {

        if (strlen(input + 5) < 1) {
            debug("ask for password");
            askPassword();
            return;
        }
        debug("set password");
        setPassword(input + 5);
        return;
    } else if (begins(input, "debug ")) {
        if (begins(input + 6, "true") || begins(input + 6, "on")) {
            setDebug(true);
        } else if (begins(input + 6, "false") || begins(input + 6, "off")) {
            setDebug(false);
        }
    } else if (begins(input, "pgpass ")) {

        if (begins(input + 7, "true") || begins(input + 7, "on")) {
            setPGPass(true);
        } else if (begins(input + 7, "false") || begins(input + 7, "off")) {
            setPGPass(false);
        }
    }
    debug("no match in set");
    printf("Don't know what you want...\n");
}
Example #2
0
void AltAzTest::setTelescope (double _lat, double _long, double _alt, long _az_ticks, long _alt_ticks, double _azZero, double _zdZero, double _azCpd, double _altCpd, long _azMin, long _azMax, long _altMin, long _altMax)
{
	setDebug (1);
	setNotDaemonize ();

	setTelLongLat (_long, _lat);
	setTelAltitude (_alt);

	az_ticks->setValueLong (_az_ticks);
	alt_ticks->setValueLong (_alt_ticks);

	azZero->setValueDouble (_azZero);
	zdZero->setValueDouble (_zdZero);

	azCpd->setValueDouble (_azCpd);
	altCpd->setValueDouble (_altCpd);

	azMin->setValueLong (_azMin);
	azMax->setValueLong (_azMax);
	altMin->setValueLong (_altMin);
	altMax->setValueLong (_altMax);

	setCorrections (false, false, false, false);

	hardHorizon = new ObjectCheck ("../conf/horizon_flat_19_flip.txt");
}
SoundDetector::SoundDetector( Ogre::String name, Ogre::SceneNode* parentNode, 
							 Ogre::Real radius )
{
	// set to true if you want debugging
	setDebug( false );

	// create the sphereQuery
	mName = name;
	mNode = parentNode->createChildSceneNode( mName );

	//Create Sphere query
	Ogre::Sphere sphere( parentNode->getPosition(), radius );
	mSphere = sphere;
	mSphereScQry = ClassPack::getSingleton()->getSceneManager()->createSphereQuery( mSphere );

	//Create Sphere Entity
	mSphereEnt = ClassPack::getSingleton()->getSceneManager()->createEntity( mName+"ShpQry", "sphere.mesh" );
	mNode->setScale( radius, radius, radius );
	mNode->createChildSceneNode( mName+"Sphere" )->attachObject( mSphereEnt );
	mSphereEnt->setMaterialName( "Simple/Translucent" );
	mSphereEnt->setVisible( false );

	// Get initial results
	mSqMovableList = mSphereScQry->execute().movables;

	mObjMng = ObjectManager::getSingleton();
	eventMng = EventManager::getSingleton();
}
/*
-------------------- Initialization functions for the SoundManager2 class --------------------
*/
bool SoundManager2::initialize( bool debug_flag ){
    setDebug( debug_flag );
    activate();
    setMusicVolume(255);
    setSoundEffectVolume(255);
    setMusicChannel(1);
    setSwapMusicChannel(2);
    setInitialSoundEffectChannel(3);    
    setSoundEffectChannel(getInitialSoundEffectChannel());
    setMaxChannels(64);

    bool initialized = FSOUND_Init (44100, getMaxChannels(), 0);

    if(isDebug()){
        printf("SoundManager Initialization (debug: %i):\n", isDebug());
        printf("\tActive: %i\n", isActive());
        printf("\tMusic Volume: %i\n", getMusicVolume());
        printf("\tSound Effect Volume: %i\n", getSoundEffectVolume());
        printf("\tSound Effect Channel: %i\n", getSoundEffectChannel());
        printf("\tMusic Channel: %i\n", getMusicChannel());
        printf("\tSwap Music Channel: %i\n", getSwapMusicChannel());
        printf("\tInitial Sound Effect Channel: %i\n", getInitialSoundEffectChannel());
        printf("\tMusic Channel: %i\n", getMusicChannel());
    }

    return initialized;

}
Example #5
0
void DebugClass::processDebugCommands(Command reqCommand, CommandOutput* commandOutput)
{
	String commandLine = reqCommand.getCmdString();
	Vector<String> commandToken;
	int numToken = splitString(commandLine, ' ' , commandToken);

	if (numToken == 1)
	{
		commandOutput->printf("Debug Commands available : \r\n");
		commandOutput->printf("on   : Start Debug output\r\n");
		commandOutput->printf("off  : Stop Debug output\r\n");
		commandOutput->printf("serial : Send Debug output to Serial\r\n");
	}
	else
	{
		if (commandToken[1] == "on")
		{
			start();
			commandOutput->printf("Debug started\r\n");
		}
		else if (commandToken[1] == "off")
		{
			commandOutput->printf("Debug stopped\r\n");
			stop();
		}
		else if (commandToken[1] == "serial")
		{
			setDebug(Serial);
			commandOutput->printf("Debug set to Serial");
		};

	}
}
Example #6
0
const vpz::AtomicModel*
Executive::createModel(const std::string& name,
                       const std::vector<std::string>& inputs,
                       const std::vector<std::string>& outputs,
                       const std::string& dynamics,
                       const std::vector<std::string>& conds,
                       const std::string& observable,
                       bool debug)
{
    auto model = new vpz::AtomicModel(name, cpled());
    if (debug) {
        model->setDebug();
    }
    std::vector<std::string>::const_iterator it;

    for (it = inputs.begin(); it != inputs.end(); ++it) {
        model->addInputPort(*it);
    }

    for (it = outputs.begin(); it != outputs.end(); ++it) {
        model->addOutputPort(*it);
    }

    m_coordinator.createModel(
      model, conditions(), dynamics, conds, observable);

    return model;
}
Example #7
0
int RDOEditorMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
	if ( CFrameWnd::OnCreate(lpCreateStruct) == -1 ) return -1;

	childView.Create( NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL );

	CString s;
	s.LoadString( ID_TOOLBAR_PROJECT );
	projectToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLOATING | CBRS_SIZE_DYNAMIC );
	projectToolBar.LoadToolBar( IDR_PROJECTTOOLBAR );
	projectToolBar.GetToolBarCtrl().SetWindowText( s );

	projectToolBarImageList.Create( IDB_PROJECTTOOLBAR_D, 16, 0, 0xFF00FF );
	projectToolBar.GetToolBarCtrl().SetDisabledImageList( &projectToolBarImageList );

	s.LoadString( ID_TOOLBAR_EDIT );
	editToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLOATING | CBRS_SIZE_DYNAMIC );
	editToolBar.LoadToolBar( IDR_EDITTOOLBAR );
	editToolBar.GetToolBarCtrl().SetWindowText( s );

	editToolBarImageList.Create( IDB_EDITTOOLBAR_D, 16, 0, 0xFF00FF );
	editToolBar.GetToolBarCtrl().SetDisabledImageList( &editToolBarImageList );

	statusBar.Create( this );
	statusBar.SetIndicators( indicators, 4 );
	statusBar.SetPaneInfo( 0, ID_COORDSTATUSBAR          , SBPS_NORMAL , 70 );
	statusBar.SetPaneInfo( 1, ID_MODIFYSTATUSBAR         , SBPS_NORMAL , 70 );
	statusBar.SetPaneInfo( 2, ID_INSERTOVERWRITESTATUSBAR, SBPS_NORMAL , 70 );
	statusBar.SetPaneInfo( 3, ID_INFOSTATUSBAR           , SBPS_STRETCH, 70 );

	projectToolBar.EnableDocking( CBRS_ALIGN_ANY );
	editToolBar.EnableDocking( CBRS_ALIGN_ANY );

	EnableDocking( CBRS_ALIGN_ANY );

	DockControlBar( &projectToolBar );
	dockControlBarBesideOf( editToolBar, projectToolBar );

	loadRdoPath();
	loadReopen();
	updateReopenSubMenu();

	rdoEditorApp.setCaption( "" );

	RDODebug d = canHook() ? RDOD_Hook : RDOD_Timer;
	debug = (RDODebug)rdoEditorApp.GetProfileInt( "debug", "debug", d );
	if ( d != RDOD_Hook && debug == RDOD_Hook ) {
		debug = d;
	}
	setDebug( debug );

	pi.dwProcessId = 0;
	pi.dwThreadId  = 0;
	pi.hProcess    = 0;
	pi.hThread     = 0;

	return 0;
}
Example #8
0
Logger::Logger(std::string logFileName, std::string className) {
	::InitializeCriticalSection(&g_cs);
	setDebug(false);
	setInfo(false);
	this->className = className;
	logFile.open(logFileName, std::ofstream::app);
	if (!logFile.is_open())
		throw CannotOpenLogFileException();	
}
Example #9
0
int	main()
{
	auto	tmp = make_unique<Compute>(make_unique<ConsoleTokeniser>(),
							make_unique<ConsoleOutput>(),
							make_unique<NPI>());
	assert(tmp && "ERROR CREATING OBJECT");
	tmp->setDebug();
	std::string	data("1 1 +\n");
	for (auto it = data.rbegin(); it != data.rend(); ++it)
		std::cin.putback(*it);
	tmp->computeLine();
};
SampledSetValueExpressionDriver::SampledSetValueExpressionDriver(
    sampledSet &surf,
    bool autoInterpolate,
    bool warnAutoInterpolate
)
:
    SubsetValueExpressionDriver(autoInterpolate,warnAutoInterpolate),
    theSet_(surf),
    interpolate_(false),
    interpolationType_("nix")
{
    setDebug();
}
Example #11
0
St_fft::St_fft(uint n, uint hop_size, Window<smp_t>* window)
{
    DASSERT(n==window->getLen());
   
    this->n=n;
    this->hop_size=hop_size;
   
    //must make room for
    int ib_sz = n;
    int ob_sz = n;///hop_size;
   
    //everytime in buffer reaches 'n' take a FFT frame and the jump hop_size and wait for next
    in_buff = new ring(ib_sz);
   
    out_ready=0; //samples ready to be returned
    oadd_index=0;
   
    //every time a FFT frame is taken: IFFT it and overlap-add it to this
    //at oadd_index, oadd_index+=hop_size
    //out_ready+=hop_size
   
    //when reading: oadd_index--
    //out_ready--
   
    out_buff = new ring(ob_sz);
   
    //some copying, maybe fix if slow
    fft_in = new smp_t[n];
    fft_out = new Complex[n];
   
    ifft_out = new smp_t[n];
   
   
    for(uint i=0;i<n;i++)
    {
        out_buff->add(0);
    }
   
    win=window;
   
    setShiftSpectrum(false);
    setDebug(false);
   
    process=NULL;
   
    in=NULL;
   
    fft = new FFTfixed<smp_t>();
    fft->setup(n);
    VERBOSE2(cout << "fft used: " << fft->getBytesUsed()/(1024*1024.0) << "mb" << endl;);
AdvancedOptionsWidget::AdvancedOptionsWidget( QWidget *parent ) :
	OptionsDialogPage( parent ),
	ui( new Ui::AdvancedOptionsWidget ) {
	ui->setupUi( this );

	connect( ui->labelTrace, SIGNAL( clicked() ), this, SLOT( setTrace() ) );
	connect( ui->labelDebug, SIGNAL( clicked() ), this, SLOT( setDebug() ) );
	connect( ui->labelInfo, SIGNAL( clicked() ), this, SLOT( setInfo() ) );
	connect( ui->labelWarn, SIGNAL( clicked() ), this, SLOT( setWarn() ) );
	connect( ui->labelError, SIGNAL( clicked() ), this, SLOT( setError() ) );
	connect( ui->labelFatal, SIGNAL( clicked() ), this, SLOT( setFatal() ) );

	ui->loggingLevel->setValue( QsLogging::Logger::instance().loggingLevel() );
}
SampledSetValueExpressionDriver::SampledSetValueExpressionDriver(
    const word &id,
    const fvMesh &mesh
)
:
    SubsetValueExpressionDriver(true,false),
    theSet_(
        SetsRepository::getRepository().getSet(
            id,
            mesh
        )
    ),
    interpolate_(false),
    interpolationType_("nix")
{
    setDebug();
}
SampledSetValueExpressionDriver::SampledSetValueExpressionDriver(const dictionary& dict,const fvMesh&mesh)
 :
    SubsetValueExpressionDriver(dict),
    theSet_(
        SetsRepository::getRepository().getSet(
            dict,
            mesh
        )
    ),
    interpolate_(dict.lookupOrDefault<bool>("interpolate",false)),
    interpolationType_(
        interpolate_ 
        ?
        word(dict.lookup("interpolationType"))
        :
        word("nix")
    )
{
    setDebug();
}
Example #15
0
///////////////////////////////////////////////////////////////////////////////
/// main routine of the demo code
///
///\param argc Number of arguments
///\param argv Arguments
///\return 0 if no error occurred
///////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) {
    const char* fmuFilNam;
    char* fmuPat;
    char* tmpPat;
    char* xmlPat;
    char* dllPat;
    
    // define default argument values
    double tEnd = 1.0;
    double h=0.1;
    int loggingOn = 0;
    char csv_separator = ',';  
   
    // parse command line arguments
    if (argc>1) {
        fmuFilNam = argv[1];
        
        if(!strcmp(fmuFilNam, "-h") | !strcmp(fmuFilNam, "--help")) {
          printHelp(argv[0]);
          return 0;
        }

        /*if(!strstr(fmuFilNam,"DoubleInputDoubleOutput.fmu")) {
          printf("Sorry, this demo only works with the FMU file DoubleInputDoubleOutput.fmu");
          return 0;
        }*/
    }
    else {
        printError("No fmu file.\n");
        printHelp(argv[0]);
        exit(EXIT_FAILURE);
    }
    if (argc>2) {
        if (sscanf(argv[2],"%lf", &tEnd) != 1) {
            printfError("The given end time (%s) is not a number.\n", argv[2]);
            exit(EXIT_FAILURE);
        }
    }
    if (argc>3) {
        if (sscanf(argv[3],"%lf", &h) != 1) {
            printfError("The given stepsize (%s) is not a number.\n", argv[3]);
            exit(EXIT_FAILURE);
        }
    }
    if (argc>4) {
        if (sscanf(argv[4],"%d", &loggingOn) != 1 || loggingOn<0 || loggingOn>1) {
            printfError("The given logging flag (%s) is not boolean.\n", argv[4]);
            exit(EXIT_FAILURE);
        }
        if(loggingOn) setDebug();
    }
    if (argc>5) {
        if (strlen(argv[5]) != 1) {
            printfError("The given CSV separator char (%s) is not valid.\n", argv[5]);
            exit(EXIT_FAILURE);
        }
        csv_separator = argv[5][0];
    }
    if (argc>6) {
        printf("warning: Ignoring %d additional arguments: %s ...\n", argc-6, argv[6]);
        printHelp(argv[0]);
    }

    // Get absolute path to FMU, NULL if not found  
    tmpPat = getTmpPath(fmuFilNam, strlen(fmuFilNam)-4);
    if(tmpPat==NULL){
      printError("Cannot allocate temporary path.\n");
      exit(EXIT_FAILURE);
    }

    // Unzip the FMU to the tmpPat directory
    if (unpack(fmuFilNam, tmpPat)) {  
        printfError("Fail to unpack fmu \"%s\".\n", fmuFilNam);
        exit(EXIT_FAILURE);
    }

    printDebug("parse tmpPat\\modelDescription.xml.\n");
    xmlPat = calloc(sizeof(char), strlen(tmpPat) + strlen(XML_FILE) + 1);
    sprintf(xmlPat, "%s%s", tmpPat, XML_FILE);

    // Parse only parses the model description and store in structure fmu.modelDescription
    fmu.modelDescription = parse(xmlPat); 
    free(xmlPat);
    if (!fmu.modelDescription) exit(EXIT_FAILURE);

    // Allocate the memory for dllPat
    dllPat = calloc(sizeof(char), strlen(tmpPat) + strlen(DLL_DIR) 
            + strlen( getModelIdentifier(fmu.modelDescription)) +  strlen(".dll") + 1); 
    sprintf(dllPat,"%s%s%s.dll", tmpPat, DLL_DIR, getModelIdentifier(fmu.modelDescription)); 

    // Load the FMU dll
    if (loadDll(dllPat, &fmu)) exit(EXIT_FAILURE); 
	  printfDebug("Loaded \"%s\"\n", dllPat); 

    free(dllPat);
    free(tmpPat);

    // Run the simulation
    printf("FMU Simulator: run '%s' from t=0..%g with step size h=%g, loggingOn=%d, csv separator='%c'\n", 
            fmuFilNam, tEnd, h, loggingOn, csv_separator);
    if (simulate(&fmu, tEnd, h, loggingOn, csv_separator)){
      printError("Simulation failed.\n");
      exit(EXIT_FAILURE);
    }

    printf("CSV file '%s' written", RESULT_FILE);

    // Release FMU 
    FreeLibrary(fmu.dllHandle);
    freeElement(fmu.modelDescription);
    return EXIT_SUCCESS;
}
Example #16
0
static void doSetCompilerPath(const char * path, const char * includes, const char * libs, const char * tmpdir, unsigned targetCompiler, bool verbose)
{
    if (!includes)
        includes = INCLUDEPATH[targetCompiler];
    if (!libs)
        libs = LIB_DIR[targetCompiler];
    if (verbose)
    {
        PrintLog("Include directory set to %s", includes);
        PrintLog("Library directory set to %s", libs);
    }
    compilerRoot.set(path ? path : targetCompiler==GccCppCompiler ? "/usr" : ".\\CL");
    stdIncludes.set(includes);
    stdLibs.clear();
    for (;;)
    {
        StringBuffer thislib;
        while (*libs && *libs != ENVSEPCHAR)
            thislib.append(*libs++);
        if (thislib.length())
        {
            stdLibs.append(" ").append(USE_LIBPATH_FLAG[targetCompiler]).append(thislib).append(USE_LIBPATH_TAIL[targetCompiler]);
            if (USE_LIBRPATH_FLAG[targetCompiler])
                stdLibs.append(" ").append(USE_LIBRPATH_FLAG[targetCompiler]).append(thislib);
        }
        if (!*libs)
            break;
        libs++;
    }
    StringBuffer fname;
    if (path)
    {
        const char *finger = CC_NAME[targetCompiler];
        while (*finger)
        {
            if (*finger == '#')
                fname.append(path);
            else
                fname.append(*finger);
            finger++;
        }

#if defined(__linux__)
        StringBuffer clbin_dir;
        const char* dir_end = strrchr(fname, '/');
        if(dir_end == NULL)
            clbin_dir.append(".");
        else
            clbin_dir.append((dir_end - fname.str()) + 1, fname.str());
        
        StringBuffer pathenv(clbin_dir.str());
        const char* oldpath = getenv("PATH");
        if(oldpath != NULL && *oldpath != '\0')
        pathenv.append(":").append(oldpath);
        setenv("PATH", pathenv.str(), 1);
#endif
    }
    else
    {
        fname.append(compilerRoot).append(CC_NAME[targetCompiler]);
        fname.replaceString("#",NULL);
    }
    if (verbose)
        PrintLog("Compiler path set to %s", fname.str());

    dequote(fname);
#ifdef _WIN32
    if (_access(fname.str(), 4))
    {
#else
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
    struct stat filestatus;
    int r = stat(fname.str(), &filestatus);
    if (    (r != 0)
        ||  (!S_ISREG(filestatus.st_mode))
        ||  ((filestatus.st_mode&(S_IXOTH|S_IXGRP|S_IXUSR))==0))
    {
        if (r == -1) errno = ENOENT;
#endif
#endif
        if (verbose)
            PrintLog("SetCompilerPath - no compiler found");
        throw makeOsExceptionV(GetLastError(), "setCompilerPath could not locate compiler %s", fname.str());
    }

    if(tmpdir && *tmpdir)
    {
        //MORE: this should be done for the child process instead of the parent but invoke does not let me do it
#if defined(__linux__)
        setenv("TMPDIR", tmpdir, 1);
#endif

#ifdef _WIN32
        StringBuffer tmpbuf;
        tmpbuf.append("TMP=").append(tmpdir);
        _putenv(tmpbuf.str());
#endif
    }
}

//===========================================================================

class CCompilerThreadParam : public CInterface
{
public:
    CCompilerThreadParam(const StringBuffer & _cmdline, Semaphore & _finishedCompiling, const StringBuffer & _logfile) : cmdline(_cmdline), logfile(_logfile), finishedCompiling(_finishedCompiling) {};

    StringBuffer        cmdline;
    StringBuffer        logfile;
    Semaphore       &   finishedCompiling;
};

//===========================================================================

static void setDirectoryPrefix(StringAttr & target, const char * source)
{
    if (source && *source)
    {
        StringBuffer temp;
        target.set(addDirectoryPrefix(temp, source));
    }
}

CppCompiler::CppCompiler(const char * _coreName, const char * _sourceDir, const char * _targetDir, unsigned _targetCompiler, bool _verbose)
{
    coreName.set(_coreName);
    targetCompiler = _targetCompiler;
    createDLL = true;
#ifdef _DEBUG
    setDebug(true);
    setDebugLibrary(true);
#else
    setDebug(false);
    setDebugLibrary(false);
#endif
    
    setDirectoryPrefix(sourceDir, _sourceDir);
    setDirectoryPrefix(targetDir, _targetDir);
    maxCompileThreads = 1;
    onlyCompile = false;
    verbose = _verbose;
    saveTemps = false;
    abortChecker = NULL;
    precompileHeader = false;
    linkFailed = false;
}
Example #17
0
void CVirtualFS::startup(){
	setDebug(false);
}
bool SoundManager2::toggleDebug( void ){
    if(isDebug()) setDebug(false);
    else setDebug(true);
    return isDebug();
}
Example #19
0
bool FGTrim::DoTrim(void) {

  trim_failed=false;
  int i;

  for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
    fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
  }

  fdmex->DisableOutput();

  fdmex->SetTrimStatus(true);
  fdmex->SuspendIntegration();

  fgic->SetPRadpsIC(0.0);
  fgic->SetQRadpsIC(0.0);
  fgic->SetRRadpsIC(0.0);

  //clear the sub iterations counts & zero out the controls
  for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
    //cout << current_axis << "  " << TrimAxes[current_axis]->GetStateName()
    //<< "  " << TrimAxes[current_axis]->GetControlName()<< endl;
    if(TrimAxes[current_axis]->GetStateType() == tQdot) {
      if(mode == tGround) {
        TrimAxes[current_axis]->initTheta();
      }
    }
    xlo=TrimAxes[current_axis]->GetControlMin();
    xhi=TrimAxes[current_axis]->GetControlMax();
    TrimAxes[current_axis]->SetControl((xlo+xhi)/2);
    TrimAxes[current_axis]->Run();
    //TrimAxes[current_axis]->AxisReport();
    sub_iterations[current_axis]=0;
    successful[current_axis]=0;
    solution[current_axis]=false;
  }


  if(mode == tPullup ) {
    cout << "Setting pitch rate and nlf... " << endl;
    setupPullup();
    cout << "pitch rate done ... " << endl;
    TrimAxes[0]->SetStateTarget(targetNlf);
    cout << "nlf done" << endl;
  } else if (mode == tTurn) {
    setupTurn();
    //TrimAxes[0]->SetStateTarget(targetNlf);
  }

  do {
    axis_count=0;
    for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
      setDebug();
      updateRates();
      Nsub=0;
      if(!solution[current_axis]) {
        if(checkLimits()) {
          solution[current_axis]=true;
          solve();
        }
      } else if(findInterval()) {
        solve();
      } else {
        solution[current_axis]=false;
      }
      sub_iterations[current_axis]+=Nsub;
    }
    for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
      //these checks need to be done after all the axes have run
      if(Debug > 0) TrimAxes[current_axis]->AxisReport();
      if(TrimAxes[current_axis]->InTolerance()) {
        axis_count++;
        successful[current_axis]++;
      }
    }


    if((axis_count == TrimAxes.size()-1) && (TrimAxes.size() > 1)) {
      //cout << TrimAxes.size()-1 << " out of " << TrimAxes.size() << "!" << endl;
      //At this point we can check the input limits of the failed axis
      //and declare the trim failed if there is no sign change. If there
      //is, keep going until success or max iteration count

      //Oh, well: two out of three ain't bad
      for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
        //these checks need to be done after all the axes have run
        if(!TrimAxes[current_axis]->InTolerance()) {
          if(!checkLimits()) {
            // special case this for now -- if other cases arise proper
            // support can be added to FGTrimAxis
            if( (gamma_fallback) &&
                (TrimAxes[current_axis]->GetStateType() == tUdot) &&
                (TrimAxes[current_axis]->GetControlType() == tThrottle)) {
              cout << "  Can't trim udot with throttle, trying flight"
              << " path angle. (" << N << ")" << endl;
              if(TrimAxes[current_axis]->GetState() > 0)
                TrimAxes[current_axis]->SetControlToMin();
              else
                TrimAxes[current_axis]->SetControlToMax();
              TrimAxes[current_axis]->Run();
              delete TrimAxes[current_axis];
              TrimAxes[current_axis]=new FGTrimAxis(fdmex,fgic,tUdot,
                                                    tGamma );
            } else {
              cout << "  Sorry, " << TrimAxes[current_axis]->GetStateName()
              << " doesn't appear to be trimmable" << endl;
              //total_its=k;
              trim_failed=true; //force the trim to fail
            } //gamma_fallback
          }
        } //solution check
      } //for loop
    } //all-but-one check
    N++;
    if(N > max_iterations)
      trim_failed=true;
  } while((axis_count < TrimAxes.size()) && (!trim_failed));
  if((!trim_failed) && (axis_count >= TrimAxes.size())) {
    total_its=N;
    if (debug_lvl > 0)
        cout << endl << "  Trim successful" << endl;
  } else {
    total_its=N;
    if (debug_lvl > 0)
        cout << endl << "  Trim failed" << endl;
  }
  for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
    fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
  }
  fdmex->SetTrimStatus(false);
  fdmex->ResumeIntegration();
  fdmex->EnableOutput();
  return !trim_failed;
}
Example #20
0
File: neclcd.c Project: jtyr/neclcd
int main(int argc, char **argv) {
	int c, value = -1, ret = 0;
	char message_type = '\xFF', destination = 'A', source = '0', code_page = '\xFF', code = '\xFF', command = '\xFF';


	/* parse command line options */
	while (1) {
		int option_index = 0;
		static struct option long_options[] = {
			{"type",
				required_argument,
				NULL,
				't'
			},
			{"dest",
				required_argument,
				NULL,
				'd'
			},
			{"src",
				required_argument,
				NULL,
				's'
			},
			{"codepage",
				required_argument,
				NULL,
				'p'
			},
			{"code",
				required_argument,
				NULL,
				'c'
			},
			{"value",
				required_argument,
				NULL,
				'v'
			},
			{"command",
				required_argument,
				NULL,
				'm'
			},
			{"debug",
				optional_argument,
				NULL,
				'e'
			},
			{"help",
				no_argument,
				NULL,
				'h'
			}
		};

		c = getopt_long(argc, argv, "t:d:s:p:c:v:e::h", long_options, &option_index);
		if (c == -1)
			break;

		switch (c) {
			case 't':
				message_type = optarg[0];
				break;

			case 'd':
				destination = optarg[0];
				break;

			case 's':
				source = optarg[0];
				break;

			case 'p':
				code_page = strhex2int(optarg);
				break;

			case 'c':
				code = strhex2int(optarg);
				break;

			case 'v':
				value = strhex2int(optarg);
				break;

			case 'm':
				command = strhex2int(optarg);
				break;

			case 'e':
				if (optarg == NULL)
					setDebug(1);
				else
					setDebug(strhex2int(optarg));
				break;

			case 'h':
				help();
				break;

			default:
				fprintf(stderr, "E: getopt returned character code 0%o\n", c);
				exit(-1);
				break;
		}
	}


	if (optind == 1) {
		help();
	}


	if (optind < argc) {
		fprintf(stderr, "W: Non-option ARGV-elements: ");
		while (optind < argc)
			fprintf(stderr, "'%s' ", argv[optind++]);
		fprintf(stderr, "\n");
	}


	/* check message type */
	if (message_type != 'A' && message_type != 'C' && message_type != 'E') {
		fprintf(stderr, "E: Wrong message type!\n");
		help();
	}

	/* check parameters */
	if ((message_type == 'A' && (command == '\xFF')) ||
	    (message_type == 'C' && (code_page == '\xFF' || code == '\xFF')) ||
	    (message_type == 'E' && (code_page == '\xFF' || code == '\xFF' || value == -1))
	) {
		fprintf(stderr, "E: Too few parameters!\n");
		help();
	}


	MESSAGE m;
	REPLAY r;

	switch (message_type) {
		case 'A':
			/*
			* COMMAND
			*/
			/* inicialisation */
			m.initMessage	= initMessage;
			m.initMessage(&m, message_type, 4);

			/* set header parameters */
			m.destination	= destination;
			m.source	= source;

			/* set message parameters */
			m.command	= command;

			/* set LCD parameters */
			m.sendMessage = sendMessage;
			if ((ret = m.sendMessage(&m)) != 0)
				perror("E: Send message failed!");

			break;
		case 'C':
			/*
			* GET CURRENT PARAMETER
			*/
			/* inicialisation */
			m.initMessage	= initMessage;
			m.initMessage(&m, message_type, 6);

			/* set header parameters */
			m.destination	= destination;
			m.source	= source;

			/* set message parameters */
			m.op_code_page	= code_page;
			m.op_code	= code;

			/* set LCD parameters */
			m.sendMessage = sendMessage;
			if ((ret = m.sendMessage(&m)) != 0)
				perror("E: Send message failed!");
			else {
				r.initReplay = initReplay;
				r.initReplay(&r, &m.replay);

				printf("max_value = %d\n", strhex2int(r.max_value));
				printf("current_value = %d\n", strhex2int(r.value));
			}

			break;

		case 'E':
			/*
			* SET PARAMETER
			*/
			/* inicialisation */
			m.initMessage	= initMessage;
			m.initMessage(&m, message_type, 10);

			/* set header parameters */
			m.destination	= destination;
			m.source	= source;

			/* set message parameters */
			m.op_code_page	= code_page;
			m.op_code	= code;
			m.value	= int2strhex(value, 4);

			/* set LCD parameters */
			m.sendMessage = sendMessage;
			if ((ret = m.sendMessage(&m)) != 0)
				perror("E: Send message failed!");

			break;
	}


	return ret;
}
Example #21
0
List<T>::List() {
  setDebug(false);
  setFirst(NULL);
  setLast(NULL);
}
Example #22
0
void MMSWindowClass::setAttributesFromTAFF(MMSTaffFile *tafff, string *path, bool reset_paths) {
    MMSFBColor color;

    if ((reset_paths)&&(path)&&(*path!="")) {
    	// unset my paths
    	unsetBgImagePath();
    }

	startTAFFScan
	{
        switch (attrid) {
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_alignment:
            setAlignment(getAlignmentFromString(attrval_str));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_dx:
            setDx(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_dy:
            setDy(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_w:
            setWidth(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_h:
            setHeight(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor:
            setBgColor(MMSFBColor((unsigned int)attrval_int));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_a:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.a = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_r:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.r = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_g:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.g = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgcolor_b:
			color.a = color.r = color.g = color.b = 0;
            if (isBgColor()) getBgColor(color);
            color.b = attrval_int;
            setBgColor(color);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgimage:
            if (*attrval_str)
                setBgImagePath("");
            else
                setBgImagePath((path)?*path:"");
            setBgImageName(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgimage_path:
            if (*attrval_str)
                setBgImagePath(attrval_str);
            else
                setBgImagePath((path)?*path:"");
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_bgimage_name:
            setBgImageName(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_opacity:
            setOpacity(attrval_int);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_fadein:
            setFadeIn((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_fadeout:
            setFadeOut((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_debug:
            setDebug((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_margin:
            setMargin(attrval_int);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_up_arrow:
            setUpArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_down_arrow:
            setDownArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_left_arrow:
            setLeftArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_right_arrow:
            setRightArrow(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_up:
            setNavigateUp(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_down:
            setNavigateDown(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_left:
            setNavigateLeft(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_navigate_right:
            setNavigateRight(attrval_str);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_own_surface:
#ifdef __HAVE_DIRECTFB__
			if(attrval_int) {
				MMSConfigData config;
				if(config.getBackend() == MMSFB_BE_DFB) {
					cerr << "Warning: DirectFB backend does not support own_surface=true (ignored)" << endl;
					break;
				}
			}
#endif
            setOwnSurface((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_movein:
            setMoveIn(getDirectionFromString(attrval_str));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_moveout:
            setMoveOut(getDirectionFromString(attrval_str));
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_modal:
            setModal((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_static_zorder:
            setStaticZOrder((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_always_on_top:
            setAlwaysOnTop((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_focusable:
            setFocusable((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_backbuffer:
            setBackBuffer((attrval_int) ? true : false);
            break;
		case MMSGUI_WINDOW_ATTR::MMSGUI_WINDOW_ATTR_IDS_initial_load:
            setInitialLoad((attrval_int) ? true : false);
            break;
		}
	}
	endTAFFScan

    if ((reset_paths)&&(path)&&(*path!="")) {
    	// set my paths
    	if (!isBgImagePath())
    		setBgImagePath(*path);
    }
}
Example #23
0
DebugClass::DebugClass()
{
	debugf("DebugClass Instantiating");
	setDebug(Serial);
}
Example #24
0
//constructor loads the bitmap when it is created
Bitmap::Bitmap(char *file, bool debug){
    reset();
	setDebug(debug);
    loadBMP(file);
}
Example #25
0
void Config::processArgs(const QStringList &args)
{
    QStringListIterator it(args);
    while (it.hasNext()) {
        const QString &arg = it.next();

        if (arg == "--version") {
            setVersionFlag(true);
            return;
        }
        if (arg == "--load-images=yes") {
            setAutoLoadImages(true);
            continue;
        }
        if (arg == "--load-images=no") {
            setAutoLoadImages(false);
            continue;
        }
        if (arg == "--load-plugins=yes") {
            setPluginsEnabled(true);
            continue;
        }
        if (arg == "--load-plugins=no") {
            setPluginsEnabled(false);
            continue;
        }
        if (arg == "--disk-cache=yes") {
            setDiskCacheEnabled(true);
            continue;
        }
        if (arg == "--disk-cache=no") {
            setDiskCacheEnabled(false);
            continue;
        }
        if (arg.startsWith("--max-disk-cache-size=")) {
            setMaxDiskCacheSize(arg.mid(arg.indexOf("=") + 1).trimmed().toInt());
            continue;
        }
        if (arg == "--ignore-ssl-errors=yes") {
            setIgnoreSslErrors(true);
            continue;
        }
        if (arg == "--ignore-ssl-errors=no") {
            setIgnoreSslErrors(false);
            continue;
        }
        if (arg == "--local-to-remote-url-access=no") {
            setLocalToRemoteUrlAccessEnabled(false);
            continue;
        }
        if (arg == "--local-to-remote-url-access=yes") {
            setLocalToRemoteUrlAccessEnabled(true);
            continue;
        }
        if (arg.startsWith("--proxy-type=")) {
            setProxyType(arg.mid(13).trimmed());
            continue;
        }
        if (arg.startsWith("--proxy=")) {
            setProxy(arg.mid(8).trimmed());
            continue;
        }
        if (arg.startsWith("--cookies-file=")) {
            setCookiesFile(arg.mid(15).trimmed());
            continue;
        }
        if (arg.startsWith("--output-encoding=")) {
            setOutputEncoding(arg.mid(18).trimmed());
            continue;
        }
        if (arg.startsWith("--script-encoding=")) {
            setScriptEncoding(arg.mid(18).trimmed());
            continue;
        }
        if (arg.startsWith("--config=")) {
            QString configPath = arg.mid(9).trimmed();
            loadJsonFile(configPath);
            continue;
        }
        if (arg.startsWith("--remote-debugger-port=")) {
            setDebug(true);
            setRemoteDebugPort(arg.mid(23).trimmed().toInt());
            continue;
        }
        if (arg.startsWith("--")) {
            setUnknownOption(QString("Unknown option '%1'").arg(arg));
            return;
        }

        // There are no more options at this point.
        // The remaining arguments are available for the script.

        m_scriptFile = arg;

        while (it.hasNext()) {
            m_scriptArgs += it.next();
        }
    }
}
Example #26
0
void Config::handleOption(const QString &option, const QVariant &value)
{
    bool boolValue = false;

    QStringList booleanFlags;
    booleanFlags << "debug";
    booleanFlags << "disk-cache";
    booleanFlags << "ignore-ssl-errors";
    booleanFlags << "load-images";
    booleanFlags << "local-to-remote-url-access";
    booleanFlags << "remote-debugger-autorun";
    booleanFlags << "web-security";
    if (booleanFlags.contains(option)) {
        if ((value != "true") && (value != "yes") && (value != "false") && (value != "no")) {
            setUnknownOption(QString("Invalid values for '%1' option.").arg(option));
            return;
        }
        boolValue = (value == "true") || (value == "yes");
    }

    if (option == "cookies-file") {
        setCookiesFile(value.toString());
    }

    if (option == "config") {
        loadJsonFile(value.toString());
    }

    if (option == "debug") {
        setPrintDebugMessages(boolValue);
    }

    if (option == "disk-cache") {
        setDiskCacheEnabled(boolValue);
    }

    if (option == "ignore-ssl-errors") {
        setIgnoreSslErrors(boolValue);
    }

    if (option == "load-images") {
        setAutoLoadImages(boolValue);
    }

    if (option == "local-storage-path") {
        setOfflineStoragePath(value.toString());
    }

    if (option == "local-storage-quota") {
        setOfflineStorageDefaultQuota(value.toInt());
    }

    if (option == "local-to-remote-url-access") {
        setLocalToRemoteUrlAccessEnabled(boolValue);
    }

    if (option == "max-disk-cache") {
        setMaxDiskCacheSize(value.toInt());
    }

    if (option == "output-encoding") {
        setOutputEncoding(value.toString());
    }

    if (option == "remote-debugger-autorun") {
        setRemoteDebugAutorun(boolValue);
    }

    if (option == "remote-debugger-port") {
        setDebug(true);
        setRemoteDebugPort(value.toInt());
    }

    if (option == "proxy") {
        setProxy(value.toString());
    }

    if (option == "proxy-type") {
        setProxyType(value.toString());
    }

    if (option == "proxy-auth") {
        setProxyAuth(value.toString());
    }

    if (option == "script-encoding") {
        setScriptEncoding(value.toString());
    }

    if (option == "web-security") {
        setWebSecurityEnabled(boolValue);
    }
}
Example #27
0
bool FGTrim::DoTrim(void) {
  bool trim_failed=false;
  unsigned int N = 0;
  unsigned int axis_count = 0;
  FGFCS *FCS = fdmex->GetFCS();
  vector<double> throttle0 = FCS->GetThrottleCmd();
  double elevator0 = FCS->GetDeCmd();
  double aileron0 = FCS->GetDaCmd();
  double rudder0 = FCS->GetDrCmd();
  double PitchTrim0 = FCS->GetPitchTrimCmd();
  fgic = *fdmex->GetIC();

  for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
    fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
  }

  fdmex->SetTrimStatus(true);
  fdmex->SuspendIntegration();

  fgic.SetPRadpsIC(0.0);
  fgic.SetQRadpsIC(0.0);
  fgic.SetRRadpsIC(0.0);

  if (mode == tGround) {
    trimOnGround();
    double theta = fgic.GetThetaRadIC();
    double phi = fgic.GetPhiRadIC();
    // Take opportunity of the first approx. found by trimOnGround() to
    // refine the control limits.
    TrimAxes[0].SetControlLimits(0., fgic.GetAltitudeAGLFtIC());
    TrimAxes[1].SetControlLimits(theta - 5.0 * degtorad, theta + 5.0 * degtorad);
    TrimAxes[2].SetControlLimits(phi - 30.0 * degtorad, phi + 30.0 * degtorad);
  }

  //clear the sub iterations counts & zero out the controls
  for(unsigned int current_axis=0;current_axis<TrimAxes.size();current_axis++) {
    //cout << current_axis << "  " << TrimAxes[current_axis]->GetStateName()
    //<< "  " << TrimAxes[current_axis]->GetControlName()<< endl;
    xlo=TrimAxes[current_axis].GetControlMin();
    xhi=TrimAxes[current_axis].GetControlMax();
    TrimAxes[current_axis].SetControl((xlo+xhi)/2);
    TrimAxes[current_axis].Run();
    //TrimAxes[current_axis].AxisReport();
    sub_iterations[current_axis]=0;
    successful[current_axis]=0;
    solution[current_axis]=false;
  }

  if(mode == tPullup ) {
    cout << "Setting pitch rate and nlf... " << endl;
    setupPullup();
    cout << "pitch rate done ... " << endl;
    TrimAxes[0].SetStateTarget(targetNlf);
    cout << "nlf done" << endl;
  } else if (mode == tTurn) {
    setupTurn();
    //TrimAxes[0].SetStateTarget(targetNlf);
  }

  do {
    axis_count=0;
    for(unsigned int current_axis=0;current_axis<TrimAxes.size();current_axis++) {
      setDebug(TrimAxes[current_axis]);
      updateRates();
      Nsub=0;
      if(!solution[current_axis]) {
        if(checkLimits(TrimAxes[current_axis])) {
          solution[current_axis]=true;
          solve(TrimAxes[current_axis]);
        }
      } else if(findInterval(TrimAxes[current_axis])) {
        solve(TrimAxes[current_axis]);
      } else {
        solution[current_axis]=false;
      }
      sub_iterations[current_axis]+=Nsub;
    }
    for(unsigned int current_axis=0;current_axis<TrimAxes.size();current_axis++) {
      //these checks need to be done after all the axes have run
      if(Debug > 0) TrimAxes[current_axis].AxisReport();
      if(TrimAxes[current_axis].InTolerance()) {
        axis_count++;
        successful[current_axis]++;
      }
    }

    if((axis_count == TrimAxes.size()-1) && (TrimAxes.size() > 1)) {
      //cout << TrimAxes.size()-1 << " out of " << TrimAxes.size() << "!" << endl;
      //At this point we can check the input limits of the failed axis
      //and declare the trim failed if there is no sign change. If there
      //is, keep going until success or max iteration count

      //Oh, well: two out of three ain't bad
      for(unsigned int current_axis=0;current_axis<TrimAxes.size();current_axis++) {
        //these checks need to be done after all the axes have run
        if(!TrimAxes[current_axis].InTolerance()) {
          if(!checkLimits(TrimAxes[current_axis])) {
            // special case this for now -- if other cases arise proper
            // support can be added to FGTrimAxis
            if( (gamma_fallback) &&
                (TrimAxes[current_axis].GetStateType() == tUdot) &&
                (TrimAxes[current_axis].GetControlType() == tThrottle)) {
              cout << "  Can't trim udot with throttle, trying flight"
              << " path angle. (" << N << ")" << endl;
              if(TrimAxes[current_axis].GetState() > 0)
                TrimAxes[current_axis].SetControlToMin();
              else
                TrimAxes[current_axis].SetControlToMax();
              TrimAxes[current_axis].Run();
              TrimAxes[current_axis]=FGTrimAxis(fdmex,&fgic,tUdot,tGamma);
            } else {
              cout << "  Sorry, " << TrimAxes[current_axis].GetStateName()
              << " doesn't appear to be trimmable" << endl;
              //total_its=k;
              trim_failed=true; //force the trim to fail
            } //gamma_fallback
          }
        } //solution check
      } //for loop
    } //all-but-one check
    N++;
    if(N > max_iterations)
      trim_failed=true;
  } while((axis_count < TrimAxes.size()) && (!trim_failed));

  if((!trim_failed) && (axis_count >= TrimAxes.size())) {
    total_its=N;
    if (debug_lvl > 0)
        cout << endl << "  Trim successful" << endl;
  } else { // The trim has failed
    total_its=N;

    // Restore the aircraft parameters to their initial values
    fgic = *fdmex->GetIC();
    FCS->SetDeCmd(elevator0);
    FCS->SetDaCmd(aileron0);
    FCS->SetDrCmd(rudder0);
    FCS->SetPitchTrimCmd(PitchTrim0);
    for (unsigned int i=0; i < throttle0.size(); i++)
      FCS->SetThrottleCmd(i, throttle0[i]);

    fdmex->Initialize(&fgic);
    fdmex->Run();

    // If WOW is true we must make sure there are no gears into the ground.
    if (fdmex->GetGroundReactions()->GetWOW())
      trimOnGround();

    if (debug_lvl > 0)
        cout << endl << "  Trim failed" << endl;
  }

  fdmex->ResumeIntegration();
  fdmex->SetTrimStatus(false);

  for(int i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
    fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
  }

  return !trim_failed;
}
Example #28
0
/*!
** @brief Xsocket implemention of the standard setsockopt function.
**
** Xsetsockopt is used to set options on the underlying Xsocket in
** the Click layer. It does not affect the actual socket passed in which
** used by the API to communicate with Click.
**
** Supported Options:
**	\n XOPT_HLIM	Sets the 'hop limit' (hlim) element of the XIA header to the
**		specified integer value. (Default is 250)
**	\n XOPT_NEXT_PROTO Sets the next proto field in the XIA header
**
** @param sockfd	The control socket
** @param optname	The socket option to set
** @param optval	A pointer to the value to set
** @param optlen	The length of the option being set
**
** @returns 0 on success
** @returns -1 on error with errno set
** @returns errno values:
** @returns EBADF: The socket descriptor is invalid
** @returns EINVAL: Either optval is null, or optlen is invalid, or optval is out of range
** @returns ENOPROTOOPT: the specified optname is not recognized
*/
int Xsetsockopt(int sockfd, int optname, const void *optval, socklen_t optlen)
{
	int rc = 0;

	/* TODO: we may need to check the type of the socket at some point, but for now
	** treat them all the same as far as options go.
	*/
	if (getSocketType(sockfd) == XSOCK_INVALID) {
		errno = EBADF;
		return -1;
	}

	if (!optval) {
		errno = EINVAL;
		return -1;
	}
	switch (optname) {

		// send these values to click *******************************

		case XOPT_HLIM:
		{
			int hlim = *(const int *)optval;

			if (hlim < 0 || hlim > 255) {
				LOGF("HLIM (%d) out of range", hlim);
				errno = EINVAL;
				rc = -1;
			} else {
				rc = ssoPutInt(sockfd, optname, (const int *)optval, optlen);
			}
			break;
		}

		case XOPT_NEXT_PROTO:
		{
			int next = *(const int *)optval;

			if (next != XPROTO_XCMP) {
				LOGF("Invalid next protocol specified (%d)", next);
				errno = EINVAL;
				rc = -1;
			} else {
				rc = ssoPutInt(sockfd, optname, (const int *)optval, optlen);
			}
			break;
		}

		case XOPT_BLOCK:
		{
			rc = ssoPutInt(sockfd, optname, (const int *)optval, optlen);
			break;
		}

		// this is handled in the API & in click ********************

		case SO_DEBUG:
			if (ssoCheckSize(&optlen, sizeof(int)) < 0) {
				rc = -1;
			}
			else {
				setDebug(sockfd, *(int *)optval);
				rc = ssoPutInt(sockfd, optname, (const int *)optval, optlen);
			}
			break;


		// SHOIULD IMPLEMENT! ***************************************
		// FIXME: implement these!
		case SO_SNDBUF:
		case SO_RCVBUF:
		case SO_SNDTIMEO:
		case SO_RCVTIMEO:
		case SO_LINGER:
		case SO_REUSEADDR:
			LOGF("Uh Oh, we need support for %s in XIA\n", optValue(optname));
			rc = 0;
			break;

		// FIXME: MAY NEED ******************************************

		case SO_BROADCAST:
			// FIXME: can we just go ahead and mark this as success?
			// or do we need to do something to check to see if bradcast DAGS are allowed on this socket?
			if (getSocketType(sockfd) == SOCK_DGRAM) {
				rc = -1;
				errno = ENOPROTOOPT;
				break;
			}
			// else silently ignore
			break;

		case SO_RCVLOWAT:
		case SO_SNDLOWAT:
			// Probably will never need to support this
			// return the default linux value of 1
			rc = 0;
			break;


		// CAN SAFELY IGNORE ****************************************

		case SO_KEEPALIVE:
			// we don't have keepalive so lie and say we did it
			rc = 0;
			break;

		case SO_BSDCOMPAT:
			// safe to mark as unsupported, being phased out on linux anyway
			errno = ENOPROTOOPT;
			rc = -1;
			break;

		// READ ONLY OPTIONS ****************************************
		case SO_ACCEPTCONN:
		case SO_DOMAIN:
		case SO_PROTOCOL:
		case SO_TYPE:
			LOGF("Option %s is read only\n", optValue(optname));
			errno = ENOPROTOOPT;
			rc = -1;
			break;

		// NOT SUPPORTED/DOESN"T MAKE SENSE IN XIA ******************
		case SO_BINDTODEVICE:	// should we support this one when we get multihoming?
		case SO_DONTROUTE:
		case SO_MARK:
		case SO_OOBINLINE:
		case SO_PASSCRED:
		case SO_PEERCRED:
		case SO_PRIORITY:
		case SO_RCVBUFFORCE:
		case SO_SNDBUFFORCE:
		case SO_TIMESTAMP:
		default:
			// return generic error
			LOGF("Option %s not supported in XIA\n", optValue(optname));
			errno = ENOPROTOOPT;
			rc = -1;
	}

	return rc;
}
Example #29
0
void Config::handleOption(const QString &option, const QVariant &value)
{
    bool boolValue = false;

    QStringList booleanFlags;
    booleanFlags << "debug";
    booleanFlags << "disk-cache";
    booleanFlags << "ignore-ssl-errors";
    booleanFlags << "load-images";
    booleanFlags << "local-to-remote-url-access";
    booleanFlags << "remote-debugger-autorun";
    booleanFlags << "web-security";
    if (booleanFlags.contains(option)) {
        if ((value != "true") && (value != "yes") && (value != "false") && (value != "no")) {
            setUnknownOption(QString("Invalid values for '%1' option.").arg(option));
            return;
        }
        boolValue = (value == "true") || (value == "yes");
    }

    if (option == "cookies-file") {
        setCookiesFile(value.toString());
    }

    if (option == "config") {
        loadJsonFile(value.toString());
    }

    if (option == "debug") {
        setPrintDebugMessages(boolValue);
    }

    if (option == "disk-cache") {
        setDiskCacheEnabled(boolValue);
    }

    if (option == "ignore-ssl-errors") {
        setIgnoreSslErrors(boolValue);
    }

    if (option == "load-images") {
        setAutoLoadImages(boolValue);
    }

    if (option == "local-storage-path") {
        setOfflineStoragePath(value.toString());
    }

    if (option == "local-storage-quota") {
        setOfflineStorageDefaultQuota(value.toInt());
    }

    if (option == "local-to-remote-url-access") {
        setLocalToRemoteUrlAccessEnabled(boolValue);
    }

    if (option == "max-disk-cache-size") {
        setMaxDiskCacheSize(value.toInt());
    }

    if (option == "output-encoding") {
        setOutputEncoding(value.toString());
    }

    if (option == "remote-debugger-autorun") {
        setRemoteDebugAutorun(boolValue);
    }

    if (option == "remote-debugger-port") {
        setDebug(true);
        setRemoteDebugPort(value.toInt());
    }

    if (option == "proxy") {
        setProxy(value.toString());
    }

    if (option == "proxy-type") {
        setProxyType(value.toString());
    }

    if (option == "proxy-auth") {
        setProxyAuth(value.toString());
    }

    if (option == "script-encoding") {
        setScriptEncoding(value.toString());
    }

    if (option == "script-language") {
        setScriptLanguage(value.toString());
    }

    if (option == "web-security") {
        setWebSecurityEnabled(boolValue);
    }
    if (option == "ssl-protocol") {
        setSslProtocol(value.toString());
    }
    if (option == "ssl-certificates-path") {
        setSslCertificatesPath(value.toString());
    }
    if (option == "webdriver") {
        setWebdriver(value.toString().length() > 0 ? value.toString() : DEFAULT_WEBDRIVER_CONFIG);
    }
    if (option == "webdriver-logfile") {
        setWebdriverLogFile(value.toString());
    }
    if (option == "webdriver-loglevel") {
        setWebdriverLogLevel(value.toString());
    }
    if (option == "webdriver-selenium-grid-hub") {
        setWebdriverSeleniumGridHub(value.toString());
    }
}
Example #30
0
int main(int argc, char* argv[]) {
    if (!setupGLFW()) return 1;
    glfwWindowHint(GLFW_SAMPLES, 4);
    setupCoreGL();

    #ifndef __APPLE__
    const char* exePath = dirname(argv[0]);
    const char* resPath = "/Resources/";
    const int newPathLen = strlen(exePath) + strlen(resPath) + 1;
    char newPath[newPathLen];
    strcpy(newPath, exePath);
    strcat(newPath, resPath);

    int cwdError;
    if ((cwdError = chdir(newPath)) != 0) {
        perror(newPath);

        return 1;
    }
    #endif

    set_log_file(fopen("../Logs/uf.log", "a"));
    
    setDebug(DEBUG);
    setBind(DEBUG);
 
    #ifdef FULLSCREEN
    GLFWmonitor* monitor = glfwGetPrimaryMonitor();
    const GLFWvidmode* vidmode = glfwGetVideoMode(monitor);
    int width = vidmode->width;
    int height = vidmode->height;
    const char* title =  "Ultra Fighters";
    GLFWwindow* window = glfwCreateWindow(width, height, title, monitor, NULL);
    #else
    int width = 640;
    int height = 480;
    const char* title =  "Ultra Fighters";
    GLFWwindow* window = glfwCreateWindow(width, height, title, NULL, NULL);
    #endif

    if (!window) {
        log_msg(LOG_ERROR, "GLFW3 window creation failed.\n");
        
        return 1;
    }
    
    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

    char cwd[PATH_MAX];
    getcwd(cwd, sizeof(cwd));

    log_msg(LOG_INFO, "#####################################\n");
    log_msg(LOG_INFO, "Started Ultra Fighters!\n");
    log_msg(LOG_INFO, "Current Working Directory: %s\n", cwd);
    log_msg(LOG_INFO, "Started loop!\n");
    
    GameScene scene(window);

    std::ifstream levelFile("levelname.txt");
    std::string levelName;
    std::getline(levelFile, levelName);
    WavefrontObject room(levelName.c_str());
    scene.addChild(&room);

    HUD hud;
    scene.addChild(&hud);

    SphereNode snode(glm::vec3(-2, 2, 4), 0.75); // @temp
    scene.addChild(&snode); // @temp

    Loop loop = Loop(&scene);
    loop.start();
    
    while (!glfwGetKey(window, GLFW_KEY_ESCAPE) && !glfwWindowShouldClose(window)) {
        glfwPollEvents();
    }
    
    log_msg(LOG_INFO, "Stopping program...\n");
    loop.stop();
    glfwTerminate();
    
    return 0;
}