Hi,
It's been a while since I used OR, but now the Rules engine is in place I think I can finally achieve what I wanted only I´m not sure how. I´ve read the exmaples and the forum posts and still really have no idea where to start.
Here's the situation. (pre-rules)
I have an Amp (Onkyo) that provides an ASCII reponse to a Command queston. I wanted to create a volume slider so I created a Sensor (VolumeSensor) from a VolumeStatus TCP/IP command: !MVLQSTN
Next I created a Slider (VolumeSlider) with the VolumeSensor from above and a new command VolumeWriter using command !1MVL$
Unknown macro: {param}
First issue the status response from the sensor is in the form of an ASCII string e.g. !MVLxx. (OK so I overcame this partially with the regexp branch to only return the int val of the reponse.) However that lead to a bigger problem, that I think only rules can resolve, so never went any further. If I add another sensor say PowerSensor from the command !PWRQSTN since both sensors are linked to the same IP/PORT the reponse goes to both, which causes some strange undesired behaviour, so here's what I need now (post-rules)and not sure about the best way to go about it.
I need to be able to take a command !MVLQSTN and covert it´s reponse !MVLxx to and integer to update a Slider (VolumeSensor) but the rules should only update the sensor if the reponse starts with !MVL. Then I´m free to create other rules of a simlar nature that only update say if the reponse to their specific question i.e. a PowerSwitch where the sensor command is !PWRQSTN and the reponse is !PWR00 or !PWR01.
In rules how do I take the value of the response to the sensor command,say VolumeSensor (!MVLxx), parse it, check the first part,(if eq !MVL) then convert the remainder to an integer (int) and 'publish' that value as the sensor output so that the Slider updates.
I'm really lost here an going round in circles.
Help much appreciated.
Phill
Comments (1)
May 04, 2012
Marcus Redeker says:
Maybe you can take this rule as a hint: package org.openremote.controller.mo...Maybe you can take this rule as a hint:
You should be able to take the source name and put that into a variable. After that perform an eval(xxx.startsWith("!MVL").
There is a very extensive documentation available on the Drools website and our testsuite also has a lot examples already.