lts_file_t aut_file_create(const char* name,lts_type_t ltstype,int segments,lts_file_t settings){ if (lts_type_get_state_length(ltstype)) { //Abort("cannot write state to AUT file"); Print(infoShort,"Ignoring state vector"); } if (lts_type_get_state_label_count(ltstype)) { Abort("cannot write state labels to AUT file"); } if (lts_type_get_edge_label_count(ltstype)!=1) { Abort("AUT files contain precisely one edge label"); } if (segments!=1) Abort("AUT files contain precisely 1 segment"); lts_file_t file=lts_file_bare(name,ltstype,1,settings,sizeof(struct lts_file_s)); file->f=fopen(name,"w"); if(file->f==NULL){ AbortCall("while opening %s",name); } file->root--; // set to -1 denoting undefined. file->states++; // set to 1, denoting one state. file->type_no=lts_type_get_edge_label_typeno(ltstype,0); lts_file_set_write_init(file,aut_write_init); lts_file_set_write_state(file,write_state); lts_file_set_write_edge(file,aut_write_edge); lts_file_set_close(file,aut_write_close); fprintf(file->f,"des(?,?,?) \n"); lts_file_complete(file); return file; }
lts_file_t lts_writer(lts_t lts,int segments,lts_file_t settings){ lts_file_t file=lts_file_bare("<heap>",lts->ltstype,segments,settings,sizeof(struct lts_file_s)); file->lts=lts; file->segments=segments; file->state_perseg=(uint32_t*)RTmallocZero(segments*sizeof(uint32_t)); file->edge_labels=lts_type_get_edge_label_count(lts->ltstype); lts_file_set_write_init(file,write_init); lts_file_set_write_state(file,write_state); lts_file_set_write_edge(file,write_edge); lts_file_set_close(file,write_close); lts_file_complete(file); lts_set_type(file->lts,LTS_LIST); int T=lts_type_get_type_count(lts->ltstype); for(int i=0;i<T;i++){ lts_file_set_table(file,i,lts->values[i]); } return file; }
lts_file_t lts_reader(lts_t lts,int segments,lts_file_t settings){ lts_file_t file=lts_file_bare("<heap>",lts->ltstype,segments,settings,sizeof(struct lts_file_s)); file->lts=lts; file->segments=segments; file->edge_labels=lts_type_get_edge_label_count(lts->ltstype); lts_file_set_read_init(file,read_init); lts_file_set_read_state(file,read_state); lts_file_set_read_edge(file,read_edge); lts_file_set_close(file,read_close); lts_file_complete(file); int T=lts_type_get_type_count(lts->ltstype); for(int i=0;i<T;i++){ lts_file_set_table(file,i,lts->values[i]); } lts_set_type(file->lts,LTS_LIST); file->init_count=0; file->state_count=0; file->edge_count=0; return file; }
lts_file_t aut_file_open(const char* name){ lts_type_t ltstype=single_action_type(); lts_file_t file=lts_file_bare(name,ltstype,1,NULL,sizeof(struct lts_file_s)); file->type_no=lts_type_get_edge_label_typeno(ltstype,0); lts_file_set_read_init(file,aut_read_init); lts_file_set_read_edge(file,aut_read_edge); lts_file_set_close(file,aut_read_close); lts_file_complete(file); file->f=fopen(name,"r"); if(file->f==NULL){ AbortCall("while opening %s",name); } int matches; matches = fscanf(file->f,"des%*[^(]s"); if (matches != 0) Abort("while parsing %s",name); matches = fscanf(file->f,"(%llu,%llu,%llu)\n",&file->root,&file->trans,&file->states); if (matches != 3) Abort("while parsing %s",name); Print(infoLong,"file %s contains %llu states and %llu transitions", name,file->states,file->trans); return file; }