Revision: 19 Author: luca.cominardi@xxxxxxxxx Date: Wed Oct 21 13:21:47 2009 Log: Ora il parser xml dovrebbe dare un'istanza corretta di Simulazione http://code.google.com/p/cooperativefsm/source/detail?r=19 Modified: /trunk/cooperativefsm/fsm.xml /trunk/cooperativefsm/src/cooperativefsm/Input.java /trunk/cooperativefsm/src/cooperativefsm/InputXML.java /trunk/cooperativefsm/src/cooperativefsm/Main.java ======================================= --- /trunk/cooperativefsm/fsm.xml Wed Oct 21 13:08:05 2009 +++ /trunk/cooperativefsm/fsm.xml Wed Oct 21 13:21:47 2009 @@ -101,6 +101,17 @@ </transval> <type>mutex</type> </relation> + <relation> + <transval> + <fsmval>A</fsmval> + <idval>b</idval> + </transval> + <transval> + <fsmval>A</fsmval> + <idval>c</idval> + </transval> + <type>mutex</type> + </relation> </simulation> =======================================--- /trunk/cooperativefsm/src/cooperativefsm/Input.java Thu Oct 15 07:02:36 2009 +++ /trunk/cooperativefsm/src/cooperativefsm/Input.java Wed Oct 21 13:21:47 2009
@@ -13,6 +13,7 @@* Metodo astratto che inizializza una vera e propria sessione di simulazione
* La chiamata è comune sia per istanze di IputTast sia di InputXML, * mentre il metodo è sovrascritto nelle sottoclassi + * @return */ public abstract Simulazione leggiSimulazione(); @@ -21,7 +22,8 @@ /** * Metodo che imposta lo stato iniziale e imposta lo stato corrente * - * @return Lo stato iniziale della simulazione + * @param list + * @return Lo stato iniziale della simulazione */ public abstract StatoCorrente leggiStatoIniziale(Vector<Fsm> list); =======================================--- /trunk/cooperativefsm/src/cooperativefsm/InputXML.java Wed Oct 21 13:08:05 2009 +++ /trunk/cooperativefsm/src/cooperativefsm/InputXML.java Wed Oct 21 13:21:47 2009
@@ -146,7 +146,7 @@//Controllo che non ci sia già un'altra fsm con lo stesso id
for(int j=0; j<listaFsm.size(); j++) { - if(id.equals(listaFsm.get(j).getId())) + if(id.equalsIgnoreCase(listaFsm.get(j).getId())) {System.out.println("-- Due fsm non possono avere lo stesso id!!! -- ");
listaFsm.get(-1);//per uscire dal programma @@ -390,6 +390,7 @@ } } } + for(int i=0, cnt=nl.getLength(); i<cnt; i++) { String test=nl.item(i).getNodeName(); @@ -400,16 +401,26 @@ //System.out.println("type: " +type); } } + for(int i=0; i<ind.size(); i++) {//System.out.println("Ind fsm: " + ind.get(i)[0] + "\tInd tr: " + ind.get(i)[1]);
for(int j=0; j<ind.size(); j++) { + if(i!=j) + { + if(ind.get(i)[0]==ind.get(j)[0]) + {+ System.out.println("-- Non è possibile inserire una relazione tra due transizioni appartenenti alla stessa macchina!!! --");
+ ind.get(-1);//per uscire dal programma + } + } int p=ind.get(j)[0]; if(i==p) app.add(ind.get(j)); } } + if(type.equalsIgnoreCase("sync")) {relazioniTransizioni[app.get(0)[1]][app.get(1)[1]]=Simulazione.Relazione.SINCRONA;
=======================================--- /trunk/cooperativefsm/src/cooperativefsm/Main.java Wed Oct 21 13:08:05 2009 +++ /trunk/cooperativefsm/src/cooperativefsm/Main.java Wed Oct 21 13:21:47 2009
@@ -28,6 +28,7 @@ final String TIPOINPUT = "TIPO DI INPUT"; final String [] SCELTAINPUT = {"da tastiera","da file xml"}; final String MESS_FINALE = "CIAO!";+ final String XML_NOT = "-- File xml non formattato correttamente!!! --";
MyMenu menuInput = new MyMenu( TIPOINPUT , SCELTAINPUT ); boolean continua = true; @@ -48,18 +49,18 @@in = new InputXML(url); //l'uri del file xml dovrà essere passato da tastiera
break; } catch (SAXException ex) {- System.out.println("File xml non formattato correttamente");
+ System.out.println(XML_NOT); } catch (IOException ex) {- System.out.println("File xml non formattato correttamente"); + System.out.println("-- Il file specificato non esiste!!! --"); //Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (ParserConfigurationException ex) {- System.out.println("File xml non formattato correttamente");
+ System.out.println(XML_NOT);//Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (NullPointerException q) {- System.out.println("File xml non formattato correttamente");
+ System.out.println(XML_NOT); } catch (ArrayIndexOutOfBoundsException t) {- System.out.println("File xml non formattato correttamente");
- }break; + System.out.println(XML_NOT); + } break; }