void workbook_style_test (Workbook *wb) { GSList *sheets; g_return_if_fail (wb != NULL); sheets = workbook_sheets (wb); while (sheets) { Sheet *sheet = sheets->data; fprintf (stderr, "Style lookups on '%s'\n", sheet->name_unquoted); sheet_styles_dump (sheet); #ifdef RUN_THRASH_SCROLL zero_stats (); thrash_scroll (sheet); dump_stats ("Scroll"); #endif zero_stats (); thrash_insert (sheet); dump_stats ("Insert"); sheets = g_slist_remove (sheets, sheet); sheet_flag_recompute_spans (sheet); } workbook_recalc (wb); workbook_calc_spans (wb, GNM_SPANCALC_RENDER); }
void timer_handle_transfer_statistics (time_t stime, time_t *trottime, time_t *justone, statistics_t *trotstat) { if (get_time() != *justone) { *justone = get_time(); if ((stime % 86400) == 0) { statistics_t stat, hourlystats; get_hourly_stats(&hourlystats); zero_stats(&info.hourly_stats); update_daily_statistics(&hourlystats); get_daily_stats(&stat); zero_stats(&info.daily_stats); update_total_statistics(&stat); write_daily_stats(&stat); } else if ((stime % 3600) == 0) { statistics_t stat; get_hourly_stats(&stat); zero_stats(&info.hourly_stats); update_daily_statistics(&stat); write_hourly_stats(&stat); } if ((stime % 60) == 0) { time_t delta; statistics_t stat; unsigned int total_bytes; double KB_per_sec = 0; get_running_stats(&stat); if (*trottime == 0) { *trottime = get_time(); get_running_stats(trotstat); } else { total_bytes = (stat.read_kilos - trotstat->read_kilos) + (stat.write_kilos - trotstat->write_kilos); delta = get_time() - *trottime; if (delta <= 0) { android_log(ANDROID_LOG_VERBOSE, "ERROR: Losing track of time.. is it xmas already? [%d - %d == %d <= 0]", get_time (), *trottime, delta); } else { KB_per_sec = (double)total_bytes / (double)delta; if (KB_per_sec < 40000000) { info.bandwidth_usage = KB_per_sec; } } get_running_stats(trotstat); *trottime = get_time(); } } } }
/* free player so someone else can use this slot */ void free_player(int pno) { Track *track; checkBadPlayerNo(pno,"in reset_player\n"); ERROR(3,("Freeing player %d\n",pno)); track = &tracks[pno]; zero_stats(track); track->t_score = 0.0; /* - nbt track->t_flags = 0; */ /* track->t_flags = PU_FILLER; */ track->t_flags = PU_SITOUT; track->t_seconds = 0; track->t_opponent = -1; track->t_wait = 0; /* resets tournament stats of player */ track->t_pos = -1; memset(&(track->t_stats), 0, sizeof(DogStat)); track->t_stats.d_ticks = 1; }
/* fully reset this guy This throws the player out of the contest It is generally appropriate to use dont_score() with this */ void reset_player(int pno) { Track *track; checkBadPlayerNo(pno,"in reset_player\n"); #ifdef DOGDEBUG ERROR(2,("Resetting %d\n",pno)); #endif track = &tracks[pno]; zero_stats(track); track->t_opponent = -1; track->t_wait = 0; if ((inprogress == 2) && (track->t_flags & PU_CONTEST)) track->t_flags = PU_CONTEST; else if (track->t_flags & PU_SITOUT) track->t_flags = PU_SITOUT; else track->t_flags = 0; do_teleport_home(pno); track->t_score = 0.0; track->t_seconds = 0; }
void get_current_stats_proc (statistics_t *stat, int lock) { avl_traverser trav = {0}; time_t ec = 0, cc = 0; connection_t *travcon; zero_stats(stat); if (lock) thread_mutex_lock(&info.double_mutex); thread_mutex_lock(&info.source_mutex); ec = (time_t)tree_time(info.sources); while ((travcon = avl_traverse(info.sources, &trav))) { thread_mutex_lock(&travcon->food.source->mutex); cc += (time_t)tree_time(travcon->food.source->clients); thread_mutex_unlock(&travcon->food.source->mutex); } thread_mutex_unlock(&info.source_mutex); if (lock) thread_mutex_unlock(&info.double_mutex); stat->client_connect_time = cc; stat->source_connect_time = ec; }
struct cmd_result * treat_cmd(struct cmd *command,void *sdata) { struct acq_workspace *ws=(struct acq_workspace *)sdata; int id1,id2,id3,id4,id5; struct data_descriptor *current_ctrl; int i; char * encoded; char *sres; int streamid; struct generic_buffer *acq_buffer; unsigned char *binary_data; struct cmd_result *res=malloc(sizeof(struct cmd_result)); res->retcode=-1; res->str=NULL; printf("********************* NEW COMMAND **********************\n"); printf("executing local function %s with %d params : \n",command->name,command->nb_params); for (i=0;i<command->nb_params;i++) { printf("param%d=%s\n",i,command->params[i]); } if (!strcmp(command->name,"init_acq")) { //param 0 : datadir //param 1 : varmod IP (or undef) if (ws->initialized!=0) { res->str=strdup("acq has been already been initialized"); res->retcode=1; return res; } if (command->nb_params<2) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"init_acq, %d arguments given, 2 needed",command->nb_params-1); return res; } //initializing the stats init_stats(ws,command->params[1]); //initializing the acquisition init_acquisition(ws,command->params[0]); //initializing the scheduler init_burst_detector(ws); //initializing all the other modules launch_consumer_chain(ws); //initialization is done ws->initialized=1; res->str=strdup("acquisition initialized"); res->retcode=1; return res; } //******************************************** if (!strcmp(command->name,"deinit_acq")) { if (ws->initialized!=1) { res->str=strdup("ethacq is not initialized"); res->retcode=1; return res; } //deinit the acquisition deinit_acquisition(ws); //stopping all the treatment modules stop_consumer_chain(ws); //deinit the scheduler deinit_burst_detector(ws); //initializing the stats deinit_stats(ws); //close and free the streams structures ws->nb_streams=0; //deinit is done ws->initialized=0; //return ok res->str=strdup("acquisition deinitialized"); res->retcode=1; return res; } //******************************************** //stop any other command until initialize is completed if (ws->initialized==0) { res->str=strdup("cmd are forbidden while acq not initialized"); res->retcode=0; return res; } //******************************************** if (!strcmp(command->name,"newunit_acq")) { //param 0 : nb_streams //param 1 : name of the acq library //param 2 : name of the uncap library //param 3 : stream_suffix //param 4 : specific param 1 //param 5 : specific param 2 //param 6 : specific param 3 if (command->nb_params<7) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"newunit_acq, %d arguments given, 7 needed",command->nb_params-1); return res; } //get first stream id int nbs=iohtoi(command->params[0]); int fid=ws->nb_streams; printf("nbs=%d fid=%d\n",nbs,fid); //create the workspace for the new unit printf("creating newunit workspace\n"); struct acqunit_workspace * newunit=make_acq_unit(nbs,fid,command->params[1],command->params[2],command->params[3],ws); if (newunit==NULL) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"error loading plugins"); return res; } //initialize acquisition library printf("initializing acquisition library\n"); newunit->specws=(newunit->init_acq)(command->params[4],command->params[5],command->params[6]); //initialize uncap library printf("initializing uncap library\n"); newunit->uncapws=(newunit->init_uncap)(nbs,fid,command->params[1]); //we initialize the nb of streams ws->nb_streams+=nbs; //initializing the streams printf("initializing the streams\n"); newunit->streams=malloc(nbs*sizeof(struct stream_workspace)); for(i=0;i<nbs;i++) { printf("creating stream %d with id %d\n",i,fid+i); newunit->streams[i].id=fid+i; newunit->streams[i].output=-1; newunit->streams[i].socket=NULL; newunit->streams[i].shdata=NULL; newunit->streams[i].acqunit=newunit; ws->streams[i+fid]=newunit->streams[i]; } //store the newunit in the main ws printf("linking the new unit\n"); newunit->next=ws->acqunits; ws->acqunits=newunit; //open new files printf("open the new files\n"); opennew_files(ws); //open new sockets printf("open the new sockets\n"); opennew_socket(ws); //open new shared buffers printf("open the new shared buffers\n"); opennew_shmem(ws); //start the thread printf("Starting the acquisition thread\n"); if (pthread_create(&(newunit->t_acquisition),NULL,acquisition,newunit)<0) { perror("pthread_create"); exit(1); } pthread_detach(newunit->t_acquisition); //attach an id to the acqunit newunit->auid=ws->nb_acqunits; ws->nb_acqunits++; //return the acqunit id as a result res->str=malloc(2048); sprintf(res->str,"%d",newunit->auid); res->retcode=1; return res; } //******************************************** if (!strcmp(command->name,"get_cpkt_byid_acq")) { //the five params are the five generic ids used freely by the uncap library //check the number of parameters if (command->nb_params<5) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"get_cpkt_byid_acq, %d arguments given, 5 needed",command->nb_params-1); return res; } //extract the parameters id1=iohtoi(command->params[0]); //this is the auid id2=iohtoi(command->params[1]); //this is id1 of uncap plugin id3=iohtoi(command->params[2]); //this is id2 of uncap plugin id4=iohtoi(command->params[3]); //this is id3 of uncap plugin id5=iohtoi(command->params[4]); //this is id4 of uncap plugin printf("searching for %x %x %x %x %x :\n",id1,id2,id3,id4,id5); for(i=1;i<10;i++) { //we try 10 times //wait for packet to come - the more chess we have the longer we wait usleep(i*50000); //search the packet in the ctrl fifo current_ctrl=ws->begin_ctrl; while(current_ctrl!=ws->end_ctrl) { if (current_ctrl->id==-1) { current_ctrl=current_ctrl->next; continue; } if (id1==current_ctrl->auws->auid) //the auid is good if ((current_ctrl->auws->select_packet_uncap)(current_ctrl->auws->uncapws,current_ctrl->generic_buffer->data,id2,id3,id4,id5)) { //result found, encode and send back encoded=encode_packet(current_ctrl->generic_buffer->data,current_ctrl->generic_buffer->size); res->str=strdup(encoded); free(encoded); res->retcode=1; //remove the found packet current_ctrl->id=-1; return res; } //if found current_ctrl=current_ctrl->next; } } //Three chess, we give up res->str=strdup("no packet with this id"); res->retcode=0; return res; } //************************************* if (!strcmp(command->name,"zero_stats_acq")) { zero_stats(ws); res->str=strdup("ok"); res->retcode=1; return res; } //************************************* if (!strcmp(command->name,"start_acq")) { printf("starting acquisition\n"); res->str=malloc(2048); memset(res->str,0,2048); if(ws->transfer_file != -1) { start_acquisition(ws); res->retcode=1; sprintf(res->str,"acquisition started"); } else { sprintf(res->str,"unknown directory : %s",ws->datadir); res->retcode=0; } return res; } //************************************* if (!strcmp(command->name,"stop_acq")) { printf("stoping acquisition\n"); stop_acquisition(ws); res->str=strdup("acquisition stopped"); res->retcode=1; return res; } //************************************* if (!strcmp(command->name,"set_refclock_acq")) { if (command->nb_params<1) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"set_refclock_acq, %d arguments given, 1 needed",command->nb_params-1); return res; } strcpy(ws->refclock,command->params[0]); //return result res->str=strdup("clock set"); res->retcode=1; return res; } //************************************* if (!strcmp(command->name,"inject_data_acq")) { printf("injecting data\n"); if (command->nb_params<2) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"inject_data_acq, %d arguments given, 2 needed",command->nb_params-1); return res; } //finding the corresponding stream streamid=iohtoi(command->params[0]); if (streamid>=ws->nb_streams) { res->str=strdup("no stream with that id"); res->retcode=0; return res; } //create a new buffer acq_buffer=get_generic_buffer(ws->bpool); //copy the data binary_data=decode_binary_data(command->params[1],&acq_buffer->size); strncpy((char *)acq_buffer->data,(const char *)binary_data,acq_buffer->size); free(binary_data); //fill a data descriptor with this packet insert_new_data_descriptor(ws,acq_buffer,ws->streams[streamid].acqunit,0); //return result res->str=strdup("data injected"); res->retcode=1; return res; } //************************************* if (!strcmp(command->name,"get_stats_acq")) { sres=get_stats(ws); res->str=sres; res->retcode=1; return res; } //************************************* if (!strcmp(command->name,"flush_files_acq")) { printf("flushing files\n"); if (get_acqstate(ws)!=0) { res->str=strdup("acquisition is still active, cant flush"); res->retcode=0; return res; } if (!strcmp(command->params[0],"")) { printf("no prefix given : using noname as prefix\n"); flush_files("noname",ws); res->str=strdup("files flushed with prefix noname"); } else { flush_files(command->params[0],ws); res->str=strdup("files flushed"); } res->retcode=1; return res; } //************************************* if (!strcmp(command->name,"start_shmem_acq")) { ws->active_shmem=1; res->retcode=1; res->str=strdup("Shared memory active"); return res; } //************************************* if (!strcmp(command->name,"stop_shmem_acq")) { ws->active_shmem=0; res->retcode=1; res->str=strdup("Shared memory inactive"); return res; } //************************************* if (!strcmp(command->name,"start_bsched_acq")) { ws->bsched_active=1; res->retcode=1; res->str=strdup("Burst scheduler active"); return res; } //************************************* if (!strcmp(command->name,"stop_bsched_acq")) { ws->bsched_active=0; res->retcode=1; res->str=strdup("Burst scheduler inactive"); return res; } //************************************* if (!strcmp(command->name,"allow_autoflush_acq")) { if (command->nb_params<1) { res->retcode=0; res->str=malloc(4096*sizeof(char)); sprintf(res->str,"allow_autoflush_acq, %d arguments given, 1 needed",command->nb_params-1); return res; } ws->autoflush_limit=iohtoi(command->params[0]); ws->autoflush_active=1; res->retcode=1; res->str=strdup("variable set"); return res; } //************************************* if (!strcmp(command->name,"dis_autoflush_acq")) { ws->autoflush_active=0; res->retcode=1; res->str=strdup("variable set"); return res; } //************************************* if (!strcmp(command->name,"allow_rawoutp_acq")) { ws->rawoutp_active=1; res->retcode=1; res->str=strdup("raw output active"); return res; } //************************************* if (!strcmp(command->name,"dis_rawoutp_acq")) { ws->rawoutp_active=0; res->retcode=1; res->str=strdup("raw output inactive"); return res; } //************************************* res->retcode=0; res->str=strdup("Unknown command"); printf("unknown command\n"); return res; }