Hi
Yet again I'm failing to understand the basics of Drools to get a rule working.
Seriously, if anyone wants to create a chargeable service to create rules, I would probably be the first customer
Anyway, today's problem...
I have a slider which has a range sensor that allows it to create a value between 0 and 256
I need to convert that Int to a HEX string between 0 and FF
This new HEX string will be passed to a HTTP command to a 6 Universe DMX output box to control some architectural lighting.
http://192.168.178.200/channel.api?uni=0&onecolour=${param}&start=1&end=3
( There will also be some LED SPi tape being driven from this box, but they will be controlled with colour pickers and different PIXEL commands to the DMX box, I.E. "http://192.168.178.200/pixel.api?uni=0&onecolour=${param}&start=2&end=7" where ${param} will be the RGB value )
The rule I have written looks like this :-
package org.openremote.controller.protocol;
global org.openremote.controller.statuscache.CommandFacade execute;
import java.util.*;
rule "TV_Wht 3 channel dec to hex" when
$evt:Event( source == "Wht-3ch-IM-status", $val : value)
then
String valStr = $val.toInt();
if (valStr != null ) {
// Convert int to hex value
Integer hex = String.format("%02X", $valStr);
execute.command( "TV_White_3ch-set", hex.toString() );
execute.command( "TV_WHT-Hex-IM-set", hex.toString() );
}
end
The errors I'm seeing in the boot log are these (Which don't mean anything to me)
ERROR 2016-09-03 18:43:02,922 : Rule definition '255toHEX.drl' could not be deployed. See errors below.
ERROR 2016-09-03 18:43:02,961 : Rule Compilation error The method toInt() is undefined for the type Object
$valStr cannot be resolved
ERROR 2016-09-03 18:43:03,080 : There was an error parsing the rule definition '255toHEX.drl' : Could not parse knowledge.
java.lang.IllegalArgumentException: Could not parse knowledge.
at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
at org.openremote.controller.statuscache.rules.RuleEngine.getValidKnowledgePackages(RuleEngine.java:581)
at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:281)
at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:112)
at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:148)
at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:697)
at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:595)
at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)
at org.openremote.controller.service.Deployer.startup(Deployer.java:1057)
at org.openremote.controller.service.Deployer.startController(Deployer.java:352)
at org.openremote.controller.spring.SpringContext.initializeController(SpringContext.java:109)
at org.openremote.controller.service.ServiceContext.init(ServiceContext.java:526)
at org.openremote.controller.bootstrap.Startup.loadServiceContext(Startup.java:89)
at org.openremote.controller.bootstrap.servlet.ServletStartup.initializeServiceContext(ServletStartup.java:195)
at org.openremote.controller.bootstrap.servlet.ServletStartup.contextInitialized(ServletStartup.java:109)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
INFO 2016-09-03 18:43:04,953 : Added rule definition 'ColourPicker-to-BGR.drl' to knowledge.
DEBUG 2016-09-03 18:43:05,030 : Adding rule definitions from 'ColourPicker-to-BGR.drl'...
INFO 2016-09-03 18:43:05,416 : Added rule definition 'TTS test rules V3.drl' to knowledge.
DEBUG 2016-09-03 18:43:05,457 : Adding rule definitions from 'TTS test rules V3.drl'...
INFO 2016-09-03 18:43:06,745 : Initialized event processor : Drools Rule Engine