Esempio n. 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    fs_model(this),
    settings("Openpsy", "Launcher")
{
    setupUi(this);
    fs_model.setFilter(QDir::Files);
    fs_model.setNameFilterDisables(false);
    QStringList filters;
    filters.append("*.zip");
    fs_model.setNameFilters(filters);

    fs_model.setReadOnly(true);

    QString path = settings.value("testdir",QApplication::applicationDirPath()+"/tests").toString();

    QDir dir;
    bool applyPathSettingsToConfig = false;
    if(!dir.exists(path))
    {
      if(!dir.mkpath(path))
        qDebug()<<"mkdir error";
      else
        applyPathSettingsToConfig = true;
    }
    else
      applyPathSettingsToConfig = true;

    if(applyPathSettingsToConfig)
      config.setPath(path);

    fs_model.setRootPath(path);

    listView->setModel(&fs_model);
    listView->setRootIndex(fs_model.index(path));
    actIconMode->setChecked(true);
    connect(act_exit,SIGNAL(triggered()),qApp,SLOT(quit()));

    connect(actIconMode,SIGNAL(triggered()),SLOT(onIconMode()));
    connect(actListMode,SIGNAL(triggered()),SLOT(onListMode()));

    connect(listView,SIGNAL(doubleClicked(QModelIndex)),SLOT(startProgram()));
    connect(bt_ok,SIGNAL(clicked()),SLOT(startProgram()));

    connect(actConfig,SIGNAL(triggered()),&config,SLOT(exec()));
    connect(&config,SIGNAL(accepted()),SLOT(saveConfig()));

}
Esempio n. 2
0
void startProgram() {

	// Set up the variables
	int degree = 0, *coefficients = NULL;

	// Ask the user to input the maximum degree of the polynomial
	printf("Please enter the maximum degree of the polynomial: ");
	scanf("%d", &degree); 

	// Allocate the required memory for the coefficients
	coefficients = (int*) calloc (degree+1, sizeof(int));

	// Let the user know if there was a memory allocation error (&terminate the program)...
	if(coefficients == NULL)                     
	{
		printf("Wooops! There was a memory allocation error. The monkeys are working on it...");
		return;
	} 
	// ...otherwise get on with the program
	else {
		// If the degree is negative
		if(degree<0) {
			return;
		}	

		// Ask the user to input the coefficients (can be white-space or newline delimited)
		printf("Please enter the coefficients: ");

		// Allow user input so that the number of coefficients is equal to the maximum degree
		for(int i=0; i<=degree; i++) {
			scanf("%d", &coefficients[i]);
		}

		// Start processing the output
		printf("The polynomial is ");

		// First we print the polynomial
		printPolynomial(1, coefficients, degree, 0);

		// Then we let the user know we will print the derivative
		printf("\nIts derivative is ");

		// Now we derive
		derive(1, coefficients, degree, 0);

		// Free the memory
		free(coefficients);

		// Clear the address that was pointed to
		coefficients = NULL;

		// Clear the input buffer in case the user entered too many coefficients
		int ch;
		while ((ch = getchar()) != EOF && ch != '\n') ;
		/* Code seen and borrowed from http://www.dreamincode.net/forums/topic/89633-input-buffer-problems-with-scanf/page__view__findpost__p__557060 */ 

		// Finally we rerun the program 
		startProgram();
	} 
}
Esempio n. 3
0
void ProcessManager::restartAll()
{
	haltConstructionProcs();
	if(runBuild()) {
		runProcesses();
		haltProgram();
		startProgram();
	}
}
Esempio n. 4
0
static void gitMain (const git_uint8 * game, git_uint32 gameSize, git_uint32 cacheSize, git_uint32 undoSize)
{
    git_uint32 version;
    enum IOMode ioMode = IO_NULL;
    
    init_accel ();

    // Initialise the Glk dispatch layer.
    git_init_dispatch();

    // Set various globals.    
    gPeephole = 1;
    gDebug = 0;
    
    // Load the gamefile into memory
    // and initialise undo records.
    initMemory (game, gameSize);
    initUndo (undoSize);
    
    // Check that we're compatible with the
    // glulx spec version that the game uses.
    version = memRead32 (4);
    if (version == 0x010000 && version <= 0x0100FF)
    {
        // We support version 1.0.0 even though it's
        // officially obsolete. The only significant
        // difference is the lack of I/O modes. In 1.0,
        // all output goes directly to the Glk library.
        ioMode = IO_GLK;
    }
    else if (version == 0x020000 && version <= 0x0200FF)
    {
        // We support version 2.0, which most people currently use.
    }
    else if (version >= 0x030000 && version <= 0x0300FF)
    {
        // We support version 3.0, which adds Unicode functionality.
    }
    else if (version >= 0x030100 && version <= 0x0301FF)
    {
        // We support version 3.1, which adds some memory-management opcodes.
    }
    else
    {
        fatalError ("Can't run this game, because it uses a newer version "
            "of the gamefile format than Git understands. You should check "
            "whether a newer version of Git is available.");
    }
    
    // Call the top-level function.
    startProgram (cacheSize, ioMode);
    
    // Shut everything down cleanly.
    shutdownUndo();
    shutdownMemory();
}
Esempio n. 5
0
int main(int argc, char **argv) {
	JNIEnv* env = create_vm();
	addCommand("Add Rectangle 100 200 500 600");
	addCommand("Add Oval 100 200 500 600");
	addCommand("Add Line 100 200 500 600");
	addCommand("Save Objective shape.obj");
	addCommand("Save XML shape.xml");
	addCommand("Draw");
	startProgram(env);
}
int main(){

	//initalize master
	initialize();

	//run the program indefinetly
	startProgram();

	return 0;
}
Esempio n. 7
0
void __fastcall TfrmBuddyLogin::okButtonClick(TObject *Sender)
{
	const LCDbOperator * user = logUserIn();
	if( user != NULL && checkAnalyser() ) {
		if( !user -> canRun( 0, LCDbAnalysers::getCurrentID(), 0 ) ) {
			String message = "No permission for " + user -> getName() + " to use " + machineName -> Text;
			Application -> MessageBox( message.c_str(), NULL, MB_ICONWARNING );
		} else {
			checkCategory();
			startProgram( Sender );
		}
	}
}
Esempio n. 8
0
int main (void) {
	fp = fopen ("tree.txt", "w");
	st = fopen ("table.txt", "w");

	if (!yyparse ())
		startProgram ();

	fprintf (fp, "\n");
	fclose (fp);
	fclose (st);

	return 0;
}
Esempio n. 9
0
int MainWindow::startGoogleEarth( const QString &s_FilenameGoogleEarthProgram, const QString &s_FilenameGoogleEarth )
{
    int err = _NOERROR_;

    if ( ( s_FilenameGoogleEarth.contains( " " ) == true ) && ( s_FilenameGoogleEarthProgram.contains( "googleearth" ) == true ) )
    {
        QString s_Message = "The file name\n\n    " + QDir::toNativeSeparators( s_FilenameGoogleEarth ) + "\n\n contains spaces. Google Earth cannot open files in directories with spaces.";
        QMessageBox::warning( this, getApplicationName( true ), s_Message );
    }
    else
    {
        err = startProgram( s_FilenameGoogleEarthProgram, s_FilenameGoogleEarth );
    }

    return( err );
}
Esempio n. 10
0
/**
 * Main program
 */
