void ResetMemoria() { LCD_Clear(); LCD_Write(" RESET", 1); LCD_Write(" MEMORIA", 2); ResetMem(); LCD_Clear(); }
int WlibMainLine( char *argv[] ) { int retcode; InitCmdLine(); // JBS 99/07/09 reset options for each use if( !setjmp( Env ) ) { ProcessCmdLine( argv ); ProcessCommands(); retcode = EXIT_SUCCESS; } else { retcode = EXIT_FAILURE; } if( !setjmp( Env ) ) { ResetInputLibs(); ResetFileTab(); ResetCmdLine(); ResetLibIo(); ResetMem(); } else { retcode = EXIT_FAILURE; } return( retcode ); }
int main(int argc, char *argv[]) { char * labFn, *listfn, *s; int i,fidx; MLFEntry *me = NULL; Transcription *t; void InitStats(char *listfn); void GatherStats(Transcription *t); void OutputStats(void); if(InitShell(argc,argv,hlstats_version,hlstats_vc_id)<SUCCESS) HError(1300,"HLStats: InitShell failed"); InitMem(); InitMath(); InitWave(); InitLabel(); InitLM(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); enterId=GetLabId("!ENTER",TRUE); /* All sentences should or are coerced */ exitId=GetLabId("!EXIT",TRUE); /* to start enterId and end exitId */ nullId=GetLabId("!NULL",TRUE); /* Name for words not in list */ while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(1319,"HLStats: Bad switch %s; must be single letter",s); switch(s[0]){ case 'b': doBigram = TRUE; if (NextArg() != STRINGARG) HError(1319,"HLStats: Ngram output file name expected"); bigFile = GetStrArg(); break; case 'c': doLCount = TRUE; lCountLimit = GetChkedInt(0,100000,s); break; case 'd': doDurs = TRUE; break; case 'f': bigFloor = GetChkedFlt(0.0,1000.0,s); break; case 'h': hSize = GetChkedInt(1,2,s); break; case 'l': doList = TRUE; if (NextArg() != STRINGARG) HError(1319,"HLStats: Output label list file name expected"); listFile = GetStrArg(); break; case 'o': doBOff = TRUE; break; case 'p': doPCount = TRUE; pCountLimit = GetChkedInt(0,100000,s); break; case 's': if (NextArg() != STRINGARG) HError(1319,"HLStats: ENTER label name expected"); enterId=GetLabId(GetStrArg(),TRUE); if (NextArg() != STRINGARG) HError(1319,"HLStats: EXIT label name expected"); exitId=GetLabId(GetStrArg(),TRUE); break; case 't': bigThresh = GetChkedInt(0,100,s); break; case 'u': uniFloor = GetChkedFlt(0.0,1000.0,s); break; case 'G': if (NextArg() != STRINGARG) HError(1319,"HLStats: Input label File format expected"); if((ff = Str2Format(GetStrArg())) == ALIEN) HError(-1389,"HLStats: Warning ALIEN Label file format set"); break; case 'I': if (NextArg() != STRINGARG) HError(1319,"HLStats: Input MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'T': if (NextArg() != INTARG) HError(1319,"HLStats: Trace value expected"); trace = GetChkedInt(0,017,s); break; default: HError(1319,"HLStats: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(1319,"HLStats: Label list file name expected"); listfn = GetStrArg(); if (!(doDurs || doBigram || doList || doLCount || doPCount)) HError(1330,"HLStats: Nothing to do!"); InitStats(listfn); i=0; while (NumArgs()>0) { if (NextArg()!=STRINGARG) HError(1319,"HLStats: Input label file name expected"); labFn = GetStrArg(); if (IsMLFFile(labFn)) { fidx = NumMLFFiles(); if ((me=GetMLFTable()) != NULL) { while(me->next != NULL) me=me->next; LoadMasterFile(labFn); me=me->next; } else { LoadMasterFile(labFn); me=GetMLFTable(); } while (me != NULL) { if (me->type == MLF_IMMEDIATE && me->def.immed.fidx == fidx) { if (trace&T_FIL) { printf(" Processing file %s\n",me->pattern); fflush(stdout); } t = LOpen(&tmpHeap,me->pattern,ff); if (t->numLists<1) HError(-1330,"HLStats: Empty file %s",me->pattern); else GatherStats(t),i++; Dispose(&tmpHeap,t); } me = me->next; if ((trace&T_BAS) && !(trace&T_FIL) && NumMLFEntries()>5000 && i%1000==0) printf(". "),fflush(stdout); } if ((trace&T_BAS) && !(trace&T_FIL) && NumMLFEntries()>5000) printf("\n"); } else { if (trace&T_FIL) { printf(" Processing file %s\n",labFn); fflush(stdout); } t = LOpen(&tmpHeap,labFn,ff); if (t->numLists<1) HError(-1330,"HLStats: Empty file %s",me->pattern); else GatherStats(t),i++; Dispose(&tmpHeap,t); } } if (trace&T_MEM) PrintAllHeapStats(); OutputStats(); if (trace&T_MEM) PrintAllHeapStats(); ResetLM(); ResetLabel(); ResetWave(); ResetMath(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int argc, char *argv[]) { char *datafn, *s; int stream = 0; void Initialise(char *datafn); void LoadFile(char *fn); void CalcMeanCov(Sequence seq[], int s); void ClusterVecs(Sequence seq[], int s); void WriteVQTable(ClusterSet *cs[], char *fn); if(InitShell(argc,argv,hquant_version,hquant_vc_id)<SUCCESS) HError(2500,"HQuant: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(2500,"HQuant: InitParm failed"); InitTrain(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); InitStreamVars(); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(2519,"HQuant: Bad switch %s; must be single letter",s); switch(s[0]){ case 'd': if ( ck != NULLC) HError(2519,"HQuant: Specify one of -d or -f, not both"); ck = INVDIAGC; break; case 'f': if ( ck != NULLC) HError(2519,"HQuant: Specify one of -d or -f, not both"); ck = FULLC; break; case 'g': globClustVar = TRUE; break; case 'l': if (NextArg() != STRINGARG) HError(2519,"HQuant: Segment label expected"); segLab = GetStrArg(); break; case 'n': if (NextArg() != INTARG) HError(2519,"HQuant: Stream number expected"); stream = GetChkedInt(1,SMAX,s); if (NextArg() != INTARG) HError(2519,"HQuant: Codebook size expected"); cbSizes[stream]= GetChkedInt(1,32768,s); break; case 's': if (NextArg() != INTARG) HError(2519,"HQuant: Number of streams expected"); swidth[0] = GetChkedInt(1,SMAX,s); break; case 't': tType = binTree; break; case 'w': if (NextArg() != INTARG) HError(2519,"HQuant: Stream number expected"); stream = GetChkedInt(1,SMAX,s); if(swidth[0] < stream) swidth[0] = stream; widthSet = TRUE; if (NextArg() != INTARG) HError(2519,"HQuant: Stream width expected"); swidth[stream]= GetChkedInt(1,256,s); break; case 'F': if (NextArg() != STRINGARG) HError(2519,"HQuant: Data File format expected"); if((dff = Str2Format(GetStrArg())) == ALIEN) HError(-2589,"HQuant: Warning ALIEN Data file format set"); break; case 'G': if (NextArg() != STRINGARG) HError(2519,"HQuant: Label File format expected"); if((lff = Str2Format(GetStrArg())) == ALIEN) HError(-2589,"HQuant: Warning ALIEN Label file format set"); break; case 'I': if (NextArg() != STRINGARG) HError(2519,"HQuant: MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'L': if (NextArg()!=STRINGARG) HError(2519,"HQuant: Label file directory expected"); labDir = GetStrArg(); break; case 'T': if (NextArg() != INTARG) HError(2519,"HQuant: Trace value expected"); trace = GetChkedInt(0,077,s); break; case 'X': if (NextArg()!=STRINGARG) HError(2519,"HQuant: Label file extension expected"); labExt = GetStrArg(); break; default: HError(2519,"HQuant: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(2519,"HQuant: Output VQ table file name expected"); vqfn = GetStrArg(); if (NextArg()!=STRINGARG) HError(2519,"HQuant: Training data file name expected"); datafn = GetStrArg(); Initialise(datafn); LoadFile(datafn); while (NumArgs()>0) { if (NextArg()!=STRINGARG) HError(2519,"HQuant: Training data file name expected"); datafn = GetStrArg(); LoadFile(datafn); } for (stream=1;stream<=swidth[0];stream++){ if (trace&T_TOP) printf("%s-clustering data for stream %d (width %d)\n", (tType==linTree)?"Flat":"Tree",stream,swidth[stream]); CalcMeanCov(dSeq,stream); ClusterVecs(dSeq,stream); } WriteVQTable(cs,vqfn); ResetTrain(); ResetParm(); ResetModel(); ResetVQ(); ResetAudio(); ResetWave(); ResetSigP(); ResetMath(); ResetLabel(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int argc, char *argv[]) { char *s,buf[MAXSTRLEN]; void ListSpeech(char *src); if(InitShell(argc,argv,hlist_version,hlist_vc_id)<SUCCESS) HError(1100,"HList: InitShell failed"); InitMem(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitLabel(); InitModel(); if(InitParm()<SUCCESS) HError(1100,"HList: InitParm failed"); SetConfParms(); if (GetConfStr(cParm,nParm,"SOURCEFORMAT",buf)) ff = Str2Format(buf); if (!InfoPrinted() && NumArgs() == 0 && ff != HAUDIO) ReportUsage(); if (NumArgs() == 0 && ff != HAUDIO) Exit(0); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s) !=1 ) HError(1119,"HList: Bad switch %s; must be single letter",s); switch(s[0]){ case 'd': frcDisc = TRUE; break; case 'e': gen = GetChkedLong(gst,LONG_MAX,s); break; case 'h': srcHdr = TRUE; break; case 'i': nItems = GetChkedInt(1,100,s); break; case 'n': numS = GetChkedInt(1,SMAX-1,s); break; case 'o': obsFmt = TRUE; break; case 'p': replay = TRUE; break; case 'r': rawOut = TRUE; break; case 's': gst = GetChkedLong(0,LONG_MAX,s); break; case 't': tgtHdr = TRUE; break; case 'z': prData = FALSE; break; case 'F': if (NextArg() != STRINGARG) HError(1119,"HList: File format expected"); if((ff = Str2Format(GetStrArg())) == ALIEN) HError(-1189,"HList: Warning ALIEN src file format set"); break; case 'T': trace = GetChkedInt(0,077,s); break; default: HError(1119,"HList: Unknown switch %s",s); } } if (NumArgs() == 0 ) ListSpeech(NULL); else while (NumArgs() > 0 ) { if (NextArg() != STRINGARG) HError(1119,"HList: List file name expected"); ListSpeech(GetStrArg()); } ResetParm(); ResetModel(); ResetLabel(); ResetVQ(); ResetAudio(); ResetWave(); ResetSigP(); ResetMath(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int argc, char *argv[]) { char *datafn, *s; int nSeg; void Initialise(void); void LoadFile(char *fn); void EstimateModel(void); void SaveModel(char *outfn); if(InitShell(argc,argv,hinit_version,hinit_vc_id)<SUCCESS) HError(2100,"HInit: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(2100,"HInit: InitParm failed"); InitTrain(); InitUtil(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); CreateHMMSet(&hset,&gstack,FALSE); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(2119,"HInit: Bad switch %s; must be single letter",s); switch(s[0]){ case 'e': epsilon = GetChkedFlt(0.0,1.0,s); break; case 'g': ignOutVec = FALSE; break; case 'i': maxIter = GetChkedInt(0,100,s); break; case 'l': if (NextArg() != STRINGARG) HError(2119,"HInit: Segment label expected"); segLab = GetStrArg(); break; case 'm': minSeg = GetChkedInt(1,1000,s); break; case 'n': newModel = FALSE; break; case 'o': outfn = GetStrArg(); break; case 'u': SetuFlags(); break; case 'v': minVar = GetChkedFlt(0.0,10.0,s); break; case 'w': mixWeightFloor = MINMIX * GetChkedFlt(0.0,100000.0,s); break; case 'B': saveBinary = TRUE; break; case 'F': if (NextArg() != STRINGARG) HError(2119,"HInit: Data File format expected"); if((dff = Str2Format(GetStrArg())) == ALIEN) HError(-2189,"HInit: Warning ALIEN Data file format set"); break; case 'G': if (NextArg() != STRINGARG) HError(2119,"HInit: Label File format expected"); if((lff = Str2Format(GetStrArg())) == ALIEN) HError(-2189,"HInit: Warning ALIEN Label file format set"); break; case 'H': if (NextArg() != STRINGARG) HError(2119,"HInit: HMM macro file name expected"); AddMMF(&hset,GetStrArg()); break; case 'I': if (NextArg() != STRINGARG) HError(2119,"HInit: MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'L': if (NextArg()!=STRINGARG) HError(2119,"HInit: Label file directory expected"); labDir = GetStrArg(); break; case 'M': if (NextArg()!=STRINGARG) HError(2119,"HInit: Output macro file directory expected"); outDir = GetStrArg(); break; case 'T': if (NextArg() != INTARG) HError(2119,"HInit: Trace value expected"); trace = GetChkedInt(0,01777,s); break; case 'X': if (NextArg()!=STRINGARG) HError(2119,"HInit: Label file extension expected"); labExt = GetStrArg(); break; default: HError(2119,"HInit: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(2119,"HInit: source HMM file name expected"); hmmfn = GetStrArg(); Initialise(); do { if (NextArg()!=STRINGARG) HError(2119,"HInit: training data file name expected"); datafn = GetStrArg(); LoadFile(datafn); } while (NumArgs()>0); nSeg = NumSegs(segStore); if (nSeg < minSeg) HError(2121,"HInit: Too Few Observation Sequences [%d]",nSeg); if (trace&T_TOP) { printf("%d Observation Sequences Loaded\n",nSeg); fflush(stdout); } EstimateModel(); SaveModel(outfn); if (trace&T_TOP) printf("Output written to directory %s\n", outDir==NULL?"current":outDir); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(2100,"HInit: InitParm failed"); InitTrain(); InitUtil(); ResetUtil(); ResetTrain(); ResetParm(); ResetModel(); ResetVQ(); ResetAudio(); ResetWave(); ResetSigP(); ResetMath(); ResetLabel(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
void main(void) { Inicia_Tiva(); REFTEMPO referencia; uint8_t date[6] = {0x00,0x00,0x0C,0x1B,0x08,0x10}; uint8_t modo_atual = START, aberta = 0x00; uint16_t leituras_salvas= 0; LCD_BlackLight_Enable(); LCD_Clear(); LCD_Write(" BEM VINDO!!!", 1); LCD_Write(" MEDIDOR DE AGUA!", 2); InitSensores(); Delay(2000); LCD_Clear(); StartMonit(date, &referencia); while(1) { Delay(250); LeSensores(); // OpenValve(); // Delay(5000); // CloseValve(); // Delay(5000); recebeDadosBluetooth = Bluetooth_RecebeDados(); char comando; // char temp[5]; // for(i = 0; i < 5; i++){ // temp[i] = recebeDadosBluetooth[i]; // } comando = recebeDadosBluetooth[5]; if(comando == '1'){ // if( strcmp(temp, "atual") == 0 ){ LCD_Clear(); LCD_Write(" ENVIA", 0); LCD_Write(" ULTIMO", 1); LCD_Write(" VALOR", 2); DADOMEDIDA ultimo; uint16_t mes_atual = referencia.end_proxmes - 0x1173; if(referencia.end_diaria.word - 3 != mes_atual) ultimo = EEPROM_PegaLeitura(referencia.end_diaria.word - 6); else ultimo.med.word = 0; Bluetooth_EnviaMedicao(ultimo.med.word); Delay(1000); } if(comando == '2'){ // if( strcmp(temp, "anter") == 0 ){ LCD_Clear(); LCD_Write(" ENVIA", 0); LCD_Write(" MEDIA ", 1); LCD_Write(" ANUAL", 2); DADOANUAL media; media = EEPROM_PegaMedia(referencia.end_proxano.word - 9); uint32_t valor = ((media.acu_hi.word*65536) + media.acu_lo.word)/media.cnt_ms.word; Bluetooth_EnviaMedicao(valor); Delay(1000); } if(comando == '3'){ // if( strcmp(temp, "histo") == 0 ){ LCD_Clear(); LCD_Write(" ENVIA ", 1); LCD_Write(" HISTORICO", 2); B16 cal; uint16_t mem_mes = MES1; uint8_t day[3]; uint8_t hour[3]; DADOMEDIDA hist; for(int ind_mes = 0; ind_mes < 6; ind_mes++) { mem_mes = mem_mes + (ind_mes*0x1173); cal = GetMesAno(mem_mes); for(int ler = 0; ler < 744; ler++) { hist = LeSequencia((ind_mes*0x1173), ler); day[0] = his.datetime[0]; day[1] = cal.byte[1]; day[2] = cal.byte[0]; hour[0] = his.datetime[1]; hour[1] = his.datetime[2]; hour[2] = his.datetime[3]; Bluetooth_EnviaDados(hist.med.word, day, hour); } } Delay(1000); } if(comando == '4'){ // if( strcmp(temp, "reset") == 0 ){ LCD_Clear(); LCD_Write(" RESET", 1); LCD_Write(" MEMORIA", 2); ResetMem(); } if(comando == '5'){ // if( strcmp(temp, "ajust") == 0 ){ LCD_Clear(); LCD_Write(" RECEBENDO DADOS", 0); //recebe data char imprime[15]; char auxData[6] = "999999"; Delay(1000); while(auxData[0] == '9'){ Delay(200); recebeDadosBluetooth = Bluetooth_RecebeDados(); for(index = 0; index < 6; index++){ auxData[index] = recebeDadosBluetooth[index]; } } date[3] = ((auxData[0] - 0x30 ) * 10) + (auxData[1] - 0x30); date[4] = ((auxData[2] - 0x30 ) * 10) + (auxData[3] - 0x30); date[5] = ((auxData[4] - 0x30 ) * 10) + (auxData[5] - 0x30); sprintf(imprime, "DATA %02d/%02d/%02d", date[3], date[4], date[5]); LCD_Write(imprime, 1); //recebe hora char auxTime[6] = "999999"; Delay(1000); while(auxTime[0] == '9'){ Delay(200); recebeDadosBluetooth = Bluetooth_RecebeDados(); for(index = 0; index < 6; index++){ auxTime[index] = recebeDadosBluetooth[index]; } } date[2] = ((auxTime[0] - 0x30 ) * 10) + (auxTime[1] - 0x30); date[1] = ((auxTime[2] - 0x30 ) * 10) + (auxTime[3] - 0x30); date[0] = ((auxTime[4] - 0x30 ) * 10) + (auxTime[5] - 0x30); sprintf(imprime, "HORA %02d:%02d:%02d", date[2], date[1], date[0]); LCD_Write(imprime, 2); Delay(1000); //HORA - MINUTO - SEGUNDO DS1307_SetTime(date[2],date[1],date[0]); //DIA - MES - ANO DS1307_SetDate(date[3],date[4],date[5]); } if(comando == '6'){ // if( strcmp(temp, "abrir") == 0 ){ LCD_Clear(); OpenValve(); LCD_Write(" ABRE VALVULA", 0); LCD_Write("---------/ /--------", 2); Delay(1000); } if(comando == '7'){ // if( strcmp(temp, "fecha") == 0 ){ LCD_Clear(); CloseValve(); LCD_Write(" FECHA VALVULA", 0); LCD_Write("--------------------", 2); Delay(1000); } if(comando == '8'){ // if( strcmp(temp, "volts") == 0 ){ LCD_Clear(); LCD_Write("FONTES DE ENERGIAS", 0); char imprime[10]; float volt = bateria / 1.67; sprintf(imprime, "BATERIA = %.2f V", volt); // 9.0v -> 2.18V LCD_Write(imprime, 1); volt = rede / 2; sprintf(imprime, "REDE = %.2f V", volt); //12.4V -> 2.80V LCD_Write(imprime, 2); Delay(1000); } ShowDateTime(); Scan(&referencia, &modo_atual, &tempo_passado, &pulsos_contados, &leituras_salvas); if(modo_atual == ENABLED) { TimerEnable(TIMER0_BASE, TIMER_A); } else if(modo_atual == RESTART || modo_atual == DISABLED) { TimerDisable(TIMER0_BASE, TIMER_A); modo_atual = START; Delay(1); } if(modo_atual != DISABLED) { if(aberta == 0x00) { OpenValve(); aberta = 0x01; } } else { if(aberta == 0x01) { CloseValve(); aberta = 0x00; } } LCD_Process(); } }
void StartMonit(uint8_t datetime[6], REFTEMPO* atual) { B16 endereco; uint8_t aux = 0, ind = 0; uint8_t mesoff[6]; uint8_t anooff[6]; uint8_t decoff[10]; //HORA - MINUTO - SEGUNDO DS1307_SetTime(datetime[2],datetime[1],datetime[0]); atual->hora = datetime[2]; atual->minu = datetime[1]; //DIA - MES - ANO DS1307_SetDate(datetime[3],datetime[4],datetime[5]); atual->mes = datetime[4]; atual->ano = datetime[5]; //LIMPA MEMORIA ResetMem(); //CALCULA OFFSET DE ESPACOS DA MEMORIA - AREA DE LEITURAS DIARIAS if(datetime[5] <= 6) { for(aux = 0; aux < 6; aux++) { mesoff[aux] = aux; anooff[aux] = 0; } } else { aux = datetime[5] - 7; for(ind = 0; ind < 6; ind++) { if(ind + aux < 6) { mesoff[ind] = ind + aux; anooff[aux] = 0; } else { mesoff[ind] = ind + aux + (251 - datetime[5]); if(datetime[6] < 99) anooff[aux] = 1; else anooff[aux] = 157; } } } //DEFINE OS VALORES DOS 6 MESES(ATUAL E PROXIMOS 5) endereco.word = MES1; //MES EEPROM_Define(endereco.word, datetime[5] + mesoff[0]); endereco.word = MES1+1; //ANO EEPROM_Define(endereco.word, datetime[6] + anooff[0]); endereco.word = MES1+2; //PRIMEIRA LEITURA EEPROM_Define(endereco.word, 0x01); atual->end_diaria.word = MES1+3; endereco.word = MES2; //MES EEPROM_Define(endereco.word, datetime[5] + mesoff[1]); endereco.word = MES2+1; //ANO EEPROM_Define(endereco.word, datetime[6] + anooff[1]); endereco.word = MES2+2; //PRIMEIRA LEITURA EEPROM_Define(endereco.word, 0x01); atual->end_proxmes.word = MES2; endereco.word = MES3; //MES EEPROM_Define(endereco.word, datetime[5] + mesoff[2]); endereco.word = MES3+1; //ANO EEPROM_Define(endereco.word, datetime[6] + anooff[2]); endereco.word = MES3+2; //PRIMEIRA LEITURA EEPROM_Define(endereco.word, 0x01); endereco.word = MES4; //MES EEPROM_Define(endereco.word, datetime[5] + mesoff[3]); endereco.word = MES4+1; //ANO EEPROM_Define(endereco.word, datetime[6] + anooff[3]); endereco.word = MES4+2; //PRIMEIRA LEITURA EEPROM_Define(endereco.word, 0x01); endereco.word = MES5; //MES EEPROM_Define(endereco.word, datetime[5] + mesoff[4]); endereco.word = MES5+1; //ANO EEPROM_Define(endereco.word, datetime[6] + anooff[4]); endereco.word = MES5+2; //PRIMEIRA LEITURA EEPROM_Define(endereco.word, 0x01); endereco.word = MES6; //MES EEPROM_Define(endereco.word, datetime[5] + mesoff[5]); endereco.word = MES6+1; //ANO EEPROM_Define(endereco.word, datetime[6] + anooff[5]); endereco.word = MES6+2; //PRIMEIRA LEITURA EEPROM_Define(endereco.word, 0x01); //DEFINE OS VALORES DOS 10 ANOS (ATUAL E PROXIMOS 9) //CALCULA OFFSET DE ESPACOS DA MEMORIA - AREA DE LEITURAS ANUAIS if(datetime[6] < 90) { for(aux = 0; aux < 10; aux++) { decoff[aux] = aux; } } else { aux = datetime[6] - 90; for(ind = 0; ind < 10; ind++) { if(ind + aux < 10) { decoff[ind] = ind + aux; } else { decoff[ind] = ind + aux + (246 - datetime[6]); } } } endereco.word = ANO1; EEPROM_Define(endereco.word, datetime[5] + decoff[0]); atual->end_media.word = ANO1 + 1; endereco.word = ANO2; EEPROM_Define(endereco.word, datetime[5] + decoff[1]); atual->end_proxano.word = ANO2; endereco.word = ANO3; EEPROM_Define(endereco.word, datetime[5] + decoff[2]); endereco.word = ANO4; EEPROM_Define(endereco.word, datetime[5] + decoff[3]); endereco.word = ANO5; EEPROM_Define(endereco.word, datetime[5] + decoff[4]); endereco.word = ANO6; EEPROM_Define(endereco.word, datetime[5] + decoff[5]); endereco.word = ANO7; EEPROM_Define(endereco.word, datetime[5] + decoff[6]); endereco.word = ANO8; EEPROM_Define(endereco.word, datetime[5] + decoff[7]); endereco.word = ANO9; EEPROM_Define(endereco.word, datetime[5] + decoff[8]); endereco.word = ANOA; EEPROM_Define(endereco.word, datetime[5] + decoff[9]); }
int main(int argc, char *argv[]) { char *s; char *labfn; int numUtt; void Initialise(void); void DoGeneration(char *labfn); if (InitShell(argc, argv, hmgens_version, hmgens_vc_id) < SUCCESS) HError(2300, "HMGenS: InitShell failed"); InitMem(); InitMath(); InitSigP(); InitWave(); InitLabel(); InitModel(); if (InitParm() < SUCCESS) HError(2300, "HMGenS: InitParm failed"); InitUtil(); InitFB(); InitAdapt(&xfInfo_hmm, &xfInfo_dur); InitMap(); InitGen(); if (NumArgs() == 0) ReportUsage(); CreateHeap(&genStack, "genStore", MSTAK, 1, 1.0, 80000, 400000); CreateHeap(&uttStack, "uttStore", MSTAK, 1, 0.5, 100, 1000); CreateHeap(&fbInfoStack, "FBInfoStore", MSTAK, 1, 0.5, 100, 1000); CreateHeap(&hmmStack, "HmmStore", MSTAK, 1, 1.0, 50000, 500000); CreateHeap(&dmStack, "dmStore", MSTAK, 1, 1.0, 50000, 500000); SetConfParms(); CreateHMMSet(&hmset, &hmmStack, TRUE); CreateHMMSet(&dmset, &dmStack, TRUE); utt = (UttInfo *) New(&uttStack, sizeof(UttInfo)); genInfo = (GenInfo *) New(&genStack, sizeof(GenInfo)); fbInfo = (FBInfo *) New(&fbInfoStack, sizeof(FBInfo)); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s) != 1) HError(9919, "HMGenS: Bad switch %s; must be single letter", s); switch (s[0]) { case 'a': xfInfo_hmm.useInXForm = TRUE; break; case 'b': xfInfo_dur.useInXForm = TRUE; break; case 'c': if (NextArg() != INTARG) HError(2119, "HMGenS: Parameter generation algorithm type value expected"); type = (ParmGenType) GetChkedInt(CHOLESKY, FB, s); break; case 'd': if (NextArg() != STRINGARG) HError(2319, "HMGenS: HMM definition directory expected"); hmmDir = GetStrArg(); break; case 'e': useAlign = TRUE; break; case 'f': frameRate = (HTime) GetChkedFlt(0.0, 10000000.0, s); break; case 'g': minFrwdP = GetChkedFlt(0.0, 1000.0, s); break; case 'h': if (NextArg() != STRINGARG) HError(1, "Speaker name pattern expected"); xfInfo_hmm.inSpkrPat = xfInfo_dur.inSpkrPat = GetStrArg(); if (NextArg() == STRINGARG) xfInfo_hmm.paSpkrPat = xfInfo_dur.paSpkrPat = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -h as the last option"); break; case 'm': modelAlign = TRUE; break; case 'n': if (NextArg() != STRINGARG) HError(2319, "HMGenS: duration model definition directory expected"); dmDir = GetStrArg(); break; case 'p': outPdf = TRUE; break; case 'r': if (NextArg() != FLOATARG) HError(2119, "HMGenS: Speaking rate value (float) expected"); speakRate = GetChkedFlt(0.0, 3.0, s); break; case 's': stateAlign = TRUE; break; case 't': pruneInit = GetChkedFlt(0.0, 1.0E20, s); if (NextArg() == FLOATARG || NextArg() == INTARG) { pruneInc = GetChkedFlt(0.0, 1.0E20, s); pruneLim = GetChkedFlt(0.0, 1.0E20, s); } else { pruneInc = 0.0; pruneLim = pruneInit; } break; case 'v': MSDthresh = GetChkedFlt(0.0, 1.0, s); break; case 'x': if (NextArg() != STRINGARG) HError(2319, "HMGenS: HMM file extension expected"); hmmExt = GetStrArg(); break; case 'y': if (NextArg() != STRINGARG) HError(2319, "HMGenS: duration model file extension expected"); dmExt = GetStrArg(); break; case 'B': inBinary = TRUE; break; case 'E': if (NextArg() != STRINGARG) HError(2319, "HMGenS: parent transform directory expected"); xfInfo_hmm.usePaXForm = TRUE; xfInfo_hmm.paXFormDir = GetStrArg(); if (NextArg() == STRINGARG) xfInfo_hmm.paXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -E as the last option"); break; case 'G': if (NextArg() != STRINGARG) HError(2119, "HMGenS: Label File format expected"); if ((lff = Str2Format(GetStrArg())) == ALIEN) HError(-2189, "HMGenS: Warning ALIEN Label file format set"); break; case 'H': if (NextArg() != STRINGARG) HError(3219, "HMGenS: HMM MMF File name expected"); AddMMF(&hmset, GetStrArg()); break; case 'I': if (NextArg() != STRINGARG) HError(2319, "HMGenS: MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'J': if (NextArg() != STRINGARG) HError(2319, "HMGenS: input transform directory expected"); AddInXFormDir(&hmset, GetStrArg()); if (NextArg() == STRINGARG) xfInfo_hmm.inXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -J as the last option"); break; case 'L': if (NextArg() != STRINGARG) HError(2319, "HMGenS: Label file directory expected"); labDir = GetStrArg(); break; case 'M': if (NextArg() != STRINGARG) HError(2319, "HMGenS: Output macro file directory expected"); genDir = GetStrArg(); break; case 'N': if (NextArg() != STRINGARG) HError(3219, "HMGenS: Duration MMF File name expected"); AddMMF(&dmset, GetStrArg()); break; case 'T': if (NextArg() != INTARG) HError(2119, "HMGenS: Trace value expected"); trace = GetChkedInt(0, 0002, s); break; case 'W': if (NextArg() != STRINGARG) HError(2319, "HMGenS: parent duration transform directory expected"); xfInfo_dur.usePaXForm = TRUE; xfInfo_dur.paXFormDir = GetStrArg(); if (NextArg() == STRINGARG) xfInfo_dur.paXFormExt = GetStrArg(); if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -W as the last option"); break; case 'X': if (NextArg() != STRINGARG) HError(2319, "HMGenS: Label file extension expected"); labExt = GetStrArg(); break; case 'Y': if (NextArg() != STRINGARG) HError(2319, "HMGenS: input duration transform directory expected"); AddInXFormDir(&dmset, GetStrArg()); if (NextArg() == STRINGARG) { if (xfInfo_dur.inXFormExt == NULL) xfInfo_dur.inXFormExt = GetStrArg(); else HError(2319, "MGenS: only one input duration transform extension may be specified"); } if (NextArg() != SWITCHARG) HError(2319, "HMGenS: cannot have -Y as the last option"); break; default: HError(9919, "HMGenS: Unknown switch %s", s); } } if (NextArg() != STRINGARG) HError(2319, "HMGenS: file name of vocabulary list expected"); Initialise(); InitUttInfo(utt, FALSE); numUtt = 1; if (trace & T_TOP) SetTraceGen(); /* generate parameter sequences */ do { if (NextArg() != STRINGARG) HError(2319, "HMGenS: data file name expected"); labfn = GetStrArg(); /* track speakers */ if (UpdateSpkrStats(&hmset, &xfInfo_hmm, labfn)) { if (!xfInfo_hmm.useInXForm) xfInfo_hmm.inXForm = NULL; } if (UpdateSpkrStats(&dmset, &xfInfo_dur, labfn)) { if (!xfInfo_dur.useInXForm) xfInfo_dur.inXForm = NULL; else ResetDMMPreComps(&dmset); } fbInfo->xfinfo_hmm = &xfInfo_hmm; fbInfo->xfinfo_dur = &xfInfo_dur; fbInfo->inXForm_hmm = xfInfo_hmm.inXForm; fbInfo->inXForm_dur = xfInfo_dur.inXForm; fbInfo->al_inXForm_hmm = xfInfo_hmm.al_inXForm; fbInfo->al_inXForm_dur = xfInfo_dur.al_inXForm; fbInfo->paXForm_hmm = xfInfo_hmm.paXForm; fbInfo->paXForm_dur = xfInfo_dur.paXForm; /* generate parameters */ DoGeneration(labfn); numUtt++; } while (NumArgs() > 0); if (trace & T_TOP) { printf("Generation complete - average log prob per frame = %e (%d frames)\n", totalPr / totalT, totalT); } /* Reset stacks */ Dispose(&fbInfoStack, fbInfo); Dispose(&genStack, genInfo); Dispose(&uttStack, utt); ResetHeap(&fbInfoStack); ResetHeap(&uttStack); ResetHeap(&genStack); ResetHeap(&dmStack); ResetHeap(&hmmStack); /* Reset modules */ ResetGen(); ResetAdapt(&xfInfo_hmm, &xfInfo_dur); ResetFB(); ResetUtil(); ResetParm(); ResetModel(); ResetLabel(); ResetWave(); ResetSigP(); ResetMath(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int argc, char *argv[]) { char *s,*lfn,*dfn; void GenSentences(char *latfn, char *dicfn); if(InitShell(argc,argv,hsgen_version,hsgen_vc_id)<SUCCESS) HError(3400,"HSGen: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(3200,"HSGen: InitParm failed"); InitDict(); InitNet(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(3419, "Bad switch %s; must be single letter", s); switch(s[0]){ case 's': stats = TRUE; break; case 'l': lnum = TRUE; break; case 'n': ngen = GetChkedInt(1,1000000,s); break; case 'q': quiet = TRUE; break; case 'T': trace = GetChkedInt(0,07,s); break; default: HError(3419, "Unknown switch %s", s); } } if (NextArg()!=STRINGARG) HError(3419, "lattice file name expected"); lfn = GetStrArg(); if (NextArg()!=STRINGARG) HError(3419, "dictionary file name expected"); dfn = GetStrArg(); GenSentences(lfn,dfn); if(InitShell(argc,argv,hsgen_version,hsgen_vc_id)<SUCCESS) HError(3400,"HSGen: InitShell failed"); ResetNet(); ResetDict(); ResetParm(); ResetModel(); ResetVQ(); ResetAudio(); ResetWave(); ResetSigP(); ResetMath(); ResetLabel(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int argc, char *argv[]) { char *wordListFn,*latFn,*ipFn=NULL; LModel *bigramLm; BuildType bType = unknown; Boolean saveLatBin = FALSE; LatFormat format = HLAT_LMLIKE; Lattice *lat,*ipLat; Vocab voc; char *s; Lattice *ProcessWordLoop(MemHeap *latHeap, Vocab *voc); Lattice *ProcessBiGram(MemHeap *latHeap, Vocab *voc, LModel *biLM); void SaveLattice(Lattice *lat, char *latFn, LatFormat format); Lattice *LoadLattice(MemHeap *latHeap, char *latFn, Vocab *voc, Boolean shortArc); Lattice *ProcessWordPair(MemHeap *latHeap, Vocab *voc, char *fn); if(InitShell(argc,argv,hbuild_version,hbuild_vc_id)<SUCCESS) HError(3000,"HBuild: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitDict(); InitNet(); InitLM(); CreateHeap(&buildStack, "HBuild Stack", MSTAK, 1, 0.0, 100000, LONG_MAX ); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); enterId=GetLabId("!ENTER",TRUE); /* All sentences should or are coerced */ exitId=GetLabId("!EXIT",TRUE); /* to start enterId and end exitId */ unknownId=GetLabId("!NULL",TRUE); /* Name for words not in list */ while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(3019,"HBuild: Bad switch %s; must be single letter",s); switch(s[0]){ case 'b': saveLatBin = TRUE; break; case 'm': if (bType != unknown) HError(3019,"HBuild: Can only specifiy one of -m, -n, -w, -x"); bType = matBiGram; if (NextArg()!=STRINGARG) HError(3019,"HBuild: Matrix Bigram file name expected"); ipFn = GetStrArg(); break; case 'n': if (bType != unknown) HError(3019,"HBuild: Can only specifiy one of -m, -n, -w, -x"); bType = boBiGram; if (NextArg()!=STRINGARG) HError(3019,"HBuild: Back-off Bigram file name expected"); ipFn = GetStrArg(); break; case 's': if (NextArg() != STRINGARG) HError(3019,"HBuild: Bigram ENTER label name expected"); enterId=GetLabId(GetStrArg(),TRUE); if (NextArg() != STRINGARG) HError(3019,"HBuild: Bigram EXIT label name expected"); exitId=GetLabId(GetStrArg(),TRUE); break; case 't': if (NextArg() != STRINGARG) HError(3019,"HBuild: Bracket start label name expected"); bStartId=GetLabId(GetStrArg(),TRUE); if (NextArg() != STRINGARG) HError(3019,"HBuild: Bracket end label name expected"); bEndId=GetLabId(GetStrArg(),TRUE); break; case 'u': if (NextArg() != STRINGARG) HError(3019,"HBuild: Unknown label name expected"); unknownId=GetLabId(GetStrArg(),TRUE); break; case 'w': if (bType != unknown) HError(3019,"HBuild: Can only specifiy one of -m, -n, -w, -x"); bType = wordPair; if (NextArg()!=STRINGARG) HError(3019,"HBuild: Word pair grammar file name expected"); ipFn = GetStrArg(); break; case 'x': if (bType != unknown) HError(3019,"HBuild: Can only specifiy one of -m, -n, -w, -x"); bType = multiLat; if (NextArg()!=STRINGARG) HError(3019,"HBuild: Multi-level lattice file name expected"); ipFn = GetStrArg(); break; case 'z': zapUnknown = TRUE; break; case 'T': trace = GetChkedInt(0,511,s); break; default: HError(3019,"HBuild: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(3019,"HBuild: Word List file name expected"); wordListFn = GetStrArg(); if (NextArg()!=STRINGARG) HError(3019,"HBuild: output lattice file name expected"); latFn = GetStrArg(); if (bType == unknown) bType = wordLoop; if (saveLatBin) format |= HLAT_LBIN; /* Read the word-list into a Vocab data structure */ InitVocab(&voc); if(ReadDict(wordListFn, &voc)<SUCCESS) HError(3013,"HBuild: ReadDict failed"); switch (bType) { case matBiGram: if (trace & T_TOP) printf("Reading bigram from file %s\n",ipFn); bigramLm = ReadLModel(&gstack, ipFn); if (bigramLm->type != matBigram) HError(3030,"HBuild: File specified is not a matrix bigram"); lat = ProcessBiGram(&gstack,&voc,bigramLm); SaveLattice(lat,latFn,format); break; case boBiGram: if (trace & T_TOP) printf("Reading bigram from file %s\n",ipFn); bigramLm = ReadLModel(&gstack, ipFn); if (bigramLm->type != boNGram) HError(3030,"HBuild: File specified is not a back-off bigram"); lat = ProcessBiGram(&gstack,&voc,bigramLm); SaveLattice(lat,latFn,format); break; case multiLat: if (trace & T_TOP) printf("Reading input lattice from file %s\n",ipFn); ipLat = LoadLattice(&buildStack,ipFn,&voc,FALSE); if (ipLat->subList!=NULL) { if (trace & T_TOP) printf("Expanding multi-level lattice\n"); lat = ExpandMultiLevelLattice(&buildStack,ipLat,&voc); } else lat = ipLat; SaveLattice(lat,latFn,format); break; case wordLoop: if (trace & T_TOP) printf("Building word loop\n"); lat = ProcessWordLoop(&gstack,&voc); SaveLattice(lat,latFn,format); break; case wordPair: lat = ProcessWordPair(&gstack,&voc,ipFn); SaveLattice(lat,latFn,format); break; default: HError(3001,"Only Bigram LMs / multiLats currently implemented"); } ResetLM(); ResetNet(); ResetDict(); ResetMath(); ResetLabel(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }
int main(int argc, char *argv[]) { Source src; int tmpInt; float tmpFlt; char *accfn, *s; void Initialise(char *hmmListFn); void Interpolate(void); void UpdateModels(void); void MakeWtAccLists(void); void AttachWtAccLists(void); void StatReport(void); if(InitShell(argc,argv,hsmooth_version,hsmooth_vc_id)<SUCCESS) HError(2400,"HSmooth: InitShell failed"); InitMem(); InitLabel(); InitMath(); InitSigP(); InitWave(); InitAudio(); InitVQ(); InitModel(); if(InitParm()<SUCCESS) HError(2400,"HSmooth: InitParm failed"); InitTrain(); InitUtil(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(0); SetConfParms(); CreateHeap(&hmmStack,"HmmStore", MSTAK, 1, 1.0, 50000, 500000); CreateHMMSet(&hset,&hmmStack,TRUE); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(2419,"HSmooth: Bad switch %s; must be single letter",s); switch(s[0]){ case 'b': epsilon = GetChkedFlt(0.0,1.0,s); break; case 'c': maxStep = GetChkedInt(1,1000,s); break; case 'd': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM definition directory expected"); hmmDir = GetStrArg(); break; case 'e': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM definition directory expected"); newDir = GetStrArg(); break; case 'm': minEgs = GetChkedInt(1,1000,s); break; case 'o': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM file extension expected"); newExt = GetStrArg(); break; case 's': stats = TRUE; if (NextArg()!=STRINGARG) HError(2419,"HSmooth: Stats file name expected"); statFN = GetStrArg(); break; case 'u': SetuFlags(); break; case 'v': minVar = GetChkedFlt(0.0,10.0,s); break; case 'w': mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); break; case 'x': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: HMM file extension expected"); hmmExt = GetStrArg(); break; case 'B': saveBinary=TRUE; break; case 'H': if (NextArg() != STRINGARG) HError(2419,"HSmooth: HMM macro file name expected"); AddMMF(&hset,GetStrArg()); break; case 'M': if (NextArg()!=STRINGARG) HError(2419,"HSmooth: Output macro file directory expected"); newDir = GetStrArg(); break; case 'T': trace = GetChkedInt(0,0100000,s); break; default: HError(2419,"HSmooth: Unknown switch %s",s); } } if (NextArg() != STRINGARG) HError(2419,"HSmooth: file name of HMM list expected"); Initialise(GetStrArg()); do { if (NextArg()!=STRINGARG) HError(2419,"HSmooth: accumulator file name expected"); accfn = GetStrArg(); src=LoadAccs(&hset,accfn,uFlags); ReadFloat(&src,&tmpFlt,1,ldBinary); totalPr += (LogDouble)tmpFlt; ReadInt(&src,&tmpInt,1,ldBinary); totalT += tmpInt; CloseSource(&src); nBlk++; MakeWtAccLists(); } while (NumArgs()>0); AttachWtAccLists(); Interpolate(); if (stats) StatReport(); UpdateModels(); ResetUtil(); ResetTrain(); ResetParm(); ResetModel(); ResetVQ(); ResetAudio(); ResetWave(); ResetSigP(); ResetMath(); ResetLabel(); ResetMem(); ResetShell(); Exit(0); return (0); /* never reached -- make compiler happy */ }