Commits

Sebastian Bub committed c538b12

better logging after external processes testing

  • Participants
  • Parent commits d141f36

Comments (0)

Files changed (2)

src/main/java/de/derbub/rpigpio/SimpleCommand.java

     }
 
     public boolean checkCondition(String otherValue) throws NumberFormatException {
-        int intValue = Integer.parseInt(value);
-        int intOtherValue = Integer.parseInt(otherValue);
-        switch (condition) {
-            case EQUAL:
-                return (intOtherValue == intValue);
-            case NOT_EQUAL:
-                return (intOtherValue != intValue);
-            case GREATER:
-                return (intOtherValue > intValue);
-            case GREATER_EQUAL:
-                return (intOtherValue >= intValue);
-            case LESS:
-                return (intOtherValue < intValue);
-            case LESS_EQUAL:
-                return (intOtherValue <= intValue);
-            default:
-                throw new RuntimeException(this.getClass().getName() + " is not a condition: " + this);
+        try {
+            int intValue = Integer.parseInt(value);
+            int intOtherValue = Integer.parseInt(otherValue);
+            switch (condition) {
+                case EQUAL:
+                    return (intOtherValue == intValue);
+                case NOT_EQUAL:
+                    return (intOtherValue != intValue);
+                case GREATER:
+                    return (intOtherValue > intValue);
+                case GREATER_EQUAL:
+                    return (intOtherValue >= intValue);
+                case LESS:
+                    return (intOtherValue < intValue);
+                case LESS_EQUAL:
+                    return (intOtherValue <= intValue);
+                default:
+                    log.warn(this.getClass().getName() + " is not a condition: " + this);
+            }
+        } catch (NumberFormatException nfe) {
+            log.warn(this.getClass().getName() + ": value is not a number: " + this + "(Exception message: " + nfe.getMessage() +")");
         }
+        return false;
     }
 
     @Override

src/main/java/de/derbub/rpigpio/cmd/ExternalProcessesManager.java

                 ExternalProcess previousP = externalProcesses.put(CMD_KEY_PREFIX + name, ep);
                 if (null != previousP) {
                     log.warn("Multiple commands named: " + previousP.commandName + ". Ignoring old " + previousP.externalCommand);
+                } else {
+                    log.info("Commands named: " + name + " configured with " + commandName + " and timeout " + timeout + "ms");
                 }
             } catch (IOException e) {
                 log.warn(EXTCMD_NAME_KEY_PREFIX + i +" throws exception during init (ignoring command): " + e.getMessage());