Commit 7cc405a5 authored by claes's avatar claes

Attributes for minvalue, maxvalue

parent aee83ace
/* /*
* Proview $Id: GeDynFillLevel.java,v 1.2 2005-09-01 14:57:50 claes Exp $ * Proview $Id: GeDynFillLevel.java,v 1.3 2005-11-02 14:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -29,15 +29,22 @@ public class GeDynFillLevel extends GeDynElem { ...@@ -29,15 +29,22 @@ public class GeDynFillLevel extends GeDynElem {
double maxValue; double maxValue;
double minPos; double minPos;
double maxPos; double maxPos;
String minValueAttr;
String maxValueAttr;
boolean attrFound; boolean attrFound;
PwrtRefId subid; PwrtRefId subid;
int p; int p;
float oldValue; float oldValue;
boolean firstScan = true; boolean firstScan = true;
int minValueP;
int maxValueP;
PwrtRefId minValueSubid;
PwrtRefId maxValueSubid;
public GeDynFillLevel( GeDyn dyn, String attribute, int color, int direction, public GeDynFillLevel( GeDyn dyn, String attribute, int color, int direction,
double minValue, double maxValue, double minPos, double maxPos) { double minValue, double maxValue, double minPos, double maxPos,
String minValueAttr, String maxValueAttr) {
super( dyn, GeDyn.mDynType_FillLevel, GeDyn.mActionType_No); super( dyn, GeDyn.mDynType_FillLevel, GeDyn.mActionType_No);
this.attribute = attribute; this.attribute = attribute;
this.color = color; this.color = color;
...@@ -46,9 +53,11 @@ public class GeDynFillLevel extends GeDynElem { ...@@ -46,9 +53,11 @@ public class GeDynFillLevel extends GeDynElem {
this.maxValue = maxValue; this.maxValue = maxValue;
this.minPos = minPos; this.minPos = minPos;
this.maxPos = maxPos; this.maxPos = maxPos;
this.minValueAttr = minValueAttr;
this.maxValueAttr = maxValueAttr;
} }
public void connect() { public void connect() {
if ( minValue == maxValue) if ( minValue == maxValue && minValueAttr == null && maxValueAttr == null)
return; return;
String attrName = dyn.getAttrName( attribute); String attrName = dyn.getAttrName( attribute);
...@@ -74,14 +83,54 @@ public class GeDynFillLevel extends GeDynElem { ...@@ -74,14 +83,54 @@ public class GeDynFillLevel extends GeDynElem {
dyn.comp.setLevelFillColor( color); dyn.comp.setLevelFillColor( color);
} }
} }
minValueP = 0;
if ( minValueAttr != null) {
attrName = dyn.getAttrName( minValueAttr);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts())
System.out.println( "FillLevel: " + attrName);
else {
minValueP = ret.id;
minValueSubid = ret.refid;
}
}
}
maxValueP = 0;
if ( maxValueAttr != null) {
attrName = dyn.getAttrName( maxValueAttr);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts())
System.out.println( "FillLevel: " + attrName);
else {
maxValueP = ret.id;
maxValueSubid = ret.refid;
}
}
}
} }
public void disconnect() { public void disconnect() {
if ( attrFound) if ( attrFound)
dyn.en.gdh.unrefObjectInfo( subid); dyn.en.gdh.unrefObjectInfo( subid);
if ( minValueP != 0)
dyn.en.gdh.unrefObjectInfo( minValueSubid);
if ( maxValueP != 0)
dyn.en.gdh.unrefObjectInfo( maxValueSubid);
} }
public void scan() { public void scan() {
if ( !attrFound) if ( !attrFound)
return; return;
if ( minValueP != 0 && maxValueP != 0) {
double minVal = dyn.en.gdh.getObjectRefInfoFloat( minValueP);
double maxVal = dyn.en.gdh.getObjectRefInfoFloat( maxValueP);
if ( (minVal != minValue || maxVal != maxValue) && maxVal != minVal) {
minValue = minVal;
maxValue = maxVal;
firstScan = true;
}
}
float value = dyn.en.gdh.getObjectRefInfoFloat( p); float value = dyn.en.gdh.getObjectRefInfoFloat( p);
if ( !firstScan) { if ( !firstScan) {
if ( value == oldValue) if ( value == oldValue)
......
/* /*
* Proview $Id: GeDynValueInput.java,v 1.4 2005-09-01 14:57:50 claes Exp $ * Proview $Id: GeDynValueInput.java,v 1.5 2005-11-02 14:00:47 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -25,15 +25,20 @@ import javax.swing.*; ...@@ -25,15 +25,20 @@ import javax.swing.*;
public class GeDynValueInput extends GeDynElem { public class GeDynValueInput extends GeDynElem {
double minValue; double minValue;
double maxValue; double maxValue;
String minValueAttr;
String maxValueAttr;
boolean attrFound = false; boolean attrFound = false;
int typeId; int typeId;
GeDynValue valueElement; GeDynValue valueElement;
public GeDynValueInput( GeDyn dyn, double minValue, double maxValue) { public GeDynValueInput( GeDyn dyn, double minValue, double maxValue,
String minValueAttr, String maxValueAttr) {
super( dyn, GeDyn.mDynType_No, GeDyn.mActionType_ValueInput); super( dyn, GeDyn.mDynType_No, GeDyn.mActionType_ValueInput);
this.minValue = minValue; this.minValue = minValue;
this.maxValue = maxValue; this.maxValue = maxValue;
this.minValueAttr = minValueAttr;
this.maxValueAttr = maxValueAttr;
} }
public void connect() { public void connect() {
// Find the value element // Find the value element
...@@ -73,10 +78,42 @@ public class GeDynValueInput extends GeDynElem { ...@@ -73,10 +78,42 @@ public class GeDynValueInput extends GeDynElem {
PwrtStatus sts; PwrtStatus sts;
try { try {
double minval = 0;
double maxval = 0;
if ( minValueAttr != null) {
String attrName = dyn.getAttrName( minValueAttr);
int typeId = dyn.getTypeId( minValueAttr);
if ( typeId < 0 || typeId == Pwr.eType_Float32) {
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "ValueInput " + attrName);
return;
}
minval = ret.value;
}
}
else
minval = minValue;
if ( maxValueAttr != null) {
String attrName = dyn.getAttrName( maxValueAttr);
int typeId = dyn.getTypeId( maxValueAttr);
if ( typeId < 0 || typeId == Pwr.eType_Float32) {
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "ValueInput " + attrName);
return;
}
maxval = ret.value;
}
}
else
maxval = maxValue;
if ( typeId == Pwr.eType_Float32) { if ( typeId == Pwr.eType_Float32) {
float inputValue = Float.parseFloat( text.trim()); float inputValue = Float.parseFloat( text.trim());
valueElement.oldValueF = inputValue; valueElement.oldValueF = inputValue;
if ( minValue == 0 && maxValue == 0) { if ( minval == 0 && maxval == 0) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
...@@ -86,8 +123,8 @@ public class GeDynValueInput extends GeDynElem { ...@@ -86,8 +123,8 @@ public class GeDynValueInput extends GeDynElem {
System.out.println( "setObjectInfoError " + sts); System.out.println( "setObjectInfoError " + sts);
} }
else { else {
if ( inputValue >= minValue && inputValue <= maxValue ) { if ( inputValue >= minval && inputValue <= maxval ) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
else else
...@@ -107,7 +144,7 @@ public class GeDynValueInput extends GeDynElem { ...@@ -107,7 +144,7 @@ public class GeDynValueInput extends GeDynElem {
typeId == Pwr.eType_UInt8) { typeId == Pwr.eType_UInt8) {
int inputValue = Integer.parseInt( text.trim(), 10); int inputValue = Integer.parseInt( text.trim(), 10);
valueElement.oldValueI = inputValue; valueElement.oldValueI = inputValue;
if ( minValue == 0 && maxValue == 0) { if ( minval == 0 && maxval == 0) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
...@@ -117,7 +154,7 @@ public class GeDynValueInput extends GeDynElem { ...@@ -117,7 +154,7 @@ public class GeDynValueInput extends GeDynElem {
System.out.println( "setObjectInfoError " + sts); System.out.println( "setObjectInfoError " + sts);
} }
else { else {
if ( inputValue >= minValue && inputValue <= maxValue ) { if ( inputValue >= minval && inputValue <= maxval ) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
......
/* /*
* Proview $Id: JopBar.java,v 1.5 2005-09-01 14:57:50 claes Exp $ * Proview $Id: JopBar.java,v 1.6 2005-11-02 14:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -242,12 +242,18 @@ public class JopBar extends JComponent implements GeComponentIfc, ...@@ -242,12 +242,18 @@ public class JopBar extends JComponent implements GeComponentIfc,
public void setLowColor( int lowColor) { this.lowColor = lowColor;} public void setLowColor( int lowColor) { this.lowColor = lowColor;}
public int getLowColor() { return lowColor;} public int getLowColor() { return lowColor;}
String pwrAttribute = new String(); String pwrAttribute = new String();
String minValueAttr;
String maxValueAttr;
public void setPwrAttribute( String pwrAttribute) { this.pwrAttribute = pwrAttribute;} public void setPwrAttribute( String pwrAttribute) { this.pwrAttribute = pwrAttribute;}
public String getPwrAttribute() { return pwrAttribute;} public String getPwrAttribute() { return pwrAttribute;}
public void setMinValueAttr( String minValueAttr) { this.minValueAttr = minValueAttr;}
public void setMaxValueAttr( String maxValueAttr) { this.maxValueAttr = maxValueAttr;}
float valueColor; float valueColor;
float valueColorOld; float valueColorOld;
boolean firstScan = true; boolean firstScan = true;
GdhrRefObjectInfo retColor = null; GdhrRefObjectInfo retColor = null;
GdhrRefObjectInfo retMinVal = null;
GdhrRefObjectInfo retMaxVal = null;
boolean colorAttrFound = false; boolean colorAttrFound = false;
float minValue = 0; float minValue = 0;
float maxValue = 100; float maxValue = 100;
...@@ -281,19 +287,44 @@ public class JopBar extends JComponent implements GeComponentIfc, ...@@ -281,19 +287,44 @@ public class JopBar extends JComponent implements GeComponentIfc,
else else
colorAttrFound = true; colorAttrFound = true;
} }
if ( minValueAttr != null) {
String attrName = dd.getAttrName( minValueAttr);
retMinVal = en.gdh.refObjectInfo( attrName);
}
if ( maxValueAttr != null) {
String attrName = dd.getAttrName( maxValueAttr);
retMaxVal = en.gdh.refObjectInfo( attrName);
}
} }
public void dynamicClose() { public void dynamicClose() {
if ( colorAttrFound) if ( colorAttrFound)
en.gdh.unrefObjectInfo( retColor.refid); en.gdh.unrefObjectInfo( retColor.refid);
if ( retMinVal != null && retMinVal.oddSts())
en.gdh.unrefObjectInfo( retMinVal.refid);
if ( retMaxVal != null && retMinVal.oddSts())
en.gdh.unrefObjectInfo( retMaxVal.refid);
} }
public void dynamicUpdate( boolean animationOnly) { public void dynamicUpdate( boolean animationOnly) {
if ( maxValue == minValue) if ( maxValue == minValue && minValueAttr == null && maxValueAttr == null)
return; return;
if ( animationOnly) if ( animationOnly)
return; return;
if ( colorAttrFound) { if ( colorAttrFound) {
if ( shapes[0] == null) if ( shapes[0] == null)
return; return;
if ( retMinVal != null && retMaxVal != null &&
retMinVal.oddSts() && retMaxVal.oddSts()) {
float minVal = en.gdh.getObjectRefInfoFloat( retMinVal.id);
float maxVal = en.gdh.getObjectRefInfoFloat( retMaxVal.id);
if ( (minVal != minValue || maxVal != maxValue) && maxVal != minVal) {
minValue = minVal;
maxValue = maxVal;
firstScan = true;
}
}
valueColor = en.gdh.getObjectRefInfoFloat( retColor.id); valueColor = en.gdh.getObjectRefInfoFloat( retColor.id);
if ( valueColorOld != valueColor || firstScan) { if ( valueColorOld != valueColor || firstScan) {
float bar_height; float bar_height;
......
/* /*
* Proview $Id: JopTrend.java,v 1.5 2005-09-01 14:57:50 claes Exp $ * Proview $Id: JopTrend.java,v 1.6 2005-11-02 14:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -376,13 +376,21 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -376,13 +376,21 @@ public class JopTrend extends JComponent implements GeComponentIfc,
public Dimension getPreferredSize() { return size;} public Dimension getPreferredSize() { return size;}
public Dimension getMinimumSize() { return size;} public Dimension getMinimumSize() { return size;}
String[] pwrAttribute = new String[2]; String[] pwrAttribute = new String[2];
String[] minValueAttr = new String[2];
String[] maxValueAttr = new String[2];
public void setPwrAttribute1( String pwrAttribute) { this.pwrAttribute[0] = pwrAttribute;} public void setPwrAttribute1( String pwrAttribute) { this.pwrAttribute[0] = pwrAttribute;}
public String getPwrAttribute1() { return pwrAttribute[0];} public String getPwrAttribute1() { return pwrAttribute[0];}
public void setPwrAttribute2( String pwrAttribute) { this.pwrAttribute[1] = pwrAttribute;} public void setPwrAttribute2( String pwrAttribute) { this.pwrAttribute[1] = pwrAttribute;}
public String getPwrAttribute2() { return pwrAttribute[1];} public String getPwrAttribute2() { return pwrAttribute[1];}
public void setMinValueAttr1( String minValueAttr1) { this.minValueAttr[0] = minValueAttr1;}
public void setMaxValueAttr1( String maxValueAttr1) { this.maxValueAttr[0] = maxValueAttr1;}
public void setMinValueAttr2( String minValueAttr2) { this.minValueAttr[1] = minValueAttr2;}
public void setMaxValueAttr2( String maxValueAttr2) { this.maxValueAttr[1] = maxValueAttr2;}
float[] valueOld = new float[2]; float[] valueOld = new float[2];
boolean firstScan = true; boolean firstScan = true;
GdhrRefObjectInfo[] retColor = {null, null}; GdhrRefObjectInfo[] retColor = {null, null};
GdhrRefObjectInfo[] retMinVal = {null, null};
GdhrRefObjectInfo[] retMaxVal = {null, null};
boolean[] attrFound = {false, false}; boolean[] attrFound = {false, false};
float[] minValue = {0,0}; float[] minValue = {0,0};
float[] maxValue = {100, 100}; float[] maxValue = {100, 100};
...@@ -415,8 +423,10 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -415,8 +423,10 @@ public class JopTrend extends JComponent implements GeComponentIfc,
} }
public void reset() { public void reset() {
for ( int j = 0; j < 2; j++) { for ( int j = 0; j < 2; j++) {
for ( int i = 0; i < noOfPoints; i++) if ( y_values[j] != null) {
y_values[j][i] = original_height; for ( int i = 0; i < noOfPoints; i++)
y_values[j][i] = original_height;
}
} }
repaint(); repaint();
} }
...@@ -432,12 +442,28 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -432,12 +442,28 @@ public class JopTrend extends JComponent implements GeComponentIfc,
else else
attrFound[j] = true; attrFound[j] = true;
} }
if ( minValueAttr[j] != null && minValueAttr[j].compareTo("") != 0) {
String attrName = dd.getAttrName(minValueAttr[j]);
retMinVal[j] = en.gdh.refObjectInfo( attrName);
if ( retMinVal[j].evenSts())
System.out.println( "refObjectInfoError " + minValueAttr[j]);
}
if ( maxValueAttr[j] != null && maxValueAttr[j].compareTo("") != 0) {
String attrName = dd.getAttrName(maxValueAttr[j]);
retMaxVal[j] = en.gdh.refObjectInfo( attrName);
if ( retMaxVal[j].evenSts())
System.out.println( "refObjectInfoError " + maxValueAttr[j]);
}
} }
} }
public void dynamicClose() { public void dynamicClose() {
for ( int j = 0; j < 2; j++) { for ( int j = 0; j < 2; j++) {
if ( attrFound[j]) if ( attrFound[j])
en.gdh.unrefObjectInfo( retColor[j].refid); en.gdh.unrefObjectInfo( retColor[j].refid);
if ( retMinVal[j] != null && retMinVal[j].oddSts())
en.gdh.unrefObjectInfo( retMinVal[j].refid);
if ( retMaxVal[j] != null && retMaxVal[j].oddSts())
en.gdh.unrefObjectInfo( retMaxVal[j].refid);
} }
} }
public void dynamicUpdate( boolean animationOnly) { public void dynamicUpdate( boolean animationOnly) {
...@@ -455,6 +481,18 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -455,6 +481,18 @@ public class JopTrend extends JComponent implements GeComponentIfc,
for ( j = 0; j < 2; j++) { for ( j = 0; j < 2; j++) {
if ( attrFound[j]) { if ( attrFound[j]) {
if ( retMinVal[j] != null && retMaxVal[j] != null &&
retMinVal[j].oddSts() && retMaxVal[j].oddSts()) {
float minVal = en.gdh.getObjectRefInfoFloat( retMinVal[j].id);
float maxVal = en.gdh.getObjectRefInfoFloat( retMaxVal[j].id);
if ( (minVal != minValue[j] || maxVal != maxValue[j]) && maxVal != minVal) {
minValue[j] = minVal;
maxValue[j] = maxVal;
reset();
}
}
switch( retColor[j].typeId) { switch( retColor[j].typeId) {
case Pwr.eType_Boolean: case Pwr.eType_Boolean:
if ( en.gdh.getObjectRefInfoBoolean( retColor[j].id)) if ( en.gdh.getObjectRefInfoBoolean( retColor[j].id))
......
/* /*
* Proview $Id: GeDynFillLevel.java,v 1.2 2005-09-01 14:57:50 claes Exp $ * Proview $Id: GeDynFillLevel.java,v 1.3 2005-11-02 14:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -29,15 +29,22 @@ public class GeDynFillLevel extends GeDynElem { ...@@ -29,15 +29,22 @@ public class GeDynFillLevel extends GeDynElem {
double maxValue; double maxValue;
double minPos; double minPos;
double maxPos; double maxPos;
String minValueAttr;
String maxValueAttr;
boolean attrFound; boolean attrFound;
PwrtRefId subid; PwrtRefId subid;
int p; int p;
float oldValue; float oldValue;
boolean firstScan = true; boolean firstScan = true;
int minValueP;
int maxValueP;
PwrtRefId minValueSubid;
PwrtRefId maxValueSubid;
public GeDynFillLevel( GeDyn dyn, String attribute, int color, int direction, public GeDynFillLevel( GeDyn dyn, String attribute, int color, int direction,
double minValue, double maxValue, double minPos, double maxPos) { double minValue, double maxValue, double minPos, double maxPos,
String minValueAttr, String maxValueAttr) {
super( dyn, GeDyn.mDynType_FillLevel, GeDyn.mActionType_No); super( dyn, GeDyn.mDynType_FillLevel, GeDyn.mActionType_No);
this.attribute = attribute; this.attribute = attribute;
this.color = color; this.color = color;
...@@ -46,9 +53,11 @@ public class GeDynFillLevel extends GeDynElem { ...@@ -46,9 +53,11 @@ public class GeDynFillLevel extends GeDynElem {
this.maxValue = maxValue; this.maxValue = maxValue;
this.minPos = minPos; this.minPos = minPos;
this.maxPos = maxPos; this.maxPos = maxPos;
this.minValueAttr = minValueAttr;
this.maxValueAttr = maxValueAttr;
} }
public void connect() { public void connect() {
if ( minValue == maxValue) if ( minValue == maxValue && minValueAttr == null && maxValueAttr == null)
return; return;
String attrName = dyn.getAttrName( attribute); String attrName = dyn.getAttrName( attribute);
...@@ -74,14 +83,54 @@ public class GeDynFillLevel extends GeDynElem { ...@@ -74,14 +83,54 @@ public class GeDynFillLevel extends GeDynElem {
dyn.comp.setLevelFillColor( color); dyn.comp.setLevelFillColor( color);
} }
} }
minValueP = 0;
if ( minValueAttr != null) {
attrName = dyn.getAttrName( minValueAttr);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts())
System.out.println( "FillLevel: " + attrName);
else {
minValueP = ret.id;
minValueSubid = ret.refid;
}
}
}
maxValueP = 0;
if ( maxValueAttr != null) {
attrName = dyn.getAttrName( maxValueAttr);
if ( attrName.compareTo("") != 0) {
GdhrRefObjectInfo ret = dyn.en.gdh.refObjectInfo( attrName);
if ( ret.evenSts())
System.out.println( "FillLevel: " + attrName);
else {
maxValueP = ret.id;
maxValueSubid = ret.refid;
}
}
}
} }
public void disconnect() { public void disconnect() {
if ( attrFound) if ( attrFound)
dyn.en.gdh.unrefObjectInfo( subid); dyn.en.gdh.unrefObjectInfo( subid);
if ( minValueP != 0)
dyn.en.gdh.unrefObjectInfo( minValueSubid);
if ( maxValueP != 0)
dyn.en.gdh.unrefObjectInfo( maxValueSubid);
} }
public void scan() { public void scan() {
if ( !attrFound) if ( !attrFound)
return; return;
if ( minValueP != 0 && maxValueP != 0) {
double minVal = dyn.en.gdh.getObjectRefInfoFloat( minValueP);
double maxVal = dyn.en.gdh.getObjectRefInfoFloat( maxValueP);
if ( (minVal != minValue || maxVal != maxValue) && maxVal != minVal) {
minValue = minVal;
maxValue = maxVal;
firstScan = true;
}
}
float value = dyn.en.gdh.getObjectRefInfoFloat( p); float value = dyn.en.gdh.getObjectRefInfoFloat( p);
if ( !firstScan) { if ( !firstScan) {
if ( value == oldValue) if ( value == oldValue)
......
/* /*
* Proview $Id: GeDynValueInput.java,v 1.4 2005-09-01 14:57:50 claes Exp $ * Proview $Id: GeDynValueInput.java,v 1.5 2005-11-02 14:00:47 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -25,15 +25,20 @@ import javax.swing.*; ...@@ -25,15 +25,20 @@ import javax.swing.*;
public class GeDynValueInput extends GeDynElem { public class GeDynValueInput extends GeDynElem {
double minValue; double minValue;
double maxValue; double maxValue;
String minValueAttr;
String maxValueAttr;
boolean attrFound = false; boolean attrFound = false;
int typeId; int typeId;
GeDynValue valueElement; GeDynValue valueElement;
public GeDynValueInput( GeDyn dyn, double minValue, double maxValue) { public GeDynValueInput( GeDyn dyn, double minValue, double maxValue,
String minValueAttr, String maxValueAttr) {
super( dyn, GeDyn.mDynType_No, GeDyn.mActionType_ValueInput); super( dyn, GeDyn.mDynType_No, GeDyn.mActionType_ValueInput);
this.minValue = minValue; this.minValue = minValue;
this.maxValue = maxValue; this.maxValue = maxValue;
this.minValueAttr = minValueAttr;
this.maxValueAttr = maxValueAttr;
} }
public void connect() { public void connect() {
// Find the value element // Find the value element
...@@ -73,10 +78,42 @@ public class GeDynValueInput extends GeDynElem { ...@@ -73,10 +78,42 @@ public class GeDynValueInput extends GeDynElem {
PwrtStatus sts; PwrtStatus sts;
try { try {
double minval = 0;
double maxval = 0;
if ( minValueAttr != null) {
String attrName = dyn.getAttrName( minValueAttr);
int typeId = dyn.getTypeId( minValueAttr);
if ( typeId < 0 || typeId == Pwr.eType_Float32) {
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "ValueInput " + attrName);
return;
}
minval = ret.value;
}
}
else
minval = minValue;
if ( maxValueAttr != null) {
String attrName = dyn.getAttrName( maxValueAttr);
int typeId = dyn.getTypeId( maxValueAttr);
if ( typeId < 0 || typeId == Pwr.eType_Float32) {
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "ValueInput " + attrName);
return;
}
maxval = ret.value;
}
}
else
maxval = maxValue;
if ( typeId == Pwr.eType_Float32) { if ( typeId == Pwr.eType_Float32) {
float inputValue = Float.parseFloat( text.trim()); float inputValue = Float.parseFloat( text.trim());
valueElement.oldValueF = inputValue; valueElement.oldValueF = inputValue;
if ( minValue == 0 && maxValue == 0) { if ( minval == 0 && maxval == 0) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
...@@ -86,8 +123,8 @@ public class GeDynValueInput extends GeDynElem { ...@@ -86,8 +123,8 @@ public class GeDynValueInput extends GeDynElem {
System.out.println( "setObjectInfoError " + sts); System.out.println( "setObjectInfoError " + sts);
} }
else { else {
if ( inputValue >= minValue && inputValue <= maxValue ) { if ( inputValue >= minval && inputValue <= maxval ) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
else else
...@@ -107,7 +144,7 @@ public class GeDynValueInput extends GeDynElem { ...@@ -107,7 +144,7 @@ public class GeDynValueInput extends GeDynElem {
typeId == Pwr.eType_UInt8) { typeId == Pwr.eType_UInt8) {
int inputValue = Integer.parseInt( text.trim(), 10); int inputValue = Integer.parseInt( text.trim(), 10);
valueElement.oldValueI = inputValue; valueElement.oldValueI = inputValue;
if ( minValue == 0 && maxValue == 0) { if ( minval == 0 && maxval == 0) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
...@@ -117,7 +154,7 @@ public class GeDynValueInput extends GeDynElem { ...@@ -117,7 +154,7 @@ public class GeDynValueInput extends GeDynElem {
System.out.println( "setObjectInfoError " + sts); System.out.println( "setObjectInfoError " + sts);
} }
else { else {
if ( inputValue >= minValue && inputValue <= maxValue ) { if ( inputValue >= minval && inputValue <= maxval ) {
String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute); String attrName = dyn.getAttrNameNoSuffix( valueElement.attribute);
if ( !valueElement.localDb) if ( !valueElement.localDb)
sts = dyn.en.gdh.setObjectInfo( attrName, inputValue); sts = dyn.en.gdh.setObjectInfo( attrName, inputValue);
......
/* /*
* Proview $Id: JopBar.java,v 1.5 2005-09-01 14:57:50 claes Exp $ * Proview $Id: JopBar.java,v 1.6 2005-11-02 14:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -242,12 +242,18 @@ public class JopBar extends JComponent implements GeComponentIfc, ...@@ -242,12 +242,18 @@ public class JopBar extends JComponent implements GeComponentIfc,
public void setLowColor( int lowColor) { this.lowColor = lowColor;} public void setLowColor( int lowColor) { this.lowColor = lowColor;}
public int getLowColor() { return lowColor;} public int getLowColor() { return lowColor;}
String pwrAttribute = new String(); String pwrAttribute = new String();
String minValueAttr;
String maxValueAttr;
public void setPwrAttribute( String pwrAttribute) { this.pwrAttribute = pwrAttribute;} public void setPwrAttribute( String pwrAttribute) { this.pwrAttribute = pwrAttribute;}
public String getPwrAttribute() { return pwrAttribute;} public String getPwrAttribute() { return pwrAttribute;}
public void setMinValueAttr( String minValueAttr) { this.minValueAttr = minValueAttr;}
public void setMaxValueAttr( String maxValueAttr) { this.maxValueAttr = maxValueAttr;}
float valueColor; float valueColor;
float valueColorOld; float valueColorOld;
boolean firstScan = true; boolean firstScan = true;
GdhrRefObjectInfo retColor = null; GdhrRefObjectInfo retColor = null;
GdhrRefObjectInfo retMinVal = null;
GdhrRefObjectInfo retMaxVal = null;
boolean colorAttrFound = false; boolean colorAttrFound = false;
float minValue = 0; float minValue = 0;
float maxValue = 100; float maxValue = 100;
...@@ -281,19 +287,44 @@ public class JopBar extends JComponent implements GeComponentIfc, ...@@ -281,19 +287,44 @@ public class JopBar extends JComponent implements GeComponentIfc,
else else
colorAttrFound = true; colorAttrFound = true;
} }
if ( minValueAttr != null) {
String attrName = dd.getAttrName( minValueAttr);
retMinVal = en.gdh.refObjectInfo( attrName);
}
if ( maxValueAttr != null) {
String attrName = dd.getAttrName( maxValueAttr);
retMaxVal = en.gdh.refObjectInfo( attrName);
}
} }
public void dynamicClose() { public void dynamicClose() {
if ( colorAttrFound) if ( colorAttrFound)
en.gdh.unrefObjectInfo( retColor.refid); en.gdh.unrefObjectInfo( retColor.refid);
if ( retMinVal != null && retMinVal.oddSts())
en.gdh.unrefObjectInfo( retMinVal.refid);
if ( retMaxVal != null && retMinVal.oddSts())
en.gdh.unrefObjectInfo( retMaxVal.refid);
} }
public void dynamicUpdate( boolean animationOnly) { public void dynamicUpdate( boolean animationOnly) {
if ( maxValue == minValue) if ( maxValue == minValue && minValueAttr == null && maxValueAttr == null)
return; return;
if ( animationOnly) if ( animationOnly)
return; return;
if ( colorAttrFound) { if ( colorAttrFound) {
if ( shapes[0] == null) if ( shapes[0] == null)
return; return;
if ( retMinVal != null && retMaxVal != null &&
retMinVal.oddSts() && retMaxVal.oddSts()) {
float minVal = en.gdh.getObjectRefInfoFloat( retMinVal.id);
float maxVal = en.gdh.getObjectRefInfoFloat( retMaxVal.id);
if ( (minVal != minValue || maxVal != maxValue) && maxVal != minVal) {
minValue = minVal;
maxValue = maxVal;
firstScan = true;
}
}
valueColor = en.gdh.getObjectRefInfoFloat( retColor.id); valueColor = en.gdh.getObjectRefInfoFloat( retColor.id);
if ( valueColorOld != valueColor || firstScan) { if ( valueColorOld != valueColor || firstScan) {
float bar_height; float bar_height;
......
/* /*
* Proview $Id: JopTrend.java,v 1.5 2005-09-01 14:57:50 claes Exp $ * Proview $Id: JopTrend.java,v 1.6 2005-11-02 14:00:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -376,13 +376,21 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -376,13 +376,21 @@ public class JopTrend extends JComponent implements GeComponentIfc,
public Dimension getPreferredSize() { return size;} public Dimension getPreferredSize() { return size;}
public Dimension getMinimumSize() { return size;} public Dimension getMinimumSize() { return size;}
String[] pwrAttribute = new String[2]; String[] pwrAttribute = new String[2];
String[] minValueAttr = new String[2];
String[] maxValueAttr = new String[2];
public void setPwrAttribute1( String pwrAttribute) { this.pwrAttribute[0] = pwrAttribute;} public void setPwrAttribute1( String pwrAttribute) { this.pwrAttribute[0] = pwrAttribute;}
public String getPwrAttribute1() { return pwrAttribute[0];} public String getPwrAttribute1() { return pwrAttribute[0];}
public void setPwrAttribute2( String pwrAttribute) { this.pwrAttribute[1] = pwrAttribute;} public void setPwrAttribute2( String pwrAttribute) { this.pwrAttribute[1] = pwrAttribute;}
public String getPwrAttribute2() { return pwrAttribute[1];} public String getPwrAttribute2() { return pwrAttribute[1];}
public void setMinValueAttr1( String minValueAttr1) { this.minValueAttr[0] = minValueAttr1;}
public void setMaxValueAttr1( String maxValueAttr1) { this.maxValueAttr[0] = maxValueAttr1;}
public void setMinValueAttr2( String minValueAttr2) { this.minValueAttr[1] = minValueAttr2;}
public void setMaxValueAttr2( String maxValueAttr2) { this.maxValueAttr[1] = maxValueAttr2;}
float[] valueOld = new float[2]; float[] valueOld = new float[2];
boolean firstScan = true; boolean firstScan = true;
GdhrRefObjectInfo[] retColor = {null, null}; GdhrRefObjectInfo[] retColor = {null, null};
GdhrRefObjectInfo[] retMinVal = {null, null};
GdhrRefObjectInfo[] retMaxVal = {null, null};
boolean[] attrFound = {false, false}; boolean[] attrFound = {false, false};
float[] minValue = {0,0}; float[] minValue = {0,0};
float[] maxValue = {100, 100}; float[] maxValue = {100, 100};
...@@ -415,8 +423,10 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -415,8 +423,10 @@ public class JopTrend extends JComponent implements GeComponentIfc,
} }
public void reset() { public void reset() {
for ( int j = 0; j < 2; j++) { for ( int j = 0; j < 2; j++) {
for ( int i = 0; i < noOfPoints; i++) if ( y_values[j] != null) {
y_values[j][i] = original_height; for ( int i = 0; i < noOfPoints; i++)
y_values[j][i] = original_height;
}
} }
repaint(); repaint();
} }
...@@ -432,12 +442,28 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -432,12 +442,28 @@ public class JopTrend extends JComponent implements GeComponentIfc,
else else
attrFound[j] = true; attrFound[j] = true;
} }
if ( minValueAttr[j] != null && minValueAttr[j].compareTo("") != 0) {
String attrName = dd.getAttrName(minValueAttr[j]);
retMinVal[j] = en.gdh.refObjectInfo( attrName);
if ( retMinVal[j].evenSts())
System.out.println( "refObjectInfoError " + minValueAttr[j]);
}
if ( maxValueAttr[j] != null && maxValueAttr[j].compareTo("") != 0) {
String attrName = dd.getAttrName(maxValueAttr[j]);
retMaxVal[j] = en.gdh.refObjectInfo( attrName);
if ( retMaxVal[j].evenSts())
System.out.println( "refObjectInfoError " + maxValueAttr[j]);
}
} }
} }
public void dynamicClose() { public void dynamicClose() {
for ( int j = 0; j < 2; j++) { for ( int j = 0; j < 2; j++) {
if ( attrFound[j]) if ( attrFound[j])
en.gdh.unrefObjectInfo( retColor[j].refid); en.gdh.unrefObjectInfo( retColor[j].refid);
if ( retMinVal[j] != null && retMinVal[j].oddSts())
en.gdh.unrefObjectInfo( retMinVal[j].refid);
if ( retMaxVal[j] != null && retMaxVal[j].oddSts())
en.gdh.unrefObjectInfo( retMaxVal[j].refid);
} }
} }
public void dynamicUpdate( boolean animationOnly) { public void dynamicUpdate( boolean animationOnly) {
...@@ -455,6 +481,18 @@ public class JopTrend extends JComponent implements GeComponentIfc, ...@@ -455,6 +481,18 @@ public class JopTrend extends JComponent implements GeComponentIfc,
for ( j = 0; j < 2; j++) { for ( j = 0; j < 2; j++) {
if ( attrFound[j]) { if ( attrFound[j]) {
if ( retMinVal[j] != null && retMaxVal[j] != null &&
retMinVal[j].oddSts() && retMaxVal[j].oddSts()) {
float minVal = en.gdh.getObjectRefInfoFloat( retMinVal[j].id);
float maxVal = en.gdh.getObjectRefInfoFloat( retMaxVal[j].id);
if ( (minVal != minValue[j] || maxVal != maxValue[j]) && maxVal != minVal) {
minValue[j] = minVal;
maxValue[j] = maxVal;
reset();
}
}
switch( retColor[j].typeId) { switch( retColor[j].typeId) {
case Pwr.eType_Boolean: case Pwr.eType_Boolean:
if ( en.gdh.getObjectRefInfoBoolean( retColor[j].id)) if ( en.gdh.getObjectRefInfoBoolean( retColor[j].id))
......
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