void far insert_megatek() /* into active megatek data segment */ { short far *address_of_page; unsigned long phy_address_of_page,phy_address_of_insert; int i; int temp_value; if((no_more_ems_pages == TRUE) || (have_display_list == FALSE)) return; /*decide if this page is full*/ address_of_page = start_of_page_frame_0; phy_address_of_page = ((long)FP_SEG(address_of_page) << 4) + (long)FP_OFF(address_of_page); phy_address_of_insert = ((long)FP_SEG(current_insert_pointer) << 4) + (long)FP_OFF(current_insert_pointer); if(phy_address_of_insert - phy_address_of_page >= 16350L) /*goto next megatek page*/ { /* store end of page marker */ temp_value = an_element.op_code; an_element.op_code = END_OF_PAGE; memcpy(current_insert_pointer,&an_element,SIZE_A_WORD); an_element.op_code = temp_value; current_logical_page++; if(current_logical_page > num_unalloc_pages) { error_logger("RAN OUT OF DISPLAY LIST MEMORY\n"); no_more_ems_pages = TRUE; } map_handle_page(current_logical_page,0,handle); current_insert_pointer = (char far *)start_of_page_frame_0; } /* store it at current insert pointer */ memcpy(current_insert_pointer,&an_element,SIZE_A_WORD); current_insert_pointer = current_insert_pointer + SIZE_A_WORD; an_element.op_code = END_OF_DL; memcpy(current_insert_pointer,&an_element,SIZE_A_WORD); }
void log_error_clipboard (short iboard, unsigned int4 addr) { char str[256]; sprintf((char *)str,"Comunication error, board %d, Function %lu",iboard, addr); error_logger(__FILE__,ERWARN,(char *)str); TERM_RED_COLOR; printf("\n ********** Error *********** \n"); printf("%s\n",str); TERM_RESET_COLOR; fflush (stdout); }
void log_error_sumboards(short Function) { char str[256]; sprintf((char *)str,"Communication error inside AstroBoard, crate %d \n",Function); error_logger(__FILE__,ERWARN,(char *)str); TERM_RED_COLOR; printf("\n ********** Error *********** \n"); printf("%s\n",str); TERM_RESET_COLOR; fflush (stdout); }
main() { const char *device = "/dev/spidev1.0"; fd = open(device, O_RDWR); int4 i; int4 status; float f; char *verb, *qual; int4 iverb; char host_name[80]; int4 port; char table_name[80]; char *theString; printf (" \n"); TERM_BLUE_COLOR; printf (" ***************************************************** \n"); printf (" ***************************************************** \n"); printf (" ** ** \n"); printf (" ** Welcome to CRISTAL: ** \n"); printf (" ** ContRol In Sum-Trigger ALgorithm ** \n"); printf (" ** ** \n"); printf (" ** by: Jezabel R. Garcia ** \n"); printf (" ** ** \n"); printf (" ***************************************************** \n"); printf (" ***************************************************** \n"); TERM_RESET_COLOR; printf (" \n"); // signal(SIGINT, myinterrupt); signal(SIGPIPE,brokenpipe); signal(SIGTERM,myabort); signal(SIGBUS,mybuserror); theString=(char *)malloc(sizeof(char)*256); STInfo.hostname[0]=(char*)malloc(sizeof(char)*80); STInfo.hostname[1]=(char*)malloc(sizeof(char)*80); /* * Set the initial values for status/times */ time(&STInfo.startime);// mirar los usos del tiempo time(&STInfo.writetime);// STInfo.istatus=ST_STATUS_BUSY; STInfo.threshold_control_flag=0; //by default off STInfo.Global_Target_rate = 500; //Hz STInfo.telescope=1; STInfo.temp_control=0; STInfo.total_time=3600; STInfo.time_interval=900; //initializes the BBmenu package menu_init(); //allow simulate_input() AllowInput=1; define_file("cristal_define.uic"); simulate_input("@cristal_init"); AllowInput=0; /* * Launch threads for service programs */ // usleep(100);//DBG STInfo.exit = False; printf("init threads \n"); STInfo.monexit=true; //monitoring thread not running //SERVER THREAD (para oir a cc) pthread_attr_init(&serv_attr); pthread_create(&serv_tid, &serv_attr, (void * (*)(void *)) server_thread, NULL); printf("server_thread initiated \n"); //CLIENT THREAD ( para hablar a cc) pthread_attr_init(&client_attr); pthread_create(&client_tid, &client_attr, (void * (*)(void *)) client_thread, NULL); printf("client_thread initiated \n"); //Add a Thread for L3 //Report thread pthread_attr_init(&Report_attr); pthread_create(&Report_tid, &Report_attr, (void * (*)(void *)) Report_thread, NULL); printf("Report_thread initiated \n"); while(True) { verb=action_menu( "ST_Main_Menu", &iverb); if(interrupted==True) { interrupted=False; flush_buffers(); } ////////////////////// if(strcmp(verb,"STOP!")==0) { transfer(0xA4, 0, 0, 0); printf("Stopping gloabl triggers."); } ////////////////////// if(strcmp(verb,"START")==0) { transfer(0xA3, 0, 0, 0); printf("Starting gloabl triggers."); } ////////////////////// if(strcmp(verb,"SETTARGETRATE")==0) { get_integer("Enter Global Target Trigger Rate", &STInfo.Global_Target_rate, 0, 0); } ////////////////////// if(strcmp(verb,"MONSTOP!")==0) //monitoring stop { STInfo.monexit=true; //stop monitpring thread } ////////////////////// if(strcmp(verb,"MONSTART")==0) //monitoring start { pthread_attr_init(&STmon_attr); pthread_create(&STmon_tid, &STmon_attr, (void * (*)(void *)) STmon_thread, NULL); //STInfo.monexit=0; // keep monitoring threat running } ////////////////////// if(strcmp(verb,"REPORT")==0) { error_logger(__FILE__,ERINFO,"Reports ON!"); if(!timer_on)start_timer(imon_sec); } ////////////////////// if(strcmp(verb,"REP!")==0) { stop_timer(); error_logger(__FILE__,ERINFO,"Reports OFF"); } ////////////////////// if(strcmp(verb,"LOCK!")==0) { //switch to remote control error_logger(__FILE__,ERINFO,"Readout ready to be engaged!"); set_async(True);//aqui es cuando cierra la conexion, usando getsring STInfo.lock_mode=True; } ////////////////////// if(strcmp(verb,"ULOCK")==0) { // if(client_conn) { // client_close(); client_conn=False; } error_logger(__FILE__,ERINFO,"Readout disengaged from CC"); set_async(False); STInfo.lock_mode=False; } ////////////////////// if(strcmp(verb,"HOSTNAME")==0) { int ihost; for(ihost=0;ihost<2;ihost++) { get_text("Enter Host Name",(char *)STInfo.hostname[ihost]); printf(" DBG HOSTNAME, %s", STInfo.hostname[ihost]); //if(STInfo.debug==True) // printf("Host Name defined: %s\n", STInfo.hostname[ihost]); } } ////////////////////// if(strcmp(verb,"HOSTNO")==0) { int ihost; for(ihost=0;ihost<2;ihost++) { get_integer("Enter Host Port Number",&STInfo.hostno[ihost],0,0); // if(STInfo.debug==True) printf("Host Port Number defined: %ld\n", STInfo.hostno[ihost]); } } ////////////////////// if(strcmp(verb,"CRISTAL")==0) { printf("\n"); TERM_PURPLE_COLOR; printf("CIRSTAL:Control in Sum-Trigger Algorithm\n"); printf("Author: Jezabel R. Garcia\n"); TERM_RESET_COLOR; printf("This progam was developed following the concept of MIR .\n"); printf("(by Riccardo Paoeletti and Daniel Mazin)\n"); printf("The Mir space station was built by connecting\n"); printf("several modules, each launched into orbit separately\n"); printf("One of the main module of the Mir was Cristal\n"); printf("that performed the astronomical observations and \n"); printf("extended the scientific possibilities of Mir.\n"); printf (" \n"); } ////////////////////// if(strcmp(verb,"TELESCOPE")==0) { get_integer("Who I am?",&STInfo.telescope,1,2); printf("This cristal version is running on M%i\n", STInfo.telescope); } ////////////////////// if(strcmp(verb,"PORTNO")==0) { get_integer("Enter Local Port Number",&STInfo.portno,0,0); // if(STInfo.debug==True) printf("Local Port Number defined: %ld\n", STInfo.portno); } ////////////////////// if(strcmp(verb,"TOOLS")==0) tools_menu(); ////////////////////// if(strcmp(verb,"DUMMY")==0) dummy_menu(); ////////////////////// if(strcmp(verb,"ASTRO")==0) astro_menu(); ////////////////////// if(strcmp(verb,"CLIP")==0) clip_menu(); ////////////////////// if(strcmp(verb,"SUM")==0) sum_menu(); ////////////////////// if(strcmp(verb,"POWER")==0) power_menu(); ////////////////////// if(strcmp(verb,"MESSAGE")==0) { get_text("Enter command", theString); puts(theString); error_logger(__FILE__,ERINFO, theString); } ////////////////////// if(strcmp(verb,"TIME_READ")==0) { int data4=0; get_hexadecimal("time? ",(long unsigned int*) &data4,0,0); int secs=15-data4&0xF; int sect=15-(data4>>4)&0x7; int mins=15-(data4>>7)&0xF; int mint=15-(data4>>11)&0x7; int hout=15-(data4>>14)&0x2; int hour=15-(data4>>16)&0xF; int tickWrong=(data4>>24)&0xFF; int tickRight = 0; int tickc = 0; for (tickc=0;tickc<8;tickc++) { tickRight += ((tickWrong>>(7-tickc))&0x1)*pow(2,tickc); // printf(" right %x wrong %x \n ",tickRight, (tickWrong>>(7-tickc))&0x1); } int tick = tickRight; //super second: // printf("R %X ",data4&0x0000FFFF); //super sub second: printf(" %X ",(data4&0xFFFF0000)>>16); //subsecond: get_hexadecimal("time? ",(long unsigned int*)&data4,0,0); printf("time: %d.%d h %d%d m %d%d %lf %d\n ",hout,hour,mint,mins,sect,secs,1.677721600-(data4&0x00007FFF)*51200e-9, tickRight); } ////////////////////// if(strcmp(verb,"SYSTEM")==0) { get_text("Enter command", theString); system(theString); } /////////////////////: if(strcmp(verb,"READY")==0) { STInfo.istatus=ST_STATUS_BUSY; TERM_BLUE_COLOR; printf (" ***************************************************** \n"); printf (" ***************************************************** \n"); printf (" ** ** \n"); printf (" ** CRISTAL IS NOW READY TO OPERATE ** \n"); printf (" ** ** \n"); printf (" ** ENJOY IT! ** \n"); printf (" ** ** \n"); printf (" ***************************************************** \n"); printf (" ***************************************************** \n"); TERM_RESET_COLOR; printf (" \n"); printf ("Press ? for more info. \n"); } if(strcmp(verb,"EXIT")==0) { stop_timer(); break; } usleep(250); }
void myabort(int dd) { error_logger(__FILE__,ERSEVR,"Aborting program"); }