static void set_geom( FL_OBJECT * obj ) { FLI_SPINNER_SPEC *sp = obj->spec; FL_Coord bwh; if ( obj->w >= obj->h ) { bwh = obj->h / 2; bwh = FL_max( bwh, 1 ); obj->h = 2 * bwh; sp->input->x = obj->x; sp->input->y = obj->y; sp->input->w = obj->w - bwh - 1; sp->input->h = obj->h; sp->up->x = sp->down->x = obj->x + obj->w - bwh - 1; sp->up->y = obj->y; sp->down->y = obj->y + bwh; sp->up->w = sp->up->h = sp->down->w = sp->down->h = bwh; if ( sp->orient == 1 ) { sp->orient = 0; fl_set_object_label( sp->up, "@8>" ); fl_set_object_label( sp->down, "@2>" ); } } else { bwh = obj->w / 2; bwh = FL_max( bwh, 1 ); obj->w = 2 * bwh; sp->input->x = obj->x; sp->input->y = obj->y; sp->input->w = obj->w; sp->input->h = obj->h - bwh - 1; sp->up->y = sp->down->y = obj->y + obj->h - bwh - 1; sp->up->x = obj->x + bwh; sp->down->x = obj->x; sp->up->w = sp->up->h = sp->down->w = sp->down->h = bwh; if ( sp->orient == 0 ) { sp->orient = 1; fl_set_object_label( sp->up, "@6>" ); fl_set_object_label( sp->down, "@4>" ); } } /* Also avoid changes of the box type and check for color changes (that must be passed on to the child input object) */ obj->boxtype = FL_NO_BOX; sp->input->col1 = obj->col1; sp->input->col2 = obj->col2; }
void uiSetInstructions(char *str1, char *str2, char *str3, char *str4) { fl_set_object_label(Instruc1, str1); fl_set_object_label(Instruc2, str2); fl_set_object_label(Instruc3, str3); fl_set_object_label(Instruc4, str4); fl_redraw_form(MainForm); }
static void ia_receiver_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { fl_set_object_label(button, "IA Receiver ON"); openair_daq_vars.use_ia_receiver = 1; fl_set_object_color(button, FL_GREEN, FL_GREEN); } else { fl_set_object_label(button, "IA Receiver OFF"); openair_daq_vars.use_ia_receiver = 0; fl_set_object_color(button, FL_RED, FL_RED); } }
static void dl_traffic_on_off( FL_OBJECT *button, long arg) { if (fl_get_button(button)) { fl_set_object_label(button, "DL Traffic ON"); otg_enabled = 1; fl_set_object_color(button, FL_GREEN, FL_GREEN); } else { fl_set_object_label(button, "DL Traffic OFF"); otg_enabled = 0; fl_set_object_color(button, FL_RED, FL_RED); } }
void *scope_thread(void *arg) { int16_t prach_corr[1024], i; char stats_buffer[16384]; //FILE *UE_stats, *eNB_stats; int len=0; struct sched_param sched_param; sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; sched_setscheduler(0, SCHED_FIFO,&sched_param); printf("Scope thread has priority %d\n",sched_param.sched_priority); /* if (UE_flag==1) UE_stats = fopen("UE_stats.txt", "w"); else eNB_stats = fopen("eNB_stats.txt", "w"); */ while (!oai_exit) { if (UE_flag==1) { len = dump_ue_stats (PHY_vars_UE_g[0], stats_buffer, 0, mode,rx_input_level_dBm); fl_set_object_label(form_stats->stats_text, stats_buffer); //rewind (UE_stats); //fwrite (stats_buffer, 1, len, UE_stats); phy_scope_UE(form_ue[UE_id], PHY_vars_UE_g[UE_id], eNB_id, UE_id,7); } else { len = dump_eNB_stats (PHY_vars_eNB_g[0], stats_buffer, 0); fl_set_object_label(form_stats->stats_text, stats_buffer); //rewind (eNB_stats); //fwrite (stats_buffer, 1, len, eNB_stats); for(UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { phy_scope_eNB(form_enb[UE_id], PHY_vars_eNB_g[eNB_id], UE_id); } } //printf("doing forms\n"); usleep(100000); } //fclose (UE_stats); //fclose (eNB_stats); pthread_exit((void*)arg); }
static void anim_udpate_optimized(void) { char text[255]; if (ZANIM->ColOpt2Res.NofFrames > 0) { sprintf(text, "AVOIDANCE OPTIMIZED"); fl_set_object_label(ARCI_OPTIMIZED, text); fl_set_object_color (ARCI_OPTIMIZED, FL_GREEN, FL_BLACK); } else { sprintf(text, "AVOIDANCE NOT OPTIMIZED"); fl_set_object_label(ARCI_OPTIMIZED, text); fl_set_object_color (ARCI_OPTIMIZED, FL_RED, FL_BLACK); } }
static void anim_udpate_solved(void) { char text[255]; if (ZANIM->ColAvoidRes.NofFrames > 0) { sprintf(text, "COLLISIONS SOLVED"); fl_set_object_label(ARCI_SOLVED, text); fl_set_object_color (ARCI_SOLVED, FL_GREEN, FL_BLACK); } else { sprintf(text, "COLLISIONS UNSOLVED"); fl_set_object_label(ARCI_SOLVED, text); fl_set_object_color (ARCI_SOLVED, FL_RED, FL_BLACK); } }
static void anim_udpate_nof_blocks(void) { char text[255]; if (ZANIM->ColOptions.NofBlocks > 0) { sprintf(text, "%d BLOCKS CONSTITUTED",ZANIM->ColOptions.NofBlocks); fl_set_object_label(ARCI_NOF_BLOCK, text); fl_set_object_color (ARCI_NOF_BLOCK, FL_GREEN, FL_BLACK); } else { sprintf(text, "BLOCKS NOT CONSTITUTED"); fl_set_object_label(ARCI_NOF_BLOCK, text); fl_set_object_color (ARCI_NOF_BLOCK, FL_RED, FL_BLACK); } }
void uiError(char *str1, char *str2, char *str3) { fl_deactivate_form(MainForm); fl_set_object_label(Error1, str1); fl_set_object_label(Error2, str2); fl_set_object_label(Error3, str3); fl_show_form(ErrorForm, FL_PLACE_MOUSE, TRUE, ""); while (fl_do_forms() != OkButton); fl_hide_form(ErrorForm); fl_activate_form(MainForm); }
static int generic_setattr(genericobject *g, char *name, PyObject *v) { int ret; if (v == NULL) { PyErr_SetString(PyExc_TypeError, "can't delete forms object attributes"); return -1; } /* "label" is an exception: setmember doesn't set strings; and FORMS wants you to call a function to set the label */ if (strcmp(name, "label") == 0) { if (!PyString_Check(v)) { PyErr_SetString(PyExc_TypeError, "label attr must be string"); return -1; } fl_set_object_label(g->ob_generic, PyString_AsString(v)); return 0; } ret = PyMember_Set((char *)g->ob_generic, generic_memberlist, name, v); /* Rather than calling all the various set_object_* functions, we call fl_redraw_object here. This is sometimes redundant but I doubt that's a big problem */ if (ret == 0) fl_redraw_object(g->ob_generic); return ret; }
static void init_colors( int cc, int thecol ) { int i; const char *cn; fl_freeze_form( cs->colorform ); for ( i = 0; i < 64; i++ ) { fl_set_object_color( cs->col[ i ], cc + i, cc + i ); fl_set_object_label( cs->col[ i ], "" ); if ( thecol == cc + i ) fl_set_object_label( cs->col[ i ], "@9plus" ); } cn = fli_query_colorname( thecol ); fl_set_object_label( cs->cindex, cn + ( cn[ 0 ] == 'F' ? 3 : 0 ) ); fl_unfreeze_form( cs->colorform ); }
static void CB_select_object(FL_OBJECT *obj, long arg) { char newLabel[64]; strcpy (newLabel,"Selected Object: "); OBJECT= select_object(); if(OBJECT!=NULL) { strcat(newLabel, OBJECT->name); GRASP_LIST.clear(); INIT_IS_DONE= false; } fl_set_object_label(BT_5_OBJ, newLabel); }
static void CB_select_hand_robot(FL_OBJECT *obj, long arg) { char newLabel[64]; strcpy (newLabel,"Selected Hand: "); HAND_ROBOT= select_hand_robot(); if(HAND_ROBOT!=NULL) { strcat(newLabel, HAND_ROBOT->name); GRASP_LIST.clear(); INIT_IS_DONE= false; } fl_set_object_label(BT_6_OBJ, newLabel); }
void adjust_dm (FL_OBJECT *ob, long data) { double f1, f2; char buf[32]; double K; K = 1.0/(2.410331 * 10e-4); f1 = frequency-(bandwidth/2); f2 = frequency+(bandwidth/2); f1 /= 1.0e6; f2 /= 1.0e6; pulsar_dm = fl_get_slider_value (ob); pulsar_delay = (1.0/(f1*f1)) - (1.0/(f2*f2)); pulsar_delay *= pulsar_dm ; pulsar_delay *= K; sprintf (buf, "%9.4f", pulsar_delay * 1000); fl_set_object_label (fd_receiver_main->pulsar_delay_display, buf); write_rcvr_params ("idm", pulsar_dm); }
void fli_show_tooltip( const char * s, int x, int y ) { int maxw = 0, maxh = 0, extra; if ( ! s ) return; create_it( ); extra = 1 + ( tip->boxtype != FL_FLAT_BOX && tip->boxtype != FL_BORDER_BOX ); fl_get_string_dimension( tip->fntstyle, tip->fntsize, s, strlen( s ), &maxw, &maxh ); maxw += 7 + extra; maxh += 7 + extra; if ( maxw > 800 ) maxw = 800; if ( maxh > 800 ) maxh = 800; fl_freeze_form( tip->tooltipper ); fl_set_form_geometry( tip->tooltipper, x, y, maxw, maxh ); fl_set_object_label( tip->text, s ); fl_unfreeze_form( tip->tooltipper ); if ( ! tip->tooltipper->visible ) fl_show_form( tip->tooltipper, FL_PLACE_GEOMETRY | FL_FREE_SIZE, FL_NOBORDER, "Tooltip" ); fl_update_display( 1 ); }
void adjust_pulsar_rate(FL_OBJECT *ob, long data) { char tbuf[50]; char *p; double real_rate; int int_rate; double err; char str[64]; strcpy (tbuf, fl_get_input(ob)); p = strchr(tbuf, '\n'); if (p != NULL) { *p = '\0'; } if ((p = strchr(tbuf, '\r')) != NULL) { *p = '\0'; } if (check_float (tbuf) < 0) { fl_set_input (ob, "Format Error"); } else { pulsar_rate = (double)atof(tbuf); real_rate = (1.0/pulsar_rate)*(double)psr_rate; int_rate = (int)(real_rate); err = fabsf(real_rate - int_rate); err = err / real_rate; sprintf (str, "%8.2f", err*1.0e6); fl_set_object_label (fd_receiver_main->phase_display, str); } }
/* Handle the entry internally. Make an image or play the sound.... */ static void HandleInternal( Int4 index ) { unsigned char *sndbuf; unsigned char *pImgBuf ; char **xpmbuf=NULL; static char imagetext[50]; int nc; unsigned short samplerate; /* Sound sample size: The specs says a short here, with the next short empty. But some entries are (32 bits) ints, and the game engine accepts it. Examples include entries 164--171 (and many more) in strife0.wad (shareware v. 1.1), and #50 in the "Clint Eastwood DOOM (II?) sfx" pwad.... */ Uint4 nsamples; short w, h, dx, dy; switch ( pEntryTag[index] ) { case TAG_SFX : /* Read sound header */ fseek( WADfp, pDirEnt[index].start + 2, SEEK_SET ); fread( &samplerate, sizeof(short), 1, WADfp ); fread( &nsamples, sizeof(Uint4), 1, WADfp ); if ( nsamples != pDirEnt[index].size - 8) Message("Warning, sample size = %d, while Directory size = %d.\n", nsamples, pDirEnt[index].size); sndbuf = malloc( nsamples ); if ( !sndbuf ) { Message("can't malloc data for snd buf (%d bytes)\n",nsamples); return; } /* read the samples */ fread( sndbuf, 1, nsamples, WADfp ); if ( fl_get_button(rev_but) ) /* reverse ! */ ReverseBuffer( sndbuf, nsamples ); PlayRaw( sndbuf, nsamples, samplerate ); free( sndbuf ); break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : pImgBuf = ParseImgBlock(pDirEnt[index], pEntryTag[index], &w, &h, &dx, &dy, WADfp); /* I planned to use the offsets (dx,dy) for better placement of the image, but I need to find out some useful heuristics for how to do it..... printf("image: %dx%d, ofs left %d, top %d\n",w,h,dx,dy); */ if ( pImgBuf && w <= 320 && h <= 200 && (xpmbuf = CreateXpmImage( pImgBuf, w, h, 0, &nc)) ) { fl_free_pixmap_pixmap( img_pxm ); fl_set_pixmap_data( img_pxm, xpmbuf ); sprintf(imagetext,"#%d, %dx%d, %d colours",index,w,h,nc); fl_set_object_label(img_txt, imagetext); } else { Message("error creating image. (%p, %hdx%hd, %p)\n", pImgBuf, w, h, xpmbuf); return; } break; default : Message("entry %d, Not implemented\n",index); break; } }
FD_lte_phy_scope_enb *create_lte_phy_scope_enb( void ) { FL_OBJECT *obj; FD_lte_phy_scope_enb *fdui = fl_malloc( sizeof *fdui ); // Define form fdui->lte_phy_scope_enb = fl_bgn_form( FL_NO_BOX, 800, 600 ); // This the whole UI box obj = fl_add_box( FL_BORDER_BOX, 0, 0, 800, 600, "" ); fl_set_object_color( obj, FL_BLACK, FL_BLACK ); // Received signal fdui->rxsig_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 20, 370, 100, "Received Signal (Time-Domain, dB)" ); fl_set_object_boxtype( fdui->rxsig_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->rxsig_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->rxsig_t, FL_WHITE ); // Label color fl_set_xyplot_ybounds(fdui->rxsig_t,30,70); // Time-domain channel response fdui->chest_t = fl_add_xyplot( FL_NORMAL_XYPLOT, 410, 20, 370, 100, "Channel Impulse Response (samples, abs)" ); fl_set_object_boxtype( fdui->chest_t, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_t, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_t, FL_WHITE ); // Label color // Frequency-domain channel response fdui->chest_f = fl_add_xyplot( FL_IMPULSE_XYPLOT, 20, 140, 760, 100, "Channel Frequency Response (RE, dB)" ); fl_set_object_boxtype( fdui->chest_f, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->chest_f, FL_BLACK, FL_RED ); fl_set_object_lcolor( fdui->chest_f, FL_WHITE ); // Label color fl_set_xyplot_ybounds( fdui->chest_f,30,70); // LLR of PUSCH fdui->pusch_llr = fl_add_xyplot( FL_POINTS_XYPLOT, 20, 260, 500, 200, "PUSCH Log-Likelihood Ratios (LLR, mag)" ); fl_set_object_boxtype( fdui->pusch_llr, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pusch_llr, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pusch_llr, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pusch_llr,2); // I/Q PUSCH comp fdui->pusch_comp = fl_add_xyplot( FL_POINTS_XYPLOT, 540, 260, 240, 200, "PUSCH I/Q of MF Output" ); fl_set_object_boxtype( fdui->pusch_comp, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pusch_comp, FL_BLACK, FL_YELLOW ); fl_set_object_lcolor( fdui->pusch_comp, FL_WHITE ); // Label color fl_set_xyplot_symbolsize( fdui->pusch_comp,2); fl_set_xyplot_xgrid( fdui->pusch_llr,FL_GRID_MAJOR); // Throughput on PUSCH fdui->pusch_tput = fl_add_xyplot( FL_NORMAL_XYPLOT, 20, 480, 500, 100, "PUSCH Throughput [frame]/[kbit/s]" ); fl_set_object_boxtype( fdui->pusch_tput, FL_EMBOSSED_BOX ); fl_set_object_color( fdui->pusch_tput, FL_BLACK, FL_WHITE ); fl_set_object_lcolor( fdui->pusch_tput, FL_WHITE ); // Label color // Generic eNB Button fdui->button_0 = fl_add_button( FL_PUSH_BUTTON, 540, 480, 240, 40, "" ); fl_set_object_lalign(fdui->button_0, FL_ALIGN_CENTER ); fl_set_button(fdui->button_0,0); otg_enabled = 0; fl_set_object_label(fdui->button_0, "DL Traffic OFF"); fl_set_object_color(fdui->button_0, FL_RED, FL_RED); fl_set_object_callback(fdui->button_0, dl_traffic_on_off, 0 ); fl_end_form( ); fdui->lte_phy_scope_enb->fdui = fdui; return fdui; }
void DistributionChoiceCB(FL_OBJECT *p0, long p1) { FL_OBJECT *ap = the_gui->AEntry; FL_OBJECT *bp = the_gui->BEntry; switch (fl_get_choice(p0)) { case 0: cout << "No choice" << endl; break; case Uniform: // uniform in the interval [a,b] fl_set_object_label(ap,"Minimum"); fl_set_input(ap,"10.0"); fl_set_object_label(bp,"Maximum"); fl_set_input(bp,"90.0"); fl_show_object(ap); fl_show_object(bp); break; case Binomial: // binomial fl_set_object_label(ap,"p"); fl_set_input(ap,"0.5"); fl_set_object_label(bp,"n"); fl_set_input(bp,"10.0"); fl_show_object(ap); fl_show_object(bp); break; case CDF: // CDF -- file will set range in a, b entries fl_set_object_label(ap,"lo"); fl_set_input(ap,"<>"); fl_set_object_label(bp,"hi"); fl_set_input(bp,"<>"); fl_show_object(ap); fl_show_object(bp); break; case Exponential: // exponential; no params fl_hide_object(ap); fl_hide_object(bp); break; case Gamma: // Time to wait for N events fl_set_object_label(ap,"Mean"); fl_set_input(ap,"1"); fl_set_object_label(bp,"Std Dev"); fl_set_input(bp,"1"); fl_show_object(ap); fl_show_object(bp); break; case LogNormal: // lognormal with mean = a and std dev = b fl_set_object_label(ap,"Mean"); fl_set_input(ap,"50.0"); fl_set_object_label(bp,"Std Dev"); fl_set_input(bp,"10.0"); fl_show_object(ap); fl_show_object(bp); break; case LogNormalLog: // lognormal with mean = exp(a) and std dev = exp(b) fl_set_object_label(ap,"Log Mean"); fl_set_input(ap,"3.0"); fl_set_object_label(bp,"Log Std Dev"); fl_set_input(bp,"0.5"); fl_show_object(ap); fl_show_object(bp); break; case Normal: // normal with mean = a and std dev = b fl_set_object_label(ap,"Mean"); fl_set_input(ap,"50.0"); fl_set_object_label(bp,"Std Dev"); fl_set_input(bp,"10.0"); fl_show_object(ap); fl_show_object(bp); break; case Poisson: // poisson with lambda = a fl_set_object_label(ap,"Lambda"); fl_set_input(ap,"1.0"); fl_show_object(ap); fl_hide_object(bp); break; } }
int main(int argc, char **argv) { #ifdef RTAI RT_TASK *task; RTIME period; #endif int i,j,aa; void *status; /* uint32_t rf_mode_max[4] = {55759,55759,55759,55759}; uint32_t rf_mode_med[4] = {39375,39375,39375,39375}; uint32_t rf_mode_byp[4] = {22991,22991,22991,22991}; */ uint32_t my_rf_mode = RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX; uint32_t rf_mode_base = TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM; uint32_t rf_mode[4] = {my_rf_mode,0,0,0}; uint32_t rf_local[4] = {8255000,8255000,8255000,8255000}; // UE zepto //{8254617, 8254617, 8254617, 8254617}; //eNB khalifa //{8255067,8254810,8257340,8257340}; // eNB PETRONAS uint32_t rf_vcocal[4] = {910,910,910,910}; uint32_t rf_vcocal_850[4] = {2015, 2015, 2015, 2015}; uint32_t rf_rxdc[4] = {32896,32896,32896,32896}; uint32_t rxgain[4] = {20,20,20,20}; uint32_t txgain[4] = {20,20,20,20}; uint16_t Nid_cell = 0; uint8_t cooperation_flag=0, transmission_mode=1, abstraction_flag=0; uint8_t beta_ACK=0,beta_RI=0,beta_CQI=2; int c; char do_forms=0; unsigned int fd; unsigned int tcxo = 114; int amp; uint8_t prach_fmt; int N_ZC; char rxg_fname[100]; char txg_fname[100]; char rflo_fname[100]; char rfdc_fname[100]; FILE *rxg_fd=NULL; FILE *txg_fd=NULL; FILE *rflo_fd=NULL; FILE *rfdc_fd=NULL; unsigned int rxg_max[4]={133,133,133,133}, rxg_med[4]={127,127,127,127}, rxg_byp[4]={120,120,120,120}; int tx_max_power=0; char line[1000]; int l; int ret, ant; int ant_offset=0; int error_code; char *itti_dump_file = NULL; const struct option long_options[] = { {"calib-ue-rx", required_argument, NULL, 256}, {"calib-ue-rx-med", required_argument, NULL, 257}, {"calib-ue-rx-byp", required_argument, NULL, 258}, {"debug-ue-prach", no_argument, NULL, 259}, {"no-L2-connect", no_argument, NULL, 260}, {NULL, 0, NULL, 0}}; //mode = normal_txrx; while ((c = getopt_long (argc, argv, "C:K:O:ST:UdF:V",long_options,NULL)) != -1) { switch (c) { case 'V': ouput_vcd = 1; break; case 'd': do_forms=1; break; case 'U': UE_flag = 1; break; case 'C': carrier_freq[0] = atoi(optarg); carrier_freq[1] = atoi(optarg); carrier_freq[2] = atoi(optarg); carrier_freq[3] = atoi(optarg); break; case 'S': fs4_test=1; break; case 'T': tcxo=atoi(optarg); break; case 'K': #if defined(ENABLE_ITTI) itti_dump_file = strdup(optarg); #else printf("-K option is disabled when ENABLE_ITTI is not defined\n"); #endif break; case 'O': #if defined(ENABLE_USE_MME) EPC_MODE_ENABLED = 1; if (optarg == NULL) /* No IP address provided: use localhost */ { memcpy(&EPC_MODE_MME_ADDRESS[0], "127.0.0.1", 10); } else { uint8_t ip_length = strlen(optarg) + 1; memcpy(&EPC_MODE_MME_ADDRESS[0], optarg, ip_length > 16 ? 16 : ip_length); } #else printf("You enabled mme mode without s1ap compiled...\n"); #endif break; case 'F': sprintf(rxg_fname,"%srxg.lime",optarg); rxg_fd = fopen(rxg_fname,"r"); if (rxg_fd) { printf("Loading RX Gain parameters from %s\n",rxg_fname); l=0; while (fgets(line, sizeof(line), rxg_fd)) { if ((strlen(line)==0) || (*line == '#')) continue; //ignore empty or comment lines else { if (l==0) sscanf(line,"%d %d %d %d",&rxg_max[0],&rxg_max[1],&rxg_max[2],&rxg_max[3]); if (l==1) sscanf(line,"%d %d %d %d",&rxg_med[0],&rxg_med[1],&rxg_med[2],&rxg_med[3]); if (l==2) sscanf(line,"%d %d %d %d",&rxg_byp[0],&rxg_byp[1],&rxg_byp[2],&rxg_byp[3]); l++; } } } else printf("%s not found, running with defaults\n",rxg_fname); sprintf(txg_fname,"%stxg.lime",optarg); txg_fd = fopen(txg_fname,"r"); if (txg_fd) { printf("Loading TX Gain parameters from %s\n",txg_fname); l=0; while (fgets(line, sizeof(line), txg_fd)) { if ((strlen(line)==0) || (*line == '#')) { continue; //ignore empty or comment lines } else { if (l==0) sscanf(line,"%d %d %d %d",&txgain[0],&txgain[1],&txgain[2],&txgain[3]); if (l==1) sscanf(line,"%d",&tx_max_power); l++; } } } else printf("%s not found, running with defaults\n",txg_fname); sprintf(rflo_fname,"%srflo.lime",optarg); rflo_fd = fopen(rflo_fname,"r"); if (rflo_fd) { printf("Loading RF LO parameters from %s\n",rflo_fname); fscanf(rflo_fd,"%d %d %d %d",&rf_local[0],&rf_local[1],&rf_local[2],&rf_local[3]); } else printf("%s not found, running with defaults\n",rflo_fname); sprintf(rfdc_fname,"%srfdc.lime",optarg); rfdc_fd = fopen(rfdc_fname,"r"); if (rfdc_fd) { printf("Loading RF DC parameters from %s\n",rfdc_fname); fscanf(rfdc_fd,"%d %d %d %d",&rf_rxdc[0],&rf_rxdc[1],&rf_rxdc[2],&rf_rxdc[3]); } else printf("%s not found, running with defaults\n",rfdc_fname); break; /* case 256: mode = rx_calib_ue; rx_input_level_dBm = atoi(optarg); printf("Running with UE calibration on (LNA max), input level %d dBm\n",rx_input_level_dBm); break; case 257: mode = rx_calib_ue_med; rx_input_level_dBm = atoi(optarg); printf("Running with UE calibration on (LNA med), input level %d dBm\n",rx_input_level_dBm); break; case 258: mode = rx_calib_ue_byp; rx_input_level_dBm = atoi(optarg); printf("Running with UE calibration on (LNA byp), input level %d dBm\n",rx_input_level_dBm); break; case 259: mode = debug_prach; break; case 260: mode = no_L2_connect; break; */ default: break; } } if (UE_flag==1) printf("configuring for UE\n"); else printf("configuring for eNB\n"); //randominit (0); //set_taus_seed (0); // initialize the log (see log.h for details) logInit(); #if defined(ENABLE_ITTI) itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file); # if defined(ENABLE_USE_MME) if (itti_create_task(TASK_SCTP, sctp_eNB_task, NULL) < 0) { LOG_E(EMU, "Create task failed"); LOG_D(EMU, "Initializing SCTP task interface: FAILED\n"); return -1; } if (itti_create_task(TASK_S1AP, s1ap_eNB_task, NULL) < 0) { LOG_E(EMU, "Create task failed"); LOG_D(EMU, "Initializing S1AP task interface: FAILED\n"); return -1; } # endif if (itti_create_task(TASK_L2L1, l2l1_task, NULL) < 0) { LOG_E(EMU, "Create task failed"); LOG_D(EMU, "Initializing L2L1 task interface: FAILED\n"); return -1; } // Handle signals until all tasks are terminated // itti_wait_tasks_end(); #endif if (ouput_vcd) { if (UE_flag==1) vcd_signal_dumper_init("/tmp/openair_dump_UE.vcd"); else vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd"); } #ifdef NAS_NETLINK netlink_init(); #endif // to make a graceful exit when ctrl-c is pressed signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); #ifndef RTAI check_clock(); #endif g_log->log_component[HW].level = LOG_DEBUG; g_log->log_component[HW].flag = LOG_HIGH; #ifdef OPENAIR2 g_log->log_component[PHY].level = LOG_INFO; #else g_log->log_component[PHY].level = LOG_INFO; #endif g_log->log_component[PHY].flag = LOG_HIGH; g_log->log_component[MAC].level = LOG_INFO; g_log->log_component[MAC].flag = LOG_HIGH; g_log->log_component[RLC].level = LOG_INFO; g_log->log_component[RLC].flag = LOG_HIGH; g_log->log_component[PDCP].level = LOG_INFO; g_log->log_component[PDCP].flag = LOG_HIGH; g_log->log_component[OTG].level = LOG_INFO; g_log->log_component[OTG].flag = LOG_HIGH; g_log->log_component[RRC].level = LOG_INFO; g_log->log_component[RRC].flag = LOG_HIGH; // Initialize card ret = openair0_open(); if ( ret != 0 ) { if (ret == -1) printf("Error opening /dev/openair0"); if (ret == -2) printf("Error mapping bigshm"); if (ret == -3) printf("Error mapping RX or TX buffer"); return(ret); } printf ("Detected %d number of cards, %d number of antennas.\n", openair0_num_detected_cards, openair0_num_antennas[card]); p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr; p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr; printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", card, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev); if (p_exmimo_id->board_swrev>=BOARD_SWREV_CNTL2) p_exmimo_config->framing.eNB_flag = 0; else p_exmimo_config->framing.eNB_flag = !UE_flag; p_exmimo_config->framing.tdd_config = DUPLEXMODE_FDD + TXRXSWITCH_LSB; for (ant=0; ant<4; ant++) p_exmimo_config->framing.resampling_factor[ant] = RESAMPLING_FACTOR; /* for (ant=0;ant<max(frame_parms->nb_antennas_tx,frame_parms->nb_antennas_rx);ant++) p_exmimo_config->rf.rf_mode[ant] = rf_mode_base; for (ant=0;ant<frame_parms->nb_antennas_tx;ant++) p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX); for (ant=0;ant<frame_parms->nb_antennas_rx;ant++) p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX); for (ant=max(frame_parms->nb_antennas_tx,frame_parms->nb_antennas_rx);ant<4;ant++) { p_exmimo_config->rf.rf_mode[ant] = 0; carrier_freq[ant] = 0; //this turns off all other LIMEs } */ ant_offset = 0; for (ant=0; ant<4; ant++) { if (ant==ant_offset) { //if (1) { p_exmimo_config->rf.rf_mode[ant] = rf_mode_base; //p_exmimo_config->rf.rf_mode[ant] += (TXEN + DMAMODE_TX); p_exmimo_config->rf.rf_mode[ant] += (RXEN + DMAMODE_RX); } else { p_exmimo_config->rf.rf_mode[ant] = 0; carrier_freq[ant] = 0; //this turns off all other LIMEs } } for (ant = 0; ant<4; ant++) { p_exmimo_config->rf.do_autocal[ant] = 1; p_exmimo_config->rf.rf_freq_rx[ant] = carrier_freq[ant]; p_exmimo_config->rf.rf_freq_tx[ant] = carrier_freq[ant]; p_exmimo_config->rf.rx_gain[ant][0] = rxgain[ant]; p_exmimo_config->rf.tx_gain[ant][0] = txgain[ant]; p_exmimo_config->rf.rf_local[ant] = rf_local[ant]; p_exmimo_config->rf.rf_rxdc[ant] = rf_rxdc[ant]; if ((carrier_freq[ant] >= 850000000) && (carrier_freq[ant] <= 865000000)) { p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal_850[ant]; p_exmimo_config->rf.rffe_band_mode[ant] = DD_TDD; } else if ((carrier_freq[ant] >= 1900000000) && (carrier_freq[ant] <= 2000000000)) { p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant]; p_exmimo_config->rf.rffe_band_mode[ant] = B19G_TDD; } else { p_exmimo_config->rf.rf_vcocal[ant] = rf_vcocal[ant]; p_exmimo_config->rf.rffe_band_mode[ant] = 0; } p_exmimo_config->rf.rffe_gain_txlow[ant] = 31; p_exmimo_config->rf.rffe_gain_txhigh[ant] = 31; p_exmimo_config->rf.rffe_gain_rxfinal[ant] = 52; p_exmimo_config->rf.rffe_gain_rxlow[ant] = 31; } number_of_cards = openair0_num_detected_cards; /* if (p_exmimo_id->board_exmimoversion==1) //ExpressMIMO1 openair_daq_vars.timing_advance = 138; else //ExpressMIMO2 openair_daq_vars.timing_advance = 0; */ openair0_dump_config(card); printf("EXMIMO_CONFIG: rf_mode 0x %x %x %x %x, [0]: TXRXEn %d, TXLPFEn %d, TXLPF %d, RXLPFEn %d, RXLPF %d, RFBB %d, LNA %d, LNAGain %d, RXLPFMode %d, SWITCH %d, rf_rxdc %d, rf_local %d, rf_vcocal %d\n", p_exmimo_config->rf.rf_mode[0], p_exmimo_config->rf.rf_mode[1], p_exmimo_config->rf.rf_mode[2], p_exmimo_config->rf.rf_mode[3], (p_exmimo_config->rf.rf_mode[0]&3), // RXen+TXen (p_exmimo_config->rf.rf_mode[0]&4)>>2, //TXLPFen (p_exmimo_config->rf.rf_mode[0]&TXLPFMASK)>>3, //TXLPF (p_exmimo_config->rf.rf_mode[0]&128)>>7, //RXLPFen (p_exmimo_config->rf.rf_mode[0]&RXLPFMASK)>>8, //TXLPF (p_exmimo_config->rf.rf_mode[0]&RFBBMASK)>>16, // RFBB mode (p_exmimo_config->rf.rf_mode[0]&LNAMASK)>>12, // RFBB mode (p_exmimo_config->rf.rf_mode[0]&LNAGAINMASK)>>14, // RFBB mode (p_exmimo_config->rf.rf_mode[0]&RXLPFMODEMASK)>>19, // RXLPF mode (p_exmimo_config->framing.tdd_config&TXRXSWITCH_MASK)>>1, // Switch mode p_exmimo_config->rf.rf_rxdc[0], p_exmimo_config->rf.rf_local[0], p_exmimo_config->rf.rf_vcocal[0]); for (ant=0;ant<4;ant++) p_exmimo_config->rf.do_autocal[ant] = 0; #ifdef EMOS error_code = rtf_create(CHANSOUNDER_FIFO_MINOR,CHANSOUNDER_FIFO_SIZE); if (error_code==0) printf("[OPENAIR][SCHED][INIT] Created EMOS FIFO %d\n",CHANSOUNDER_FIFO_MINOR); else if (error_code==ENODEV) printf("[OPENAIR][SCHED][INIT] Problem: EMOS FIFO %d is greater than or equal to RTF_NO\n",CHANSOUNDER_FIFO_MINOR); else if (error_code==ENOMEM) printf("[OPENAIR][SCHED][INIT] Problem: cannot allocate memory for EMOS FIFO %d\n",CHANSOUNDER_FIFO_MINOR); else printf("[OPENAIR][SCHED][INIT] Problem creating EMOS FIFO %d, error_code %d\n",CHANSOUNDER_FIFO_MINOR,error_code); #endif mlockall(MCL_CURRENT | MCL_FUTURE); #ifdef RTAI // make main thread LXRT soft realtime task = rt_task_init_schmod(nam2num("MYTASK"), 9, 0, 0, SCHED_FIFO, 0xF); // start realtime timer and scheduler #ifdef TIMER_ONESHOT_MODE rt_set_oneshot_mode(); start_rt_timer(0); printf("started RTAI timer inoneshot mode\n"); #else rt_set_periodic_mode(); period = start_rt_timer(nano2count(500000)); printf("started RTAI timer with period %llu ns\n",count2nano(period)); #endif printf("Init mutex\n"); //mutex = rt_get_adr(nam2num("MUTEX")); mutex = rt_sem_init(nam2num("MUTEX"), 1); if (mutex==0) { printf("Error init mutex\n"); exit(-1); } else printf("mutex=%p\n",mutex); #endif DAQ_MBOX = (volatile unsigned int *) openair0_exmimo_pci[card].rxcnt_ptr[0]; // this starts the DMA transfers if (UE_flag!=1) openair0_start_rt_acquisition(card); #ifdef XFORMS if (do_forms==1) { fl_initialize (&argc, argv, NULL, 0, 0); form_stats = create_form_stats_form(); if (UE_flag==1) { form_ue[UE_id] = create_lte_phy_scope_ue(); sprintf (title, "LTE DL SCOPE UE"); fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); } else { for(UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { form_enb[UE_id] = create_lte_phy_scope_enb(); sprintf (title, "UE%d LTE UL SCOPE eNB",UE_id+1); fl_show_form (form_enb[UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); } } fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); if (UE_flag==0) { for (UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { if (otg_enabled) { fl_set_button(form_enb[UE_id]->button_0,1); fl_set_object_label(form_enb[UE_id]->button_0,"DL Traffic ON"); } else { fl_set_button(form_enb[UE_id]->button_0,0); fl_set_object_label(form_enb[UE_id]->button_0,"DL Traffic OFF"); } } } else { if (openair_daq_vars.use_ia_receiver) { fl_set_button(form_ue[UE_id]->button_0,1); fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); } else { fl_set_button(form_ue[UE_id]->button_0,0); fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); } } ret = pthread_create(&thread2, NULL, scope_thread, NULL); printf("Scope thread created, ret=%d\n",ret); } #endif #ifdef EMOS ret = pthread_create(&thread3, NULL, emos_thread, NULL); printf("EMOS thread created, ret=%d\n",ret); #endif rt_sleep_ns(10*FRAME_PERIOD); #ifndef RTAI pthread_attr_init (&attr_dlsch_threads); pthread_attr_setstacksize(&attr_dlsch_threads,OPENAIR_THREAD_STACK_SIZE); //attr_dlsch_threads.priority = 1; sched_param_dlsch.sched_priority = sched_get_priority_max(SCHED_FIFO); //OPENAIR_THREAD_PRIORITY; pthread_attr_setschedparam (&attr_dlsch_threads, &sched_param_dlsch); pthread_attr_setschedpolicy (&attr_dlsch_threads, SCHED_FIFO); #endif // start the main thread if (UE_flag == 1) { /* #ifdef RTAI thread1 = rt_thread_create(UE_thread, NULL, 100000000); #else error_code = pthread_create(&thread1, &attr_dlsch_threads, UE_thread, NULL); if (error_code!= 0) { LOG_D(HW,"[lte-softmodem.c] Could not allocate UE_thread, error %d\n",error_code); return(error_code); } else { LOG_D(HW,"[lte-softmodem.c] Allocate UE_thread successful\n"); } #endif #ifdef DLSCH_THREAD init_rx_pdsch_thread(); rt_sleep_ns(FRAME_PERIOD/10); init_dlsch_threads(); #endif printf("UE threads created\n"); */ } else { #ifdef RTAI thread0 = rt_thread_create(eNB_thread, NULL, 100000000); #else error_code = pthread_create(&thread0, &attr_dlsch_threads, eNB_thread, NULL); if (error_code!= 0) { LOG_D(HW,"[lte-softmodem.c] Could not allocate eNB_thread, error %d\n",error_code); return(error_code); } else { LOG_D(HW,"[lte-softmodem.c] Allocate eNB_thread successful\n"); } #endif #ifdef ULSCH_THREAD init_ulsch_threads(); #endif printf("eNB threads created\n"); } // wait for end of program printf("TYPE <CTRL-C> TO TERMINATE\n"); //getchar(); while (oai_exit==0) rt_sleep_ns(FRAME_PERIOD); // stop threads #ifdef XFORMS printf("waiting for XFORMS thread\n"); if (do_forms==1) { pthread_join(thread2,&status); fl_hide_form(form_stats->stats_form); fl_free_form(form_stats->stats_form); if (UE_flag==1) { fl_hide_form(form_ue[UE_id]->lte_phy_scope_ue); fl_free_form(form_ue[UE_id]->lte_phy_scope_ue); } else { for(UE_id=0;UE_id<scope_enb_num_ue;UE_id++) { fl_hide_form(form_enb[UE_id]->lte_phy_scope_enb); fl_free_form(form_enb[UE_id]->lte_phy_scope_enb); } } } #endif printf("stopping MODEM threads\n"); // cleanup if (UE_flag == 1) { /* #ifdef RTAI rt_thread_join(thread1); #else pthread_join(thread1,&status); #endif #ifdef DLSCH_THREAD cleanup_dlsch_threads(); cleanup_rx_pdsch_thread(); #endif */ } else { #ifdef RTAI rt_thread_join(thread0); #else pthread_join(thread0,&status); #endif #ifdef ULSCH_THREAD cleanup_ulsch_threads(); #endif } #ifdef OPENAIR2 //cleanup_pdcp_thread(); #endif #ifdef RTAI stop_rt_timer(); #endif printf("stopping card\n"); openair0_stop(card); printf("closing openair0_lib\n"); openair0_close(); #ifdef EMOS printf("waiting for EMOS thread\n"); pthread_cancel(thread3); pthread_join(thread3,&status); #endif #ifdef EMOS error_code = rtf_destroy(CHANSOUNDER_FIFO_MINOR); printf("[OPENAIR][SCHED][CLEANUP] EMOS FIFO closed, error_code %d\n", error_code); #endif if (ouput_vcd) vcd_signal_dumper_close(); logClean(); return 0; }
int fl_show_question( const char * str, int ans ) { FL_OBJECT *retobj; char shortcut[ 4 ]; int k = 0; if ( fd_yesno ) { fl_hide_form( fd_yesno->form ); fl_free_form( fd_yesno->form ); fl_free( fd_yesno ); } else fl_deactivate_all_forms( ); fd_yesno = create_yesno( ); default_ans = ans; fli_parse_goodies_label( fd_yesno->yes, FLQuestionYesLabel ); fli_parse_goodies_label( fd_yesno->no, FLQuestionNoLabel ); /* We don't set a shortcut if the first letter of the "yes" label is identical to all letters in the "no" label */ while ( fd_yesno->no->label[ k ] && tolower( ( int ) fd_yesno->yes->label[ 0 ] ) == tolower( ( int ) fd_yesno->yes->label[ k ] ) ) k++; if ( fd_yesno->no->label[ k ] ) { shortcut[ 0 ] = fd_yesno->yes->label[ 0 ]; shortcut[ 1 ] = tolower( ( int ) fd_yesno->yes->label[ 0 ] ); shortcut[ 2 ] = toupper( ( int ) fd_yesno->yes->label[ 0 ] ); shortcut[ 3 ] = '\0'; fl_set_button_shortcut( fd_yesno->yes, shortcut, 1 ); shortcut[ 0 ] = fd_yesno->no->label[ k ]; shortcut[ 1 ] = toupper( ( int ) fd_yesno->no->label[ k ] ); shortcut[ 2 ] = tolower( ( int ) fd_yesno->no->label[ k ] ); fl_set_button_shortcut( fd_yesno->no, shortcut, 1 ); } fli_get_goodie_title( fd_yesno->form, FLQuestionTitle ); fli_handle_goodie_font( fd_yesno->yes, fd_yesno->str ); fli_handle_goodie_font( fd_yesno->no, NULL ); fl_set_object_label( fd_yesno->str, str ); if ( ans == 1 ) fl_set_form_hotobject( fd_yesno->form, fd_yesno->yes ); else if ( ans == 0 ) fl_set_form_hotobject( fd_yesno->form, fd_yesno->no ); else fl_set_form_hotspot( fd_yesno->form, -1, -1 ); fl_show_form( fd_yesno->form, FL_PLACE_HOTSPOT, FL_TRANSIENT, fd_yesno->form->label ); fl_update_display( 0 ); while ( ( retobj = fl_do_only_forms( ) ) != fd_yesno->yes && retobj != fd_yesno->no ) /* empty */; k = retobj == fd_yesno->yes; fl_hide_form( fd_yesno->form ); fl_free_form( fd_yesno->form ); fli_safe_free( fd_yesno ); fl_activate_all_forms( ); return k; }
void NeoWindow::HandleMainWinObject( FL_OBJECT *obj ) { // Handle command from form on main window int scale = neo->scale, i; if ( obj == mainWin->pause ) { // Pause/un-pause if ( ! neo->setup ) return; neo->started = true; neo->paused = ! neo->paused; Refresh( true ); } else if ( obj == mainWin->step ) { // If paused, update by one timestep neo->started = true; if ( neo->paused ) neo->nextStep = true; } else if ( obj == mainWin->add_food ) { // Add food to world neo->borrowed_energy -= neo->food_button_increment; } else if ( obj == mainWin->remove_food ) { // Remove food neo->borrowed_energy += neo->food_button_increment; } else if ( obj == mainWin->file_menu ) { const char *choice = fl_get_menu_text( obj ); if ( ! strcmp( "New", choice ) ) { neo->started = false; neo->paused = true; neo->SetUpRun(); // Set up the run Refresh( true ); //portal = new NeoPortal( 1115 ); //( portal = new NeoPortal() )->CallServer( "localhost", 1115 ); } else if ( ! strcmp( "Close", choice ) ) { neo->started = false; neo->paused = true; Refresh( true ); } else if ( ! strcmp( "Load", choice ) ) { const char *output = NULL; if ( ( output = fl_show_fselector( "Load simulation from file:" , ".", "*", neo->fileName ) ) != NULL ) { strcpy( neo->fileName, output ); neo->LoadSimulation(); Refresh( true ); } } else if ( ! strcmp( "Save", choice ) ) { const char *output = NULL; if ( ( output = fl_show_fselector( "Save simulation to file:" , ".", "*", neo->fileName ) ) != NULL ) { strcpy( neo->fileName, output ); neo->SaveSimulation(); } Refresh(); } else if ( ! strcmp( "Print...", choice ) ) { char tmp[50]; sprintf( tmp, "%s.%08d.ps", neo->fileName, neo->time_step ); const char *output = NULL; if ( ( output = fl_show_fselector( "Print simulation to PostScript file:" , ".", "*", tmp ) ) != NULL ) { fl_object_ps_dump( mainWin->mainCanvas, tmp ); } } else if ( ! strcmp( "Quit", choice ) ) { neo->done = true; neo->started = false; neo->keepDrawing = false; } } else if ( obj == mainWin->other_menu ) { const char *choice = fl_get_menu_text( obj ); if ( ! strcmp( "Update Display", choice ) ) { neo->keepDrawing = ! neo->keepDrawing; Refresh( true ); // Need to update the whole screen } else if ( ! strcmp( "NNet Window", choice ) ) { nnet_plot = create_form_neural_net_plot(); fl_add_canvas_handler( nnet_plot->mainCanvas, Expose, expose_callback, (void *) this ); fl_show_form( nnet_plot->neural_net_plot, FL_PLACE_MOUSE, FL_TRANSIENT, "Neural Net Plot" ); RedrawNNetPlot(); } else if ( ! strcmp( "Chart Window", choice ) ) { chart_wind = create_form_chart_window(); fl_show_form( chart_wind->chart_window, FL_PLACE_MOUSE, FL_TRANSIENT, "Population Statistics" ); } else if ( ! strcmp( "Leave Trails", choice ) ) { neo->leaveTrails = ! neo->leaveTrails; if ( ! neo->leaveTrails ) Refresh( true ); } else if ( ! strcmp( "Add Bug", choice ) ) { const char *output = NULL; fl_add_fselector_appbutton( "Number", fselector_callback, this ); if ( ( output = fl_show_fselector( "Add creature from file:", ".", "*", neo->creatureFile ) ) != NULL ) { for ( int jj = 0; jj < neo->initialBugSeed; jj ++ ) { strcpy( neo->creatureFile, output ); new Creature( Introduced, neo ); } } fl_remove_fselector_appbutton( "Number" ); Draw( true ); } else if ( ! strcmp( "Save Bug", choice ) ) { if ( neo->output_creature < 0 ) return; const char *output = NULL; if ( ( output = fl_show_fselector( "Save creature to file:" , ".", "*", neo->creatureFile ) ) != NULL ) { Creature *creature = neo->ppCreatureList[ neo->output_creature ]; if ( creature != NULL ) creature->WriteGenotype( (char *) output ); } } else if ( ! strcmp( "Options...", choice ) ) { options_box = create_form_options(); FD_options *box = options_box; if ( neo->started ) { fl_deactivate_object( box->initial_parameters_group ); fl_set_object_label( box->initial_params_frame, "Initial Parameters (currently inactive)" ); } fl_set_slider_value( box->initial_pop, neo->initial_creatures ); fl_set_slider_value( box->initial_plant, neo->num_initial_food_locs ); fl_set_slider_value( box->initial_flesh, neo->num_initial_meat_locs ); fl_set_button( box->give_head_start, neo->bGiveHeadStart ); fl_set_button( box->allow_sex, neo->bAllowSexual ); fl_set_button( box->allow_asex, neo->bAllowAsexual ); char tmp[5]; sprintf( tmp, "%d", neo->terrain_size ); fl_set_choice_text( box->terrain_size, tmp ); fl_set_slider_value( box->scale, neo->scale ); fl_set_slider_value( box->prob_crossover, neo->prob_crossover ); fl_set_slider_value( box->prob_mutation, neo->prob_mutation ); fl_set_slider_value( box->max_pop, neo->maximum_creatures ); fl_set_slider_value( box->min_pop, neo->nMinimumPopulation ); fl_set_slider_value( box->age_factor, neo->age_factor ); fl_set_slider_value( box->carcass_decay_rate, neo->nCarcassDecayRate ); fl_set_slider_value( box->waste_decay_rate, neo->nWasteDecayRate ); fl_set_slider_value( box->poison_decay_rate, neo->nPoisonDecayRate ); fl_set_button( box->give_head_start, neo->bGiveHeadStart ); fl_set_button( box->maintain_min_pop, neo->bKeepMinimumPopulation ); fl_set_button( box->use_survivor, neo->bUseSurvivorForMinimum ); fl_set_slider_value( box->save_every, neo->saveEveryNsteps ); if ( neo->saveEveryNsteps == -1 ) fl_set_button( box->save_sim, 0 ); else fl_set_button( box->save_sim, 1 ); fl_set_input( box->file_name, neo->fileName ); fl_show_form( box->options, FL_PLACE_MOUSE, FL_TRANSIENT, "Key Commands" ); } } }
int main(int argc, char *argv[]) { void lmst_update (FL_OBJECT *, long); int i; void dismiss_psr(); void spectrum_hide(); void tp_hide (); void hide_waterfall(); void hide_interferometer(); void hide_info(); void receiver_leave(); int close_sub (); int close_main (); char *p; char fntstr[128]; char d[128]; int binwidth; /* * Init xforms library */ fl_initialize(&argc, argv, "Ira", 0, 0); fl_get_app_resources (NULL, 0); time (&started_at); /* * Create various windows, including the main one */ fd_receiver_main = create_form_receiver_main(); fl_set_form_atclose(fd_receiver_main->receiver_main, close_main, 0); fd_receiver_pulsar = create_form_receiver_pulsar(); fl_set_form_atclose (fd_receiver_pulsar->receiver_pulsar, close_sub, dismiss_psr); fd_receiver_spectrum = create_form_receiver_spectrum(); fl_set_form_atclose (fd_receiver_spectrum->receiver_spectrum, close_sub, spectrum_hide); fd_receiver_continuum = create_form_receiver_continuum(); fl_set_form_atclose (fd_receiver_continuum->receiver_continuum, close_sub, tp_hide); fd_receiver_waterfall = create_form_receiver_waterfall(); fl_set_form_atclose (fd_receiver_waterfall->receiver_waterfall, close_sub, hide_waterfall); fd_receiver_info = create_form_receiver_info(); fl_set_form_atclose (fd_receiver_info->receiver_info, close_sub, hide_info); fd_receiver_lproblem = create_form_receiver_lproblem (); fd_receiver_error = create_form_receiver_error (); fd_receiver_shutdown = create_form_receiver_shutdown (); flps_init(); fl_free_pixmap_pixmap(fd_receiver_main->ira_xpm_button); fl_set_pixmap_data(fd_receiver_main->ira_xpm_button, Ira_xpm); sprintf (version_info, "Ver: %s (BETA)", VERSION); /* * Stuff lines in info window */ for (i = 0; ; i++) { if (ira_info[i] == NULL) { break; } fl_add_browser_line (fd_receiver_info->info_browser, ira_info[i]); } fl_set_browser_fontsize(fd_receiver_info->info_browser, 14); /* fill-in form initialization code */ fl_set_object_label (fd_receiver_main->startup_text, "PLEASE WAIT........."); /* show the first form */ fl_show_form(fd_receiver_main->receiver_main,FL_PLACE_CENTER,FL_FULLBORDER,"IRA Control Panel"); fl_check_forms(); /* * Now we check a raft of environment variables, and use those to initialize * various settable values */ refmult = 1.0; if ((p = getenv ("RCVR_REF_MULT")) != NULL) { refmult = atof(p); } fl_set_slider_value (fd_receiver_main->refmult_slider, refmult); seti_integ = 15; if ((p = getenv ("RCVR_SETI_INTEG")) != NULL) { seti_integ = (int)atof(p); } fl_set_slider_value (fd_receiver_main->seti_integ_slider, (float)seti_integ); strcpy (datadir, "."); if ((p = getenv ("RCVR_DATA_DIR")) != NULL) { strcpy (datadir, p); } /* * Set the input field for freq, as well as the actual frequency */ if ((p = getenv ("RCVR_INITIAL_FREQ")) != NULL) { fl_set_input (fd_receiver_main->frequency_input, p); frequency = atof(p); sky_freq = frequency; sky_locked = 1; } /* * Start out with sky_freq unavailable for input */ fl_deactivate_object (fd_receiver_main->sky_freq_input); fl_set_input (fd_receiver_main->sky_freq_input, "--------"); /* If there's a sky_freq parameter, use it, and re-activate the * sky_freq_input control */ if ((p = getenv ("RCVR_SKY_FREQ")) != NULL) { if (abs(atof(p) - frequency) > 100.0) { sky_locked = 0; fl_set_input (fd_receiver_main->sky_freq_input, p); sky_freq = atof(p); fl_activate_object (fd_receiver_main->sky_freq_input); fl_set_button (fd_receiver_main->sky_lock_button, 0); } else { sky_freq = atof(p); fl_set_button (fd_receiver_main->sky_lock_button, 1); sky_locked = 1; } } PUSHVAR("ifreq", frequency); PUSHVAR("skyfreq", sky_freq); /* * * And again for RF gain */ if ((p = getenv ("RCVR_RF_GAIN")) != NULL) { rf_gain = atoi(p); } fl_set_slider_value (fd_receiver_main->rf_gain_slider, rf_gain); PUSHVAR("igain", rf_gain); /* * Gain correction values for A and B sides */ if ((p = getenv ("RCVR_COR_A")) != NULL) { gc_a = atof(p); } sprintf (d, "%f", gc_a); fl_set_input (fd_receiver_main->gc_a, d); if ((p = getenv ("RCVR_COR_B")) != NULL) { gc_b = atof(p); } sprintf (d, "%f", gc_b); fl_set_input (fd_receiver_main->gc_b, d); /* * Set bounds/values for DC gain */ if ((p = getenv ("RCVR_DC_GAIN")) != NULL) { dc_gain = atof(p); } fl_set_slider_value (fd_receiver_main->dc_gain_control, dc_gain); /* * And again for DC offset */ if ((p = getenv ("RCVR_DC_OFFSET")) != NULL) { dc_offset = atof(p); } fl_set_slider_value (fd_receiver_main->dc_offset_control, dc_offset); /* * Receiver DC Gain multiplier */ if ((p = getenv ("RCVR_DC_MULT")) != NULL) { int which; dc_mult = (double)atoi(p); which = 1; /* * It's a choice widget, so we need to set 'which' appropriately */ switch ((int)dc_mult) { case 1: which = 1; break; case 5: which = 2; break; case 10: which = 3; break; case 15: which = 4; break; case 20: which = 5; break; case 25: which = 6; break; case 30: which=7; break; case 35: which = 8; break; case 40: which = 9; break; } fl_set_choice (fd_receiver_main->mult_choice, which); } /* * Total power integration value */ tp_integration = 5; if ((p = getenv ("RCVR_TP_INTEG")) != NULL) { tp_integration = atoi(p); } fl_set_slider_value (fd_receiver_main->continuum_int, (double)atof(getenv("RCVR_TP_INTEG")) ); /* * Spectral integration */ spec_integration = 15; if ((p = getenv ("RCVR_SPEC_INTEG")) != NULL) { spec_integration = atoi(p); } fl_set_slider_value (fd_receiver_main->spec_int_slider, (double)atof(getenv("RCVR_SPEC_INTEG")) ); /* * Sigma_K for SETI analysis */ sigma_k = 2.5; if ((p = getenv ("RCVR_SIGMA_K")) != NULL) { sigma_k = atof(p); } fl_set_slider_value (fd_receiver_main->sigma_k_slider, sigma_k); /* * Check desired receiver mode */ if (getenv("RCVR_MODE") != NULL) { strcpy (rcvr_mode, getenv("RCVR_MODE")); } else { strcpy (rcvr_mode, "unknown"); } /* * Interferometer? Create the interferometer window */ if (strcmp (rcvr_mode, "interferometer") == 0) { fd_receiver_interferometer = create_form_receiver_interferometer(); fl_set_form_atclose (fd_receiver_interferometer->receiver_interferometer, close_sub, hide_interferometer); } /* * Otherwise, delete the "show interferograms" control */ else { fl_delete_object (fd_receiver_main->interferometer_button); } /* * Various values */ declination = -28.3; if ((p = getenv ("RCVR_DECLINATION")) != NULL) { declination = atof(p); } fl_set_input (fd_receiver_main->declination_input, getenv("RCVR_DECLINATION")); longitude = 0.0; if ((p = getenv ("RCVR_LONGITUDE")) != NULL) { longitude = atof(p); } seti_size = 500000; if ((p = getenv ("RCVR_SETI_SIZE")) != NULL) { seti_size = atoi (p); } bandwidth = 5000000; if ((p = getenv ("RCVR_BANDWIDTH")) != NULL) { bandwidth = atoi (p); } psr_rate = 10000; if ((p = getenv ("RCVR_PSR_RATE")) != NULL) { psr_rate = atoi (getenv ("RCVR_PSR_RATE")); } for (i = 0; i < NNOTCHES; i++) { notches[i] = -1.0; } if ((p = getenv ("RCVR_NOTCHES")) != NULL) { char *tp; char pcopy[128]; FILE *fp; strcpy (pcopy, p); tp = strtok (pcopy, ","); notches[0] = atof(tp); for (i = 1; i < NNOTCHES; i++) { tp = strtok (NULL, ","); if (tp == NULL) { break; } notches[i] = atof(tp); } } if ((p = getenv ("RCVR_NOTCH_SIZE")) != NULL) { notch_length = atoi(p); fl_set_slider_value (fd_receiver_spectrum->notch_slider, (double)notch_length); } if ((p = getenv ("RCVR_DM")) != NULL) { pulsar_dm = atof(p); fl_set_slider_value (fd_receiver_main->dm_input, (double)pulsar_dm); } PUSHVAR("idm", pulsar_dm); if ((p = getenv ("PULSAR_RATE")) != NULL) { pulsar_rate = atof(p); fl_set_input (fd_receiver_main->pulsar_rate_input, p); } if ((p = getenv ("PULSAR_FOLDING")) != NULL) { pulsar_folding = atoi(p); fl_set_choice (fd_receiver_main->pulsar_choice, pulsar_folding/5); } /* * Set spec_fft_size based on width of spectral plot display */ { FL_Coord x, y, w, h; fl_get_object_bbox (fd_receiver_spectrum->spectral_plot, &x, &y, &w, &h); spec_fft_size = w-130; } tp_maxval = 100000; tp_span = 20000; /* * Establish parameters for TP plot */ if ((p = getenv("RCVR_TP_MAXVAL")) != NULL) { tp_maxval = (double)atoi(p); } if ((p = getenv ("RCVR_TP_SPAN")) != NULL) { tp_span = (double)atoi(p); } tp_minval = tp_maxval - tp_span; fl_set_slider_value (fd_receiver_continuum->tp_max_slider, (double)tp_maxval); fl_set_slider_value (fd_receiver_continuum->tp_span_slider, (double)tp_span); fl_set_xyplot_ybounds(fd_receiver_continuum->tp_chart, (double)tp_minval, (double)tp_maxval); fl_set_xyplot_ytics(fd_receiver_continuum->tp_chart, 10, 1); fl_set_xyplot_xgrid (fd_receiver_continuum->tp_chart, FL_GRID_MINOR); fl_set_xyplot_ygrid (fd_receiver_continuum->tp_chart, FL_GRID_MINOR); fl_set_object_posthandler(fd_receiver_continuum->tp_chart, continuum_plot_post); /* * Set a post handler for inteferometer display */ if (strcmp (rcvr_mode, "interferometer") == 0) { fl_set_object_posthandler(fd_receiver_interferometer->interferometer_chart, continuum_plot_post); if ((p = getenv ("RCVR_INT_GAIN")) != NULL) { interferometer_gain = atof(p); } if ((p = getenv ("RCVR_INT_SPAN")) != NULL) { interferometer_span = atof(p); } if ((p = getenv ("RCVR_PHCORR")) != NULL) { interferometer_phase = atof(p); } if ((p = getenv ("RCVR_DELAY")) != NULL) { interferometer_delay = atof(p); } fl_set_xyplot_ytics (fd_receiver_interferometer->interferometer_chart, 10, 1); fl_set_xyplot_xgrid (fd_receiver_interferometer->interferometer_chart, FL_GRID_MINOR); fl_set_xyplot_ygrid (fd_receiver_interferometer->interferometer_chart, FL_GRID_MINOR); fl_set_slider_value (fd_receiver_interferometer->int_gain_slider, interferometer_gain); fl_set_slider_value (fd_receiver_interferometer->int_span_slider, interferometer_span); fl_set_slider_value (fd_receiver_interferometer->phase_adjust, interferometer_phase); fl_set_slider_value (fd_receiver_interferometer->delay_adjust, interferometer_delay); fl_set_xyplot_ybounds (fd_receiver_interferometer->interferometer_chart, -1*interferometer_span, interferometer_span); } fl_add_timeout (1000.0, (FL_TIMEOUT_CALLBACK)lmst_update, 0); /* * Setup parameters for spectral plot */ if ((p = getenv ("RCVR_SPEC_MAX")) != NULL) { current_smax = atoi(p); } if ((p = getenv ("RCVR_SPEC_SPAN")) != NULL) { current_span = atoi(p); } if ((p = getenv ("RCVR_SPEC_FLAT")) != NULL) { spec_flat_on = atoi(p); fl_set_button (fd_receiver_spectrum->flaten_button, spec_flat_on); } if ((p = getenv ("RCVR_SPEC_METHOD")) != NULL) { spec_method = atoi (p); } fl_set_xyplot_xgrid(fd_receiver_spectrum->spectral_plot, FL_GRID_MINOR); fl_set_xyplot_ygrid(fd_receiver_spectrum->spectral_plot, FL_GRID_MINOR); fl_set_xyplot_ybounds(fd_receiver_spectrum->spectral_plot, (double)(current_smax-current_span), (double) current_smax); fl_set_xyplot_ytics(fd_receiver_spectrum->spectral_plot, 10, 1); fl_set_xyplot_xtics(fd_receiver_spectrum->spectral_plot, 10, 1); fl_set_object_posthandler(fd_receiver_spectrum->spectral_plot, spectral_plot_post); fl_set_choice (fd_receiver_spectrum->spec_method_choice, spec_method); fl_set_choice_fontsize (fd_receiver_spectrum->spec_method_choice, 14); fl_set_slider_value (fd_receiver_spectrum->spec_max_slider, (double)current_smax); fl_set_slider_value (fd_receiver_spectrum->spec_span_slider, (double)current_span); /* * Set post handler for pulsar display */ fl_set_object_posthandler(fd_receiver_pulsar->pulsar_plot, pulsar_plot_post); /* * Set parameters for waterfall (SETI) display */ { FL_Coord x, y; FL_Coord w, h; fl_get_object_bbox(fd_receiver_waterfall->waterfall_display, &x, &y, &w, &h); fl_set_slider_bounds (fd_receiver_waterfall->wfall_seg_slider, 1.0, (float)seti_size/w); fl_set_object_dblbuffer(fd_receiver_waterfall->waterfall_display, 1); if ((p = getenv ("RCVR_WFALL_SEGMENT")) != NULL) { waterfall_segment = atoi(p); fl_set_slider_value (fd_receiver_waterfall->wfall_seg_slider, (double)waterfall_segment); } if ((p = getenv ("RCVR_WFALL_FINE")) != NULL) { waterfall_fine = atoi(p); fl_set_slider_value (fd_receiver_waterfall->fine_segment, waterfall_fine); } if ((p = getenv ("RCVR_WFALL_BRIGHTNESS")) != NULL) { double w; w = atof(p); if (fabsf(w-1.0) < 0.1) { fl_set_choice (fd_receiver_waterfall->wfall_brightness, 1); w = 1.0; } if (fabsf(w-0.75) < 0.1) { fl_set_choice (fd_receiver_waterfall->wfall_brightness, 2); w = 0.75; } if (fabsf(w-0.66) < 0.1) { fl_set_choice (fd_receiver_waterfall->wfall_brightness, 3); w = 0.66; } if (fabsf(w-0.50) < 0.1) { fl_set_choice (fd_receiver_waterfall->wfall_brightness, 4); w = 0.50; } waterfall_brightness = (float)w; } } if ((p = getenv ("RCVR_TRANS_THRESH")) != NULL) { transient_threshold = atof(p); fl_set_slider_value (fd_receiver_main->trans_thr_slider, transient_threshold); } if ((p = getenv ("RCVR_TRANS_DUR")) != NULL) { transient_duration = atof(p); fl_set_slider_value (fd_receiver_main->trans_dur_slider, transient_duration); } /* * Open various FIFOs--that's where we get our data from */ if ((seti_fd = open ("ra_seti_fifo", O_RDONLY|O_NONBLOCK)) > 0) { fcntl (seti_fd, F_SETFL, 0); fl_add_io_callback (seti_fd, FL_READ, (FL_IO_CALLBACK)handle_seti_io, fd_receiver_main); } if ((pulsar_fd = open ("ra_psr_fifo", O_RDONLY|O_NONBLOCK)) > 0) { fcntl (pulsar_fd, F_SETFL, 0); fl_add_io_callback (pulsar_fd, FL_READ, (FL_IO_CALLBACK)handle_pulsar_io, fd_receiver_main); } if ((dicke_fd = open ("ra_switching_fifo", O_RDONLY|O_NONBLOCK)) > 0) { fcntl (dicke_fd, F_SETFL, 0); fl_set_object_label (fd_receiver_main->dicke_mode, "DICKE: ON"); fl_add_io_callback (dicke_fd, FL_READ, (FL_IO_CALLBACK)handle_dicke_io, fd_receiver_main); } if (strcmp (rcvr_mode, "interferometer") == 0) { if ((inter_fd = open ("ra_inter_fifo", O_RDONLY|O_NONBLOCK)) > 0) { fcntl (inter_fd, F_SETFL, 0); fl_add_io_callback (inter_fd, FL_READ, (FL_IO_CALLBACK)handle_inter_io, fd_receiver_main); } } if (strcmp (rcvr_mode, "split") == 0) { if ((validation_fd = open ("ra_validation_fifo", O_RDONLY|O_NONBLOCK)) > 0) { fcntl (validation_fd, F_SETFL, 0); split_mode = 1; fl_add_io_callback (validation_fd, FL_READ, (FL_IO_CALLBACK)handle_validation_io, fd_receiver_main); } } fl_set_oneliner_font (FL_FIXEDBOLDITALIC_STYLE, FL_MEDIUM_FONT); fl_set_oneliner_color (FL_GREEN, FL_BLACK); while(fl_do_forms()) ; return 0; }
void handleServInp(int socket, void *data) { int br; char locBuf[]="\0\0"; if ((br=read(socket, &locBuf[0], 1)) == 1) { if (LoseNextChar) { LoseNextChar=FALSE; return; } strcat(&ServBuf[0], &locBuf[0]); /* Check for Newline */ if (locBuf[0] == '\n') { /* Parse it */ fe_parse(ServBuf); ServBuf[0]='\0'; } else { /* Check for a prompt line */ if (DoingLogin) { if ((locBuf[0] == ':') && (ServBuf[0] == ':') && (ServBuf[1] != '\0')) { fl_addto_browser_chars(fd_ImpFeMain->MainBrowser, ServBuf); if (strcmp(ServBuf, ":Enter player name:") == 0) { LoseNextChar=TRUE; if (game_player[0] != '\0') { write_str("!"); write_str(game_player); write_str("\n"); fl_addto_browser_chars(fd_ImpFeMain->MainBrowser, game_player); fl_addto_browser_chars(fd_ImpFeMain->MainBrowser, "\n"); } } else if (strcmp(ServBuf, ":Enter player password:"******"\n"); fl_addto_browser_chars(fd_ImpFeMain->MainBrowser, game_player_pswd); fl_addto_browser_chars(fd_ImpFeMain->MainBrowser, "\n"); } DoingLogin=FALSE; } ServBuf[0]='\0'; } } } } else { /* Remove the callback */ fl_remove_io_callback(GameSocket, MyCond, handleServInp); /* Close the socket */ close(GameSocket); GameSocket=-1; fl_set_menu_item_mode(fd_ImpFeMain->MainServerMenu, MAIN_SERVER_MENU_CLOSE, FL_PUP_GREY); fl_set_menu_item_mode(fd_ImpFeMain->MainServerMenu, MAIN_SERVER_MENU_OPEN, FL_PUP_NONE); fl_set_object_label(fd_ImpFeMain->StatusBox, "Offline"); fe_puts("*** Connection to server terminated...\n"); AtMainPrompt=FALSE; } }
/* * buildShDetDisp - Clears the existing contents of the ship detail * window and redraws it based on current known * ships. */ void buildShDetDisp(void) { ULONG itNum; USHORT num_comp=0, num_eng=0, num_life=0, num_wpn=0, num_elect=0; FeShip_t tmpShip; FeItem_t tmpItem; int compChar, engChar, lifeChar, photChar, blasChar, sensChar, shldChar, telepChar, tractChar; char workBuf[90], nameBuf[10], itType, location[15], tBuff[28], inst; /* Speed up output */ fl_freeze_form(fd_ShipDetailForm->ShipDetailForm); /* Clear the existing contents, if any */ fl_clear_browser(fd_ShipDetailForm->ShDetItem); compChar = (int) BIG_PART_CHAR[bp_computer]; engChar = (int) BIG_PART_CHAR[bp_engines]; lifeChar = (int) BIG_PART_CHAR[bp_lifeSupp]; photChar = (int) BIG_PART_CHAR[bp_photon]; blasChar = (int) BIG_PART_CHAR[bp_blaser]; sensChar = (int) BIG_PART_CHAR[bp_sensors]; shldChar = (int) BIG_PART_CHAR[bp_shield]; telepChar = (int) BIG_PART_CHAR[bp_teleport]; tractChar = (int) BIG_PART_CHAR[bp_tractor]; /* Loop for each known big item */ for (itNum=0; itNum < next_item; itNum++) { /* Make sure the item has been seen and is on the ship */ if (!readItem(&tmpItem, itNum)) { continue; } if ((tmpItem.last_seen != 0) && (tmpItem.where == LastShip) && !(tmpItem.flags & BF_ONPLAN)) { if (tmpItem.owner != 0) { strncpy(nameBuf, Player[tmpItem.owner].name, 9); nameBuf[9] = '\0'; } else { strcpy(nameBuf, "???"); } if (tmpItem.type != 0) { itType=tmpItem.type; } else { itType='?'; } /* Check if it is installed, or just cargo */ if (tmpItem.flags & BF_INSTALL) { /* Installed */ inst='Y'; /* Increment our running counts */ if (itType == tractChar) { num_comp++; } else if (itType == engChar) { num_eng++; } else if (itType == lifeChar) { num_life++; } else if ((itType == photChar) || (itType == blasChar)) { num_wpn++; } else if ((itType == sensChar) || (itType == shldChar) || (itType == telepChar) || (itType == tractChar)) { num_elect++; } } else { /* Not installed, just being carried */ inst=' '; } sprintf(workBuf, "%8u %c %3u %3u %5u %c", itNum, itType, tmpItem.it_tf, tmpItem.efficiency, tmpItem.weight, inst); fl_add_browser_line(fd_ShipDetailForm->ShDetItem, workBuf); } } /* read the ship in */ (void) readShip(&tmpShip, LastShip); /* Update using the counts we saw before */ tmpShip.num_comp = num_comp; tmpShip.num_eng = num_eng; tmpShip.num_life = num_life; tmpShip.num_wpn = num_wpn; tmpShip.num_elect = num_elect; /* Write ship back */ (void) writeShip(&tmpShip, LastShip); sprintf(workBuf, "%u", tmpShip.fuelLeft); fl_set_object_label(fd_ShipDetailForm->Fuel, workBuf); sprintf(workBuf, "%u", tmpShip.energy); fl_set_object_label(fd_ShipDetailForm->Energy, workBuf); sprintf(workBuf, "%u", tmpShip.armourLeft); fl_set_object_label(fd_ShipDetailForm->Armor, workBuf); sprintf(workBuf, "%u", tmpShip.shields); fl_set_object_label(fd_ShipDetailForm->Shields, workBuf); sprintf(workBuf, "%u", tmpShip.shieldsKeep); fl_set_object_label(fd_ShipDetailForm->ShKeep, workBuf); sprintf(workBuf, "%u", tmpShip.airLeft); fl_set_object_label(fd_ShipDetailForm->Air, workBuf); sprintf(workBuf, "%u", tmpShip.efficiency); fl_set_object_label(fd_ShipDetailForm->Effic, workBuf); sprintf(workBuf, "%u", tmpShip.sh_tf); fl_set_object_label(fd_ShipDetailForm->TF, workBuf); sprintf(workBuf, "%u", tmpShip.hullTF); fl_set_object_label(fd_ShipDetailForm->HullTF, workBuf); sprintf(workBuf, "%u", tmpShip.engTF); fl_set_object_label(fd_ShipDetailForm->EngTF, workBuf); sprintf(workBuf, "%u", tmpShip.engEff); fl_set_object_label(fd_ShipDetailForm->EngEff, workBuf); if (tmpShip.plagueStage != 0) { fl_set_object_label(fd_ShipDetailForm->Plague, "YES"); } else { fl_set_object_label(fd_ShipDetailForm->Plague, "NO"); } sprintf(workBuf, "%u", tmpShip.num_civ); fl_set_object_label(fd_ShipDetailForm->Civ, workBuf); sprintf(workBuf, "%u", tmpShip.num_sci); fl_set_object_label(fd_ShipDetailForm->Sci, workBuf); sprintf(workBuf, "%u", tmpShip.num_mil); fl_set_object_label(fd_ShipDetailForm->Mil, workBuf); sprintf(workBuf, "%u", tmpShip.num_ofc); fl_set_object_label(fd_ShipDetailForm->Ofc, workBuf); sprintf(workBuf, "%u", tmpShip.num_torp); fl_set_object_label(fd_ShipDetailForm->Torp, workBuf); sprintf(workBuf, "%u", tmpShip.num_ore); fl_set_object_label(fd_ShipDetailForm->Ore, workBuf); sprintf(workBuf, "%u", tmpShip.num_gold); fl_set_object_label(fd_ShipDetailForm->Bars, workBuf); sprintf(workBuf, "%u", tmpShip.num_airt); fl_set_object_label(fd_ShipDetailForm->AirTnk, workBuf); sprintf(workBuf, "%u", tmpShip.num_ftnk); fl_set_object_label(fd_ShipDetailForm->FuelTnk, workBuf); sprintf(workBuf, "%u", tmpShip.cargo); fl_set_object_label(fd_ShipDetailForm->Cargo, workBuf); strcpy(workBuf, ctime(&tmpShip.last_seen)); workBuf[24]='\0'; /* strip off NL */ fl_set_object_label(fd_ShipDetailForm->Seen, workBuf); sprintf(workBuf, "%u", LastShip); fl_set_object_label(fd_ShipDetailForm->ShNum, workBuf); sprintf(workBuf, "%u,%u", tmpShip.sh_row, tmpShip.sh_col); fl_set_object_label(fd_ShipDetailForm->RowCol, workBuf); if (tmpShip.owner != 0) { strcpy(workBuf, Player[tmpShip.owner].name); } else { strcpy(workBuf, "???"); } fl_set_object_label(fd_ShipDetailForm->Owner, workBuf); if (tmpShip.flags & BF_ONPLAN) { sprintf(workBuf, "Ship is on planet %u", tmpShip.planet); fl_set_object_label(fd_ShipDetailForm->Where, workBuf); } else { fl_set_object_label(fd_ShipDetailForm->Where, "Ship is in space"); } fl_unfreeze_form(fd_ShipDetailForm->ShipDetailForm); }
void lmst_update (FL_OBJECT *ob, long data) { struct tm *ltp; time_t now; unsigned char sid[6]; char lmst_buf[64]; FILE *fp; int i, j; FL_Coord x, y; FL_Coord w, h; double high, low; char *p; int delta; int hours, mins, secs; fl_add_timeout (1000.0, (FL_TIMEOUT_CALLBACK)lmst_update, 0); /* * Determine current LMST */ time (&now); ltp = gmtime (&now); get_sid_time (sid, longitude, ltp); memcpy (current_lmst, sid, 3); sprintf (lmst_buf, "%02d:%02d:%02d", sid[0], sid[1], sid[2]); fl_set_object_label(fd_receiver_main->lmst_display, lmst_buf); delta = now - started_at; hours = delta / 3600; mins = (delta - (hours * 3600)) / 60; secs = (delta - ((hours * 3600) + (mins*60))); sprintf (lmst_buf, "%02d:%02d:%02d", hours, mins, secs); fl_set_object_label (fd_receiver_main->runtime_text, lmst_buf); ra_mode[0] = 0x00; dec_mode[0] = 0x00; if ((p = getenv ("RCVR_RA_MODE")) != NULL) { strcpy (ra_mode, p); if (strcmp (p, "transit") == 0) { ra = (float)sid[0] + (float)sid[1]/60.0 + (float)sid[2]/3600.0; sprintf (lmst_buf, "%f", ra); fl_set_input (fd_receiver_main->ra_input, lmst_buf); } else if (strncmp (p, "external", 8) == 0) { char keyword[128], filename[128]; sscanf (p, "%s %s", keyword, filename); if ((fp = fopen (filename, "r")) != NULL) { fscanf (fp, "%f", &ra); sprintf (lmst_buf, "%f", ra); fl_set_input (fd_receiver_main->ra_input, lmst_buf); fclose(fp); } } } if ((p = getenv ("RCVR_DEC_MODE")) != NULL) { strcpy (dec_mode, p); if (strncmp (p, "external", 8) == 0) { char keyword[128], filename[128]; sscanf (p, "%s %s", keyword, filename); if ((fp = fopen (filename, "r")) != NULL) { fscanf (fp, "%f", &declination); sprintf (lmst_buf, "%f", declination); fl_set_input (fd_receiver_main->declination_input, lmst_buf); fclose(fp); } } } dump_params (); time (&now); if ((startup_cleared > 0) && (last_io_time > 1000) && ((now - last_io_time) > 30)) { if (no_more_input == 0) { fprintf (stderr, "Leaving from %s\n", __FUNCTION__); receiver_leave (NULL, -10); } } if (startup_cleared > 0) { time (&now); /* * We know that the python script has started and can now take * XMLRPC commands, because it's sending us data, so update * some variables, *once*. */ if (writeback_flag == 0) { void write_pushed_variables(void); writeback_flag = 1; /* * Write (via XMLRPC) all our "pushed" variables * into the Gnu Radio flowgraph. */ write_pushed_variables(); write_notches (); } /* * Set the warning levels for I/O lag from Gnu Radio flowgraph */ if ((now - last_io_time) <= 1) { fl_set_object_color (fd_receiver_main->io_status, FL_GREEN, FL_GREEN); } else if ((now - last_io_time) < 8) { fl_set_object_color (fd_receiver_main->io_status, FL_YELLOW, FL_YELLOW); } else if ((now - last_io_time) >= 8) { fl_set_object_color (fd_receiver_main->io_status, FL_RED, FL_RED); } } }
void plot_graphes_dl(int src, int dst, int ctime) //eNB -->UE { int i, dst_idx=1, curve_id=1; char loss_rate[100]; char curve_label[100]; char simu_time[100]; int x_key_position=27; int y_key_position=75; if (otg_forms_info->idx_dl[src][dst]==MAX_SAMPLES-1){ fl_update_display(1); //the function flushes the X buffer so the drawing requests are on their way to the server if (otg_forms_info->is_data_plot_dl == -1) otg_forms_info->is_data_plot_dl=dst; if (otg_forms_info->is_data_plot_dl == dst) { fl_set_xyplot_data (form_dl->owd, otg_forms_info->data_ctime_dl[src][dst], otg_forms_info->data_owd_dl[src][dst], otg_forms_info->idx_dl[src][dst], "", "time", "ms"); sprintf(curve_label, "%d%s%d", src,"-->", dst); fl_set_xyplot_key(form_dl->owd, 0, curve_label); fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT); fl_set_xyplot_data (form_dl->throughput, otg_forms_info->data_ctime_dl[src][dst], otg_forms_info->data_throughput_dl[src][dst], otg_forms_info->idx_dl[src][dst], "", "time", "kbit/s"); sprintf(curve_label, "%d%s%d", src,"-->", dst); fl_set_xyplot_key(form_dl->throughput, 0, curve_label); fl_set_xyplot_key_position(form_dl->throughput, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT); otg_kpi_nb_loss_pkts(); sprintf(loss_rate, "%s%d","NB Loss pkts DL=",otg_info->total_loss_dl); fl_set_object_label(form_dl->loss_ratio, loss_rate); sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime); fl_set_object_label(form_dl->simu_time, simu_time); } else { fl_set_xyplot_data (form_dl->owd, otg_forms_info->data_ctime_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->data_owd_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->idx_dl[src][otg_forms_info->is_data_plot_dl], "", "time", "ms"); sprintf(curve_label, "%d%s%d", src,"-->", otg_forms_info->is_data_plot_dl); fl_set_xyplot_key(form_dl->owd, 0, curve_label); fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT); fl_set_xyplot_data (form_dl->throughput, otg_forms_info->data_ctime_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->data_throughput_dl[src][otg_forms_info->is_data_plot_dl], otg_forms_info->idx_dl[src][otg_forms_info->is_data_plot_dl], "", "time", "kB/s"); sprintf(curve_label, "%d%s%d", src,"-->",otg_forms_info->is_data_plot_dl); fl_set_xyplot_key(form_dl->throughput, 0, curve_label); fl_set_xyplot_key_position(form_dl->throughput,x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT); otg_kpi_nb_loss_pkts(); sprintf(loss_rate, "%s%d","NB Loss pkts DL=",otg_info->total_loss_dl); fl_set_object_label(form_dl->loss_ratio, loss_rate); sprintf(simu_time, "%s%d","Simulation Time(ms)=", ctime); fl_set_object_label(form_dl->simu_time, simu_time); } for (dst_idx=1;dst_idx<=NB_UE_INST;dst_idx++){ if (dst_idx!=otg_forms_info->is_data_plot_dl){ fl_add_xyplot_overlay(form_dl->owd,curve_id++, otg_forms_info->data_ctime_dl[src][dst_idx], otg_forms_info->data_owd_dl[src][dst_idx], otg_forms_info->idx_dl[src][dst_idx],dst_idx+6); sprintf(curve_label, "%d%s%d", src,"-->", dst_idx); fl_set_xyplot_key(form_dl->owd, curve_id-1, curve_label); fl_set_xyplot_key_position(form_dl->owd, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT); fl_add_xyplot_overlay(form_dl->throughput,curve_id++, otg_forms_info->data_ctime_dl[src][dst_idx], otg_forms_info->data_throughput_dl[src][dst_idx], otg_forms_info->idx_dl[src][dst_idx],dst_idx+6); sprintf(curve_label, "%d%s%d", src,"-->", dst_idx); fl_set_xyplot_key(form_dl->throughput, curve_id-1, curve_label); fl_set_xyplot_key_position(form_dl->throughput, x_key_position,y_key_position, FL_ALIGN_BOTTOM_LEFT); } } for (i=0;i<otg_forms_info->idx_dl[src][dst];i++){ otg_forms_info->data_ctime_dl[src][dst][otg_forms_info->idx_dl[src][dst]]=i; otg_forms_info->data_owd_dl[src][dst][i]= otg_forms_info->data_owd_dl[src][dst][i+1]; otg_forms_info->data_throughput_dl[src][dst][i]= otg_forms_info->data_throughput_dl[src][dst][i+1]; } otg_forms_info->idx_dl[src][dst]--; } fl_check_forms(); }