Commit 3a108f36 authored by Claes Sjofors's avatar Claes Sjofors

Java trend and fast curves implemented

parent 2dc523c3
...@@ -58,7 +58,7 @@ public class JopCurve extends JFrame ...@@ -58,7 +58,7 @@ public class JopCurve extends JFrame
static final int COLUMN_SCALE = 3; static final int COLUMN_SCALE = 3;
static final int COLUMN_ATTRIBUTE = 4; static final int COLUMN_ATTRIBUTE = 4;
static final int COLUMNS = 5; static final int COLUMNS = 5;
static final float ZOOM_FACTOR = 1.2F;
JopSession session; JopSession session;
JopEngine engine; JopEngine engine;
...@@ -67,6 +67,7 @@ public class JopCurve extends JFrame ...@@ -67,6 +67,7 @@ public class JopCurve extends JFrame
private JTable names; private JTable names;
private JToolBar toolbar; private JToolBar toolbar;
private JScrollPane chartScrollPane; private JScrollPane chartScrollPane;
private AxisPanel axisPanel;
private Chart chart; private Chart chart;
private Chart navigator; private Chart navigator;
private JopCurveAxis[] yaxis = new JopCurveAxis[JopCurveData.CURVE_MAX_COLS]; private JopCurveAxis[] yaxis = new JopCurveAxis[JopCurveData.CURVE_MAX_COLS];
...@@ -137,7 +138,6 @@ public class JopCurve extends JFrame ...@@ -137,7 +138,6 @@ public class JopCurve extends JFrame
} }
chart.setVerticalLines(gcd.x_trend_lines[0]-2); chart.setVerticalLines(gcd.x_trend_lines[0]-2);
chart.setHorizontalLines(gcd.y_trend_lines[0]-2); chart.setHorizontalLines(gcd.y_trend_lines[0]-2);
System.out.println( "Lines " + (gcd.x_trend_lines[0]-2) + " " + (gcd.y_trend_lines[0]-2));
chart.repaint(); chart.repaint();
navigator.repaint(); navigator.repaint();
} }
...@@ -201,14 +201,14 @@ public class JopCurve extends JFrame ...@@ -201,14 +201,14 @@ public class JopCurve extends JFrame
panel1.add(scp1); panel1.add(scp1);
// Y axes // Y axes
AxisPanel panel5 = new AxisPanel(); axisPanel = new AxisPanel();
Dimension dsize = new Dimension( gcd.cols * 40, 700); Dimension dsize = new Dimension( gcd.cols * 40, 700);
panel5.setSize(dsize); axisPanel.setSize(dsize);
// panel5.addComponentListener(new AspectRatioListener(this, dsize)); // axisPanel.addComponentListener(new AspectRatioListener(this, dsize));
panel5.setLayout( new JopCurveAxisLayout()); axisPanel.setLayout( new JopCurveAxisLayout());
for ( int i = 0; i < gcd.cols; i++) { for ( int i = 0; i < gcd.cols; i++) {
panel5.add( yaxis[i]); axisPanel.add( yaxis[i]);
} }
// Scrolled chart // Scrolled chart
...@@ -221,8 +221,8 @@ public class JopCurve extends JFrame ...@@ -221,8 +221,8 @@ public class JopCurve extends JFrame
chartScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); chartScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
chartScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); chartScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
chartScrollPane.setBounds(new Rectangle( gcd.cols*40, 0, 1000, 700)); chartScrollPane.setBounds(new Rectangle( gcd.cols*40, 0, 1000, 700));
panel5.add( chartScrollPane); axisPanel.add( chartScrollPane);
panel2.add( panel5); panel2.add( axisPanel);
panel3.add( navigator); panel3.add( navigator);
...@@ -245,7 +245,6 @@ public class JopCurve extends JFrame ...@@ -245,7 +245,6 @@ public class JopCurve extends JFrame
if ( gcd.type == JopCurveData.eDataType_DsTrend) { if ( gcd.type == JopCurveData.eDataType_DsTrend) {
JScrollBar sb = chartScrollPane.getHorizontalScrollBar(); JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
int value = sb.getMaximum(); int value = sb.getMaximum();
System.out.println( "Scrollbar maximum " + value);
sb.setValue( value); sb.setValue( value);
} }
} }
...@@ -326,7 +325,6 @@ public class JopCurve extends JFrame ...@@ -326,7 +325,6 @@ public class JopCurve extends JFrame
{ {
public void actionPerformed(ActionEvent event) public void actionPerformed(ActionEvent event)
{ {
System.out.println("Button Clicked in JTable Cell " + currentNamesScale);
maxMinDialog( currentNamesScale); maxMinDialog( currentNamesScale);
} }
} }
...@@ -383,7 +381,6 @@ public class JopCurve extends JFrame ...@@ -383,7 +381,6 @@ public class JopCurve extends JFrame
public Component getTableCellEditorComponent(JTable table, Object value, public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) { boolean isSelected, int row, int column) {
System.out.println( "Button editor row: " + row);
label = (value == null) ? "" : value.toString(); label = (value == null) ? "" : value.toString();
currentNamesScale = row; currentNamesScale = row;
button.setText(label); button.setText(label);
...@@ -505,6 +502,22 @@ public class JopCurve extends JFrame ...@@ -505,6 +502,22 @@ public class JopCurve extends JFrame
} }
} }
// Time task used to adjust scroll value for zoom in when the scroll value is larger
// than the old maximum value.
// This has to be done in a timer task as the revalidation doesn't have immediate effect.
java.util.Timer timer;
int scrollValue;
class ScrollSet extends TimerTask {
public void run() {
JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
int value = sb.getValue();
int extent = sb.getVisibleAmount();
float new_value = ZOOM_FACTOR * value + (ZOOM_FACTOR - 1) * extent / 2;
sb.setValue( scrollValue);
}
}
private class MenuAction extends AbstractAction { private class MenuAction extends AbstractAction {
public MenuAction( String text, Icon icon) { public MenuAction( String text, Icon icon) {
super( text, icon); super( text, icon);
...@@ -512,25 +525,53 @@ public class JopCurve extends JFrame ...@@ -512,25 +525,53 @@ public class JopCurve extends JFrame
public void actionPerformed( ActionEvent e) { public void actionPerformed( ActionEvent e) {
if ( e.getActionCommand() == "Zoom In") { if ( e.getActionCommand() == "Zoom In") {
chartWidth += 1000; JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
int value = sb.getValue();
int extent = sb.getVisibleAmount();
chartWidth *= ZOOM_FACTOR;
Dimension d = chartScrollPane.getSize(); Dimension d = chartScrollPane.getSize();
xaxis.setBounds(new Rectangle(0,d.height - JopCurveChartLayout.AXIS_HEIGHT, chartWidth,30)); xaxis.setBounds(new Rectangle(0,d.height - JopCurveChartLayout.AXIS_HEIGHT, chartWidth,30));
chart.setFixWidth(chartWidth); chart.setFixWidth(chartWidth);
chartScrollPane.setPreferredSize( new Dimension( chartWidth, d.height)); chart.setVerticalLines(gcd.x_trend_lines[0]-2);
chart.setHorizontalLines(gcd.y_trend_lines[0]-2);
chart.repaint();
axisPanel.revalidate();
float new_value = ZOOM_FACTOR * value + (ZOOM_FACTOR - 1) * extent / 2;
sb.setValue( (int)new_value);
if ( new_value + extent > chartWidth / ZOOM_FACTOR) {
// Maximum value is not changed yet, and a value > old width can't be set.
scrollValue = (int)new_value;
timer = new java.util.Timer();
timer.schedule( new ScrollSet(), 1);
}
} }
else if ( e.getActionCommand() == "Zoom Out") { else if ( e.getActionCommand() == "Zoom Out") {
chartWidth -= 1000; JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
int value = sb.getValue();
int extent = sb.getVisibleAmount();
chartWidth /= ZOOM_FACTOR;
Dimension d = chartScrollPane.getSize(); Dimension d = chartScrollPane.getSize();
xaxis.setBounds(new Rectangle(0,d.height - JopCurveChartLayout.AXIS_HEIGHT, chartWidth,30)); xaxis.setBounds(new Rectangle(0,d.height - JopCurveChartLayout.AXIS_HEIGHT, chartWidth,30));
chart.setFixWidth(chartWidth); chart.setFixWidth(chartWidth);
chartScrollPane.setPreferredSize( new Dimension( chartWidth, d.height)); chart.setVerticalLines(gcd.x_trend_lines[0]-2);
chart.setHorizontalLines(gcd.y_trend_lines[0]-2);
chart.repaint();
axisPanel.revalidate();
float new_value = 1F/ZOOM_FACTOR * value + (1F/ZOOM_FACTOR - 1) * extent / 2;
sb.setValue( (int)new_value);
} }
else if ( e.getActionCommand() == "Zoom Reset") { else if ( e.getActionCommand() == "Zoom Reset") {
chartWidth = 5000; chartWidth = 5000;
Dimension d = chartScrollPane.getSize(); Dimension d = chartScrollPane.getSize();
xaxis.setBounds(new Rectangle(0,d.height - JopCurveChartLayout.AXIS_HEIGHT, chartWidth,30)); xaxis.setBounds(new Rectangle(0,d.height - JopCurveChartLayout.AXIS_HEIGHT, chartWidth,30));
chart.setFixWidth(chartWidth); chart.setFixWidth(chartWidth);
chartScrollPane.setPreferredSize( new Dimension( chartWidth, chartScrollPane.getHeight())); // chartScrollPane.setPreferredSize( new Dimension( chartWidth, chartScrollPane.getHeight()));
chart.setVerticalLines(gcd.x_trend_lines[0]-2);
chart.setHorizontalLines(gcd.y_trend_lines[0]-2);
chart.repaint();
axisPanel.revalidate();
JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
} }
else if ( e.getActionCommand() == "Page Left") { else if ( e.getActionCommand() == "Page Left") {
JScrollBar sb = chartScrollPane.getHorizontalScrollBar(); JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
...@@ -551,7 +592,6 @@ public class JopCurve extends JFrame ...@@ -551,7 +592,6 @@ public class JopCurve extends JFrame
JScrollBar sb = chartScrollPane.getHorizontalScrollBar(); JScrollBar sb = chartScrollPane.getHorizontalScrollBar();
int value = sb.getValue(); int value = sb.getValue();
sb.setValue( value + sb.getVisibleAmount()); sb.setValue( value + sb.getVisibleAmount());
System.out.println( "Page Right value: " + value);
} }
} }
...@@ -620,8 +660,8 @@ public class JopCurve extends JFrame ...@@ -620,8 +660,8 @@ public class JopCurve extends JFrame
boolean updateLines = true; boolean updateLines = true;
int verticalLines = 0; int verticalLines = 0;
int horizontalLines = 0; int horizontalLines = 0;
int lineColor = 35; int lineColor = GeColor.COLOR_37;
int fillColor = 38; int fillColor = GeColor.COLOR_39;
int borderColor = 9999; int borderColor = 9999;
public void setVerticalLines( int verticalLines) { public void setVerticalLines( int verticalLines) {
...@@ -635,7 +675,8 @@ public class JopCurve extends JFrame ...@@ -635,7 +675,8 @@ public class JopCurve extends JFrame
public void setFixWidth( float fixWidth) { public void setFixWidth( float fixWidth) {
this.fixWidth = fixWidth; this.fixWidth = fixWidth;
float height = getHeight(); float height = getHeight();
setSize(new Dimension((int)fixWidth, (int)height)); //setSize(new Dimension((int)fixWidth, (int)height));
setBounds(new Rectangle(0,0,(int)fixWidth,(int)height));
} }
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
......
...@@ -129,7 +129,6 @@ public class JopCurveData ...@@ -129,7 +129,6 @@ public class JopCurveData
} }
if ( type == eDataType_MultiTrend) { if ( type == eDataType_MultiTrend) {
System.out.println( "get_borders datatype: " + type);
for ( int i = 0; i < cols; i++) { for ( int i = 0; i < cols; i++) {
x_max_value[i] = 1e-37; x_max_value[i] = 1e-37;
x_min_value[i] = 1e37; x_min_value[i] = 1e37;
...@@ -145,7 +144,6 @@ public class JopCurveData ...@@ -145,7 +144,6 @@ public class JopCurveData
} }
} }
else { else {
System.out.println( "get_borders datatype: " + type + " rows " + rows[0]);
for ( int i = 0; i < 1; i++) { for ( int i = 0; i < 1; i++) {
x_max_value[i] = 1e-37; x_max_value[i] = 1e-37;
x_min_value[i] = 1e37; x_min_value[i] = 1e37;
...@@ -173,7 +171,6 @@ public class JopCurveData ...@@ -173,7 +171,6 @@ public class JopCurveData
double axis_width; double axis_width;
if ( type != eDataType_MultiTrend) { if ( type != eDataType_MultiTrend) {
System.out.println( "x_min_value " + x_min_value[0] + " x_max_value " + x_max_value[0]);
scale( x_axis_type[i], i, x_value_type[i], x_min_value[i], x_max_value[i], false, false); scale( x_axis_type[i], i, x_value_type[i], x_min_value[i], x_max_value[i], false, false);
} }
else { else {
...@@ -554,7 +551,6 @@ public class JopCurveData ...@@ -554,7 +551,6 @@ public class JopCurveData
} }
} }
System.out.println( "Time format: " + time_format);
switch ( time_format) { switch ( time_format) {
case eTimeFormat_Float: case eTimeFormat_Float:
// Float format // Float format
...@@ -570,7 +566,6 @@ public class JopCurveData ...@@ -570,7 +566,6 @@ public class JopCurveData
format = new String( "%" + format_int + "." + format_dec + "f"); format = new String( "%" + format_int + "." + format_dec + "f");
axis_width = 0.65 * format_int + 0.4; axis_width = 0.65 * format_int + 0.4;
System.out.println( "format " + format);
break; break;
case eTimeFormat_HourMinute: case eTimeFormat_HourMinute:
// Hour and minute format // Hour and minute format
...@@ -589,7 +584,6 @@ public class JopCurveData ...@@ -589,7 +584,6 @@ public class JopCurveData
y_max_value_axis[idx] = maxval; y_max_value_axis[idx] = maxval;
y_min_value_axis[idx] = minval; y_min_value_axis[idx] = minval;
y_trend_lines[idx] = Math.abs(max_lines - min_lines) + 1; y_trend_lines[idx] = Math.abs(max_lines - min_lines) + 1;
System.out.println( "trend_lines " + y_trend_lines[idx] + " " + idx);
y_axis_lines[idx] = (y_trend_lines[idx] - 1) * trendlinequot + 1; y_axis_lines[idx] = (y_trend_lines[idx] - 1) * trendlinequot + 1;
y_axis_linelongq[idx] = axlinequot; y_axis_linelongq[idx] = axlinequot;
y_axis_valueq[idx] = axvaluequot; y_axis_valueq[idx] = axvaluequot;
...@@ -604,7 +598,6 @@ public class JopCurveData ...@@ -604,7 +598,6 @@ public class JopCurveData
x_axis_linelongq[idx] = axlinequot; x_axis_linelongq[idx] = axlinequot;
x_axis_valueq[idx] = axvaluequot; x_axis_valueq[idx] = axvaluequot;
x_format[idx] = format; x_format[idx] = format;
System.out.println( "x_format " + idx + " " + x_format[idx]);
} }
} }
......
...@@ -161,8 +161,8 @@ public class JopSession { ...@@ -161,8 +161,8 @@ public class JopSession {
((JopSessionIfc) sessionRep).setOpWindowLanguage( language); ((JopSessionIfc) sessionRep).setOpWindowLanguage( language);
} }
public void openTrend( String[] trendList, String plotGroup) { public void openTrend( String[] trendList) {
((JopSessionIfc) sessionRep).openTrend( trendList, plotGroup); ((JopSessionIfc) sessionRep).openTrend( trendList);
} }
public void openFast( String fastObject) { public void openFast( String fastObject) {
......
...@@ -64,6 +64,6 @@ public interface JopSessionIfc { ...@@ -64,6 +64,6 @@ public interface JopSessionIfc {
public void openSearch(String object); public void openSearch(String object);
public void setOpWindowLabelText( String text ); public void setOpWindowLabelText( String text );
public void setOpWindowLanguage( int language ); public void setOpWindowLanguage( int language );
public void openTrend( String[] trendList, String plotGroup); public void openTrend( String[] trendList);
public void openFast( String fastObject); public void openFast( String fastObject);
} }
...@@ -404,8 +404,8 @@ public class JopSessionRep implements JopSessionIfc { ...@@ -404,8 +404,8 @@ public class JopSessionRep implements JopSessionIfc {
((JopOpWindowFrame)root).setLanguage( language); ((JopOpWindowFrame)root).setLanguage( language);
} }
public void openTrend( String[] trendList, String plotGroup) { public void openTrend( String[] trendList) {
new JopXttTrend( session, trendList, plotGroup); new JopXttTrend( session, trendList);
} }
public void openFast( String fastObject) { public void openFast( String fastObject) {
......
...@@ -389,7 +389,7 @@ System.out.println( "qcom put finished"); ...@@ -389,7 +389,7 @@ System.out.println( "qcom put finished");
for ( int i = 0; i < cnt; i++) for ( int i = 0; i < cnt; i++)
trendList[i] = tokens.nextToken(); trendList[i] = tokens.nextToken();
session.openTrend( trendList, null); session.openTrend( trendList);
} }
else if ( fast.length() >= cli_arg1.length() && else if ( fast.length() >= cli_arg1.length() &&
fast.substring(0,cli_arg1.length()).equals(cli_arg1)) { fast.substring(0,cli_arg1.length()).equals(cli_arg1)) {
......
...@@ -203,6 +203,18 @@ public class JopXttFast implements ActionListener, JopCurveIfc { ...@@ -203,6 +203,18 @@ public class JopXttFast implements ActionListener, JopCurveIfc {
sret = engine.gdh.getObjectInfoString( fastObject + ".Attribute[" + fast_cnt + "]"); sret = engine.gdh.getObjectInfoString( fastObject + ".Attribute[" + fast_cnt + "]");
if ( sret.evenSts()) return; if ( sret.evenSts()) return;
String attrName = sret.str; String attrName = sret.str;
int offs = attrName.lastIndexOf('.');
String Unit;
if ( offs != -1) {
sret = engine.gdh.getObjectInfoString( attrName.substring(0,offs) + ".Unit");
if ( sret.oddSts())
Unit = sret.str;
else
Unit = new String();
}
else
Unit = new String();
sret = engine.gdh.getObjectInfoString( fastObject + ".Buffers[" + fast_cnt + "]"); sret = engine.gdh.getObjectInfoString( fastObject + ".Buffers[" + fast_cnt + "]");
if ( sret.evenSts()) return; if ( sret.evenSts()) return;
...@@ -211,7 +223,7 @@ public class JopXttFast implements ActionListener, JopCurveIfc { ...@@ -211,7 +223,7 @@ public class JopXttFast implements ActionListener, JopCurveIfc {
gcd.y_axis_type[fast_cnt] = JopCurveData.eAxis_y; gcd.y_axis_type[fast_cnt] = JopCurveData.eAxis_y;
gcd.y_name[fast_cnt] = attrName; gcd.y_name[fast_cnt] = attrName;
gcd.rows[fast_cnt] = noOfPoints; gcd.rows[fast_cnt] = noOfPoints;
gcd.y_unit[i] = new String( "m/s"); gcd.y_unit[i] = Unit;
if ( !active) { if ( !active) {
faret = engine.gdh.getObjectInfoFloatArray( buffers[fast_cnt], noOfPoints); faret = engine.gdh.getObjectInfoFloatArray( buffers[fast_cnt], noOfPoints);
...@@ -278,7 +290,6 @@ public class JopXttFast implements ActionListener, JopCurveIfc { ...@@ -278,7 +290,6 @@ public class JopXttFast implements ActionListener, JopCurveIfc {
} }
for ( j = 0; j < noOfPoints; j++) { for ( j = 0; j < noOfPoints; j++) {
gcd.x_data[0][j] = faret.value[j]; gcd.x_data[0][j] = faret.value[j];
System.out.println( "Time value[" + j + "]: " + faret.value[j]);
} }
for ( i = 0; i < fast_cnt; i++) { for ( i = 0; i < fast_cnt; i++) {
......
...@@ -77,6 +77,8 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -77,6 +77,8 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
CircBuffInfo[] cb_info = new CircBuffInfo[XTT_TREND_MAX]; CircBuffInfo[] cb_info = new CircBuffInfo[XTT_TREND_MAX];
private class DsTrend { private class DsTrend {
public String DataName;
public String Unit;
public int NoOfBuffers; public int NoOfBuffers;
public int ScanTime; public int ScanTime;
public int Multiple; public int Multiple;
...@@ -101,30 +103,30 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -101,30 +103,30 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
public String Buffer; public String Buffer;
public int ElementType; public int ElementType;
public int ActualDataSize; public int ActualDataSize;
public String Unit;
public DsTrendCurve() {} public DsTrendCurve() {}
} }
public JopXttTrend( String[] trendList, String plotGroup ) { public JopXttTrend( String[] trendList) {
engine = new JopEngine( 1000, (Object)this); engine = new JopEngine( 1000, (Object)this);
session = new JopSession( engine, (Object)this); session = new JopSession( engine, (Object)this);
init( trendList, plotGroup); init( trendList);
} }
public JopXttTrend( JopSession session, String[] trendList, String plotGroup ) { public JopXttTrend( JopSession session, String[] trendList) {
this.session = session; this.session = session;
engine = session.getEngine(); engine = session.getEngine();
init( trendList, plotGroup); init( trendList);
} }
public void close() { public void close() {
System.out.println("JopXttTrend.close");
timer.stop(); timer.stop();
} }
void init( String[] trendList, String plotGroup) { void init( String[] trendList) {
int i, j, k; int i, j, k;
int start_idx; int start_idx;
...@@ -132,28 +134,12 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -132,28 +134,12 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
timer = new Timer( 1000, this); timer = new Timer( 1000, this);
if ( trendList != null) { if ( trendList.length == 0) {
trend_name = trendList;
trend_cnt = trend_name.length;
}
else {
// Plotgroup as input
CdhrString ret;
trend_cnt = 0;
for ( i = 0; i < 20; i ++) {
ret = engine.gdh.getObjectInfoString( plotGroup + ".YObjectName["+i+"]");
if ( ret.evenSts() || ret.str.equals(""))
continue;
trend_name[trend_cnt++] = ret.str;
}
}
if ( trend_cnt == 0) {
System.out.println("Error in trend configuration"); System.out.println("Error in trend configuration");
return; return;
} }
CdhrObjid oret = engine.gdh.nameToObjid( trend_name[0]); CdhrObjid oret = engine.gdh.nameToObjid( trendList[0]);
if ( oret.evenSts()) { if ( oret.evenSts()) {
System.out.println("Error in trend configuration"); System.out.println("Error in trend configuration");
return; return;
...@@ -165,12 +151,60 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -165,12 +151,60 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
} }
trend_tid = cret.classId; trend_tid = cret.classId;
if ( trend_tid == Pwrb.cClass_PlotGroup) {
// Plotgroup as input
CdhrString ret;
trend_cnt = 0;
for ( i = 0; i < 20; i ++) {
ret = engine.gdh.getObjectInfoString( trendList[0] + ".YObjectName["+i+"]");
if ( ret.evenSts() || ret.str.equals(""))
continue;
trend_name[trend_cnt++] = ret.str;
}
oret = engine.gdh.nameToObjid( trend_name[0]);
if ( oret.evenSts()) {
System.out.println("Error in trend configuration");
return;
}
cret = engine.gdh.getObjectClass( oret.objid);
if ( cret.evenSts()) {
System.out.println("Error in trend configuration");
return;
}
trend_tid = cret.classId;
}
else {
// DsTrend or DsTrendCurve as input
trend_name = trendList;
trend_cnt = trend_name.length;
}
if ( trend_tid == Pwrb.cClass_DsTrend) { if ( trend_tid == Pwrb.cClass_DsTrend) {
tp = new DsTrend[trend_cnt]; tp = new DsTrend[trend_cnt];
for ( i = 0; i < trend_cnt; i++) { for ( i = 0; i < trend_cnt; i++) {
tp[i] = new DsTrend(); tp[i] = new DsTrend();
CdhrString sret = engine.gdh.getObjectInfoString( trend_name[i] + ".DataName");
if ( sret.evenSts()) {
System.out.println("Trend object error, " + trend_name[i]);
return;
}
tp[i].DataName = sret.str;
int offs = tp[i].DataName.lastIndexOf('.');
if ( offs != -1) {
sret = engine.gdh.getObjectInfoString( tp[i].DataName.substring(0,offs) + ".Unit");
if ( sret.oddSts())
tp[i].Unit = sret.str;
else
tp[i].Unit = new String();
}
else
tp[i].Unit = new String();
CdhrInt ret = engine.gdh.getObjectInfoInt( trend_name[i] + ".ScanTime"); CdhrInt ret = engine.gdh.getObjectInfoInt( trend_name[i] + ".ScanTime");
if ( ret.oddSts()) { if ( ret.oddSts()) {
tp[i].ScanTime = ret.value; tp[i].ScanTime = ret.value;
...@@ -203,6 +237,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -203,6 +237,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
System.out.println("Trend object error, " + trend_name[i]); System.out.println("Trend object error, " + trend_name[i]);
return; return;
} }
CdhrFloatArray faret = engine.gdh.getObjectInfoFloatArray( trend_name[i] + ".DataBuffer", 478); CdhrFloatArray faret = engine.gdh.getObjectInfoFloatArray( trend_name[i] + ".DataBuffer", 478);
if ( faret.evenSts()) { if ( faret.evenSts()) {
System.out.println("Trend object error, " + trend_name[i]); System.out.println("Trend object error, " + trend_name[i]);
...@@ -217,7 +252,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -217,7 +252,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
min_interval = 100000; min_interval = 100000;
int time; int time;
for ( i = 0; i < trend_cnt; i++) { for ( i = 0; i < trend_cnt; i++) {
System.out.println( "Multiple " + tp[i].Multiple + " ScanTime " + tp[i].ScanTime + " NoOfBuffers " + tp[i].NoOfBuffers + " NoOfSample " + tp[i].NoOfSample);
time = tp[i].Multiple * tp[i].ScanTime * tp[i].NoOfBuffers * time = tp[i].Multiple * tp[i].ScanTime * tp[i].NoOfBuffers *
tp[i].NoOfSample; tp[i].NoOfSample;
if ( time > max_time) if ( time > max_time)
...@@ -235,7 +269,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -235,7 +269,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
} }
max_points = max_time / min_interval; max_points = max_time / min_interval;
System.out.println( "max_points: " + max_points);
for ( i = 0; i < trend_cnt; i++) { for ( i = 0; i < trend_cnt; i++) {
interval[i] = tp[i].Multiple * tp[i].ScanTime / min_interval; interval[i] = tp[i].Multiple * tp[i].ScanTime / min_interval;
...@@ -270,7 +303,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -270,7 +303,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
int idx = 0; int idx = 0;
for ( j = start_idx; j >= write_buffer * trend_buff_size/2; j--) { for ( j = start_idx; j >= write_buffer * trend_buff_size/2; j--) {
for ( k = 0; k < interval[i]; k++) { for ( k = 0; k < interval[i]; k++) {
System.out.println( "idx: " + idx + " i: " + i + " j: " + j + " DataBuffer.length: " + tp[i].DataBuffer.length + " gcd.y_data[i].length: " + gcd.y_data[i].length);
gcd.y_data[i][idx] = tp[i].DataBuffer[j]; gcd.y_data[i][idx] = tp[i].DataBuffer[j];
idx++; idx++;
} }
...@@ -296,8 +328,8 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -296,8 +328,8 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
last_next_index[i] = tp[i].NextWriteIndex[last_buffer[i]]; last_next_index[i] = tp[i].NextWriteIndex[last_buffer[i]];
gcd.y_axis_type[i] = JopCurveData.eAxis_y; gcd.y_axis_type[i] = JopCurveData.eAxis_y;
gcd.y_name[i] = trend_name[i]; gcd.y_name[i] = tp[i].DataName;
gcd.y_unit[i] = new String( "m/s"); gcd.y_unit[i] = tp[i].Unit;
gcd.rows[i] = max_points; gcd.rows[i] = max_points;
} }
...@@ -326,6 +358,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -326,6 +358,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
int noOfSample; int noOfSample;
int displayResolution; int displayResolution;
int timeResolution; int timeResolution;
String unit;
tcp[object_cnt] = new DsTrendCurve(); tcp[object_cnt] = new DsTrendCurve();
...@@ -359,9 +392,14 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -359,9 +392,14 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
continue; continue;
timeResolution = iret.value; timeResolution = iret.value;
CdhrString sret = engine.gdh.getObjectInfoString( object_names[i] + ".Unit");
if ( sret.oddSts())
unit = sret.str;
else
unit = new String();
for ( j = 0; j < 10; j++) { for ( j = 0; j < 10; j++) {
CdhrString sret = engine.gdh.getObjectInfoString( object_names[i] + ".Attribute["+j+"]"); sret = engine.gdh.getObjectInfoString( object_names[i] + ".Attribute["+j+"]");
if ( sret.oddSts() && !sret.str.equals("")) { if ( sret.oddSts() && !sret.str.equals("")) {
tcp[tcp_i] = new DsTrendCurve(); tcp[tcp_i] = new DsTrendCurve();
...@@ -372,7 +410,19 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -372,7 +410,19 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
tcp[tcp_i].NoOfSample = noOfSample; tcp[tcp_i].NoOfSample = noOfSample;
tcp[tcp_i].DisplayResolution = displayResolution; tcp[tcp_i].DisplayResolution = displayResolution;
tcp[tcp_i].TimeResolution = timeResolution; tcp[tcp_i].TimeResolution = timeResolution;
tcp[tcp_i].Unit = unit;
int offs = tcp[tcp_i].AttrName.lastIndexOf('.');
if ( offs != -1) {
sret = engine.gdh.getObjectInfoString( tcp[tcp_i].AttrName.substring(0,offs) + ".Unit");
if ( sret.oddSts())
tcp[tcp_i].Unit = sret.str;
else
tcp[tcp_i].Unit = new String();
}
else
tcp[tcp_i].Unit = new String();
sret = engine.gdh.getObjectInfoString( object_names[i] + ".Buffers["+j+"]"); sret = engine.gdh.getObjectInfoString( object_names[i] + ".Buffers["+j+"]");
if ( sret.evenSts() || sret.str.equals("")) if ( sret.evenSts() || sret.str.equals(""))
continue; continue;
...@@ -404,17 +454,14 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -404,17 +454,14 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
for ( i = 0; i < trend_cnt; i++) { for ( i = 0; i < trend_cnt; i++) {
System.out.println("Attribute " + tcp[i].AttrName + " Buffer " + tcp[i].Buffer);
cb_info[i] = new CircBuffInfo(); cb_info[i] = new CircBuffInfo();
cb_info[i].circAref = tcp[i].AttrRef; cb_info[i].circAref = tcp[i].AttrRef;
cb_info[i].resolution = tcp[i].DisplayResolution; cb_info[i].resolution = tcp[i].DisplayResolution;
cb_info[i].elementType = tcp[i].ElementType; cb_info[i].elementType = tcp[i].ElementType;
cb_info[i].samples = (int)(tcp[i].DisplayTime / tcp[i].ScanTime / cb_info[i].resolution); cb_info[i].samples = (int)(tcp[i].DisplayTime / tcp[i].ScanTime / cb_info[i].resolution);
System.out.println( "Samples: " + cb_info[i].samples);
engine.gdh.getCircBuffInfo( cb_info[i]); engine.gdh.getCircBuffInfo( cb_info[i]);
System.out.println( "sts: " + cb_info[i].status);
tcp[i].ActualDataSize = cb_info[i].size; tcp[i].ActualDataSize = cb_info[i].size;
...@@ -443,12 +490,10 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -443,12 +490,10 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
for ( i = 0; i < trend_cnt; i++) { for ( i = 0; i < trend_cnt; i++) {
gcd.y_data[i] = new double[max_points]; gcd.y_data[i] = new double[max_points];
System.out.println("ElementType " + tcp[i].ElementType + " " + Pwr.eType_Float32);
switch ( tcp[i].ElementType) { switch ( tcp[i].ElementType) {
case Pwr.eType_Float32: case Pwr.eType_Float32:
for ( j = 0; j < tcp[i].ActualDataSize; j++) { for ( j = 0; j < tcp[i].ActualDataSize; j++) {
gcd.y_data[i][j] = (double)((float[])cb_info[i].bufp)[ tcp[i].ActualDataSize - j - 1]; gcd.y_data[i][j] = (double)((float[])cb_info[i].bufp)[ tcp[i].ActualDataSize - j - 1];
System.out.println( j + " " + (double)((float[])cb_info[i].bufp)[ tcp[i].ActualDataSize - j - 1]);
} }
break; break;
case Pwr.eType_Int32: case Pwr.eType_Int32:
...@@ -459,7 +504,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -459,7 +504,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
case Pwr.eType_UInt8: case Pwr.eType_UInt8:
for ( j = 0; j < tcp[i].ActualDataSize; j++) { for ( j = 0; j < tcp[i].ActualDataSize; j++) {
gcd.y_data[i][j] = (double)((int[])cb_info[i].bufp)[ tcp[i].ActualDataSize - j - 1]; gcd.y_data[i][j] = (double)((int[])cb_info[i].bufp)[ tcp[i].ActualDataSize - j - 1];
System.out.println( j + " " + (double)((int[])cb_info[i].bufp)[ tcp[i].ActualDataSize - j - 1]);
} }
break; break;
default: ; default: ;
...@@ -469,7 +513,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -469,7 +513,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
gcd.y_axis_type[i] = JopCurveData.eAxis_y; gcd.y_axis_type[i] = JopCurveData.eAxis_y;
gcd.y_name[i] = tcp[i].AttrName; gcd.y_name[i] = tcp[i].AttrName;
gcd.rows[i] = max_points; gcd.rows[i] = max_points;
gcd.y_unit[i] = new String( "m/s"); gcd.y_unit[i] = tcp[i].Unit;
} }
gcd.cols = trend_cnt; gcd.cols = trend_cnt;
...@@ -495,8 +539,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -495,8 +539,6 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
gcd.get_default_axis(); gcd.get_default_axis();
gcd.select_color(false); gcd.select_color(false);
System.out.println( "Lines h : " + gcd.y_trend_lines[0] + " v: " + gcd.x_trend_lines[0]);
curve = new JopCurve( session, this, gcd); curve = new JopCurve( session, this, gcd);
curve.setFillCurve(false); curve.setFillCurve(false);
...@@ -635,7 +677,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc { ...@@ -635,7 +677,7 @@ public class JopXttTrend implements ActionListener, JopCurveIfc {
JopXttTrend trend = new JopXttTrend(new String[] {"H28-Trend2"},null); JopXttTrend trend = new JopXttTrend(new String[] {"H28-Plot2"});
} }
} }
...@@ -1304,7 +1304,27 @@ public class XttTree extends JPanel ...@@ -1304,7 +1304,27 @@ public class XttTree extends JPanel
Logg.loggToApplet("Select an object"); Logg.loggToApplet("Select an object");
return; return;
} }
String cmd = "open graph/class/inst=" + name;
int cid = 0;
CdhrObjid oret = gdh.nameToObjid(name);
if ( oret.oddSts()) {
CdhrClassId cret = gdh.getObjectClass(oret.objid);
if ( cret.oddSts())
cid = cret.getClassId();
}
String cmd;
switch ( cid) {
case Pwrb.cClass_DsTrend:
case Pwrb.cClass_DsTrendCurve:
case Pwrb.cClass_PlotGroup:
cmd = "open trend/name=" + name;
break;
case Pwrb.cClass_DsFastCurve:
cmd = "open fast/name=" + name;
break;
default:
cmd = "open graph/class/inst=" + name;
}
session.executeCommand(cmd); session.executeCommand(cmd);
} }
catch(Exception e) { catch(Exception e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment