Use OnCartSelected event to change color of D&R Airlite button

You have a question or need an advice about how to do something? Ask it here!
Post Reply
franksiegers
Posts: 122
Joined: 15 Nov 2019 14:24
Use OnCartSelected event to change color of D&R Airlite button

Post by franksiegers »

Hi Bernd,

When I start a cart, the color of the corresponding Airlite button changes to red thanks to the event OnAnyCartStarted which executes:
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|1

So far so good. When I select a cart with the mouse, I would like to change to color of the corresponding Airlite button to green. I've gotten this far with OnCartSelected:
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|${cartisselected}

However, this changes the color to red instead of green. Is there a way to add the color parameter for green to this command? I've tried adding the parameter to the end of the command, but that didn't work. Could be a syntax error?
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|${cartisselected}|2

Thanks again,

Frank
User avatar
radio42
Site Admin
Posts: 8330
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Use OnCartSelected event to change color of D&R Airlite button

Post by radio42 »

Maybe you start with the OnCartSelected event and using the command: SHOW_ALERT_WINDOW Cart=${cartid} - Selected=${cartisselected}
Than you might expand that to: SHOW_ALERT_WINDOW *[TOINT:{${cartid}}:{vert}:{2}:{8}]|${cartisselected}

Also note, that you can select the command multiple times.

The EXEC_SEND_DRAIRLITE_SETLED command takes 2 parameters:
1. led-numbner. this is being represented by *[TOINT:{${cartid}}:{vert}:{2}:{8}]
2. the color. 0=Off,1=Red, 2=Green. this is being represented by ${cartisselected} in your case

${cartisselected} however resolves to 0=unselected=Off and 1=selected=red.
But you want to to be green, i.e. you need to transform 1=>2 for green!

E.g. you can use the *[IF... macro function like this:
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|*[IF:{${cartisselected}}:{Equals(1)}:{2}:{0}]

In addition, I advise to look here (if you haven't done so):
https://github.com/benhartwich/proppfrexx-remote/
franksiegers
Posts: 122
Joined: 15 Nov 2019 14:24
Re: Use OnCartSelected event to change color of D&R Airlite button

Post by franksiegers »

Awesome, the green light is working!

Everything works fine when I start my carts one after another, but there's a small problem when I have two carts running at the same time:

- the first cart goes to red successfully when started, but the second cart does not change color.
- the second cart goes to light off successfully when stopped, but the first cart does not change its light to off.

Here's my current config:

OnCartSelected:
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|*[IF:{${cartisselected}}:{Equals(1)}:{2}:{0}]

OnAnyCartStarted:
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|1

OnAnyCartEnded:
EXEC_SEND_DRAIRLITE_SETLED *[TOINT:{${cartid}}:{vert}:{2}:{8}]|0

Could this be solved?

Thanks,

Frank
User avatar
radio42
Site Admin
Posts: 8330
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Use OnCartSelected event to change color of D&R Airlite button

Post by radio42 »

For individual cards use the I:OnCardPlay and I:OnCartPause events instead.
As said, the default implementation is done by a user...

Post Reply