This page last changed on Jun 21, 2011 by michal.

Hi,

I'm new on OR. I can not find answer for my questions on forum....
1) I know how to send command or slider value to TCP device, but I can't not send feedback value from TCP device to OR controller. How should looks sensor command for read slider and switch. What I should send from TCP device to controller.
2) How to control Label widget? How to configure sensor for it?

Best Regards
Michal

Your command has to extend "ReadCommand" and implement ExecutableCommand. The send() method is used to send a command to your device and you have to implement a read(sensor) method. Depending on the sensor which you define in the modeller (switch, range, ...) you have to return the coresponding value. So your read method will check what sensor it is and perform the actually request on the device.

The label field in the modellet depends on the sensor you create. The switch sensor for example returns "on" or "off" and you can assign a text for each status.

Posted by mredeker at Jun 22, 2011 09:30

Thanks,

I've designed simple panel with switch button with configuration:

<components>
<switch id="42">
<on>
<include type="command" ref="44" />
</on>
<off>
<include type="command" ref="45" />
</off>
<include type="sensor" ref="43" />
</switch>
</components>
<sensors>
<sensor id="43" name="switchsens" type="switch">
<include type="command" ref="46" />
<state name="on" />
<state name="off" />
</sensor>
</sensors>
<commands>
<command id="44" protocol="socket">
<property name="port" value="5000" />
<property name="command" value="set Light1 on" />
<property name="ipAddress" value="10.0.0.120" />
</command>
<command id="45" protocol="socket">
<property name="port" value="5000" />
<property name="command" value="set Light1 off" />
<property name="ipAddress" value="10.0.0.120" />
</command>
<command id="46" protocol="socket">
<property name="port" value="5000" />
<property name="command" value="{ $value{Light1}}" />
<property name="ipAddress" value="10.0.0.120" />
</command>
</commands>

when I click on button, I've got
set Light1 on
string on TCP socket. When I've answered sending
on
string to TCP socket, button is still in 'off' state. I can see that action in log file:

Controller2011-06-21 12:40:29,983 INFO Thread\-5 org.openremote.controller.protocol.socket.TCPSocketCommand.requestSocket(153) | received message: on
Controller2011-06-21 12:40:29,983 INFO HTTP\-Thread\-4 org.openremote.controller.protocol.socket.TCPSocketCommand.requestSocket(153) | received message: on
Controller2011-06-21 12:40:29,986 INFO HTTP\-Thread\-8 org.openremote.controller.protocol.socket.TCPSocketCommand.requestSocket(153) | received message: on

I don't know where is a problem...

Posted by michal at Jun 22, 2011 11:59

The controller should ask your device in an extra thread where the sensor is executed for the status. So answering directly on your "on" command will not reflect the status. Also, older version from TCPSocketCommand did not implment the read(). I don't know which version you have.

Posted by mredeker at Jun 22, 2011 14:48

Hi, I've just submitted a patch to Juha for the TCPSocketCommand to implement the regex StatusFilter that Richard Turner added to the Telnet implementation. You need to compile the source for the controller (not hard.. I did it) and then manually add the StatusFilter/StatusFilterGroup and StatusDefault commands to the controller.xml (it can't yet be done from the online designer) All the instructions are in in Richards telnet post in the design forum.

This should allow you to write regex filters that look for specific things in your tcp responses (anything that you can write a regex filter for) and link them to switches/levels/ranges etc.

Phill

Posted by flipit at Jun 24, 2011 10:44

Thanks a lot,
I can see sensor extra thread, where controller is sending { $value{Light1}}, but when I reply "on" for this socket, there is no reaction on panel.

I have Controller-2.0.0_SNAPSHOT_20110611 at revision 4162. It is possible to send simply status like 'on', 'off' to sensors in this revision? Regular expression is not neccessary for me at this moment.

I've tried to compile controller under win32, but i can not find com.io.* package.

Best Regards
Michal

Posted by michal at Jun 24, 2011 12:21

It should work, it was added in revision 3615, all be it limited (only Custom Senors and Level Sensors are really defined, Ranges will no work)

For a custom sensor you need to map the 'raw' return values (what your socket responds with minus any control characters, since the code revision removes these i.e. \r\n ) to the 'wanted' return values in the online Designer- Box labeled: Custom State Items - Name/Values.

I think I your case it should probably be:

on - on
off - off

Phill

Posted by flipit at Jun 25, 2011 12:08

Thank you,

With custom sensor type switch is working!!! But I still have a problem with sensor of slider. I use 'level' sensor type for it. I've tried to send slider position with ascii and as a 1 byte - no reaction. From time to time, web application response : "The returned format of polling value n/a for slider is wrong". Additionally, I can't move slider, it's still at 0 position and when I click on it, it sends 0 to socket. Any ideas?

Thanks
Michal

Posted by michal at Jun 28, 2011 13:15

Sounds like your socket doesn't respond with a value between 0 and 100. It's the same issue I had, which is why I moved to the Regex filters.

Example: I have a amp connected to a RS232-TCP converter which for volume query expects !1MVLQSTN, which is fine for the query, but responds with !1MVLxx where xx is 00-99. The 'level' code expects only values from 0-99 in the response or it fails.

The regex filters allow me to pick out the 'xx' value and pass this to the 'level' code.

BTW. Quote "I've tried to compile controller under win32, but i can not find com.io.* package "...

Did you follow these instructions , right ?

http://openremote.org/display/docs/OpenRemote+2.0+How+To+-+Controller+Installation#OpenRemote2.0HowTo-ControllerInstallation-WindowsXP

Phill

Posted by flipit at Jun 28, 2011 16:02

Hi,

I'm sure, that socket is sending correct data to controller, log below. I think difference is that you are using telnet protocol but I'm using TCP protocol.

Controller2011-06-28 16:10:21,767 INFO Thread\-4 org.openremote.controller.protocol.socket.TCPSocketCommand.requestSocket(153) | received message: 36
Controller2011-06-28 16:10:21,848 INFO Thread\-3 org.openremote.controller.protocol.socket.TCPSocketCommand.requestSocket(153) | received message: off

Phillip, I've installed controller under WIN32 without any problem, but I have a problem with compile sources under WIN32. Many missing packages like "org.io.*", "org.jdom" - i'm not java programmer

Best Regards
Michal

Posted by michal at Jun 30, 2011 11:07
Document generated by Confluence on Jun 05, 2016 09:31