[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Surface.java, 1.221, 1.222 Project.j
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-02-04 15:09:59
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31741/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Project.java Log Message: Sensors Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.221 retrieving revision 1.222 diff -C2 -d -r1.221 -r1.222 *** Surface.java 23 Oct 2008 05:35:36 -0000 1.221 --- Surface.java 4 Feb 2009 15:09:52 -0000 1.222 *************** *** 927,931 **** /** ! * A method for controlled extrusion (like a push/pull tool) * @param delta The distance to extrude * @param sides Pass a list for the created surfaces --- 927,931 ---- /** ! * A method for controlled extrusion. * @param delta The distance to extrude * @param sides Pass a list for the created surfaces Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** Project.java 3 Nov 2008 14:26:18 -0000 1.156 --- Project.java 4 Feb 2009 15:09:52 -0000 1.157 *************** *** 12,15 **** --- 12,17 ---- import java.io.File; import java.io.IOException; + import java.io.InputStream; + import java.io.OutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; *************** *** 32,35 **** --- 34,38 ---- import net.sourceforge.bprocessor.model.bridge.Sensor; import net.sourceforge.bprocessor.model.bridge.Serializer; + import net.sourceforge.bprocessor.model.bridge.UnSerializer; import net.sourceforge.bprocessor.model.modellor.InnerWallModellor; import net.sourceforge.bprocessor.model.modellor.ModelBathModellor2; *************** *** 39,42 **** --- 42,46 ---- import org.apache.log4j.Logger; + /** * The Project *************** *** 54,58 **** /** */ ! private static final boolean SENSE = false; /** The observers */ --- 58,64 ---- /** */ ! public static final boolean SENSE = false; ! private static final String HOST = "dhcp-11-71-167"; ! private static final int PORT = 8800; /** The observers */ *************** *** 147,153 **** */ public static List<Integer> motes() throws IOException { ! InetAddress address = InetAddress.getByName("dhcp-11-71-167"); ! int port = 15342; ! SocketAddress endpoint = new InetSocketAddress(address, port); Socket socket = new Socket(); socket.connect(endpoint, 2000); --- 153,158 ---- */ public static List<Integer> motes() throws IOException { ! InetAddress address = InetAddress.getByName(HOST); ! SocketAddress endpoint = new InetSocketAddress(address, PORT); Socket socket = new Socket(); socket.connect(endpoint, 2000); *************** *** 171,174 **** --- 176,195 ---- /** * + * @return List of sensor-ids + * @throws IOException IOException + */ + public static List<Integer> sensors() throws IOException { + List<Integer> result = new LinkedList(); + result.add(15198069); + result.add(15198041); + result.add(15198042); + result.add(15198043); + result.add(15198044); + result.add(15198028); + return result; + } + + /** + * * @param id moteid * @return data *************** *** 176,182 **** */ public static List<DataItem> data(int id) throws IOException { ! InetAddress address = InetAddress.getByName("dhcp-11-71-167"); ! int port = 15342; ! SocketAddress endpoint = new InetSocketAddress(address, port); Socket socket = new Socket(); socket.connect(endpoint, 2000); --- 197,202 ---- */ public static List<DataItem> data(int id) throws IOException { ! InetAddress address = InetAddress.getByName(HOST); ! SocketAddress endpoint = new InetSocketAddress(address, PORT); Socket socket = new Socket(); socket.connect(endpoint, 2000); *************** *** 184,188 **** ByteArrayOutputStream output = new ByteArrayOutputStream(); Serializer serializer = new Serializer(output); ! serializer.writeString("data"); serializer.writeInt(id); connection.write(output.toByteArray()); --- 204,208 ---- ByteArrayOutputStream output = new ByteArrayOutputStream(); Serializer serializer = new Serializer(output); ! serializer.writeString("latest"); serializer.writeInt(id); connection.write(output.toByteArray()); *************** *** 205,208 **** --- 225,259 ---- /** * + * @param id moteid + * @return data + * @throws IOException error + */ + public static DataItem latest(int id) throws IOException { + InetAddress address = InetAddress.getByName(HOST); + SocketAddress endpoint = new InetSocketAddress(address, PORT); + Socket socket = new Socket(); + socket.connect(endpoint, 2000); + OutputStream output = socket.getOutputStream(); + Serializer serializer = new Serializer(output); + serializer.writeString("latest"); + serializer.writeInt(id); + + InputStream input = socket.getInputStream(); + UnSerializer deserializer = new UnSerializer(input); + String result = deserializer.readString(); + + if (result.equals("data")) { + long timestamp = deserializer.readInt(); + long data = deserializer.readInt(); + DataItem item = new DataItem(id, timestamp, (short) 1, data); + return item; + } else { + return null; + } + } + + + /** + * * @return boolean */ *************** *** 285,289 **** if (SENSE) { try { ! sensor.init(motes()); } catch (IOException e) { // empty --- 336,340 ---- if (SENSE) { try { ! sensor.init(sensors()); } catch (IOException e) { // empty *************** *** 1206,1208 **** --- 1257,1266 ---- return library; } + + /** + * + */ + public void updateSensors() { + sensor.update(); + } } |