void analyse(t_atoms *atoms,t_blocka *gb,char ***gn,bool bASK,bool bVerb) { t_aa_names *aan; eRestp *restp; char *resnm; atom_id *aid; int nra; int i; size_t j; if (bVerb) printf("Analysing residue names:\n"); snew(restp,atoms->nres); aid=mk_aid(atoms,restp,etOther,&nra,TRUE); add_grp(gb,gn,nra,aid,"System"); sfree(aid); aan = get_aa_names(); for(i=0; (i<atoms->nres); i++) { resnm = *atoms->resinfo[i].name; if ((restp[i] == etOther) && is_protein(aan,resnm)) restp[i] = etProt; if (restp[i] == etOther) for(j=0; (j<NDNA); j++) { if (strcasecmp(Sugars[j],resnm) == 0) restp[i] = etDNA; } } p_status(atoms->nres,restp,bVerb); done_aa_names(&aan); /* Protein */ aid=mk_aid(atoms,restp,etProt,&nra,TRUE); if (nra > 0) analyse_prot(restp,atoms,gb,gn,bASK,bVerb); sfree(aid); /* Non-Protein */ aid=mk_aid(atoms,restp,etProt,&nra,FALSE); if ((nra > 0) && (nra < atoms->nr)) add_grp(gb,gn,nra,aid,"Non-Protein"); sfree(aid); /* DNA */ aid=mk_aid(atoms,restp,etDNA,&nra,TRUE); if (nra > 0) { add_grp(gb,gn,nra,aid,"DNA"); analyse_dna(restp,atoms,gb,gn,bASK,bVerb); } sfree(aid); /* Other */ analyse_other(restp,atoms,gb,gn,bASK,bVerb); aid=mk_aid(atoms,restp,etOther,&nra,TRUE); if ((nra > 0) && (nra < atoms->nr)) add_grp(gb,gn,nra,aid,"Other"); sfree(aid); sfree(restp); }
unsigned char scegli_sonda(){ // ritorna 1..7 unsigned char scelta,press,i,sonda; y_pos(1,1); lcd_printf("Scegli la sonda"); y_pos(4,2); lcd_printf(">1 2 3 4 5 6 7"); y_pos(3,3); for (i=0;i<15;i++) lcd_printf(sonde_nomi[0][i]); scelta=4; y_pos(scelta,2); sonda=1; while(p_status() != P_OK){ press=p_status(); if (press!=0) { y_pos(scelta,2); lcd_printf(" "); if (press==P_RIGHT) { scelta+=2; sonda++; if (scelta>17){ scelta=4; sonda=1; } } else if (press==P_LEFT) { scelta-=2; sonda--; if (scelta<4){ scelta=16; sonda=7; } } y_pos(scelta,2); lcd_printf(">"); y_pos(3,3); for (i=0;i<15;i++) lcd_printf(sonde_nomi[sonda-1][i]); while (p_status()!=0) msDelay(1); } } clean_row(2); return sonda; // da1..7 }
//da spostare in qualke altro file, viene comoda anke x assegnare i nomi alle sonde.... oppure il nome esce in automatiko... // kidere al gruppo.... boh.. void assegna_nome(unsigned x, unsigned y, unsigned char presa) { //presa 1..7 char alfabeto[37][2]= {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ","0","1","2","3","4","5","6","7","8","9"}; char nome[15][2]; unsigned char lettera,carattere,press,i; y_pos(x,y); lettera=0; carattere=0; while(p_status() != P_OK) { msDelay(10); press=p_status(); if (press!=0) { if (press==P_DOWN) { if(lettera<26) lettera++; else lettera=0; } else if (press==P_UP) { if(lettera<26) lettera++; else lettera=0; } else if (press==P_RIGHT) { if(carattere<15) { nome[carattere][0]=alfabeto[lettera][0]; carattere++; x++; // avanza di un carattere lettera=0;// il prox carattere partirà dalla lettere a. } } y_pos(x,y); lcd_printf(alfabeto[lettera]); while (p_status()!=0) msDelay(10); } } presa--; for(i=0; i<carattere; i++) prese_nomi[presa][i][0]=nome[i][0]; //for(i=carattere;i<15;i++) prese_nomi[presa][i][0]=" ";//azera gli altri caratteri }
unsigned char imposta_stato(unsigned char presa) { unsigned char level,press; y_pos(1,1); lcd_printf("Scegli lo stato"); y_pos(6,2); lcd_printf(" 0 1"); level=presa_read_level(presa); //porta il cursore sullivello del pin if (!level) y_pos(6,2); else y_pos(12,2); lcd_printf(">"); press=0; while(p_status() != P_OK) { press=p_status(); if (press!=0) { if (press==P_LEFT) { y_pos(12,2); lcd_printf(" "); y_pos(6,2); lcd_printf(">"); level=0; while (p_status()==P_LEFT) msDelay(1); } if (press==P_RIGHT) { y_pos(6,2); lcd_printf(" "); y_pos(12,2); lcd_printf(">"); level=1; while (p_status()==P_RIGHT) msDelay(1); } } } printf("restituisco %d",level); return level; }
void analyse(t_atoms *atoms,t_blocka *gb,char ***gn,gmx_bool bASK,gmx_bool bVerb) { gmx_residuetype_t rt; char *resnm; atom_id *aid; const char ** restype; int nra; int i,k; size_t j; int ntypes; char * p; const char ** p_typename; int iwater,iion; int nwater,nion; int found; if (bVerb) { printf("Analysing residue names:\n"); } /* Create system group, every single atom */ snew(aid,atoms->nr); for(i=0;i<atoms->nr;i++) { aid[i]=i; } add_grp(gb,gn,atoms->nr,aid,"System"); sfree(aid); /* For every residue, get a pointer to the residue type name */ gmx_residuetype_init(&rt); snew(restype,atoms->nres); ntypes = 0; p_typename = NULL; for(i=0;i<atoms->nres;i++) { resnm = *atoms->resinfo[i].name; gmx_residuetype_get_type(rt,resnm,&(restype[i])); /* Note that this does not lead to a N*N loop, but N*K, where * K is the number of residue _types_, which is small and independent of N. */ found = 0; for(k=0;k<ntypes && !found;k++) { found = !strcmp(restype[i],p_typename[k]); } if(!found) { srenew(p_typename,ntypes+1); p_typename[ntypes++] = strdup(restype[i]); } } if (bVerb) { p_status(restype,atoms->nres,p_typename,ntypes); } for(k=0;k<ntypes;k++) { aid=mk_aid(atoms,restype,p_typename[k],&nra,TRUE); /* Check for special types to do fancy stuff with */ if(!gmx_strcasecmp(p_typename[k],"Protein") && nra>0) { sfree(aid); /* PROTEIN */ analyse_prot(restype,atoms,gb,gn,bASK,bVerb); /* Create a Non-Protein group */ aid=mk_aid(atoms,restype,"Protein",&nra,FALSE); if ((nra > 0) && (nra < atoms->nr)) { add_grp(gb,gn,nra,aid,"non-Protein"); } sfree(aid); } else if(!gmx_strcasecmp(p_typename[k],"Water") && nra>0) { add_grp(gb,gn,nra,aid,p_typename[k]); /* Add this group as 'SOL' too, for backward compatibility with older gromacs versions */ add_grp(gb,gn,nra,aid,"SOL"); sfree(aid); /* Solvent, create a negated group too */ aid=mk_aid(atoms,restype,"Water",&nra,FALSE); if ((nra > 0) && (nra < atoms->nr)) { add_grp(gb,gn,nra,aid,"non-Water"); } sfree(aid); } else if(nra>0) { /* Other groups */ add_grp(gb,gn,nra,aid,p_typename[k]); sfree(aid); analyse_other(restype,atoms,gb,gn,bASK,bVerb); } } sfree(p_typename); sfree(restype); gmx_residuetype_destroy(rt); /* Create a merged water_and_ions group */ iwater = -1; iion = -1; nwater = 0; nion = 0; for(i=0;i<gb->nr;i++) { if(!gmx_strcasecmp((*gn)[i],"Water")) { iwater = i; nwater = gb->index[i+1]-gb->index[i]; } else if(!gmx_strcasecmp((*gn)[i],"Ion")) { iion = i; nion = gb->index[i+1]-gb->index[i]; } } if(nwater>0 && nion>0) { srenew(gb->index,gb->nr+2); srenew(*gn,gb->nr+1); (*gn)[gb->nr] = strdup("Water_and_ions"); srenew(gb->a,gb->nra+nwater+nion); if(nwater>0) { for(i=gb->index[iwater];i<gb->index[iwater+1];i++) { gb->a[gb->nra++] = gb->a[i]; } } if(nion>0) { for(i=gb->index[iion];i<gb->index[iion+1];i++) { gb->a[gb->nra++] = gb->a[i]; } } gb->nr++; gb->index[gb->nr]=gb->nra; } }
//***************** // MAIN //***************** int main (int argc, char *argv[]) { //orologio time_t now; struct tm *tm_now; char conv[3]; char buff[20]; //match unsigned char hr; unsigned char min; int presa,timer;//x cicli for //aspetta alim stabile delay_ms(50); sk_clear(); delay_ms(50); system ("clear"); if (i2c_open()<0) { printf("Apertura del bus I2C fallita\n"); return 1; } board_init(); printf("--Init board [PASS]\n"); lcd_init(); printf("--Init lcd [PASS]\n"); ciabatta_init(); printf("--Init ciabatta [PASS]\n"); // socket_init(); printf("--Init socket on 15000 [PASS]\n"); board_init(); ciabatta_init(); sk_init(); printf("\nfox-acqua in esecuzione.\n"); if(fork() != 0){ //eseguito dal processo padre for(;;){ y_pos(1,3); lcd_printf("MENU"); cursore_scegli_opz(3); while(p_status()!= P_OK){ //disegna lo stato delle prese y_pos(1,0); lcd_printf(" P:"); for(presa=1;presa<8;presa++) lcd_printf("%d",presa_read_level(presa)); //mostra ora e data y_pos(12,1); now = time ( NULL ); tm_now = localtime ( &now ); //%a /* Abbreviated weekday */ //%A /* Full weekday */ //%b /* Abbreviated month */ //%b /* Full month */ //%c /* Full date and time */ //%d /* Day of the month (1-31) */ //%H /* Hour (24 hour clock) */ //%I /* Hour (12 hour clock) */ //%j /* Day of the year (1-366)*/ //%m /* Month (1-12) */ //%M /* Minute (0-59) */ //%p /* AM/PM for 12 hour clock */ //%S /* Second (0-60) */ //%U /* Week number from Sunday */ //%w /* Weekday (0-6) from Sunday */ //%W /* Week number from Monday */ //%x /* Full date */ //%X /* Full time of day */ //%y /* Year without century */ //%Y /* Year with century */ //%Z /* Time zone */ //%% /* Print a % character */ strftime ( buff, sizeof buff, "%H:%M:%S", tm_now ); strftime ( conv, sizeof conv, "%H", tm_now ); hr=atoi(conv); strftime ( conv, sizeof conv, "%M", tm_now ); min=atoi(conv); lcd_printf( "%s", buff ); y_pos(12,2); strftime ( buff, sizeof buff, "%d/%m/%y", tm_now ); lcd_printf( "%s", buff ); //----match tra rtc e timer vari---- //controlla se un delle 10 prese ha un timer attivo s_timer timer[70]; for (a=0; a<70; a++) read_timer(&timer[a], a); //for (presa=0;presa<8;presa++){ //sfoglia le prese //for(timer=0;timer<10;timer++){ //sfoglia i 10 timer di questa presa if (presa_timer_stato[presa][timer]<99){ //allora c'� un timer impostato x questa presa //controlla se deve scattare in questo momento // !!!!!!!!!!!!!! // risolvere il problema nel caso in cui: l'utente sia nel menu, // e quando si ritorna qui l'orologio � andato // dopo l'evento di un timer. if (presa_timer[presa][timer][0]==hr){ if (presa_timer[presa][timer][1]==min){//ok, allora imposta la presa. presa_set_level(presa+1,presa_timer_stato[presa][timer]); } } } } } } //luppa fink� non � premuto sk_clear(); //socket_printf(cs,"Menu_1_0"); //write(cs,zero,1); //fa scrivee effettivamente la frase sopra svuotando il buffer ke ha interno(penso). sk_menu_1(); sk_clear(); }//for