I integrated this rule engine in my native application (sensor bus system in a building) and it works fine right now. What already is working:
Building facts for apartments, rooms and sensors within the rooms. Then I store these facts within a map so that I can modify them later. I also know how to modify the fact which is executing the rule on the RHS but this is not what I want to achieve.
I want to modify facts which where build previously in my native application based on a execution of a rule.
The process chain would be sensor values change (native) --> sensor facts (e.g. Switch) change (native) --> rules are triggered --> room (deftemplate Aktivitaetswechsel with same apartment and room) and apartement (deftemplate Apartment_Status with same apartment) change as cause of certain rule.
But I do not know how I can find these previously build facts in CLIPS language. These are my deftemplates I use. The slots apartment and room are fixed.
You can use the fact set query functions such as do-for-all-facts if you want to iterate over facts either in the actions of a rule or outside of a rule.
That is not really what I wanted to achieve. I partially solve this issue via assigning each fact a fact_id. I store all facts within different maps in my embedded application. Over this fact_id I can find the fact in the map an modify it if there are changes in the embedded application. However this is solved using the UDF. For now I still have the issue that the UDF only gives the value of the given variables. Is there any way to receive the name of the variable also so that the UDF do different things depending on the given variable?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, the symbolic names of variables are not available once the rule has been compiled. I'd suggest adding a separate argument to your UDF if if needs additional information to determine what to do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey,
I integrated this rule engine in my native application (sensor bus system in a building) and it works fine right now. What already is working:
Building facts for apartments, rooms and sensors within the rooms. Then I store these facts within a map so that I can modify them later. I also know how to modify the fact which is executing the rule on the RHS but this is not what I want to achieve.
I want to modify facts which where build previously in my native application based on a execution of a rule.
The process chain would be sensor values change (native) --> sensor facts (e.g. Switch) change (native) --> rules are triggered --> room (deftemplate Aktivitaetswechsel with same apartment and room) and apartement (deftemplate Apartment_Status with same apartment) change as cause of certain rule.
But I do not know how I can find these previously build facts in CLIPS language. These are my deftemplates I use. The slots apartment and room are fixed.
Thanks in advance!
You can use the fact set query functions such as do-for-all-facts if you want to iterate over facts either in the actions of a rule or outside of a rule.
From C, you can use the Eval function (similar to Build except for function calls) to execute the query.
That is not really what I wanted to achieve. I partially solve this issue via assigning each fact a fact_id. I store all facts within different maps in my embedded application. Over this fact_id I can find the fact in the map an modify it if there are changes in the embedded application. However this is solved using the UDF. For now I still have the issue that the UDF only gives the value of the given variables. Is there any way to receive the name of the variable also so that the UDF do different things depending on the given variable?
No, the symbolic names of variables are not available once the rule has been compiled. I'd suggest adding a separate argument to your UDF if if needs additional information to determine what to do.
Okay, I solved it via delivering a String before every variable and checking this string.