This page last changed on Jan 31, 2016 by pierre2302.

I have a raspberry with java 1.7 and drool modified file (drools-compiler-5.1.1.jar)

I do not manage to run this rule:


package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
global org.openremote.controller.statuscache.RangeFacade ranges;

import org.openremote.controller.Constants;
import org.openremote.controller.protocol.*;


rule "test"

timer (cron: 0 30 17-23 * * ?)

when eval(true)

then

execute.command( "chauffage_off" );

end  

by against this rule works:


package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
global org.openremote.controller.statuscache.LevelFacade levels;
global org.openremote.controller.statuscache.RangeFacade ranges;

import org.openremote.controller.Constants;
import org.openremote.controller.protocol.*;


rule "test2"

timer (cron: 00 30 17 * * ?)

when eval(true)

then

execute.command( "chauffage_off" );

end  

What is that it is possible to run this type of rule with Java 1.7 or Java 1.8 or it is absolutely necessary to have Java 1.6 ??

Thanks in advance.

Hi

Do you get any errors?

I changed the crontab a bit:


rule "pierre"
timer (cron: 0 10-20 11-23 * * ?)
when eval(true)
then
System.out.println ( "Pierre...");
//System.out.println ( "Pierre " + _TimeStamp());
//I am not sure how to print date time
end

This seems to work.
Well I didn't wait a full day but "10-20" and "11-23" seems to work.

Maybe you can add a println to your rule ?


timer (cron: 0 30 17-23 * * ?)
when eval(true)
then
System.out.println ( "Hi ... Cron works! ... Heater off");
execute.command( "chauffage_off" );
end

Posted by sek at Jan 31, 2016 12:29

Hello,

Thanks for your help

I noticed that I get errors in the logs :

ERROR 2016-02-02 22:41:48,360 : Rule definition 'modeler_rules.drl' could not be deployed. See errors below.
ERROR 2016-02-02 22:41:48,361 : Rule Compilation error Date cannot be resolved to a type
Date cannot be resolved to a type
SimpleDateFormat cannot be resolved to a type
SimpleDateFormat cannot be resolved to a type
ERROR 2016-02-02 22:41:48,363 : There was an error parsing the rule definition 'modeler_rules.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:532)
	at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:253)
	at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:112)
	at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:120)
	at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:659)
	at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:557)
	at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)
	at org.openremote.controller.service.Deployer.startup(Deployer.java:858)
	at org.openremote.controller.service.Deployer.softRestart(Deployer.java:440)
	at org.openremote.controller.service.Deployer$ControllerDefinitionWatch.run(Deployer.java:1324)
	at java.lang.Thread.run(Thread.java:744)
INFO 2016-02-02 22:41:48,371 : Initialized event processor : Drools Rule Engine
INFO 2016-02-02 22:41:48,400 : Initialized event processor : RRD4J Data Logger
INFO 2016-02-02 22:41:48,400 : Initialized event processor : EmonCMS Data Logger

/
/
/

So I added packages and this time the logs are good:

import java.util.Date;
import java.text.SimpleDateFormat;

DEPLOYING NEW CONTROLLER RUNTIME...

--------------------------------------------------------------------

INFO 2016-02-02 22:56:05,728 : Initialized event processor : Drools Rule Engine
INFO 2016-02-02 22:56:05,756 : Initialized event processor : RRD4J Data Logger
INFO 2016-02-02 22:56:05,757 : Initialized event processor : EmonCMS Data Logger

/
/
/

On the other hand these rules do not still work ( despite a restart ):

rule "pierre"

timer (cron: 0 10-20 11-23 * * ?)

when eval(true)

then

System.out.println ( "Pierre...");

end


rule "pierre2"

timer (cron: 0 30 17-23 * * ?)

when eval(true)

then

System.out.println ( "Pierre...");

end
Posted by pierre2302 at Feb 02, 2016 22:19

It works. I modified the timer so that it runs every minute

http://www.openremote.org/pages/viewpage.action?pageId=20451656&focusedCommentId=23605610#comment-23605610

thank you for help.

Posted by pierre2302 at Feb 09, 2016 20:53
Document generated by Confluence on Jun 05, 2016 09:33