ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
823
823
EMPFEHLEN
-
Hai,
Ich habe ne Analyse SW die früher mit ner Anbindung an Postgres lief aber jetzt hab ich das ganze auf MSSQL umgeschwenkt - was ich nicht bedacht hatte war das MSSQL keine NaN implementiert hat.
es gibt ne funktion RealTime datenabrufe in einem BarChart + XYChart (JFreeChart) darzustellen
So die Datenabrufe laufen über nen HTTP request an ne SPS, ich bekomm bei jedem HTTP request einen ByteStream den ich dann in nen Floatwert umwandle + nen Timestamp
nun kann es sein das die Datenabrufe keine werte zurückliefern sondern Fehlermeldungen
Fehler oder Aus. Ich hab die 2 msgs bisland einfach rausgefiltered und dann die Float Variable NaN gesetzt.
ach btw es werden die Float werte + Timestamps in nen Vector gespeichert und am ende dann komplett in die DB gespeichert
Da MSSQL aber den crap mit NaN nicht implementiert hat und ich somit das gefiltere von den ErrorMSGS umändern musste dachte ich mir filter die ErrorMSGS so aus:
Beim ersten durchlauf kann es sein das eines der ErrorMSGS auftritt erstell dann einfach nen leeres dataset für das XY Chart und für das Barchar ein dataset mit NaN
Wenn die ErrorMsgs dauerhaft auftreten bekomm ich die JAVA HEAP SPACE exception
hier einfach mal paar code schnipsel - das ganze programm ist zu komplex um alles zu posten ich versuch mal nur das nötigste reinzuhaun
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
private static CategoryDataset createDataset(ASClientOptions opts, SensorEinstellungen sensor) throws HttpException, IOException { * HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams(); cmparams.setSoTimeout(5000); cmparams.setConnectionTimeout(5000); cmparams.setTcpNoDelay(true); HttpConnectionManager manager = new SimpleHttpConnectionManager(); manager.setParams(cmparams); HttpClientParams params = new HttpClientParams(); params.setSoTimeout(5000); params.setConnectionManagerTimeout(new Long(5000)); HttpClient client = new HttpClient(params, manager); statusCode = 0; GetMethod method = new GetMethod("http://" + sensor.getIPAddress() + "/dir/cgi-bin/readVal.exe?@GV.Durchfluss"); String series = sensor.getStandort(); // data = new DefaultCategoryDataset(); statusCode = client.executeMethod(method); System.out.println("Request gesendet"); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); } // Read the response body. byte[] responseBody = method.getResponseBody(); String value = new String(responseBody); if (value.equals(off) || value.equals(error)) { method.releaseConnection(); if (StartupStatistics.errorcatching == 1) { System.out.println("errocatch = 1"); StartupStatistics.errorcatching=2; StartupStatistics.tsc = new TimeSeriesCollection(); data1 = new double[][] { { Double.NaN } }; return DatasetUtilities.createCategoryDataset("mytest", "ITS ALLRIGHT", data1); } else if(StartupStatistics.errorcatching==2){ System.out.println("errocatch != 1"); data1 = new double[][] { { Double.NaN } }; return DatasetUtilities.createCategoryDataset("error", "ERROR", data1); }else{ System.out.println("dürfte nicht passieren"); return null; } } else { StartupStatistics.errorcatching=2; value2 = Double.parseDouble(value); String hehe = ""; System.out.println(responseBody); for (int x = 0; x < responseBody.length; x++) { char c = (char) responseBody[x]; hehe += c; System.out.print(c + " - " + responseBody[x] + "\n"); } System.out.println(hehe); // System.out.println(value2); data1 = new double[][] { { value2 } }; float flooat = value2.floatValue(); method.releaseConnection(); Date category = new Date(); String category1 = category.toString(); // System.out.println(sensor.getID()); // System.out.println(StartupStatistics.getFlowRateSensorId()); StartupStatistics.addFlowRateSensorId(sensor.getID()); StartupStatistics.addFlowRatedate(category); StartupStatistics.addFlowRateMessung(flooat); RegularTimePeriod category2 = new Second(category); TimeSeriesDataItem tsdi = new TimeSeriesDataItem(category2, value2); System.out.println(value2); StartupStatistics.tsc = new TimeSeriesCollection(); // StartupStatistics.avg.add(category2, value2); // StartupStatistics.tsc.addSeries(StartupStatistics.avg); Vector<TimeSeriesDataItem> t = new Vector<TimeSeriesDataItem>(); if (StartupStatistics.h == 1) { System.out.println("1"); StartupStatistics.avg.add(category2, value2); StartupStatistics.tsc.addSeries(StartupStatistics.avg); // StartupStatistics.avg2 = new TimeSeries(""); StartupStatistics.h++; } else { if (StartupStatistics.h % 2 == 0) { System.out.println("2"); for (int i = 0; StartupStatistics.avg.getItemCount() > i; i++) { t.addElement(StartupStatistics.avg.getDataItem(i)); } StartupStatistics.avg = new TimeSeries(""); for (int i = 0; i < t.size(); i++) { StartupStatistics.avg2.add(t.elementAt(i)); } StartupStatistics.avg2.add(tsdi); StartupStatistics.tsc.addSeries(StartupStatistics.avg2); StartupStatistics.h++; } else if (StartupStatistics.h % 2 == 1) { System.out.println("3"); for (int i = 0; StartupStatistics.avg2.getItemCount() > i; i++) { t.addElement(StartupStatistics.avg2.getDataItem(i)); } StartupStatistics.avg2 = new TimeSeries(""); for (int i = 0; t.size() > i; i++) { StartupStatistics.avg.add(t.elementAt(i)); } StartupStatistics.avg.add(tsdi); StartupStatistics.tsc.addSeries(StartupStatistics.avg); StartupStatistics.h++; } } return DatasetUtilities.createCategoryDataset(series, category1, data1); } }
Code java:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
public class FlowRateRequest implements Runnable { private static boolean doit = true; private static ASClientOptions asopts = null; private static SensorEinstellungen sens = null; private static JPanel report = null; private static JPanel report2 = null; public void request() { try { // erstellung der verschiedenen reports report = FlowRateReport.createStandardReportPanel(asopts, sens); report2 = XYChartFlowRate.createStandardReportPanel(asopts, sens); FlowRateReport.optsSet(asopts); // ich create ein neues panel mit verschiedenen split panels in der methode StandardReportPanell mit übergabe der beiden reports // das erstelle panel wird dann an showChartPanel übergeben asopts.mainframe.showChartPanel(FlowRateReport.StandardReportPanel .StandardReportPanell(report, report2)); report = null; report2 = null; } catch (HttpException e) { System.err.println("Fatal protocol violation: " + e.getMessage()); e.printStackTrace(); if (asopts != null) { if (sens != null) FlowRateRequest.doitFalse(); FlowRateReport.t = null; } } catch (IOException e) { JOptionPane.showMessageDialog(null, "IP Address is invalid"); System.err.println("Fatal transport error: " + e.getMessage()); e.printStackTrace(); if (asopts != null) { if (sens != null) { FlowRateRequest.doitFalse(); FlowRateReport.t = null; } } } } @Override public void run() { DisplayChangeHandler dch = new DisplayChangeHandler(); // die methode läuft solange true while (doit) { dch.run(); request(); System.gc(); try { reports.flowRate.FlowRateReport.t .sleep(1000); } catch (InterruptedException ex) { ex.printStackTrace(); } } }
der aufruf im groben -
ich starte den Thread - Erstelle chart1 + chart 2 - füge es auf das splitpane
Ich hab mir schon die bug reports auf der sun page und etliche foren threads durchgelesen und versucht das zu ändern aber ich komme atm nicht drauf.
Ähnliche Themen
-
java.lang.OutOfMemoryError: Java heap space
Von MopsdeBops im Forum JavaAntworten: 2Letzter Beitrag: 09.12.08, 09:33 -
Datei schreiben und Heap Space
Von fsmarine im Forum JavaAntworten: 4Letzter Beitrag: 24.10.08, 18:32 -
MySql JTable Probleme mit Heap Space
Von PUM1212 im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 0Letzter Beitrag: 03.12.07, 03:33 -
Heap Space - System.setProperty()?
Von flashray im Forum JavaAntworten: 9Letzter Beitrag: 24.05.07, 13:08 -
Applet heap space
Von magnet im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 0Letzter Beitrag: 29.11.05, 13:06





Zitieren
Login





