Exemplo n.º 1
0
void menu_ask_store_settings(void) {
  lcd_clear();
  lcd_puts_P(PSTR("Save settings?\n\nyes\nno"));
  if (menu_vertical(2,3) == 2) {
    write_configuration();
  }
}
Exemplo n.º 2
0
// U1 the links
int
read_and_U1( const char *infile , 
	     const GLU_bool rtrans ,
	     const struct u1_info U1INFO ,
	     const char *outfile , 
	     const GLU_output storage , 
	     const char *output_details ) 
{
  struct head_data HEAD_DATA ;
  struct site *lat = read_file( &HEAD_DATA , infile ) ;
  int FLAG = GLU_SUCCESS ;
  
  if( lat == NULL ) return GLU_FAILURE ;

  // if we want a random transform then here is where we do it
  if( rtrans == GLU_TRUE ) { random_gtrans( lat ) ; }

  suNC_cross_u1( lat , U1INFO ) ;

  if( (Latt.argc-1) == WRITE ) {
    FLAG = write_configuration( lat , outfile , storage , output_details ) ;
  }

  free_lat( lat ) ;

  return FLAG ;
}
Exemplo n.º 3
0
// checks unitarity and can write out a configuration
int
read_and_check( const char *infile ,
		const GLU_bool rtrans , 
		const char *outfile , 
		const GLU_output storage , 
		const char *output_details )
{
  struct head_data HEAD_DATA ;
  struct site *lat = read_file( &HEAD_DATA , infile ) ;
  int FLAG = GLU_SUCCESS ;
  
  // should print out a warning
  if( lat == NULL ) return GLU_FAILURE ;

  // if we want a random transform then here is where we do it
  if( rtrans == GLU_TRUE ) { random_gtrans( lat ) ; }

  gauge( lat ) ;

  if( (Latt.argc-1) == WRITE ) {
    FLAG = write_configuration( lat , outfile , storage , output_details ) ;
  }

  free_lat( lat ) ;

  return FLAG ;
}
Exemplo n.º 4
0
void
on_apply_button_clicked                (GtkButton       *button,
                                        gpointer         user_data)
{
	write_configuration (&key_list, &current_keyboard_name);
	write_preferences (&preferences);
	system ("killall keytouchd");
	usleep (5000);
	system ("keytouchd &");
}
// Override wxDialog's default behavior for clicking an OK button.
void preferences_dialog::OnOK( wxCommandEvent& event )
{
    // Write out the values of the dialog's controls to the configuration file.
    write_configuration();
    // Get rid of the modal dialog. Not transferring any info from this modal's control
    // to a parent dialog, so don't have to bother with wxWindow::Validate or
    // wxWindow::TransferDataFromWindow. TODO: could return whether or not the list control
    // needs to be redrawn (since changed channel name or update time), or use a global.
    EndModal( wxID_OK );
}
Exemplo n.º 6
0
static void
pipeline_started (Common * c)
{
  int ret = 0;

  if (!write_configuration (c, out, dev)) {
    ret = 1;
  }

  common_quit (c, ret);
}
Exemplo n.º 7
0
int main(int argc, const char* argv[])
{
    pid_t server_child = 0;
    int fd;
    int res = 0, status;
    struct sigaction sigchildAction;

    tio_param sParam [] = {
       {"D:", "DURATION", "Duration"},
       { "m:", "PORTSPEED", "Prot speed"},
       { "s:", "SENDPACKSLENGTH", "Send pack length"},
       { "d", "SERVERMODE", "Server mode" },
       { "l", "CLIENTMODE", "Client mode" },
       { "L", "CLIENTSERVERMODE", "Client/Server mode" }, 
       {NULL, NULL, NULL}
    };

    sigchildAction.sa_handler = termination_signal;
    sigchildAction.sa_flags    = SA_NOCLDSTOP;
    sigemptyset(&(sigchildAction.sa_mask));
    sigaddset(&(sigchildAction.sa_mask),SIGTERM);

    if (sigaction(SIGTERM, &sigchildAction, NULL))
    {
        perror("Signal SIGTERM registration failed");
        return -1;
    }
    if (sigaction(SIGINT, &sigchildAction, NULL))
    {
        perror("Signal SIGINT registration failed");
        return -1;
    }

    // Инициализация tio и разбор входных параметров командной строки  
    tioInit( "alpha", "RS232 test", sParam, argc, argv); 
    
    if (write_configuration(&config))
    {
        fputs("Congiguration read error\n", stderr);
        return -1;
    }
    
    fd = open_serial_port( tio_argv[0], tioGetDefL( "PORTSPEED", 115200 ));
    if (fd < 0)
    {
        return -1;
    }
    config.outputDevice = fd;
    
    if ( tioGetL( "CLIENTSERVERMODE" ) > 0 )
    {
        server_child = fork();
    }
    if ((server_child == 0) && (tioGetL( "CLIENTSERVERMODE" ) || tioGetL( "SERVERMODE" ) ) )
    {
        if (server_process(&config))
        {
            return -1;
        }
    }
    else if ( tioGetL( "CLIENTSERVERMODE" ) || tioGetL( "CLIENTMODE" ))
        res = client_process(&config);
    else 
    {
        DEBUGMSG("Undefined target action");
        return -1;
    }

    if (server_child != 0)
        waitpid(server_child, &status, WNOHANG);

    // Завершение работы библиотеки tio  
    tioFinish(0);

    return (int)(res || status);
    /*return 0;*/
}
Exemplo n.º 8
0
// perform a heatbath
int
hb_update( struct site *lat ,
           const struct hb_info HBINFO ,
           const char *traj_name ,
           const GLU_output storage ,
           const char *output_details ,
           const GLU_bool continuation )
{
    // counters
    size_t i ;

    // seed the parallel RNG
    char str[ 256 ] ;

    // strip the number in the infile if it has one
    char *pch = strtok( (char*)traj_name , "." ) ;

    sprintf( str , "%s.%zu.rand" , pch , Latt.flow ) ;
    if( continuation == GLU_FALSE ) {
        fprintf( stdout , "[UPDATE] initialising par_rng from pool\n" ) ;
        if( initialise_par_rng( NULL ) == GLU_FAILURE ) {
            return GLU_FAILURE ;
        }
    } else {
        fprintf( stdout , "[UPDATE] restarting from a previous trajectory\n" ) ;
        if( initialise_par_rng( str ) == GLU_FAILURE ) {
            return GLU_FAILURE ;
        }
    }

    // initialise the draughtboard
    struct draughtboard db ;
    if( init_cb( &db , LVOLUME , ND ) == GLU_FAILURE ) {
        return GLU_FAILURE ;
    }

    // this guy appears throughout the HB algorithm
    const double inverse_beta = NC/(HBINFO.beta) ;

    // give us some information
    fprintf( stdout , "[UPDATE] Performing %zu HB-OR iterations\n" ,
             HBINFO.iterations ) ;
    fprintf( stdout , "[UPDATE] Themalising for %zu iterations\n" ,
             HBINFO.therm ) ;
    fprintf( stdout , "[UPDATE] %zu over-relaxations per heatbath\n" ,
             HBINFO.Nor ) ;
    fprintf( stdout , "[UPDATE] Saving every %zu iteration(s)\n" ,
             HBINFO.Nsave ) ;
    fprintf( stdout , "[UPDATE] Using beta = %1.12f \n" , HBINFO.beta ) ;

    // thermalise
    start_timer( ) ;

    for( i = 0 ; i < HBINFO.therm ; i++ ) {
        update_lattice( lat , inverse_beta , db , HBINFO.Nor ) ;
        if( !(i&15) ) {
            fprintf( stdout , "\n[UPDATE] config %zu done \n" , i ) ;
            print_time() ;
        }
    }
    print_time( ) ;

    // iterate the number of runs
    const size_t start = Latt.flow ;
    for( i = Latt.flow ; i < HBINFO.iterations ; i++ ) {

        // perform a hb-OR step
        update_lattice( lat , inverse_beta , db , HBINFO.Nor ) ;

        // set the lattice flow
        // if we are saving the data print out the plaquette and write a file
        if( i%HBINFO.Nmeasure == 0 ) {
            // write out the plaquette
            fprintf( stdout , "[UPDATE] %zu :: {P} %1.12f \n" ,
                     i , av_plaquette( lat ) ) ;
            // write the temporal polyakov loop, (re,im) |L|
            const double complex L = poly( lat , ND-1 ) / ( LCU * NC ) ;
            fprintf( stdout , "[UPDATE] {L} ( %f , %f ) %f \n" ,
                     creal( L ) , cimag( L ) , cabs( L ) ) ;
        }

        // if we hit a save point we write out the configuration
        if( i%HBINFO.Nsave == 0 && i != start ) {
            // write a configuration
            sprintf( str , "%s.%zu" , traj_name , i ) ;
            write_configuration( lat , str , storage , output_details ) ;
            // write out the rng state
            sprintf( str , "%s.rand" , str ) ;
            write_par_rng_state( str ) ;
        }
        Latt.flow = i + 1 ;
    }

    // free the draughtboard
    free_cb( &db ) ;

    // tell us how long this generation took
    print_time() ;

    // free the rng
    free_par_rng( ) ;

    return GLU_SUCCESS ;
}
Exemplo n.º 9
0
void display_service(void) {
  if (menustate == MENU_NONE) {
    /* No menu active, upload+run system menu */
    uint8_t i;

    /* Dummy read to reset the interrupt line */
    i2c_read_register(DISPLAY_I2C_ADDR, DISPLAY_MENU_GETSELECTION);

    display_menu_reset();
    i = 0;
    while (pgm_read_byte(systemmenu+i)) {
      ustrcpy_P(displaybuffer, systemmenu+i);
      display_menu_add(displaybuffer);
      i += ustrlen(displaybuffer)+1;
    }
    display_menu_show(0);
    menustate = MENU_SYSTEM;

  } else if (menustate == MENU_SYSTEM) {
    /* Selection on the system menu */
    uint8_t sel = i2c_read_register(DISPLAY_I2C_ADDR, DISPLAY_MENU_GETSELECTION);

    switch (sel) {
    case SYSMENU_CHDIR:
      menu_chdir();
      break;

    case SYSMENU_CHADDR:
      menu_chaddr();
      break;

    case SYSMENU_STORE:
      menustate = MENU_NONE;
      write_configuration();
      break;

    case SYSMENU_CANCEL:
      menustate = MENU_NONE;
      return;
    }
  } else if (menustate == MENU_CHADDR) {
    /* New address selected */
    uint8_t sel = i2c_read_register(DISPLAY_I2C_ADDR, DISPLAY_MENU_GETSELECTION);

    device_address = sel+4;
    menustate = MENU_NONE;
    display_address(device_address);
  } else if (menustate == MENU_CHDIR) {
    /* New directory selected */
    uint8_t sel = i2c_read_register(DISPLAY_I2C_ADDR, DISPLAY_MENU_GETSELECTION);
    path_t path;
    cbmdirent_t dent;

    menustate = MENU_NONE;
    if (sel == 0)
      /* Cancel */
      return;

    /* Read directory name into displaybuffer */
    path.part = current_part;
    path.dir  = partition[current_part].current_dir;

    if (sel == 1) {
      /* Previous directory */
      dent.name[0] = '_';
      dent.name[1] = 0;
    } else {
      i2c_read_registers(DISPLAY_I2C_ADDR, DISPLAY_MENU_GETENTRY, sizeof(displaybuffer), displaybuffer);

      if (first_match(&path, displaybuffer, FLAG_HIDDEN, &dent))
        return;
    }

    chdir(&path, &dent);
    update_current_dir(&path);
  }
}