1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
| import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
import java.lang.*;
public class Exemple extends MIDlet implements CommandListener, Runnable{
Form fenetre, fenetre1, fenetre2;
Display d;
public static int a[] = new int[5000];
Command cmd, cmd1, cmd2, cmd3, cmd4, cmd5, cmmd2;
Exemple1 exemple;
public Exemple(){
d = Display.getDisplay(this);
fenetre=new Form ("Données ECG");
fenetre1=new Form ("Page de garde");
cmd=new Command("Démarrer", Command.SCREEN,1);
cmd1=new Command("Quitter", Command.SCREEN,2);
cmd2=new Command("Connecter", Command.SCREEN,1);
cmd3=new Command("Retour", Command.SCREEN,2);
cmd4=new Command("Signal_ECG", Command.SCREEN,1);
cmmd2=new Command("Signal_ECG", Command.SCREEN,1);
cmd5=new Command("Retour", Command.SCREEN,2);
fenetre1.addCommand(cmd);
fenetre1.addCommand(cmd1);
fenetre.addCommand(cmd2);
fenetre.addCommand(cmd3);
fenetre1.setCommandListener(this);
fenetre.setCommandListener(this);
}
public void startApp() {
d.setCurrent(fenetre1);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void run(){
try{
HttpConnection conn = (HttpConnection) Connector.open("http://127.0.0.1/ecg.txt");
InputStream in=conn.openInputStream();
StringBuffer b= new StringBuffer();
int ch, i=0, k=0;
String mot="";
fenetre.append("N° Echantillon: Valeur (mV):");
while((ch= in.read()) != -1){
if (ch == 13)
ch= in.read();
if (ch == 10) {
k++;
// fenetre.append(" " +k+" "+b.toString()+"\n");
a[i]=Integer.parseInt(b.toString());
//System.out.println(a[i]);
i++;
b=new StringBuffer();
}
else {
b.append((char)ch);
}
}
k++;
//fenetre.append(" " +k+" "+b.toString()+"\n");
a[i]=Integer.parseInt(b.toString());
//System.out.println(a[i]);
//for (int j=0;j<5000;j++)
//System.out.println(k);
//System.out.println(i);
/*try{
} catch(NumberFormatException e){
}*/
//fenetre.append(b.toString());
}
catch (IOException e){}
//------------------------------------------------------
d.setCurrent(fenetre);
}
public void commandAction(Command c, Displayable s){
if (c==cmd) {
d.setCurrent(fenetre);
}
if (c==cmd2){
fenetre.removeCommand(cmd2);
fenetre.addCommand(cmd4);
Thread t=new Thread(this);
t.start();
}
if (c==cmd4){
fenetre2=new Form ("Signal ECG");
fenetre2.addCommand(cmmd2);
d.setCurrent(fenetre2);
fenetre2.setCommandListener(this);
}
if (c==cmmd2){
exemple=new Exemple1(this);
d.setCurrent(exemple);
}
}
} |
Partager