[zb4osgi-changeset] [scm] ZigBee 4 OSGi repository change: r518 - /projects/zb4osgi/trunk/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java
scm-notify at zb4osgi.aaloa.org
scm-notify at zb4osgi.aaloa.org
Thu Oct 18 10:30:26 CEST 2012
Author: stefano.lenzi
Date: Thu Oct 18 10:30:25 2012
New Revision: 518
Log:
Report invalid value instead of NumberFormatException when setting a numeric attribute if the data does not represent a number ( fixes #128 )
Default values for Subscribing are taken from the zigbee.zcl.library bundle
Modified:
projects/zb4osgi/trunk/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java
Modified: projects/zb4osgi/trunk/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java
==============================================================================
--- projects/zb4osgi/trunk/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java (original)
+++ projects/zb4osgi/trunk/zigbee.tester/src/main/java/org/persona/zigbee/tester/gui/AttributeActionPanel.java Thu Oct 18 10:30:25 2012
@@ -100,7 +100,15 @@
public void actionPerformed(ActionEvent e) {
Object newValue = null;
try {
- newValue = Converter.fromString(getInputText().getText(), attribute.getZigBeeType());
+ try{
+ newValue = Converter.fromString(getInputText().getText(), attribute.getZigBeeType());
+ }catch(NumberFormatException ex){
+ LogPanel.log(
+ "Invalid value for " + attribute.getName() + " we where expecting a number." +
+ "\n\tStatus: SKYPPED"
+ );
+ return;
+ }
attribute.setValue( newValue );
LogPanel.log(
"Set Attribute " + attribute.getName() + " to " + newValue +
@@ -160,31 +168,36 @@
}catch(NumberFormatException ex){
LogPanel.log(
"The value '"+maxText.getText()+"' typed in the Maximum field is not a number" +
- "Using default value 60, that means report the value at least once per minute"
+ "Using default value " + Subscription.DEFAULT_MAX_REPORTING_INTERVAL + ", " +
+ "that means report the value at least once every " + Subscription.DEFAULT_MAX_REPORTING_INTERVAL + " seconds"
);
- sub.setMaximumReportingInterval( 60 );
+ sub.setMaximumReportingInterval( Subscription.DEFAULT_MAX_REPORTING_INTERVAL );
}
try{
sub.setMinimumReportingInterval( Integer.parseInt( minText.getText() ) );
}catch(NumberFormatException ex){
LogPanel.log(
"The value '"+minText.getText()+"' typed in the Minimum field is not a number." +
- "Using default value 0, that means reports every time the value of the attribute changes"
+ "Using default value " + Subscription.DEFAULT_MIN_REPORTING_INTERVAL + ", " +
+ "that means reports every time the value of the attribute changes"
);
- sub.setMinimumReportingInterval( 0 );
+ sub.setMinimumReportingInterval( Subscription.DEFAULT_MIN_REPORTING_INTERVAL );
}
if ( sub instanceof AnalogSubscription ) {
- AnalogSubscription asub = (AnalogSubscription) sub;
- final ZigBeeType type = attribute.getZigBeeType();
- try{
- asub.setReportableChange( Converter.fromString( changeText.getText(), type ) );
- }catch(NumberFormatException ex){
- LogPanel.log(
- "The value '"+changeText.getText()+"' typed in the Delta field is not a number." +
- "Using default value 0, that means reports every changes of the Analog attribute"
- );
- asub.setReportableChange( Converter.fromString( "0", type ) );
- }
+ AnalogSubscription asub = (AnalogSubscription) sub;
+ final ZigBeeType type = attribute.getZigBeeType();
+ try {
+ asub.setReportableChange(Converter.fromString(
+ changeText.getText(), type));
+ } catch (NumberFormatException ex) {
+ LogPanel.log(
+ "The value '" + changeText.getText() +"' typed in the Delta field is not a number." +
+ "Using default value " + AnalogSubscription.DEFAULT_REPORTABLE_CHANGE_INTERVAL + ", " +
+ "that means reports every changes of the Analog attribute greter then " +
+ AnalogSubscription.DEFAULT_REPORTABLE_CHANGE_INTERVAL
+ );
+ asub.setReportableChange(AnalogSubscription.DEFAULT_REPORTABLE_CHANGE_INTERVAL);
+ }
}
if ( attribute.getSubscription().addReportListner(listener) ) {
More information about the Commit
mailing list