bprocessor-commit Mailing List for B-processor (Page 9)
Status: Pre-Alpha
Brought to you by:
henryml
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(117) |
Aug
(151) |
Sep
(157) |
Oct
(81) |
Nov
(117) |
Dec
(119) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(183) |
Feb
(130) |
Mar
(117) |
Apr
(61) |
May
(82) |
Jun
(45) |
Jul
(149) |
Aug
(173) |
Sep
(199) |
Oct
(165) |
Nov
(107) |
Dec
(137) |
2007 |
Jan
(124) |
Feb
(58) |
Mar
(123) |
Apr
(80) |
May
(130) |
Jun
(64) |
Jul
(31) |
Aug
(42) |
Sep
(114) |
Oct
(167) |
Nov
(239) |
Dec
(200) |
2008 |
Jan
(43) |
Feb
(43) |
Mar
(4) |
Apr
(9) |
May
(5) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(13) |
Oct
(9) |
Nov
(12) |
Dec
|
2009 |
Jan
|
Feb
(20) |
Mar
(7) |
Apr
(12) |
May
(34) |
Jun
(72) |
Jul
|
Aug
(3) |
Sep
(31) |
Oct
(2) |
Nov
(8) |
Dec
(4) |
2010 |
Jan
(5) |
Feb
(32) |
Mar
(8) |
Apr
(7) |
May
(36) |
Jun
|
Jul
(11) |
Aug
(15) |
Sep
(7) |
Oct
(2) |
Nov
(13) |
Dec
(80) |
2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
(12) |
May
(32) |
Jun
(9) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(8) |
2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(22) |
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael L. <he...@us...> - 2010-11-26 14:20:36
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26258/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Display.java Log Message: Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** Display.java 22 Apr 2010 08:13:39 -0000 1.106 --- Display.java 26 Nov 2010 14:20:27 -0000 1.107 *************** *** 45,48 **** --- 45,50 ---- import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; + import net.sourceforge.bprocessor.model.sense.core.Target; /** *************** *** 90,96 **** --- 92,108 ---- private static float[] middleblue = new float[] {0.11f, 0.72f, 0.67f, 0.0f}; private static float[] red = new float[]{0.8f, 0.1f, 0.1f}; + private static float[] yellow = new float[]{0.8f, 0.8f, 0.1f}; private static float[] green = new float[]{0.1f, 0.8f, 0.1f}; private static float[] blue = new float[]{0.1f, 0.1f, 0.8f}; private static float[] misty = new float[] {255f / 280, 228f / 280, 225f / 280}; + + + + private static final int ALARM_NONE = 0; + private static final int ALARM_TEMPERATURE = 1; + private static final int ALARM_HUMIDITY = 2; + private static final int ALARM_SKIMMEL = 3; + + private static byte[] highlight = new byte[128]; *************** *** 448,451 **** --- 460,471 ---- } } + private static void paintEdges(Collection<Edge> edges, float[] color, float size, double alpha) { + apply(color, (float) alpha); + gl.glLineWidth(size); + for (Edge current : edges) { + draw(current); + } + } + private static void paintStippled(Collection<Edge> edges, float[] color, float size) { if (!edges.isEmpty()) { *************** *** 919,922 **** --- 939,990 ---- } + private static int alarmOf(Instance instance) { + if (instance.getParameters() != null) { + Object id = instance.getParameters().get("moteid"); + if (id instanceof String) { + Target target = TargetManager.instance().getTarget((String) id); + if (target.humidityAlarm) { + return ALARM_HUMIDITY; + } else if (target.temperatureAlarm) { + return ALARM_TEMPERATURE; + } else if (target.skimmelAlarm) { + return ALARM_SKIMMEL; + } + } + } + return ALARM_NONE; + } + + private static void checkAlarm(Item space) { + int alarm = ALARM_NONE; + + Space s = (Space) space; + for (Item current : s.getElements()) { + if (current instanceof Instance) { + int itsAlarm = alarmOf((Instance) current); + if (itsAlarm != ALARM_NONE) { + alarm = itsAlarm; + } + } else { + checkAlarm(current); + } + } + + if (alarm != ALARM_NONE) { + Collection<Edge> edges = space.hiliteEdges(); + float[] color = null; + if (alarm == ALARM_HUMIDITY) { + color = blue; + } else if (alarm == ALARM_TEMPERATURE) { + color = red; + } else { + color = yellow; + } + disable(GL.GL_DEPTH_TEST); + paintEdges(edges, color, 6.0f, 0.4); + enable(GL.GL_DEPTH_TEST); + } + } + private static void draw(Item space, boolean inside) { if (space.isInstance()) { *************** *** 961,964 **** --- 1029,1051 ---- private static void drawInstance(Instance space, boolean inside) { + + // + // int alarm = alarmOf(space); + // + // if (alarm != ALARM_NONE) { + // Collection<Edge> edges = space.hiliteEdges(); + // float[] color = null; + // if (alarm == ALARM_HUMIDITY) { + // color = blue; + // } else if (alarm == ALARM_TEMPERATURE) { + // color = red; + // } else { + // color = yellow; + // } + // paintEdges(edges, color, 4.0f, 0.5); + // } + // + + if (Project.useDisplayLists()) { if (selecting()) { *************** *** 1433,1445 **** if (!selecting()) { disableClipplanes(); - geometrics.addAll(Selection.primary()); if (target != null) { geometrics.add(target); } enableClipplanes(); } draw(world, world == active); if (!selecting()) { --- 1520,1533 ---- if (!selecting()) { disableClipplanes(); geometrics.addAll(Selection.primary()); if (target != null) { geometrics.add(target); } + //hiliteSpaces(geometrics); enableClipplanes(); } draw(world, world == active); + checkAlarm(world); if (!selecting()) { Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.295 retrieving revision 1.296 diff -C2 -d -r1.295 -r1.296 *** View.java 20 May 2010 10:58:51 -0000 1.295 --- View.java 26 Nov 2010 14:20:27 -0000 1.296 *************** *** 8,11 **** --- 8,12 ---- import net.sourceforge.bprocessor.gl.Editor; + import net.sourceforge.bprocessor.gl.tool.FourTool; import net.sourceforge.bprocessor.gl.tool.SelectTool; import net.sourceforge.bprocessor.gl.tool.SpaceSelectTool; *************** *** 33,37 **** --- 34,48 ---- import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; + import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; + import net.sourceforge.bprocessor.model.sense.core.Measurement; + import net.sourceforge.bprocessor.model.sense.core.MoldEntry; + import net.sourceforge.bprocessor.model.sense.core.Target; + import net.sourceforge.bprocessor.model.sense.monitor.MonitorManager; + import net.sourceforge.bprocessor.model.sense.monitor.TargetMonitor; + import java.text.DateFormat; + import java.text.DecimalFormat; + import java.text.NumberFormat; + import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; *************** *** 757,766 **** } } else if (candidate instanceof Item) { ! if (editor.getTool() instanceof SpaceSelectTool) { drawSpeechBubble((Item) candidate, hitdetection); } } } //drawObscureBox(); --- 768,782 ---- } } else if (candidate instanceof Item) { ! if (editor.getTool() instanceof SpaceSelectTool || editor.getTool() instanceof FourTool) { drawSpeechBubble((Item) candidate, hitdetection); } + } } + if (editor.getTool() instanceof FourTool) { + drawMoldTable(); + } + //drawObscureBox(); *************** *** 1046,1049 **** --- 1062,1070 ---- gl.glPopMatrix(); } + + private int measureString(String string) { + return glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, string); + } + /** *************** *** 1205,1212 **** } private void drawSpeechBubble(Item space, boolean clickable) { Transformation transformation = transformation(); ! double width = 240; ! double height = 180; double delta = 10; --- 1226,1296 ---- } + private void drawMoldTable() { + double gw = 100; + double gh = 100; + double gx = View.width - gw - 10; + double gy = View.height - gh - 10; + double c0 = 75; + double c1 = 100; + double cscale = gh / (c1 - c0); + + gl.glColor3d(0.3, 0.3, 0.3); + gl.glLineWidth(1f); + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(gx, gy); + gl.glVertex2d(gx + gw, gy); + gl.glVertex2d(gx, gy); + gl.glVertex2d(gx, gy + gh); + gl.glEnd(); + + { + + double range = c1 - c0; + double step = range / 5; + double m0 = c0; + + + + for (int i = 0; i < 5; i++) { + String m0s = String.valueOf(m0); + double mx = (m0 - c0) * cscale; + double xx = measureString(m0s); + drawString(gx - xx - 4, gy + mx, 0, m0s); + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(gx - 2, gy + mx); + gl.glVertex2d(gx + 2, gy + mx); + gl.glEnd(); + m0 = m0 + step; + } + } + + { + drawString(gx + gw - 20, gy - 14, 0, "50"); + } + + { + gl.glColor3d(0.9, 0.1, 0.1); + gl.glLineWidth(2.5f); + gl.glBegin(GL.GL_LINE_STRIP); + + double dx = 0; + + for (MoldEntry current : Project.moldtable.entries) { + double value = current.humidity; + double dy = (value - c0) * cscale; + gl.glVertex2d(gx + dx, gy + dy); + dx = dx + 4; + } + + gl.glEnd(); + } + } + private void drawSpeechBubble(Item space, boolean clickable) { Transformation transformation = transformation(); ! double width = 400; ! double height = 200; ! double margin = 20; ! double offset = 20; double delta = 10; *************** *** 1218,1225 **** Vertex d = c.add(new Vertex(width, 0, 0)); Vertex e = a.add(new Vertex(width, 0, 0)); - front.setZ(1); gl.glColor4d(0.94f, 0.97f, 1, 0.9); - gl.glBegin(GL.GL_POLYGON); gl.glVertex3d(a.getX(), a.getY(), a.getZ()); --- 1302,1307 ---- *************** *** 1227,1231 **** gl.glVertex3d(b.getX(), b.getY(), b.getZ()); gl.glEnd(); - gl.glBegin(GL.GL_POLYGON); gl.glVertex3d(a.getX(), a.getY(), a.getZ()); --- 1309,1312 ---- *************** *** 1234,1238 **** gl.glVertex3d(e.getX(), e.getY(), e.getZ()); gl.glEnd(); - gl.glColor3d(0.1, 0.1, 0.1); gl.glLineWidth(0.5f); --- 1315,1318 ---- *************** *** 1251,1255 **** --- 1331,1568 ---- gl.glVertex3d(a.getX(), a.getY(), a.getZ()); gl.glEnd(); + + if (space instanceof Instance) { + Instance instance = (Instance) space; + if (instance.getParameters() != null) { + String id = (String) instance.getParameters().get("moteid"); + Target target = TargetManager.instance().getTarget(id); + if (target != null) { + + System.out.println("-- graph --"); + + TargetMonitor monitor = MonitorManager.instance().get(target); + + List<Measurement> temperatures = monitor.getTemperatures(); + List<Measurement> humidities = monitor.getHumidities(); + + + if (temperatures.size() > 0) { + long t0 = Long.MAX_VALUE; + long t1 = Long.MIN_VALUE; + + for (Measurement current : temperatures) { + if (current.getTime() < t0) { + t0 = current.getTime(); + } + if (current.getTime() > t1) { + t1 = current.getTime(); + } + } + + for (Measurement current : humidities) { + if (current.getTime() < t0) { + t0 = current.getTime(); + } + if (current.getTime() > t1) { + t1 = current.getTime(); + } + } + + long ellapsed = t1 - t0; + + long twohours = 2 * 60 * 60 * 1000; + long minutes = 4 * 60 * 1000; + + if (ellapsed < twohours) { + if (ellapsed > minutes) { + t0 = t1 - minutes; + } + t0 = (t0 / 1000) * 1000; + t1 = t0 + minutes; + ellapsed = minutes; + } + + double gx = a.getX() + margin + offset; + double gy = a.getY() + margin; + + double gw = width - offset - 2 * margin; + double gh = height - 2 * margin; + + double tscale = gw / (double) ellapsed; + + { + gl.glColor3d(0.3, 0.3, 0.3); + gl.glLineWidth(1f); + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(gx, gy); + gl.glVertex2d(gx + gw, gy); + gl.glVertex2d(gx, gy); + gl.glVertex2d(gx, gy + gh); + gl.glEnd(); + } + + + if (ellapsed > 4 * 24 * 60 * 60 * 1000) { + DateFormat format = new SimpleDateFormat("dd/MM"); + { + long oneweek = 7 * 24 * 60 * 60 * 1000; + long m0 = ((t0 / oneweek) + 1) * oneweek; + + gl.glColor3d(0.3, 0.3, 0.3); + gl.glLineWidth(1f); + gl.glLineStipple(1, (short) 0x0F0F); + gl.glEnable(GL.GL_LINE_STIPPLE); + + for (int i = 0; i < 4; i++) { + String m0s = format.format(new Date(m0)); + double mx = gx + (m0 - t0) * tscale; + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(mx, gy); + gl.glVertex2d(mx, gy + gh); + gl.glEnd(); + String[] s = m0s.split("/"); + double xx = measureString(s[0]); + drawString(mx - xx - 2, gy - 12, 0, m0s); + m0 = m0 + oneweek; + } + gl.glDisable(GL.GL_LINE_STIPPLE); + } + + } else { + DateFormat format = new SimpleDateFormat("HH:mm"); + { + long oneminute = 60 * 1000; + long m0 = ((t0 / oneminute) + 1) * oneminute; + + gl.glColor3d(0.3, 0.3, 0.3); + gl.glLineWidth(1f); + gl.glLineStipple(1, (short) 0x0F0F); + gl.glEnable(GL.GL_LINE_STIPPLE); + + for (int i = 0; i < 4; i++) { + String m0s = format.format(new Date(m0)); + double mx = gx + (m0 - t0) * tscale; + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(mx, gy); + gl.glVertex2d(mx, gy + gh); + gl.glEnd(); + String[] s = m0s.split(":"); + double xx = measureString(s[0]); + drawString(mx - xx - 2, gy - 12, 0, m0s); + m0 = m0 + oneminute; + } + gl.glDisable(GL.GL_LINE_STIPPLE); + } + } + + + + double c0 = 15.0; + double c1 = 40.0; + double cscale = gh / (c1 - c0); + double h0 = 0; + double h1 = 100; + double hscale = gh / (h1 - h0); + + + System.out.println("cscale: " + cscale); + + { + double range = c1 - c0; + double step = range / 5; + double m0 = c0; + + gl.glColor3d(0.3, 0.3, 0.3); + gl.glLineWidth(1f); + NumberFormat f = new DecimalFormat("00.00"); + + for (int i = 0; i < 5; i++) { + String m0s = f.format(m0); + double mx = (m0 - c0) * cscale; + double xx = measureString(m0s); + drawString(gx - xx - 4, gy + mx, 0, m0s); + if (i > 0) { + drawString(gx + 4, gy + mx, 0, String.valueOf(i * 20)); + } + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(gx - 2, gy + mx); + gl.glVertex2d(gx + 2, gy + mx); + gl.glEnd(); + + + m0 = m0 + step; + } + + gl.glColor3d(0.9, 0.1, 0.1); + drawString(gx - 20, gy + gh, 0, "¼C"); + + if (Project.enableAlarms) { + if (Project.historic) { + double value = target.average; + double dy = (value - c0) * cscale; + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(gx, gy + dy); + gl.glVertex2d(gx + gw, gy + dy); + gl.glEnd(); + } + } + + gl.glColor3d(0.1, 0.1, 0.9); + drawString(gx + 5, gy + gh, 0, "RH%"); + + if (Project.enableAlarms) { + if (Project.historic) { + double value = target.limit; + double dy = (value - h0) * hscale; + gl.glBegin(GL.GL_LINES); + gl.glVertex2d(gx, gy + dy); + gl.glVertex2d(gx + gw, gy + dy); + gl.glEnd(); + } + } + } + + + { + gl.glColor3d(0.9, 0.1, 0.1); + gl.glLineWidth(2.5f); + gl.glBegin(GL.GL_LINE_STRIP); + + for (Measurement current : temperatures) { + long t = current.getTime(); + if (t >= t0 && t <= t1) { + double value = Double.valueOf(current.getValue()); + double dx = ((double) (t - t0)) * tscale; + double dy = (value - c0) * cscale; + gl.glVertex2d(gx + dx, gy + dy); + } + } + gl.glEnd(); + } + + { + gl.glColor3d(0.1, 0.1, 0.9); + gl.glLineWidth(2.5f); + gl.glBegin(GL.GL_LINE_STRIP); + + for (Measurement current : humidities) { + long t = current.getTime(); + if (t >= t0 && t <= t1) { + double value = Double.valueOf(current.getValue()); + double dx = ((double) (t - t0)) * tscale; + double dy = (value - h0) * hscale; + gl.glVertex2d(gx + dx, gy + dy); + } + } + + gl.glEnd(); + } + + } + } + } + } + String text = space.getDescription().toString(); BufferedReader reader = new BufferedReader(new StringReader(text)); *************** *** 1897,1900 **** --- 2210,2215 ---- } + + /** * *************** *** 1958,1961 **** --- 2273,2277 ---- clearNames(); if (surface != null) { + System.out.println("path: " + surface); return ((Surface)surface.getLastInPath()); } else { *************** *** 1964,1967 **** --- 2280,2353 ---- } } + + /** + * + * @param x x + * @param y y + * @return surface + */ + public Item getSelectedItem(double x, double y) { + this.x = x; + this.y = y; + + picking = 10; + + editor.repaint(true); + + { + int bufferOffset = 0; + int names = 0; + long zMax = 0xFFFFFFFFL; + double nearestSurface = 1.0; + SelectionPath surface = null; + + for (int i = 0; i < hits; i++) { + names = selectBuffer.get(bufferOffset); + if (names > 0) { + long z1 = 0xFFFFFFFFL & selectBuffer.get(bufferOffset + 1); + long z2 = 0xFFFFFFFFL & selectBuffer.get(bufferOffset + 2); + double near = (double) z1 / (double) zMax; + double far = (double) z2 / (double) zMax; + near = (near + far) / 2; + bufferOffset += 2; + SelectionPath currentPath = new SelectionPath(); + if (names > 1) { + for (int namesIndex = 1; namesIndex < names; namesIndex++) { + Instance instance = (Instance)getObject(selectBuffer.get(bufferOffset + namesIndex)); + currentPath.addGeometricToPath(instance); + } + if (currentPath == null) { + bufferOffset += names + 1; + continue; + } + } + int id = selectBuffer.get(bufferOffset + names); + bufferOffset += names + 1; + Object current = getObject(id); + + if (current instanceof Surface) { + Surface it = (Surface) current; + if (!Display.transparent(it)) { + if (near < nearestSurface) { + nearestSurface = near; + currentPath.addGeometricToPath((Surface) current); + surface = currentPath; + } + } + } + } else { + bufferOffset += 3; + } + } + clearNames(); + if (surface != null) { + return surface.getItem(); + } else { + return null; + } + } + } + + /** |
From: Michael L. <he...@us...> - 2010-11-26 14:20:36
|
Update of /cvsroot/bprocessor/gl/src/gfx In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26258/src/gfx Added Files: four.png Log Message: --- NEW FILE: four.png --- (This appears to be a binary file; contents omitted.) |
From: Michael L. <he...@us...> - 2010-11-26 14:20:36
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26258/src/net/sourceforge/bprocessor/gl/tool Modified Files: ToolFactory.java Tool.java SpaceSelectTool.java Added Files: FourTool.java Log Message: Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** ToolFactory.java 20 May 2010 12:02:06 -0000 1.108 --- ToolFactory.java 26 Nov 2010 14:20:27 -0000 1.109 *************** *** 69,73 **** private AbstractTool assign; private AbstractTool spaceselect; ! private Pencil pencil; private EraserTool eraser; --- 69,74 ---- private AbstractTool assign; private AbstractTool spaceselect; ! private AbstractTool four; ! private Pencil pencil; private EraserTool eraser; *************** *** 143,146 **** --- 144,149 ---- assign = new SpaceTool(editor, null); spaceselect = new SpaceSelectTool(editor, null); + four = new FourTool(editor, null); + pencil = new Pencil(editor, pencilcursor); eraser = new EraserTool(editor, pencilcursor); *************** *** 165,168 **** --- 168,174 ---- "Biconselecttool2.gif", "Sensor Select")); + viewingset.add(registerTool(Tool.FOUR, four, + "four.png", "Mold ~ Four Weeks")); + modellingset.add(registerTool(Tool.SELECT_TOOL, select, "Biconselecttool.gif", "Select")); modellingset.add(registerTool(Tool.ASSIGN_TOOL, assign, "assign-icon-3.png", "Assign")); Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Tool.java 19 Jun 2009 13:32:29 -0000 1.42 --- Tool.java 26 Nov 2010 14:20:27 -0000 1.43 *************** *** 83,86 **** --- 83,89 ---- public static final int SPACE_SELECT = 28; + /** the FOUR tool */ + public static final int FOUR = 29; + /** * Return the current selection Index: SpaceSelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SpaceSelectTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SpaceSelectTool.java 14 Sep 2009 16:22:59 -0000 1.5 --- SpaceSelectTool.java 26 Nov 2010 14:20:27 -0000 1.6 *************** *** 8,13 **** --- 8,17 ---- import net.sourceforge.bprocessor.gl.Editor; + import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Geometric; + import net.sourceforge.bprocessor.model.Instance; + import net.sourceforge.bprocessor.model.Item; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Space; *************** *** 20,23 **** --- 24,28 ---- import javax.swing.JPopupMenu; + /** * The Space Select Tool *************** *** 46,49 **** --- 51,55 ---- public void prepare() { Selection.primary().clear(); + Project.getInstance().clearHistoriuc(); } *************** *** 57,72 **** double x = e.getX(); double y = e.getY(); ! ! Surface surface = editor.getView().getSelectedSurface(x, y); ! if (surface != null) { ! Space front = surface.getFrontDomain(); ! Space back = surface.getBackDomain(); ! if (front.isConstructionSpace()) { ! Selection.primary().set(front); ! } else if (back.isConstructionSpace()) { ! Selection.primary().set(back); ! } } else { ! Selection.primary().clear(); } } else { --- 63,90 ---- double x = e.getX(); double y = e.getY(); ! ! Item item = editor.getView().getSelectedItem(x, y); ! if (item != null) { ! Selection.primary().set(item); } else { ! Object found = editor.getView().getObjectAtPoint(e.getX(), e.getY(), View.OBJECTS); ! if (found instanceof Instance) { ! Selection.primary().set((Instance) found); ! } else { ! Surface surface = editor.getView().getSelectedSurface(x, y); ! System.out.println("selected surface: " + surface); ! if (surface != null) { ! Space front = surface.getFrontDomain(); ! Space back = surface.getBackDomain(); ! if (front.isConstructionSpace()) { ! Selection.primary().set(front); ! } else if (back.isConstructionSpace()) { ! Selection.primary().set(back); ! } ! } else { ! Selection.primary().clear(); ! } ! } ! } } else { --- NEW FILE: FourTool.java --- //--------------------------------------------------------------------------------- // $Id: FourTool.java,v 1.1 2010/11/26 14:20:27 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gl.tool; import net.sourceforge.bprocessor.gl.Editor; import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Instance; import net.sourceforge.bprocessor.model.Item; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import java.awt.Cursor; import java.awt.event.MouseEvent; import java.util.LinkedList; import javax.swing.JPopupMenu; /** * The Space Select Tool */ public class FourTool extends AbstractTool { /** * The constructor * @param editor The 3D canvas * @param cursor The cursor */ public FourTool(Editor editor, Cursor cursor) { super(editor, cursor); } /** * Invoked when the mouse cursor has been moved * @param e The MouseEvent object */ protected void moved(MouseEvent e) { } /** * {@inheritDoc} */ public void prepare() { Selection.primary().clear(); Project.getInstance().fetchHistoric(); } /** * Invoked when a mouse button has been pressed on a component. * @param e The MouseEvent object */ protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { double x = e.getX(); double y = e.getY(); Item item = editor.getView().getSelectedItem(x, y); if (item != null) { Selection.primary().set(item); } else { Object found = editor.getView().getObjectAtPoint(e.getX(), e.getY(), View.OBJECTS); if (found instanceof Instance) { Selection.primary().set((Instance) found); } else { Surface surface = editor.getView().getSelectedSurface(x, y); System.out.println("selected surface: " + surface); if (surface != null) { Space front = surface.getFrontDomain(); Space back = surface.getBackDomain(); if (front.isConstructionSpace()) { Selection.primary().set(front); } else if (back.isConstructionSpace()) { Selection.primary().set(back); } } else { Selection.primary().clear(); } } } } else { Selection.primary().clear(); } } /** * Invoked when the mouse is held pressed and moved * @param e The MouseEvent object */ protected void dragged(MouseEvent e) { if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK) { // Empty if block } } /** * Invoked when a mouse button has been released on a component. * @param e The MouseEvent */ protected void released(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { // Empty if block } } /** * {@inheritDoc} */ public String initialTip() { return "Click objects to select." + " Hold shift to add to selection." + " Drag to multi-select."; } /** * {@inheritDoc} */ public void handleMenu(MouseEvent event) { Selection selection = Selection.primary(); JPopupMenu menu = null; if (target == null) { selection.clear(); menu = GUI.getInstance().menuFactory().menuFor(new LinkedList<Geometric>()); } else { if (target instanceof Geometric) { if (!selection.contains(target)) { selection.set((Geometric) target); } menu = GUI.getInstance().menuFactory().menuFor(selection); } } if (menu != null && menu.getComponentCount() > 0) { editor.popup(menu, event.getX(), event.getY()); } } } |
From: Michael L. <he...@us...> - 2010-11-26 14:20:35
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26258/src/net/sourceforge/bprocessor/gl/model Modified Files: SelectionPath.java Log Message: Index: SelectionPath.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model/SelectionPath.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SelectionPath.java 13 Jan 2010 10:58:30 -0000 1.4 --- SelectionPath.java 26 Nov 2010 14:20:27 -0000 1.5 *************** *** 16,19 **** --- 16,22 ---- import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Instance; + import net.sourceforge.bprocessor.model.Item; + import net.sourceforge.bprocessor.model.Space; + import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; *************** *** 121,123 **** --- 124,149 ---- return translated; } + + /** + * + * @return Item + */ + public Item getItem() { + Geometric last = getLastInPath(); + if (last instanceof Surface) { + if (getFirstInPath() instanceof Instance) { + return (Instance) getFirstInPath(); + } else { + Surface surface = (Surface) last; + Space front = surface.getFrontDomain(); + Space back = surface.getBackDomain(); + if (front.isConstructionSpace()) { + return front; + } else if (back.isConstructionSpace()) { + return back; + } + } + } + return null; + } } |
From: Michael L. <he...@us...> - 2010-11-26 14:20:30
|
Update of /cvsroot/bprocessor/bprocessor In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26248 Added Files: skimmel.csv Log Message: --- NEW FILE: skimmel.csv --- 0;100.0;100.0;99.41588785046729 2;100.0;96.3785046728972;93.80841121495327 4;100.0;92.40654205607477;88.78504672897196 6;95.44392523364486;90.07009345794393;84.92990654205607 8;93.92523364485982;88.55140186915888;81.77570093457943 10;92.64018691588785;87.14953271028037;79.08878504672897 12;91.58878504672897;86.33177570093459;77.92056074766356 14;90.77102803738318;85.51401869158879;76.75233644859813 16;90.07009345794393;84.69626168224299;76.28504672897196 18;89.36915887850468;84.11214953271028;75.93457943925233 20;88.9018691588785;83.64485981308411;75.93457943925233 22;88.3177570093458;83.0607476635514;75.93457943925233 24;87.85046728971963;82.71028037383178;75.93457943925233 26;87.5;82.24299065420561;75.93457943925233 28;87.14953271028037;81.89252336448598;75.93457943925233 30;86.6822429906542;81.54205607476635;75.93457943925233 32;86.33177570093459;81.19158878504673;75.93457943925233 34;86.0981308411215;81.07476635514018;75.93457943925233 36;85.74766355140187;80.60747663551402;75.93457943925233 38;85.51401869158879;80.37383177570094;75.93457943925233 40;85.16355140186916;80.14018691588785;75.93457943925233 42;84.92990654205607;79.90654205607477;75.93457943925233 44;84.69626168224299;79.67289719626169;75.93457943925233 46;84.57943925233644;79.4392523364486;75.93457943925233 48;84.34579439252336;79.32242990654206;75.93457943925233 50;84.11214953271028;79.08878504672897;75.93457943925233 |
From: Michael L. <he...@us...> - 2010-11-26 14:20:26
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/sense/ti In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv26235/src/net/sourceforge/bprocessor/model/sense/ti Log Message: Directory /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/sense/ti added to the repository |
From: Michael L. <he...@us...> - 2010-10-26 06:44:33
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28248/src/net/sourceforge/bprocessor/gui/attrview Modified Files: GenericPanel.java ClassificationTextAttribute.java Log Message: Classification update problem Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** GenericPanel.java 31 Aug 2010 13:48:06 -0000 1.58 --- GenericPanel.java 26 Oct 2010 06:44:25 -0000 1.59 *************** *** 104,108 **** simpleUpdate = true; } ! Project.getInstance().changed(); Project.getInstance().checkpoint(); } --- 104,108 ---- simpleUpdate = true; } ! Project.getInstance().changed(obj); Project.getInstance().checkpoint(); } Index: ClassificationTextAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/ClassificationTextAttribute.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ClassificationTextAttribute.java 18 Sep 2009 10:16:18 -0000 1.13 --- ClassificationTextAttribute.java 26 Oct 2010 06:44:25 -0000 1.14 *************** *** 197,213 **** if (value != null) { valueLabel = new JLabel(value.getName()); - /*if (attribute.getClassification().getId().equalsIgnoreCase("-1")) { - valueLabel = new JLabel(value.getName()); - } else { - if (attribute.getClassification() == null || - ((Classification)attribute.getValue()).getName(). - equalsIgnoreCase(attribute.getClassification().getParent().getName())) { - valueLabel = new JLabel(value.getName()); - } else { - //valueLabel = new JLabel(value.getParent().getName() + "." + value.getName()); - valueLabel = new JLabel(value.getName()); - } - }*/ - } else { valueLabel = new JLabel("None"); --- 197,200 ---- *************** *** 284,293 **** if (e.getSource() instanceof MyMenuItem) { MyMenuItem source = (MyMenuItem)(e.getSource()); - System.out.println("menu selected " + source); - attribute.setValue(source.getClassification()); - component.remove(0); - component.add(createValueLabel((Structure)attribute.getThe2ndValue())); - component.revalidate(); valueChanged(); } --- 271,275 ---- *************** *** 346,366 **** if (entered != null) { attribute.setValue(entered); ! } /*else { ! Classification newclas, egne; ! if (((Classification) attribute.getValue()).getType() == 0) { ! egne = Project.getInstance().getClassification("-99", 0); ! newclas = new Classification("-1", editor.getText(), egne, 0); ! } else { ! egne = Project.getInstance().getClassification("-99", 1); ! newclas = new Classification("-1", editor.getText(), egne, 1); ! } ! if (egne != null && newclas != null) { ! egne.addChild(newclas); ! } else { ! log.warn("Tried to create classification in " + egne + " as " + newclas); ! } ! ! attribute.setThe2ndValue(newclas); ! }*/ component.remove(editor); editor.removeKeyListener(this); --- 328,332 ---- if (entered != null) { attribute.setValue(entered); ! } component.remove(editor); editor.removeKeyListener(this); |
From: Michael L. <he...@us...> - 2010-10-26 06:44:28
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28205/src/net/sourceforge/bprocessor/model Modified Files: Item.java Log Message: Classification update problem Index: Item.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Item.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Item.java 13 Jul 2010 09:32:43 -0000 1.8 --- Item.java 26 Oct 2010 06:44:20 -0000 1.9 *************** *** 522,526 **** setName((String)a.getValue()); } else if (a.getName().equals("Classification")) { - System.out.println("setting classification:"); setClassification(((Classification)a.getValue())); } else if (a.getName().equals("Type")) { --- 522,525 ---- |
From: Michael L. <he...@us...> - 2010-09-08 07:34:25
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv23500/src/net/sourceforge/bprocessor/model Modified Files: Project.java Log Message: Added the BSplinePackage Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.197 retrieving revision 1.198 diff -C2 -d -r1.197 -r1.198 *** Project.java 6 Sep 2010 13:08:36 -0000 1.197 --- Project.java 8 Sep 2010 07:34:15 -0000 1.198 *************** *** 31,34 **** --- 31,35 ---- import javax.swing.SwingUtilities; + import net.sourceforge.bprocessor.model.plugin.BSplinePackage; import net.sourceforge.bprocessor.model.plugin.FacadePackage; import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; *************** *** 283,286 **** --- 284,288 ---- reset(); new FacadePackage(); + new BSplinePackage(); } |
From: Michael L. <he...@us...> - 2010-09-08 07:34:24
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv23500/src/net/sourceforge/bprocessor/model/plugin Added Files: BSplinePackage.java Log Message: Added the BSplinePackage --- NEW FILE: BSplinePackage.java --- package net.sourceforge.bprocessor.model.plugin; import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Space; public class BSplinePackage { public static class BSpline extends NetCommand { public void initialize(Space net) { } public void evaluate() { } } public BSplinePackage() { Command.register(BSpline.class); } } |
From: Michael L. <he...@us...> - 2010-09-06 13:08:51
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9114/src/net/sourceforge/bprocessor/gui Modified Files: GUI.java Log Message: Index: GUI.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/GUI.java,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** GUI.java 31 Aug 2010 13:48:06 -0000 1.120 --- GUI.java 6 Sep 2010 13:08:43 -0000 1.121 *************** *** 19,23 **** import net.sourceforge.bprocessor.gui.actions.FileSaveActionListener; import net.sourceforge.bprocessor.gui.actions.FileSaveAsActionListener; - import net.sourceforge.bprocessor.gui.actions.ModellorMenuAction; import net.sourceforge.bprocessor.gui.actions.ToolsEnergyActionListener; import net.sourceforge.bprocessor.gui.attrview.AttributeView; --- 19,22 ---- *************** *** 26,29 **** --- 25,29 ---- import net.sourceforge.bprocessor.gui.treeview.LibraryTreeView; import net.sourceforge.bprocessor.gui.treeview.SpaceTreeView; + import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Project; *************** *** 429,473 **** create.add(action); } ! ! for (Modellor current : Modellor.getRegisteredModellors()) { ! if (current.application() == Modellor.SHAPE) { ! AbstractAction action = new ModellorAction(current) { ! public void actionPerformed(ActionEvent e) { ! System.out.println("actionate " + modellor); ! Space space = modellor.createSpace(); ! Project.getInstance().world().add(space); ! Project.getInstance().changed(); ! } ! }; ! create.add(action); } } - - - - JMenu modellorSubmenu = new JMenu("Modellors"); - modellorSubmenu.setMnemonic(KeyEvent.VK_M); - modellorSubmenu.addMenuListener(new MenuListener() { - public void menuCanceled(MenuEvent e) { - } - - public void menuDeselected(MenuEvent e) { - } - - public void menuSelected(MenuEvent e) { - JMenu jm = (JMenu)e.getSource(); - jm.removeAll(); - Space s = Project.getInstance().getActiveSpace(); - int level = s.getLevel(); - for (Modellor m : Modellor.getRegisteredModellors()) { - JMenuItem mod = new JMenuItem(m.title()); - if (level == m.getUseableLevel()) { - mod.addActionListener(new ModellorMenuAction(s, m)); - jm.add(mod); - } - } - } - }); - create.add(modellorSubmenu); } }); --- 429,440 ---- create.add(action); } ! { ! JMenu submenu = new JMenu("Parametric Objects"); ! for (Class<? extends Command> current : Command.getCommands()) { ! AbstractAction action = new CommandAction(current); ! submenu.add(action); } + create.add(submenu); } } }); *************** *** 475,478 **** --- 442,479 ---- return create; } + + class CommandAction extends AbstractAction { + private Class<? extends Command> clarse; + + public CommandAction(Class<? extends Command> clarse) { + super(clarse.getSimpleName()); + this.clarse = clarse; + } + public void actionPerformed(ActionEvent e) { + try { + Space union = Command.invoke(clarse); + Space active = Project.getInstance().getActiveSpace(); + active.add(union); + Space net = (Space) union.find("Construction Geometry"); + if (net != null) { + net.edit(); + } + Command command = null; + for (Command current : union.getScripts()) { + command = current; + } + if (command != null) { + AttributeView.instance().display(command); + } else { + AttributeView.instance().display(union); + } + Project.getInstance().checkpoint(); + Project.getInstance().changed(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } private JMenu createEditMenu() { |
From: Michael L. <he...@us...> - 2010-09-06 13:08:48
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9105/src/net/sourceforge/bprocessor/gl/view Modified Files: PopupMenu.java Log Message: Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/PopupMenu.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** PopupMenu.java 13 Jul 2010 12:33:48 -0000 1.48 --- PopupMenu.java 6 Sep 2010 13:08:40 -0000 1.49 *************** *** 58,61 **** --- 58,63 ---- import net.sourceforge.bprocessor.model.Command.BoundingSphere; import net.sourceforge.bprocessor.model.modellor.Modellor; + import net.sourceforge.bprocessor.model.plugin.FacadePackage; + import net.sourceforge.bprocessor.model.plugin.NetCommand; import org.apache.log4j.Logger; *************** *** 350,354 **** AbstractAction action = new SpaceMenuAction(sp, "Frame..") { public void actionPerformed(ActionEvent event) { ! Command command = new Command.Frame(space); AttributeView.instance().display(command); space.getOwner().add(command); --- 352,357 ---- AbstractAction action = new SpaceMenuAction(sp, "Frame..") { public void actionPerformed(ActionEvent event) { ! NetCommand command = new FacadePackage.Frame(); ! command.initialize(space); AttributeView.instance().display(command); space.getOwner().add(command); |
From: Michael L. <he...@us...> - 2010-09-06 13:08:45
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9074/src/net/sourceforge/bprocessor/model Modified Files: Command.java Project.java Log Message: Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** Command.java 17 Jul 2010 21:19:32 -0000 1.95 --- Command.java 6 Sep 2010 13:08:36 -0000 1.96 *************** *** 18,21 **** --- 18,23 ---- import java.util.Set; + import net.sourceforge.bprocessor.model.plugin.NetCommand; + /** * Command *************** *** 23,26 **** --- 25,56 ---- public abstract class Command extends Entity implements Parametric { + private static List<Class<? extends Command>> commands; + + static { + commands = new LinkedList(); + } + + public static void register(Class<? extends Command> clarse) { + commands.add(clarse); + System.out.println("command: " + clarse.getSimpleName()); + } + + public static List<Class<? extends Command>> getCommands() { + return commands; + } + + public static Space invoke(Class<? extends Command> clarse) throws Exception { + Space union = Item.createUnion(clarse.getSimpleName()); + Space net = Space.createNet("Construction Geometry"); + union.add(net); + Command command = clarse.newInstance(); + if (command instanceof NetCommand) { + NetCommand nc = (NetCommand) command; + nc.initialize(net); + } + union.add(command); + return union; + } + /** * *************** *** 1801,2000 **** } - /** - * - */ - public static class Frame extends Command { - /** - * Constructs a frame command - * @param net Space - */ - public Frame(Space net) { - // Space net is the B-Net which is part of the construction space, it is saved as the parameter "net" - parameters.put("net", net); - parameters.put("frame-width", 0.035); - parameters.put("interior-width", 0.035); - parameters.put("depth", 0.07); - - parameters.put("frame name", "Frame"); - parameters.put("exterior name", "Exterior"); - parameters.put("hole name", "Hole"); - } - - /** - * {@inheritDoc} - */ - public String title() { - // this is the title shown on top of the parameters section - return "Frame Net"; - } - - private List<Edge> simplify(List<Edge> edges) { - // what exactly do you simplify here and why? - if (edges.size() > 3) { - List<Edge> result = new LinkedList(); - List<Vertex> vertices = Offset.vertices(edges); - LinkedList<Vertex> live = new LinkedList(); - { - int n = vertices.size(); - Vertex previous = vertices.get(n - 1); - Vertex current = vertices.get(0); - Vertex next = null; - for (int i = 0; i < n; i++) { - next = vertices.get((i + 1) % n); // the reuslt is always i+1, only if i is already the last edge in the list, the operation will return 0 - Vertex u = current.minus(previous); - Vertex v = next.minus(current); - Vertex cross = u.cross(v); - if (!cross.isZero()) { //this excludes parallel vectors and vectors of length 0 - live.add(current); - } - previous = current; - current = next; - } - } - Vertex previous = live.getLast(); - for (Vertex current : live) { - result.add(new Edge(previous, current)); - previous = current; - } - return result; - } else { - return edges; - } - } - - - /** {@inheritDoc} */ - @Override - public void evaluate() { - Space net = (Space) parameters.get("net"); - double inside = parameters.getDouble("frame-width"); - double delta = parameters.getDouble("interior-width"); - double depth = parameters.getDouble("depth"); - String frameName = (String) parameters.get("frame name"); - String exteriorName = (String) parameters.get("exterior name"); - String holeName = (String) parameters.get("hole name"); - List<Surface> surfaces = new LinkedList(); - - { - HashMap map = new HashMap(); - for (Surface current : net.getSurfaces()) { - surfaces.add((Surface) current.copy(map)); //what happens here? - } - } - List<Edge> boundary = new LinkedList(); - - { - Inverse inv = new Inverse(surfaces); // inverse? - - for (Edge current : inv.edges()) { - Collection<Surface> adjacant = inv.surfaces(current); - if (adjacant.size() == 1) { // if an edge only is adjacent to 1 surface it is a border edge - boundary.add(current); - } - } - - boundary = Offset.order(boundary); //order? does offset basically create a copy here? - } - - Offset.offsetIt(boundary, -inside + (delta / 2)); - - Space union = (Space) net.getOwner().find("Frame"); //check if the frame is created or redrawn... - - if (union == null) { - union = Item.createUnion("Frame"); - net.getOwner().add(union); - } else { - union.clear(); - } - - Collection<Surface> inserted = new LinkedList(); - - List<Edge> offset = Offset.offset(boundary, inside - (delta / 2)); //offset the boundary to the inside by the frame width minus half the interior width - Surface exterior = new Surface(simplify(offset)); - inserted.add(exterior); - //does this mean that the boundary edges are now basically moved inside and the next step is to move all edges inside? - - List<Surface> interior = new LinkedList(); - for (Surface current : surfaces) { - List<Edge> curve = Offset.offset(current.getEdges(), -delta / 2); //offset all surfaces by half the interior width - interior.add(new Surface(simplify(curve))); - } - inserted.addAll(interior); - - for (Surface current : interior) { - exterior.addHole(current); - } - - - Set<Surface> tops = new HashSet(); - - if (depth != 0) { - Collection<Surface> sides = new LinkedList(); - Surface top = exterior.extrusionall(depth, sides, tops); - inserted.addAll(sides); - inserted.addAll(tops); - inserted.add(top); - } - - Shape.addSurfacesTo(union, inserted); //add geometry to the space - - { - Space ext = Item.createFunctionalSpace(exteriorName); - Space frame = Item.createConstructionSpace(frameName); - // ?????????????? What happens here? Do you assign the surface sides to the adjacent spaces? These are named in the paramters, right? - if (depth > 0) { - exterior.assignBack(ext, true); - exterior.assignFront(frame, true); - } else { - exterior.assignFront(ext, true); - exterior.assignBack(frame, true); - } - union.add(ext); - union.add(frame); - Vertex n1 = exterior.normal(); - int i = 0; - for (Surface current : interior) { - i++; - Vertex n2 = current.normal(); - double sign; - if (n1.dot(n2) < 0) { - //what does the dot product of two vectors tell me? - sign = -depth; - } else { - sign = depth; - } - Space hole = Item.createFunctionalSpace(holeName + " " + i); - if (sign > 0) { - current.assignFront(hole, true); - current.setBackDomain(ext); - } else { - current.assignBack(hole, true); - current.setFrontDomain(ext); - } - for (Surface s : tops) { - if (s.getBackDomain().isVoid()) { - s.setBackDomain(ext); - } - if (s.getFrontDomain().isVoid()) { - s.setFrontDomain(ext); - } - } - for (Surface s : hole.getEnvelope()) { - if (s.getBackDomain().isVoid()) { - s.setBackDomain(frame); - } - if (s.getFrontDomain().isVoid()) { - s.setFrontDomain(frame); - } - } - - union.add(hole); - } - } - } - } - - - /** new command start ........................................................................................ * --- 1831,1834 ---- Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.196 retrieving revision 1.197 diff -C2 -d -r1.196 -r1.197 *** Project.java 31 Aug 2010 13:48:03 -0000 1.196 --- Project.java 6 Sep 2010 13:08:36 -0000 1.197 *************** *** 31,34 **** --- 31,35 ---- import javax.swing.SwingUtilities; + import net.sourceforge.bprocessor.model.plugin.FacadePackage; import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; import net.sourceforge.bprocessor.model.sense.core.Target; *************** *** 281,284 **** --- 282,286 ---- staticObservers = new LinkedList(); reset(); + new FacadePackage(); } |
From: Michael L. <he...@us...> - 2010-09-06 13:08:44
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9074/src/net/sourceforge/bprocessor/model/plugin Added Files: NetCommand.java FacadePackage.java Log Message: --- NEW FILE: NetCommand.java --- package net.sourceforge.bprocessor.model.plugin; import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Space; public abstract class NetCommand extends Command { public abstract void initialize(Space net); } --- NEW FILE: FacadePackage.java --- package net.sourceforge.bprocessor.model.plugin; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import net.sourceforge.bprocessor.model.Command; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Item; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; public class FacadePackage { /** * */ public static class Frame extends NetCommand { public void initialize(Space net) { parameters.put("net", net); parameters.put("frame-width", 0.035); parameters.put("interior-width", 0.035); parameters.put("depth", 0.07); parameters.put("frame name", "Frame"); parameters.put("exterior name", "Exterior"); parameters.put("hole name", "Hole"); } /** * {@inheritDoc} */ public String title() { // this is the title shown on top of the parameters section return "Frame Net"; } private List<Edge> simplify(List<Edge> edges) { // what exactly do you simplify here and why? if (edges.size() > 3) { List<Edge> result = new LinkedList(); List<Vertex> vertices = Offset.vertices(edges); LinkedList<Vertex> live = new LinkedList(); { int n = vertices.size(); Vertex previous = vertices.get(n - 1); Vertex current = vertices.get(0); Vertex next = null; for (int i = 0; i < n; i++) { next = vertices.get((i + 1) % n); // the reuslt is always i+1, only if i is already the last edge in the list, the operation will return 0 Vertex u = current.minus(previous); Vertex v = next.minus(current); Vertex cross = u.cross(v); if (!cross.isZero()) { //this excludes parallel vectors and vectors of length 0 live.add(current); } previous = current; current = next; } } Vertex previous = live.getLast(); for (Vertex current : live) { result.add(new Edge(previous, current)); previous = current; } return result; } else { return edges; } } /** {@inheritDoc} */ @Override public void evaluate() { Space net = (Space) parameters.get("net"); double inside = parameters.getDouble("frame-width"); double delta = parameters.getDouble("interior-width"); double depth = parameters.getDouble("depth"); String frameName = (String) parameters.get("frame name"); String exteriorName = (String) parameters.get("exterior name"); String holeName = (String) parameters.get("hole name"); List<Surface> surfaces = new LinkedList(); { HashMap map = new HashMap(); for (Surface current : net.getSurfaces()) { surfaces.add((Surface) current.copy(map)); //what happens here? } } List<Edge> boundary = new LinkedList(); { Inverse inv = new Inverse(surfaces); // inverse? for (Edge current : inv.edges()) { Collection<Surface> adjacant = inv.surfaces(current); if (adjacant.size() == 1) { // if an edge only is adjacent to 1 surface it is a border edge boundary.add(current); } } boundary = Offset.order(boundary); //order? does offset basically create a copy here? } if (boundary.size() > 0) { Offset.offsetIt(boundary, -inside + (delta / 2)); Space union = (Space) net.getOwner().find("Frame"); //check if the frame is created or redrawn... if (union == null) { union = Item.createUnion("Frame"); net.getOwner().add(union); } else { union.clear(); } Collection<Surface> inserted = new LinkedList(); Surface exterior = null; List<Edge> offset = Offset.offset(boundary, inside - (delta / 2)); //offset the boundary to the inside by the frame width minus half the interior width exterior = new Surface(simplify(offset)); inserted.add(exterior); List<Surface> interior = new LinkedList(); for (Surface current : surfaces) { List<Edge> curve = Offset.offset(current.getEdges(), -delta / 2); //offset all surfaces by half the interior width interior.add(new Surface(simplify(curve))); } inserted.addAll(interior); for (Surface current : interior) { exterior.addHole(current); } Set<Surface> tops = new HashSet(); if (depth != 0) { Collection<Surface> sides = new LinkedList(); Surface top = exterior.extrusionall(depth, sides, tops); inserted.addAll(sides); inserted.addAll(tops); inserted.add(top); } Shape.addSurfacesTo(union, inserted); //add geometry to the space { Space ext = Item.createFunctionalSpace(exteriorName); Space frame = Item.createConstructionSpace(frameName); // ?????????????? What happens here? Do you assign the surface sides to the adjacent spaces? These are named in the paramters, right? if (depth > 0) { exterior.assignBack(ext, true); exterior.assignFront(frame, true); } else { exterior.assignFront(ext, true); exterior.assignBack(frame, true); } union.add(ext); union.add(frame); Vertex n1 = exterior.normal(); int i = 0; for (Surface current : interior) { i++; Vertex n2 = current.normal(); double sign; if (n1.dot(n2) < 0) { //what does the dot product of two vectors tell me? sign = -depth; } else { sign = depth; } Space hole = Item.createFunctionalSpace(holeName + " " + i); if (sign > 0) { current.assignFront(hole, true); current.setBackDomain(ext); } else { current.assignBack(hole, true); current.setFrontDomain(ext); } for (Surface s : tops) { if (s.getBackDomain().isVoid()) { s.setBackDomain(ext); } if (s.getFrontDomain().isVoid()) { s.setFrontDomain(ext); } } for (Surface s : hole.getEnvelope()) { if (s.getBackDomain().isVoid()) { s.setBackDomain(frame); } if (s.getFrontDomain().isVoid()) { s.setFrontDomain(frame); } } union.add(hole); } } } } } public FacadePackage() { Command.register(Frame.class); } } |
From: Michael L. <he...@us...> - 2010-09-06 13:08:38
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9053/src/net/sourceforge/bprocessor/model/plugin Log Message: Directory /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/plugin added to the repository |
From: Michael L. <he...@us...> - 2010-08-31 15:54:23
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20330/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java SpaceTreeView.java Log Message: Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** GenericTreeView.java 13 Jul 2010 12:33:55 -0000 1.151 --- GenericTreeView.java 31 Aug 2010 13:48:06 -0000 1.152 *************** *** 58,67 **** import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; - import net.sourceforge.bprocessor.model.bridge.DataItem; - import net.sourceforge.bprocessor.model.bridge.Mote; - import net.sourceforge.bprocessor.model.bridge.Sensor; import net.sourceforge.bprocessor.model.modellor.Modellor; ! import net.sourceforge.bprocessor.model.sense.SensorItem; ! import net.sourceforge.bprocessor.model.sense.SensorStorage; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.gui.attrview.AttributeView; --- 58,70 ---- import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.modellor.Modellor; ! import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; ! import net.sourceforge.bprocessor.model.sense.core.Target; ! import net.sourceforge.bprocessor.model.sense.monitor.DataSet; ! import net.sourceforge.bprocessor.model.sense.monitor.DataItem; ! import net.sourceforge.bprocessor.model.sense.monitor.MonitorManager; ! import net.sourceforge.bprocessor.model.sense.monitor.SensorHistory; ! import net.sourceforge.bprocessor.model.sense.monitor.SensorMonitor; ! import net.sourceforge.bprocessor.model.sense.monitor.TargetMonitor; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.gui.attrview.AttributeView; *************** *** 659,662 **** --- 662,705 ---- } + + private class TargetMonitorNode extends EntityNode { + public TargetMonitorNode(TargetMonitor monitor) { + super(monitor); + for (SensorMonitor current : monitor.getMonitors()) { + add(new SensorMonitorNode(current)); + } + } + } + + private class SensorMonitorNode extends EntityNode { + public SensorMonitorNode(SensorMonitor monitor) { + super(monitor); + add(new SensorHistoryNode(monitor.getSensorHistory())); + } + } + + private class SensorHistoryNode extends EntityNode { + public SensorHistoryNode(SensorHistory sensorHistory) { + super(sensorHistory); + add(new DataSetNode(sensorHistory.getData())); + } + } + + private class DataSetNode extends EntityNode { + public DataSetNode(DataSet graph) { + super(graph); + for (DataItem current : graph.getItems()) { + add(new DataItemNode(current)); + } + } + } + + private class DataItemNode extends EntityNode { + public DataItemNode(DataItem item) { + super(item); + } + } + + /** * *************** *** 682,688 **** add(new ConstructorNode(cs)); } ! if (space.getStorage() != null) { ! SensorStorage storage = (SensorStorage) space.getStorage(); ! add(new SensorStorageContainer("Data", storage.getItems())); } } --- 725,733 ---- add(new ConstructorNode(cs)); } ! Object obj = space.getParameters().get("target"); ! if (obj instanceof String) { ! Target target = TargetManager.instance().getTarget((String) obj); ! TargetMonitor monitor = MonitorManager.instance().get(target); ! add(new TargetMonitorNode(monitor)); } } *************** *** 702,707 **** } } - - } --- 747,750 ---- *************** *** 1303,1386 **** /** - * - */ - public class SensorContainer extends CompositeNode { - - /** - * @param sensor Sensor - */ - public SensorContainer(Sensor sensor) { - super(sensor, sensor.motes(), false); - } - - - /** {@inheritDoc} */ - public EntityNode nodeFor(Object entity) { - return new MoteNode((Mote) entity); - } - - /** - * Update the node with the given object - * @param o The object - */ - public void update(Object o) { - userObject = o; - super.update(((Sensor)o).motes()); - } - - } - - /** - * - */ - public class MoteNode extends EntityNode { - /** - * @param label Mote - */ - public MoteNode(Mote label) { - super(label); - add(new DataContainer("Data", label.items())); - } - - /** - * {@inheritDoc} - */ - public void update(Object o) { - super.update(o); - Mote mote = (Mote) o; - updateChild(0, mote.items()); - } - } - - - /** - * - */ - public class SensorStorageContainer extends CompositeNode { - /** - * - * @param name String - * @param content data items - */ - public SensorStorageContainer(String name, Collection<SensorItem> content) { - super(name, content, false); - } - } - - /** - * - */ - public class DataContainer extends CompositeNode { - /** - * - * @param name String - * @param content data items - */ - public DataContainer(String name, Collection<DataItem> content) { - super(name, content, false); - } - } - - /** * Component Container */ --- 1346,1349 ---- Index: SpaceTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/SpaceTreeView.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** SpaceTreeView.java 21 May 2010 07:28:54 -0000 1.36 --- SpaceTreeView.java 31 Aug 2010 13:48:06 -0000 1.37 *************** *** 37,43 **** root.add(new ScriptContainer("Scripts", p.world().getScripts(), false)); root.add(new ComponentContainer("Catalog", p.getCatalogObjects())); - if (Project.SENSE) { - root.add(new SensorContainer(p.sensor())); - } model.nodeStructureChanged(root); } catch (Exception error) { --- 37,40 ---- *************** *** 57,63 **** ((GenericNode)root.getChildAt(2)).update(p.world().getScripts()); ((GenericNode)root.getChildAt(3)).update(p.getCatalogObjects()); ! if (Project.SENSE) { ! ((GenericNode)root.getChildAt(4)).update(p.sensor()); ! } } catch (ArrayIndexOutOfBoundsException e) { log.error("There were a inconsistent number of nodes attached to " + --- 54,58 ---- ((GenericNode)root.getChildAt(2)).update(p.world().getScripts()); ((GenericNode)root.getChildAt(3)).update(p.getCatalogObjects()); ! } catch (ArrayIndexOutOfBoundsException e) { log.error("There were a inconsistent number of nodes attached to " + |
From: Michael L. <he...@us...> - 2010-08-31 13:48:14
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20330/src/net/sourceforge/bprocessor/gui Modified Files: GUI.java Log Message: Index: GUI.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/GUI.java,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** GUI.java 20 May 2010 10:58:40 -0000 1.119 --- GUI.java 31 Aug 2010 13:48:06 -0000 1.120 *************** *** 32,41 **** import net.sourceforge.bprocessor.model.Item; import net.sourceforge.bprocessor.model.modellor.Modellor; - import net.sourceforge.bprocessor.model.sense.DataReader; - import net.sourceforge.bprocessor.model.sense.SensorItem; - import java.text.ParseException; import java.util.Collection; - import java.util.List; import java.util.Set; import java.util.HashSet; --- 32,37 ---- *************** *** 55,59 **** import java.io.FileNotFoundException; import java.io.FileOutputStream; - import java.io.IOException; import java.io.OutputStream; --- 51,54 ---- *************** *** 621,635 **** int state = chooser.showOpenDialog(null); File file = chooser.getSelectedFile(); - DataReader reader = new DataReader(); - try { - List<SensorItem> data = reader.read(file); - Project.getInstance().setMeasures(data); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (ParseException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } } }); --- 616,619 ---- |
From: Michael L. <he...@us...> - 2010-08-31 13:48:14
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20330/src/net/sourceforge/bprocessor/gui/attrview Modified Files: GenericPanel.java Added Files: GraphAttribute.java Log Message: --- NEW FILE: GraphAttribute.java --- //--------------------------------------------------------------------------------- // $Id: GraphAttribute.java,v 1.1 2010/08/31 13:48:06 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.attrview; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.swing.BoxLayout; import javax.swing.JPanel; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.sense.core.Measurement; import net.sourceforge.bprocessor.model.sense.monitor.DataItem; import net.sourceforge.bprocessor.model.sense.monitor.DataSet; import net.sourceforge.bprocessor.model.sense.monitor.Graph; import net.sourceforge.bprocessor.model.sense.monitor.Graph.Period; /** * A attribute for a preview */ public class GraphAttribute extends GenericAttribute { private Attribute attribute; private class GraphPanel extends JPanel { private Graph graph; public GraphPanel(Graph graph) { this.graph = graph; setBackground(Color.white); } public void paintComponent(Graphics g) { super.paintComponent(g); List<Color> colors = new LinkedList<Color>(); colors.add(Color.blue); colors.add(Color.red); colors.add(Color.green); colors.add(Color.yellow); colors.add(Color.cyan); colors.add(Color.magenta); double width = getSize().width; double height = getSize().height; int maxx = 0; long maxtime = 0; double maxvalue = Double.NEGATIVE_INFINITY; Period period = graph.period; long elapsed = period.to - period.from; System.out.println("elapsed " + elapsed); Iterator<Color> iter = colors.iterator(); for (DataSet set : graph.data) { if (!iter.hasNext()) { iter = colors.iterator(); } g.setColor(iter.next()); for (DataItem item : set.getItems()) { Measurement measurement = item.getMeasureMent(); long initial = measurement.getTime() - period.from; double delta = initial / (double) elapsed; int x = (int) (delta * width); double value = Double.valueOf(measurement.getValue()); if (value > maxvalue) { maxvalue = value; maxtime = measurement.getTime(); maxx = x; } int y = (int) ((value / 100) * height); y = (int) (height - y); if (set.getSensor().getType().equals("temperature")) { g.fillRect(x, y, 4, 4); } else { g.fillOval(x, y, 4, 4); } } } g.setColor(Color.gray); g.drawLine(maxx, 5, maxx, (int) (height - 5)); g.setFont(new Font("Verdana", Font.PLAIN, 10)); DateFormat format = new SimpleDateFormat("dd/MM HH:mm"); Date date = new Date(maxtime); g.drawString(format.format(date), 5, 12); } } /** * Constructor * @param attribute the attribute for the panel */ public GraphAttribute(Attribute attribute) { super(BoxLayout.PAGE_AXIS); this.setPreferredSize(new Dimension(150, 200)); this.setBackground(Color.white); this.attribute = attribute; GraphPanel panel = new GraphPanel((Graph) attribute.getValue()); this.add(panel); } /** {@inheritDoc} */ @Override public Attribute attribute() { return attribute; } /** {@inheritDoc} */ @Override public void cancelEditing() { } /** {@inheritDoc} */ @Override public void startEditing() { } /** {@inheritdoc} */ @Override public void stopEditing() { } } Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** GenericPanel.java 20 May 2010 10:58:39 -0000 1.57 --- GenericPanel.java 31 Aug 2010 13:48:06 -0000 1.58 *************** *** 35,38 **** --- 35,39 ---- import net.sourceforge.bprocessor.model.Selector; import net.sourceforge.bprocessor.model.Structure; + import net.sourceforge.bprocessor.model.sense.monitor.Graph; /** *************** *** 206,209 **** --- 207,216 ---- } + private void handleGraph(Attribute attribute, JComponent where) { + GenericAttribute generic = new GraphAttribute(attribute); + genAttributes.add(generic); + where.add(new AttributeRow(generic)); + } + private void generateContent(List what, JComponent where) { Iterator iter = what.iterator(); *************** *** 222,225 **** --- 229,234 ---- } else if (a.getValue() instanceof Boolean) { handleBoolean(a, where); + } else if (a.getValue() instanceof Graph) { + handleGraph(a, where); } else if (a.getValue() instanceof Component) { handleComponent(a, where); |
From: Michael L. <he...@us...> - 2010-08-31 13:48:12
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model Modified Files: Project.java Log Message: Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.195 retrieving revision 1.196 diff -C2 -d -r1.195 -r1.196 *** Project.java 13 Jul 2010 12:33:52 -0000 1.195 --- Project.java 31 Aug 2010 13:48:03 -0000 1.196 *************** *** 8,13 **** package net.sourceforge.bprocessor.model; - import java.io.ByteArrayInputStream; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; --- 8,11 ---- *************** *** 16,30 **** import java.io.OutputStream; import java.io.PrintStream; - - import java.net.InetAddress; - import java.net.InetSocketAddress; - import java.net.Socket; - import java.net.SocketAddress; import java.net.URL; - import java.net.URLConnection; - import java.text.DateFormat; - import java.text.DecimalFormat; - import java.text.ParseException; - import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; --- 14,18 ---- *************** *** 43,64 **** import javax.swing.SwingUtilities; ! import net.sourceforge.bprocessor.model.bridge.Connection; ! import net.sourceforge.bprocessor.model.bridge.DataItem; ! import net.sourceforge.bprocessor.model.bridge.DeSerializer; ! 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.brunata.io.BPersistence; ! import net.sourceforge.bprocessor.model.brunata.io.XMLDocument; ! import net.sourceforge.bprocessor.model.brunata.io.DocumentParser; ! import net.sourceforge.bprocessor.model.sense.SensorItem; ! import net.sourceforge.bprocessor.model.sense.SensorStorage; import net.sourceforge.bprocessor.model.xml.Bmodel; import org.apache.log4j.Logger; - import dk.au.perpos.spatialsupport.routefinding.Boundary; import dk.au.perpos.spatialsupport.locationmodel.Location; import dk.au.perpos.spatialsupport.routefinding.Area; import dk.au.perpos.spatialsupport.routefinding.LocationModel; import dk.au.perpos.spatialsupport.routefinding.Opening; --- 31,47 ---- import javax.swing.SwingUtilities; ! import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; ! import net.sourceforge.bprocessor.model.sense.core.Target; ! import net.sourceforge.bprocessor.model.sense.monitor.DataSet; ! import net.sourceforge.bprocessor.model.sense.monitor.Graph; ! import net.sourceforge.bprocessor.model.sense.monitor.MonitorManager; ! import net.sourceforge.bprocessor.model.sense.monitor.TargetMonitor; import net.sourceforge.bprocessor.model.xml.Bmodel; import org.apache.log4j.Logger; import dk.au.perpos.spatialsupport.locationmodel.Location; import dk.au.perpos.spatialsupport.routefinding.Area; + import dk.au.perpos.spatialsupport.routefinding.Boundary; import dk.au.perpos.spatialsupport.routefinding.LocationModel; import dk.au.perpos.spatialsupport.routefinding.Opening; *************** *** 82,91 **** /** */ ! public static final boolean SENSE = false; - /** */ - public static final boolean BRUN = false; - private static final String HOST = "localhost"; - private static final int PORT = 8800; private static boolean brunata; --- 65,70 ---- /** */ ! public static final boolean SENSE = true; private static boolean brunata; *************** *** 96,102 **** private Tesselator tesselator; - private List<SensorItem> measures; - private int index; - /** The observers */ private List<Observer> observers; --- 75,78 ---- *************** *** 131,137 **** private ParameterBlock globals; - /** */ - private Sensor sensor; - /** Has changes been made */ private boolean dirty; --- 107,110 ---- *************** *** 180,194 **** private List<Component> catalog; - - - /** - * - * @param data data - */ - public void setMeasures(List<SensorItem> data) { - measures = data; - } - - private Space findIn(Item item, String name) { if (item instanceof Space) { --- 153,156 ---- *************** *** 235,277 **** */ public void updateSensorData() { - if (measures != null) { - if (index < measures.size()) { - SensorItem data = measures.get(index); - if (data != null) { - String name = "Sensor - " + data.id(); - Space sensor = find(name); - if (sensor != null) { - DecimalFormat format = new DecimalFormat("0.000"); - String t = format.format(data.temperature()); - String h = format.format(data.humimdity()); - - String id = ""; - if (data.id().equals("2501858")) { - id = "3134"; - } else if (data.id().equals("2501861")) { - id = "3132"; - } else if (data.id().equals("2501863")) { - id = "3119"; - } else if (data.id().equals("2501864")) { - id = "3138"; - } else if (data.id().equals("2501865")) { - id = "3127"; - } - - String header = "Internal ID: " + data.id() + "\nExternal ID: " + id + "\n"; - - String info = "Temperatur: " + t + " C\n" + "Relativ luftfugtighed: " + h + "ä\n"; - sensor.setDescription(header + info); - - if (data.temperature() < 18 && data.humimdity() > 70) { - sensor.setMaterial(findMaterial("Red")); - } else { - sensor.setMaterial(findMaterial("Green")); - } - changed(); - } - } - } - } } --- 197,200 ---- *************** *** 280,289 **** */ public void forward() { - if (measures != null) { - if ((index + 1) < measures.size()) { - index++; - updateSensorData(); - } - } } --- 203,206 ---- *************** *** 292,301 **** */ public void backward() { - if (measures != null) { - if (index > 0) { - index--; - updateSensorData(); - } - } } --- 209,212 ---- *************** *** 305,423 **** */ public Date getDate() { ! if (measures != null) { ! SensorItem item = measures.get(index); ! return item.date(); ! } ! return null; ! } ! ! /** ! * ! * @return motes ! * @throws IOException error ! */ ! 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); ! Connection connection = new Connection(socket); ! ByteArrayOutputStream output = new ByteArrayOutputStream(); ! Serializer serializer = new Serializer(output); ! serializer.writeString("motes"); ! connection.write(output.toByteArray()); ! byte[] reply = connection.read(); ! ByteArrayInputStream input = new ByteArrayInputStream(reply); ! DeSerializer deserializer = new DeSerializer(input); ! int n = deserializer.readInt(); ! List<Integer> result = new LinkedList(); ! for (int i = 0; i < n; i++) { ! int id = deserializer.readInt(); ! result.add(new Integer(id)); ! } ! return result; ! } ! ! /** ! * ! * @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 ! * @throws IOException error ! */ ! 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); ! Connection connection = new Connection(socket); ! ByteArrayOutputStream output = new ByteArrayOutputStream(); ! Serializer serializer = new Serializer(output); ! serializer.writeString("latest"); ! serializer.writeInt(id); ! connection.write(output.toByteArray()); ! byte[] reply = connection.read(); ! ByteArrayInputStream input = new ByteArrayInputStream(reply); ! DeSerializer deserializer = new DeSerializer(input); ! int n = deserializer.readInt(); ! List<DataItem> items = new LinkedList(); ! for (int i = 0; i < n; i++) { ! int moteid = deserializer.readInt(); ! long timestamp = Long.valueOf(deserializer.readString()); ! short type = (short) deserializer.readInt(); ! long data = deserializer.readInt(); ! DataItem item = new DataItem(moteid, timestamp, type, data); ! items.add(item); ! } ! return items; ! } ! ! /** ! * ! * @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")) { ! String stamp = deserializer.readString(); ! long timestamp = Long.valueOf(stamp); ! long data = deserializer.readInt(); ! DataItem item = new DataItem(id, timestamp, (short) 1, data); ! return item; ! } else { ! return null; ! } } - /** * --- 216,222 ---- */ public Date getDate() { ! return new Date(); } /** * *************** *** 528,539 **** globals.putDouble("brick", 0.12); globals.putDouble("roof", 0.07); - sensor = new Sensor(); - if (SENSE) { - try { - sensor.init(sensors()); - } catch (IOException e) { - // empty - } - } makeClean(); } --- 327,330 ---- *************** *** 570,581 **** } - - /** - * - * @return sensor - */ - public Sensor sensor() { - return sensor; - } /** * Get the world --- 361,364 ---- *************** *** 1211,1217 **** res.add(new Attribute("Export", Boolean.valueOf(doExport))); res.add(new Attribute("Export Path", getExportPath())); ! if (BRUN) { ! res.add(new Attribute("Brunata Server", Boolean.valueOf(brunata))); ! res.add(new Attribute("Initial Date", initialDate)); } res.add(new Attribute("Script", script)); --- 994,1011 ---- res.add(new Attribute("Export", Boolean.valueOf(doExport))); res.add(new Attribute("Export Path", getExportPath())); ! if (SENSE) { ! List<DataSet> lst = new LinkedList<DataSet>(); ! for (Instance current : world.collectInstances()) { ! Object obj = current.getParameters().get("target"); ! if (obj instanceof String) { ! Target target = TargetManager.instance().getTarget((String) obj); ! TargetMonitor monitor = MonitorManager.instance().get(target); ! monitor.collect(lst); ! } ! } ! if (!lst.isEmpty()) { ! Graph graph = new Graph(lst); ! res.add(new Attribute("graph", graph)); ! } } res.add(new Attribute("Script", script)); *************** *** 2185,2191 **** */ public void updateSensors() { - if (SENSE) { - sensor.update(); - } if (brunata) { fetch(); --- 1979,1982 ---- *************** *** 2200,2360 **** } } ! private void fetch() { System.out.println("fetching..."); ! List<Instance> sensors = getSensors(); ! if (initialized) { ! // ! } else { ! for (Instance current : sensors) { ! String value = (String) current.getParameters().get("Intern ID"); ! System.out.println(value); ! long id = Long.valueOf(value); ! SensorStorage storage = new SensorStorage(id); ! current.setStorage(storage); ! } ! DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); ! try { ! Date date = format.parse(initialDate); ! stamp = date.getTime(); ! } catch (ParseException e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } ! for (Instance current : sensors) { ! SensorStorage storage = (SensorStorage) current.getStorage(); ! if (storage != null) { ! long id = storage.getId(); ! try { ! List<SensorItem> items = process(id, new Date(stamp)); ! storage.update(items); ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! } ! stamp = System.currentTimeMillis(); ! initialized = true; ! Project.getInstance().changed(); ! } ! } ! ! private void fetch1() { ! try { ! List<SensorItem> items1 = process(2501858); ! List<SensorItem> items2 = process(2501861); ! List<SensorItem> items3 = process(2501863); ! List<SensorItem> items4 = process(2501864); ! List<SensorItem> items5 = process(2501865); ! ! List<SensorItem> result = new LinkedList(); ! ! Iterator<SensorItem> iter1 = items1.iterator(); ! Iterator<SensorItem> iter2 = items2.iterator(); ! Iterator<SensorItem> iter3 = items3.iterator(); ! Iterator<SensorItem> iter4 = items4.iterator(); ! Iterator<SensorItem> iter5 = items5.iterator(); ! for (int i = 0; i < items1.size(); i++) { ! if (iter1.hasNext()) { ! result.add(iter1.next()); ! } ! if (iter2.hasNext()) { ! result.add(iter2.next()); ! } ! if (iter3.hasNext()) { ! result.add(iter3.next()); ! } ! if (iter4.hasNext()) { ! result.add(iter4.next()); ! } ! if (iter5.hasNext()) { ! result.add(iter5.next()); ! } ! } ! setMeasures(result); ! } catch (Exception e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } ! } ! ! ! ! /** ! * ! * @param url URL ! * @return XMLDocument ! * @throws Exception Error ! */ ! public static XMLDocument fetch(URL url) throws Exception { ! URLConnection connection = url.openConnection(); ! DocumentParser parser = new DocumentParser(); ! InputStream input = connection.getInputStream(); ! XMLDocument document = parser.parse(input); ! input.close(); ! return document; ! } ! ! private URL address(long id) throws Exception { ! String www = "https://ext.brunata.com/ws-webmon/v1/da/"; ! String login = "040985:b35c52662aee64d6b12faa2a2eb7013a/"; ! String what = "meters/"; ! String type = ":(DEWPOINT,HUMIDITY,TEMPERATURE).xml"; ! String address = www + login + what + id + type; ! return new URL(address); ! } ! ! private static URL address(long id, Date from) throws Exception { ! String www = "https://ext.brunata.com/ws-webmon/v1/da/"; ! String login = "040985:b35c52662aee64d6b12faa2a2eb7013a/"; ! String what = "meters/"; ! String type = ":(DEWPOINT,HUMIDITY,TEMPERATURE).xml"; ! String parameter = "?period=" + from.getTime(); ! String address = www + login + what + id + type + parameter; ! return new URL(address); ! } ! ! ! private List<SensorItem> process(long id) throws Exception { ! URL url = address(id); ! return process(id, url); ! } ! ! private List<SensorItem> process(long id, Date from) throws Exception { ! URL url = address(id, from); ! return process(id, url); } - private List<SensorItem> process(long id, URL url) throws Exception { - XMLDocument document = fetch(url); - BPersistence persistence = new BPersistence(); - List<BPersistence.Serie> series = persistence.internalize(document); - BPersistence.Serie leader = series.get(0); - List<SensorItem> items = new ArrayList(); - for (int i = 0; i < leader.size(); i++) { - SensorItem item = new SensorItem(); - item.setId(String.valueOf(id)); - items.add(item); - } - for (BPersistence.Serie current : series) { - String type = current.getType(); - int i = 0; - for (BPersistence.DataItem data : current.items()) { - SensorItem item = items.get(i); - if (type.equals("TEMPERATURE")) { - item.setTemparature(data.value); - item.setTime(data.timestamp); - } else if (type.equals("HUMIDITY")) { - item.setHumidity(data.value); - } - i++; - } - } - for (SensorItem current : items) { - System.out.println(current); - } - return items; - } - /** * --- 1991,2003 ---- } } ! private void fetch() { System.out.println("fetching..."); ! stamp = System.currentTimeMillis(); ! initialized = true; ! Project.getInstance().changed(); ! } /** * |
From: Michael L. <he...@us...> - 2010-08-31 13:48:12
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/sense/brunata In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model/sense/brunata Added Files: BrunataHistory.java TargetManager.java Log Message: --- NEW FILE: TargetManager.java --- package net.sourceforge.bprocessor.model.sense.brunata; import java.util.HashMap; import java.util.Map; import net.sourceforge.bprocessor.model.sense.core.History; import net.sourceforge.bprocessor.model.sense.core.Sensor; import net.sourceforge.bprocessor.model.sense.core.Target; public class TargetManager { private static TargetManager instance; public static TargetManager instance() { if (instance == null) { instance = new TargetManager(); } return instance; } private Map<String, Target> targets; private BrunataHistory history; public TargetManager() { targets = new HashMap<String, Target>(); history = new BrunataHistory(); } public Target getTarget(String id) { Target target = targets.get(id); if (target == null) { target = new Target(id); Sensor temperature = new Sensor("TEMPERATURE", "temperature"); target.getSensors().add(temperature); Sensor humidity = new Sensor("HUMIDITY", "humidity"); target.getSensors().add(humidity); targets.put(id, target); } return target; } public History getHistory() { return history; } } --- NEW FILE: BrunataHistory.java --- package net.sourceforge.bprocessor.model.sense.brunata; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import net.sourceforge.bprocessor.model.sense.brunata.xml.Document; import net.sourceforge.bprocessor.model.sense.brunata.xml.DocumentParser; import net.sourceforge.bprocessor.model.sense.brunata.xml.Element; import net.sourceforge.bprocessor.model.sense.brunata.xml.Atom; import net.sourceforge.bprocessor.model.sense.brunata.xml.Persistence; import net.sourceforge.bprocessor.model.sense.brunata.xml.Persistence.Serie; import net.sourceforge.bprocessor.model.sense.brunata.xml.Persistence.DataItem; import net.sourceforge.bprocessor.model.sense.core.History; import net.sourceforge.bprocessor.model.sense.core.Measurement; import net.sourceforge.bprocessor.model.sense.core.Sensor; import net.sourceforge.bprocessor.model.sense.core.Target; public class BrunataHistory extends History { private Map<String, String> map; public BrunataHistory() { map = new HashMap<String, String>(); map.put("3134", "2501858"); map.put("3132", "2501861"); map.put("3119", "2501863"); map.put("3138", "2501864"); map.put("3127", "2501865"); } public List<Measurement> fetch(Target target, Sensor sensor, Date from) { List<Measurement> result = new LinkedList<Measurement>(); String id = map.get(target.getId()); String type = sensor.getId(); try { URL url = address(id, type, from); Document document = fetch(url); Persistence persistence = new Persistence(); List<Serie> series = persistence.internalize(document); NumberFormat format = new DecimalFormat("0.0"); for (Serie current : series) { for (DataItem item : current.items()) { String value = format.format(item.value); long time = item.timestamp; Measurement measurement = new Measurement(time, value); result.add(measurement); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; } public List<Measurement> fetch(Target target, Sensor sensor, Date from, Date to) { List<Measurement> result = new LinkedList<Measurement>(); for (Measurement current : fetch(target, sensor, from)) { if (current.getTime() < to.getTime()) { result.add(current); } } return result; } private Document fetch(URL url) throws Exception { URLConnection connection = url.openConnection(); DocumentParser parser = new DocumentParser(); InputStream input = connection.getInputStream(); Document document = parser.parse(input); input.close(); return document; } private URL address(String id, String type, Date from) throws Exception { String www = "https://ext.brunata.com/ws-webmon/v1/da/"; String login = "040985:b35c52662aee64d6b12faa2a2eb7013a/"; String what = "meters/"; String meter = ":(" + type + ").xml"; String parameter = "?period=" + from.getTime(); String address = www + login + what + id + meter + parameter; return new URL(address); } } |
From: Michael L. <he...@us...> - 2010-08-31 13:48:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/sense/monitor In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model/sense/monitor Added Files: TargetMonitor.java SensorMonitor.java Graph.java DataSet.java DataItem.java MonitorManager.java SensorHistory.java Log Message: --- NEW FILE: Graph.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.util.HashMap; import java.util.List; import java.util.Map; public class Graph { public List<DataSet> data; public class Range { public double min; public double max; } public class Period { public long from; public long to; } public Map<String, Range> ranges; public Period period; public Graph(List<DataSet> data) { this.data = data; ranges = new HashMap<String, Range>(); period = periodOf(data); Range t = new Range(); t.min = 10; t.max = 30; ranges.put("temperature", t); Range h = new Range(); h.min = 0; h.max = 100; ranges.put("humidity", h); } private Period periodOf(List<DataSet> data) { Period result = new Period(); result.to = Long.MIN_VALUE; result.from = Long.MAX_VALUE; for (DataSet current : data) { Period period = periodOf(current); result.from = Math.min(result.from, period.from); result.to = Math.max(result.to, period.to); } return result; } private Period periodOf(DataSet data) { Period result = new Period(); result.to = Long.MIN_VALUE; result.from = Long.MAX_VALUE; for (DataItem current : data.getItems()) { result.from = Math.min(result.from, current.getMeasureMent().getTime()); result.to = Math.max(result.to, current.getMeasureMent().getTime()); } return result; } } --- NEW FILE: TargetMonitor.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.sense.core.Sensor; import net.sourceforge.bprocessor.model.sense.core.Target; public class TargetMonitor extends Entity implements Parametric { private Target target; private List<SensorMonitor> monitors; public TargetMonitor(Target target) { this.target = target; monitors = new LinkedList<SensorMonitor>(); for (Sensor current : target.getSensors()) { monitors.add(new SensorMonitor(target, current)); } } public List<SensorMonitor> getMonitors() { return monitors; } public void delete() { } public List<Attribute> getAttributes() { List<Attribute> attributes = new LinkedList<Attribute>(); attributes.add(new Attribute("Name", target.getId(), false)); return attributes; } public void setAttributes(List<Attribute> attributes) { } public String title() { return "Target"; } public String getName() { return "Target " + target.getId(); } public void collect(List<DataSet> lst) { for (SensorMonitor current : monitors) { current.collect(lst); } } } --- NEW FILE: SensorMonitor.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.util.LinkedList; import java.util.List; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.sense.core.Sensor; import net.sourceforge.bprocessor.model.sense.core.Target; public class SensorMonitor extends Entity implements Parametric { private Target target; private Sensor sensor; private SensorHistory sensorHistory; public SensorMonitor(Target target, Sensor sensor) { this.target = target; this.sensor = sensor; sensorHistory = new SensorHistory(target, sensor); } public SensorHistory getSensorHistory() { return sensorHistory; } public void delete() { } public List<Attribute> getAttributes() { List<Attribute> attributes = new LinkedList<Attribute>(); attributes.add(new Attribute("Name", sensor.getId(), false)); return attributes; } public void setAttributes(List<Attribute> attributes) { } public String title() { return "Sensor"; } public String getName() { return sensor.getType() + " sensor"; } public void collect(List<DataSet> lst) { sensorHistory.collect(lst); } } --- NEW FILE: MonitorManager.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.util.HashMap; import java.util.Map; import net.sourceforge.bprocessor.model.sense.core.Target; public class MonitorManager { private static MonitorManager instance; public static MonitorManager instance() { if (instance == null) { instance = new MonitorManager(); } return instance; } private Map<Target, TargetMonitor> targetMap; public MonitorManager() { targetMap = new HashMap<Target, TargetMonitor>(); } public TargetMonitor get(Target target) { TargetMonitor monitor = targetMap.get(target); if (monitor == null) { monitor = new TargetMonitor(target); targetMap.put(target, monitor); } return monitor; } } --- NEW FILE: DataItem.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.util.LinkedList; import java.util.List; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.sense.core.Measurement; import net.sourceforge.bprocessor.model.sense.core.Sensor; public class DataItem extends Entity implements Parametric { private Sensor sensor; private Measurement measurement; public DataItem(Sensor sensor, Measurement measurement) { this.sensor = sensor; this.measurement = measurement; } public Measurement getMeasureMent() { return measurement; } public void delete() { } public List<Attribute> getAttributes() { List<Attribute> attributes = new LinkedList<Attribute>(); attributes.add(new Attribute(sensor.getType(), measurement.getValue(), false)); return attributes; } public void setAttributes(List<Attribute> attributes) { } public String title() { return "Measurement"; } public String getName() { return measurement.toString(); } } --- NEW FILE: SensorHistory.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import java.util.List; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Operation; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.sense.brunata.TargetManager; import net.sourceforge.bprocessor.model.sense.core.History; import net.sourceforge.bprocessor.model.sense.core.Measurement; import net.sourceforge.bprocessor.model.sense.core.Sensor; import net.sourceforge.bprocessor.model.sense.core.Target; public class SensorHistory extends Entity implements Parametric { private Target target; private Sensor sensor; private String from; private String to; private DataSet data; public SensorHistory(Target target, Sensor sensor) { this.target = target; this.sensor = sensor; from = "2010.04.23 08:00:00"; to = "2010.04.24 08:00:00"; data = new DataSet(sensor, new LinkedList<Measurement>()); } public DataSet getData() { return data; } public void fetch() { try { DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); Date f = format.parse(from); Date t = format.parse(to); System.out.println("fetch " + from + " => " + to); History history = TargetManager.instance().getHistory(); List<Measurement> result = history.fetch(target, sensor, f, t); data = new DataSet(sensor, result); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void delete() { } public List<Attribute> getAttributes() { List<Attribute> attributes = new LinkedList<Attribute>(); attributes.add(new Attribute("from", from, true)); attributes.add(new Attribute("to", to, true)); attributes.add(new Attribute("Fetch", new Operation() { public void perform() { fetch(); } })); return attributes; } public void setAttributes(List<Attribute> attributes) { for (Attribute current : attributes) { if (current.getName().equals("from")) { from = (String) current.getValue(); } else if (current.getName().equals("to")) { to = (String) current.getValue(); } } } public String title() { return "History"; } public String getName() { return sensor.getType() + " history"; } public void collect(List<DataSet> lst) { if (!data.isEmpty()) { lst.add(data); } } } --- NEW FILE: DataSet.java --- package net.sourceforge.bprocessor.model.sense.monitor; import java.util.LinkedList; import java.util.List; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.sense.core.Measurement; import net.sourceforge.bprocessor.model.sense.core.Sensor; public class DataSet extends Entity implements Parametric { private Sensor sensor; private List<DataItem> items; public DataSet(Sensor sensor, List<Measurement> measurements) { this.sensor = sensor; items = new LinkedList<DataItem>(); for (Measurement current : measurements) { items.add(new DataItem(sensor, current)); } } public Sensor getSensor() { return sensor; } public List<DataItem> getItems() { return items; } public void delete() { } public List<Attribute> getAttributes() { List<Attribute> attributes = new LinkedList<Attribute>(); List<DataSet> lst = new LinkedList<DataSet>(); lst.add(this); attributes.add(new Attribute("graph", new Graph(lst))); return attributes; } public void setAttributes(List<Attribute> attributes) { } public String title() { return "Data Set"; } public String getName() { return sensor.getType() + " data"; } public boolean isEmpty() { return items.isEmpty(); } } |
From: Michael L. <he...@us...> - 2010-08-31 13:48:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/sense In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model/sense Removed Files: DataReader.java SensorItem.java SensorStorage.java Log Message: --- DataReader.java DELETED --- --- SensorItem.java DELETED --- --- SensorStorage.java DELETED --- |
From: Michael L. <he...@us...> - 2010-08-31 13:48:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/bridge In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model/bridge Removed Files: package.html Sensor.java DeSerializer.java UnSerializer.java DataItem.java Serializer.java Mote.java Connection.java Log Message: --- UnSerializer.java DELETED --- --- Mote.java DELETED --- --- DeSerializer.java DELETED --- --- Connection.java DELETED --- --- Sensor.java DELETED --- --- DataItem.java DELETED --- --- package.html DELETED --- --- Serializer.java DELETED --- |
From: Michael L. <he...@us...> - 2010-08-31 13:48:10
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/sense/brunata/xml In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model/sense/brunata/xml Added Files: Persistence.java Properties.java DocumentParser.java Document.java Property.java Atom.java Element.java Log Message: --- NEW FILE: Document.java --- package net.sourceforge.bprocessor.model.sense.brunata.xml; import java.io.PrintStream; public class Document { Element root; public Document(Element root) { this.root = root; } public Element getRoot() { return root; } public void display(PrintStream out) { root.display(out, 0); } } --- NEW FILE: Persistence.java --- //--------------------------------------------------------------------------------- // $Id: Persistence.java,v 1.1 2010/08/31 13:48:02 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model.sense.brunata.xml; import java.util.LinkedList; import java.util.List; public class Persistence { private class Internalizer { private Document document; public Internalizer(Document document) { this.document = document; } public List<Serie> internalize() { return internalizeDataseries(document.getRoot()); } public List<Serie> internalizeDataseries(Element xml) { List<Serie> series = new LinkedList(); for (Atom atom : xml.getChildren()) { if (atom instanceof Element) { Element element = (Element) atom; series.add(internalizeDataserie(element)); } } return series; } private Serie internalizeDataserie(Element xml) { Serie serie = new Serie(xml.getValue("regType")); for (Atom atom : xml.getChildren()) { if (atom instanceof Element) { Element element = (Element) atom; serie.add(internalizeDataitem(element)); } } return serie; } private DataItem internalizeDataitem(Element xml) { DataItem item = new DataItem(); item.timestamp = Long.valueOf(xml.getValue("timestamp")); item.value = Double.valueOf(xml.getValue("value")); return item; } } public class Serie { String type; List<DataItem> items; public Serie(String t) { type = t; items = new LinkedList(); } public void add(DataItem item) { items.add(item); } public List<DataItem> items() { return items; } public int size() { return items.size(); } public String getType() { return type; } } public class DataItem { public double value; public long timestamp; } public List<Serie> internalize(Document document) { Internalizer internalizer = new Internalizer(document); return internalizer.internalize(); } } --- NEW FILE: DocumentParser.java --- package net.sourceforge.bprocessor.model.sense.brunata.xml; import java.io.IOException; import java.io.InputStream; import java.util.LinkedList; import java.util.List; import java.util.Stack; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.XMLReaderFactory; public class DocumentParser { public Document parse(InputStream input) throws SAXException, IOException { XMLReader reader = XMLReaderFactory.createXMLReader(); DocumentHandler handler = new DocumentHandler(); reader.setContentHandler(handler); reader.setErrorHandler(handler); InputSource source = new InputSource(input); source.setEncoding("UTF8"); reader.parse(source); return document; } Document document; private class DocumentHandler extends DefaultHandler { Stack<Element> stack; Element root; private Properties asProperties(Attributes attributes) { List<Property> content = new LinkedList(); for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getLocalName(i); String value = attributes.getValue(i); Property property = new Property(name, value); content.add(property); } Properties properties = new Properties(content); return properties; } public void startDocument() { stack = new Stack(); } public void endDocument() { document = new Document(root); } public void startElement(String uri, String name, String cue, Attributes attributes) { Properties properties = asProperties(attributes); Element element = new Element(name, properties); stack.push(element); } public void endElement(String uri, String name, String cue) { Element element = stack.pop(); if (!stack.isEmpty()) { Element top = stack.peek(); top.add(element); } else { root = element; } } } } --- NEW FILE: Properties.java --- package net.sourceforge.bprocessor.model.sense.brunata.xml; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; public class Properties { List<Property> content; public Properties(List<Property> content) { this.content = content; } public String getValue(String key) { for (Property current : content) { if (current.key.equals(key)) { return current.value; } } return null; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(" | "); DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); for (Property current : content) { String value = current.value; if (current.key.equals("timestamp")) { value = format.format(new Date(Long.valueOf(value))); } buffer.append(current.key + "=" + "\"" + value + "\""); buffer.append(" "); } return buffer.toString(); } } --- NEW FILE: Property.java --- package net.sourceforge.bprocessor.model.sense.brunata.xml; public class Property { String key; String value; public Property(String key, String value) { this.key = key; this.value = value; } } --- NEW FILE: Element.java --- package net.sourceforge.bprocessor.model.sense.brunata.xml; import java.io.PrintStream; import java.util.LinkedList; import java.util.List; public class Element extends Atom { String tag; List<Atom> children; Properties properties; public Element(String tag, Properties properties) { this.tag = tag; this.properties = properties; } public void add(Element element) { if (children == null) { children = new LinkedList(); } children.add(element); } public String getTag() { return tag; } public List<Atom> getChildren() { return children; } public String getValue(String key) { return properties.getValue(key); } public void display(PrintStream out, int level) { for (int i = 0; i < level; i++) { System.out.print(" "); } out.print(tag); out.println(properties); if (children != null) { for (Atom current : children) { current.display(out, level + 1); } } } } --- NEW FILE: Atom.java --- package net.sourceforge.bprocessor.model.sense.brunata.xml; import java.io.PrintStream; public class Atom { public void display(PrintStream out, int i) { // nothing } } |
From: Michael L. <he...@us...> - 2010-08-31 13:48:10
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/brunata/io In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20256/src/net/sourceforge/bprocessor/model/brunata/io Removed Files: DocumentParser.java Properties.java Element.java Data.java XMLDocument.java Atom.java BPersistence.java Property.java Log Message: --- DocumentParser.java DELETED --- --- Properties.java DELETED --- --- XMLDocument.java DELETED --- --- Data.java DELETED --- --- BPersistence.java DELETED --- --- Property.java DELETED --- --- Element.java DELETED --- --- Atom.java DELETED --- |