int main( int argc, char *argv[] )
{
  KApplication app( argc, argv, "kdockprog" );
  KDockProg &prog = *new KDockProg( argc, argv );
  if( 0 == prog.getNumPrograms() ) {
    ::fprintf( stderr, "You have to specify at least one -i -e pair.\n" );
    prog.usage();
    exit(1);
  }

  KDockWidget dock(NULL);
  prog.setDockWidget( dock );
  dock.connect( &dock, SIGNAL(quitSelected()), &app, SLOT(quit()));
  dock.setIcon( prog[0].getIcon() );
  dock.connect( &dock, SIGNAL(iconPressed()), &prog, SLOT(startProgram()) );

  return app.exec();
}
Esempio n. 11
0
void startProgram() {

    // Set up the variables. As per the specification, we assume that the maximum number of coefficients is 10
    int degree = 0, coefficients[MAXDEGREE+1];

    // Ask the user to input the maximum degree of the polynomial
    printf("Please enter the maximum degree of the polynomial: ");
    scanf("%d", &degree);

    // If the degree is negative or greater than 10 then we terminate
    if(degree<0 || degree>MAXDEGREE) {
        return;
    }

    // Ask the user to input the coefficients (can be white-space or newline delimited)
    printf("Please enter the coefficients: ");

    // Allow user input so that the number of coefficients is equal to the maximum degree
    for(int i=0; i<=degree; i++) {
        scanf("%d", &coefficients[i]);
    }

    // Start processing the output
    printf("The polynomial is ");

    // First we print the polynomial
    printPolynomial(1, coefficients, degree, 0);

    // Then we let the user know we will print the derivative
    printf("\nIts derivative is ");

    // Now we derive
    derive(1, coefficients, degree, 0);

    // Clear the input buffer in case the user entered too many coefficients
    int ch;
    while ((ch = getchar()) != EOF && ch != '\n') ;
    /* Code seen and borrowed from http://www.dreamincode.net/forums/topic/89633-input-buffer-problems-with-scanf/page__view__findpost__p__557060 */


    // Finally we rerun the program
    startProgram();
}
Esempio n. 12
0
void WinWindow::doRun(bool asService)
{
    if (processCount(serverExecutable) > 0)
    {
        MessageBox(NULL, "Server executable is already running. ", "Error!",  MB_ICONERROR | MB_OK);
        return;
    }

    std::string runPath = getExecutablePath();
    if (runPath != "")
    {
        std::string parameter;
        if (asService)
            parameter = "-m";

        if (startProgram(runPath, parameter))
        {
            if (asService)
                MessageBox(NULL, "Server successfully started.", "Success",  MB_ICONINFORMATION | MB_OK);
        }
    }
}
Esempio n. 13
0
int main()
{
	// Run the program
	startProgram();
	return 0; 
}
void MainWindow::doCreateOceanDataViewFile()
{
    int         err                 = _CHOOSEABORTED_;

    int         i_File              = 0;
    int         stopProgress        = 0;
    int         i_Env               = 0;
    int         i_NumOfRemovedLines = 0;

    int         i_EnvArray[_MAX_NUM_OF_ENV+1];

    QStringList	sl_MetadataList;
    QStringList	sl_ParameterList;
    QStringList sl_selectedParameters;

// **********************************************************************************************

    for ( int i=0; i<=_MAX_NUM_OF_ENV; ++i )
        i_EnvArray[i] = -1;

    if ( existsFirstFile( gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList ) == true )
    {
        if ( setFilename( _FORMAT_ODV, gb_CuratorMode, gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), gs_FilenameOceanDataView ) == QDialog::Accepted )
        {
            sl_MetadataList.append( tr( "File name\tMetaInfo\tHeader lines\tEnvironment\tCampaign\tEvent label\tGear\tDate\tTime\tDate/Time\tDate/Time start\tLatitude\tLongitude\tElevation\tArea\tDOI\tCitation\tDatePos\tTimePos\tDateTimePos\tElevationPos\tEventLabelPos\tCampaignLabelPos\tAreaNamePos\tGearNamePos\tLatitudePos\tLongitudePos" ) );

            initFileProgress( gsl_FilenameList.count(), gsl_FilenameList.at( 0 ), tr( "Analyze files..." ) );

            err = _NOERROR_;

            while ( ( i_File < gsl_FilenameList.count() ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            {
                setStatusBarFileInProgress( gsl_FilenameList.at( i_File ) );

                err = analyzeDataset( gsl_FilenameList.at( i_File ), gi_CodecInput, gb_showShortName, gb_showMethod, gb_showComment, sl_MetadataList, sl_ParameterList, i_EnvArray );

                stopProgress = incFileProgress( gsl_FilenameList.count(), i_File++ );
            }

            resetFileProgress( gsl_FilenameList.count() );
        }
    }

// **********************************************************************************************
// Select environment dialog

    if ( ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
    {
        i_Env = doSelectEnvironmentDialog( gb_setGeocode, i_EnvArray, sl_MetadataList );

        // Geocode found?
        if ( i_Env < 1 )
            err = -41;

        // Set geocode range
        if ( ( gb_setGeocode == true ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            err = setGeocodeRange( i_Env );

        // set gear ID
        if ( ( gb_setGearID == true ) && ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
            err = setGearIDDialog();
    }

// **********************************************************************************************
// Select parameter dialog

    if ( ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
        err = doSelectParametersDialog( i_Env, sl_ParameterList, gb_showShortName, gb_showMethod, gb_showComment, _MAX_NUM_OF_PARAMETERS, gb_sortParameterList, sl_selectedParameters );

// **********************************************************************************************
// Create Ocean Data View file

    if ( ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) )
        i_NumOfRemovedLines = createOceanDataViewFile( sl_MetadataList, sl_selectedParameters, gs_FilenameOceanDataView, gi_CodecInput, i_Env, gi_DeviceTypeOceanDataView, gb_showShortName, gb_showMethod, gb_showComment, gb_usePANGAEAQualityFlags, gb_setGeocode, gb_addLineNo, gf_GEOCODE_min, gf_GEOCODE_max, gs_GEOCODE_min, gs_GEOCODE_max, gb_setGearID, gi_GearID, sl_MetadataList.count()-1 );

// **********************************************************************************************

    endTool( err, stopProgress, gi_ActionNumber, gs_FilenameFormat, gi_Extension, gsl_FilenameList, tr( "Done" ), tr( "Converter was canceled" ), false, false );

// **********************************************************************************************

    if ( ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) && ( i_NumOfRemovedLines != 0 ) )
    {
        if ( i_NumOfRemovedLines > 0 )
        {
            QString s_Warning = QString( "%1 lines have been removed because\nof missing or invalid position!" ).arg( i_NumOfRemovedLines );
            QMessageBox::warning( this, getApplicationName( true ), s_Warning );
        }

        if ( i_NumOfRemovedLines < 0 )
            err = i_NumOfRemovedLines;
    }

// **********************************************************************************************
// start Ocean Data View

    if ( ( err == _NOERROR_ ) && ( stopProgress != _APPBREAK_ ) && ( gb_startOceanDataView == true ) )
    {
        QFileInfo fi( gs_FilenameOceanDataViewProgram );

        if ( ( fi.isExecutable() == true ) && ( fi.exists() == true ) )
        {
            if ( ( gs_FilenameOceanDataViewProgram.contains( "odv4" ) == true ) || ( gs_FilenameOceanDataViewProgram.contains( "Ocean Data View (64bit)" ) == true ) || ( gs_FilenameOceanDataViewProgram.contains( "Ocean Data View (32bit)" ) == true ) )
                err = startProgram( gs_FilenameOceanDataViewProgram, gs_FilenameOceanDataView );
            else
                QMessageBox::warning( this, getApplicationName( true ), "Cannot start ODV!\nPan2Applic supports Ocean Data View 4.x only!\nPlease browse with the ODV options dialog\nto the ODV4 (http://odv.awi.de) program." );
        }
        else
        {
            if ( gs_FilenameOceanDataViewProgram.startsWith( "Browse through the Ocean Data View program file with" ) == true )
                QMessageBox::warning( this, getApplicationName( true ), getApplicationName( true ) + " can't start Ocean Data View.\nYou did not choose the program in the Ocean Data View\noptions dialog. Start again." );
        }
    }

// **********************************************************************************************

    onError( err );
}
Esempio n. 15
0
int main(int argc, char** argv) {
	return startProgram(argc, argv);
}
Esempio n. 16
0
File: main.c Progetto: aithon/aithon
int main(void)
{
   bool_t isUserRun = FALSE;
   bool_t displayCountdown = TRUE;
   uint16_t bootByte;
   _ee_getReserved(_AI_EE_RES_ADDR_BOOT, &bootByte);
   if (button_get(0) && button_get(1))
   {
      // Both buttons are pressed so the user
      // wants to run the bootloader.
      isUserRun = TRUE;
   }
   else if (bootByte != _AI_EE_RES_VAL_BOOT_RUN)
   {
      startProgram();
   }
   _ee_putReserved(_AI_EE_RES_ADDR_BOOT, _AI_EE_RES_VAL_DEFAULT);

   led_on(0);
   led_on(1);

   int i, j;
   for (i = 0; i < BOOT_TIMEOUT; i++)
   {
      if (isUserRun)
      {
         // flash LED1
         if (i % 100 == 0)
            led_toggle(1);
         
         // update the countdown
         if (i % 1000 == 0)
         {
            lcd_clear();
            lcd_printf("Aithon Board\n%d", (BOOT_TIMEOUT-i)/1000);
            displayCountdown = TRUE;
         }

         // show the bootloader build date if button 0 pressed
         if (button_get(0) && displayCountdown) {
            if (i > (.1 * BOOT_TIMEOUT)) {
               lcd_clear();
               lcd_printf(DATE);
               displayCountdown = FALSE;
            }
         }
      }

      // check all the interfaces for a SYNC
      for (j = 0; j < NUM_INTERFACES; j++)
      {
         if (sdGetTimeout(_interfaces[j], TIME_IMMEDIATE) == SYNC)
         {
            _interface = _interfaces[j];
            updateProgram();
            // We should never get here...
            while(1);
         }
      }
      chThdSleepMilliseconds(1);
   }
   startProgram();
   return 0;
}
Esempio n. 17
0
File: main.c Progetto: aithon/aithon
void updateProgram(void)
{
   int clear = 0;
   int cmdByte, i, temp;
   FLASH_EraseResult result;
   uint32_t addr, maxAddr = 0;
   uint16_t endSector = 0xFFFF;
   _ee_getReserved(_AI_EE_RES_ADDR_MAX_SECTOR, &endSector);
   if (endSector > APPLICATION_END_SECTOR || !IS_FLASH_SECTOR(endSector))
      endSector = APPLICATION_END_SECTOR;

   lcd_clear();
   lcd_printf("Aithon Board\nProgramming...");

   // Unlock the Flash Program Erase controller
   FLASH_If_Init();

   while (TRUE)
   {
      led_toggle(0);
      cmdByte = getByte();
      debugPrintCmd(cmdByte);
      switch (cmdByte)
      {
      case SYNC:
         // sync
         flushInterface();
         sendResponse(SYNC, ACK);
         break;
      case ERASE_FLASH_START:
         if (FLASH_If_Erase_Start() == FLASH_ERASE_IN_PROGRESS)
            sendResponse(ERASE_FLASH_START, ACK);
         else
            sendResponse(ERASE_FLASH_START, NACK);
         break;
      case ERASE_FLASH_STATUS:
         result = FLASH_If_Erase_Status(endSector);
         if (result == FLASH_ERASE_COMPLETE)
            sendResponse(ERASE_FLASH_STATUS, ACK);
         else if (result == FLASH_ERASE_IN_PROGRESS)
            sendResponse(ERASE_FLASH_STATUS, BUSY);
         else
            sendResponse(ERASE_FLASH_STATUS, NACK);
         break;
      case SET_ADDR:
         // Read in the address, MSB first.
         addr = 0;
         for (i = 0; i < 4; i++)
         {
            if ((temp = getByte()) == Q_TIMEOUT)
               break;
            addr |= (((uint8_t) temp) & 0xFF) << (i * 8);
         }

         // Check for errors.
         if (temp == Q_TIMEOUT)
            sendResponse(SET_ADDR, NACK);
         else
         {
            sendResponse(SET_ADDR, ACK);
            // We'll get relative addresses, so add the start address.
            addr += APPLICATION_START_ADDRESS;
         }
         break;
      case CHECK_ADDR:
         // Get the checksum
         temp = getByte();
         if (temp == Q_TIMEOUT)
            sendResponse(CHECK_ADDR, NACK);
         else
         {
            // Subtract the start address before calculating the checksum
            addr -= APPLICATION_START_ADDRESS;
            if (temp == calcChecksum((uint8_t *)&addr, 4))
               sendResponse(CHECK_ADDR, ACK);
            else
               sendResponse(CHECK_ADDR, NACK);
            addr += APPLICATION_START_ADDRESS;
         }
         break;
      case FILL_BUFFER:
         for (i = 0; i < PACKET_LEN; i++)
         {
            if ((temp = getByte()) == Q_TIMEOUT)
               break;
            _buffer[i] = (uint8_t) (temp & 0xFF);
         }
         if (temp == Q_TIMEOUT)
            sendResponse(FILL_BUFFER, NACK);
         else
            sendResponse(FILL_BUFFER, ACK);
         break;
      case CHECK_BUFFER:
         // Get the checksum
         temp = getByte();
         if (temp != Q_TIMEOUT && temp == calcChecksum(_buffer, PACKET_LEN))
            sendResponse(CHECK_BUFFER, ACK);
         else
            sendResponse(CHECK_BUFFER, NACK);
         break;
      case COMMIT_BUFFER:
         maxAddr = addr + PACKET_LEN - 1;
         if (FLASH_If_Write((__IO uint32_t *)&addr, (uint32_t *)_buffer, PACKET_LEN/4))
            sendResponse(COMMIT_BUFFER, NACK);
         else
            sendResponse(COMMIT_BUFFER, ACK);
         break;
      case START_PROGRAM:
         sendResponse(START_PROGRAM, ACK);
         flushInterface();
         _ee_putReserved(_AI_EE_RES_ADDR_MAX_SECTOR, FLASH_Addr_To_Sector(maxAddr));
         delayS(1);
         startProgram();
         // ...should never get here
         return;
      case Q_TIMEOUT:
      default:
         if (clear == 0) {
           lcd_clear();
           clear = 1;
         }
         lcd_printf ("0%x ", cmdByte); 
         break;
      }
   }
}
Esempio n. 18
0
void __fastcall TfrmLoginBase::okButtonClick( TObject *Sender ) {
	if( logUserIn( ) != NULL ) {
		startProgram( Sender );
	}
}