Commit c517727b authored by claes's avatar claes

Integer attributes also supported

parent 066f5758
......@@ -31,23 +31,51 @@ public class GeDynIncrAnalog extends GeDynElem {
break;
String attrName = dyn.getAttrName( attribute);
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "IncrAnalog " + attrName);
int typeId = dyn.getTypeId( attribute);
if ( typeId < 0)
typeId = Pwr.eType_Float32;
switch ( typeId) {
case Pwr.eType_Int32: {
CdhrInt ret = dyn.en.gdh.getObjectInfoInt( attrName);
if ( ret.evenSts()) {
System.out.println( "IncrAnalog " + attrName);
break;
}
ret.value += (int)increment;
if ( !( min_value == 0 && max_value == 0)) {
if ( ret.value < (int)min_value)
ret.value = (int) min_value;
if ( ret.value > (int)max_value)
ret.value = (int) max_value;
}
PwrtStatus sts = dyn.en.gdh.setObjectInfo( attrName, ret.value);
if ( sts.evenSts())
System.out.println( "IncrAnalog " + attrName);
break;
}
ret.value += increment;
if ( !( min_value == 0 && max_value == 0)) {
if ( ret.value < min_value)
ret.value = (float) min_value;
if ( ret.value > max_value)
ret.value = (float) max_value;
default: {
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "IncrAnalog " + attrName);
break;
}
ret.value += increment;
if ( !( min_value == 0 && max_value == 0)) {
if ( ret.value < min_value)
ret.value = (float) min_value;
if ( ret.value > max_value)
ret.value = (float) max_value;
}
PwrtStatus sts = dyn.en.gdh.setObjectInfo( attrName, ret.value);
if ( sts.evenSts())
System.out.println( "IncrAnalog " + attrName);
}
}
PwrtStatus sts = dyn.en.gdh.setObjectInfo( attrName, ret.value);
if ( sts.evenSts())
System.out.println( "IncrAnalog " + attrName);
break;
}
}
}
......@@ -15,7 +15,9 @@ public class GeDynSlider extends GeDynElem {
boolean attrFound;
PwrtRefId subid;
int p;
float oldValue;
public int typeId;
float oldValueF;
int oldValueI;
boolean firstScan = true;
boolean moveActive = false;
Point offset = new Point();
......@@ -40,6 +42,7 @@ public class GeDynSlider extends GeDynElem {
attrFound = true;
p = ret.id;
subid = ret.refid;
typeId = ret.typeId;
}
}
}
......@@ -51,36 +54,48 @@ public class GeDynSlider extends GeDynElem {
if ( !attrFound || moveActive)
return;
float value = dyn.en.gdh.getObjectRefInfoFloat( p);
if ( oldValue != value || firstScan) {
Point loc = ((JComponent)dyn.comp).getLocation();
int pos;
float value;
switch ( typeId) {
case Pwr.eType_Int32:
int ivalue = dyn.en.gdh.getObjectRefInfoInt( p);
if ( oldValueI == ivalue && !firstScan)
return;
oldValueI = ivalue;
value = (float) ivalue;
break;
default:
value = dyn.en.gdh.getObjectRefInfoFloat( p);
if ( oldValueF == value && !firstScan)
return;
oldValueF = value;
}
Point loc = ((JComponent)dyn.comp).getLocation();
int pos;
switch ( direction) {
case Ge.DIRECTION_RIGHT:
switch ( direction) {
case Ge.DIRECTION_RIGHT:
pos = (int)((maxValue - value)/(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.x = pos;
break;
case Ge.DIRECTION_LEFT:
case Ge.DIRECTION_LEFT:
pos = (int)(value /(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.x = pos;
break;
case Ge.DIRECTION_UP:
case Ge.DIRECTION_UP:
pos = (int)((value - minValue)/(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.y = pos;
break;
default:
default:
pos = (int)((maxValue - value)/(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.y = pos;
}
((JComponent)dyn.comp).setLocation( loc);
((JComponent)dyn.comp).repaint();
}
oldValue = value;
((JComponent)dyn.comp).setLocation( loc);
((JComponent)dyn.comp).repaint();
if ( firstScan)
firstScan = false;
......@@ -153,7 +168,13 @@ public class GeDynSlider extends GeDynElem {
}
((JComponent)dyn.comp).setLocation(new_loc);
sts = dyn.en.gdh.setObjectInfo( attribute, value);
switch ( typeId) {
case Pwr.eType_Int32:
sts = dyn.en.gdh.setObjectInfo( attribute, (int) value);
break;
default:
sts = dyn.en.gdh.setObjectInfo( attribute, value);
}
if ( sts.evenSts())
System.out.println( "GeSlider: " + sts);
break;
......
......@@ -31,23 +31,51 @@ public class GeDynIncrAnalog extends GeDynElem {
break;
String attrName = dyn.getAttrName( attribute);
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "IncrAnalog " + attrName);
int typeId = dyn.getTypeId( attribute);
if ( typeId < 0)
typeId = Pwr.eType_Float32;
switch ( typeId) {
case Pwr.eType_Int32: {
CdhrInt ret = dyn.en.gdh.getObjectInfoInt( attrName);
if ( ret.evenSts()) {
System.out.println( "IncrAnalog " + attrName);
break;
}
ret.value += (int)increment;
if ( !( min_value == 0 && max_value == 0)) {
if ( ret.value < (int)min_value)
ret.value = (int) min_value;
if ( ret.value > (int)max_value)
ret.value = (int) max_value;
}
PwrtStatus sts = dyn.en.gdh.setObjectInfo( attrName, ret.value);
if ( sts.evenSts())
System.out.println( "IncrAnalog " + attrName);
break;
}
ret.value += increment;
if ( !( min_value == 0 && max_value == 0)) {
if ( ret.value < min_value)
ret.value = (float) min_value;
if ( ret.value > max_value)
ret.value = (float) max_value;
default: {
CdhrFloat ret = dyn.en.gdh.getObjectInfoFloat( attrName);
if ( ret.evenSts()) {
System.out.println( "IncrAnalog " + attrName);
break;
}
ret.value += increment;
if ( !( min_value == 0 && max_value == 0)) {
if ( ret.value < min_value)
ret.value = (float) min_value;
if ( ret.value > max_value)
ret.value = (float) max_value;
}
PwrtStatus sts = dyn.en.gdh.setObjectInfo( attrName, ret.value);
if ( sts.evenSts())
System.out.println( "IncrAnalog " + attrName);
}
}
PwrtStatus sts = dyn.en.gdh.setObjectInfo( attrName, ret.value);
if ( sts.evenSts())
System.out.println( "IncrAnalog " + attrName);
break;
}
}
}
......@@ -15,7 +15,9 @@ public class GeDynSlider extends GeDynElem {
boolean attrFound;
PwrtRefId subid;
int p;
float oldValue;
public int typeId;
float oldValueF;
int oldValueI;
boolean firstScan = true;
boolean moveActive = false;
Point offset = new Point();
......@@ -40,6 +42,7 @@ public class GeDynSlider extends GeDynElem {
attrFound = true;
p = ret.id;
subid = ret.refid;
typeId = ret.typeId;
}
}
}
......@@ -51,36 +54,48 @@ public class GeDynSlider extends GeDynElem {
if ( !attrFound || moveActive)
return;
float value = dyn.en.gdh.getObjectRefInfoFloat( p);
if ( oldValue != value || firstScan) {
Point loc = ((JComponent)dyn.comp).getLocation();
int pos;
float value;
switch ( typeId) {
case Pwr.eType_Int32:
int ivalue = dyn.en.gdh.getObjectRefInfoInt( p);
if ( oldValueI == ivalue && !firstScan)
return;
oldValueI = ivalue;
value = (float) ivalue;
break;
default:
value = dyn.en.gdh.getObjectRefInfoFloat( p);
if ( oldValueF == value && !firstScan)
return;
oldValueF = value;
}
Point loc = ((JComponent)dyn.comp).getLocation();
int pos;
switch ( direction) {
case Ge.DIRECTION_RIGHT:
switch ( direction) {
case Ge.DIRECTION_RIGHT:
pos = (int)((maxValue - value)/(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.x = pos;
break;
case Ge.DIRECTION_LEFT:
case Ge.DIRECTION_LEFT:
pos = (int)(value /(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.x = pos;
break;
case Ge.DIRECTION_UP:
case Ge.DIRECTION_UP:
pos = (int)((value - minValue)/(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.y = pos;
break;
default:
default:
pos = (int)((maxValue - value)/(maxValue - minValue) *
(maxPos - minPos) + minPos);
loc.y = pos;
}
((JComponent)dyn.comp).setLocation( loc);
((JComponent)dyn.comp).repaint();
}
oldValue = value;
((JComponent)dyn.comp).setLocation( loc);
((JComponent)dyn.comp).repaint();
if ( firstScan)
firstScan = false;
......@@ -153,7 +168,13 @@ public class GeDynSlider extends GeDynElem {
}
((JComponent)dyn.comp).setLocation(new_loc);
sts = dyn.en.gdh.setObjectInfo( attribute, value);
switch ( typeId) {
case Pwr.eType_Int32:
sts = dyn.en.gdh.setObjectInfo( attribute, (int) value);
break;
default:
sts = dyn.en.gdh.setObjectInfo( attribute, value);
}
if ( sts.evenSts())
System.out.println( "GeSlider: " + sts);
break;
......
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