Xtend operators?

588 views
Skip to first unread message

Cyril Jaquier

unread,
Jan 17, 2014, 2:16:12 PM1/17/14
to ope...@googlegroups.com
Hi all,

I'm trying to use && or % but somehow it doesn't work at all. I always get the following error:

20:13:45.162 ERROR o.o.c.s.ScriptExecutionThread[:70] - Error during the execution of rule 'RTCU Status Rez Repas': The name '<XFeatureCallImplCustom> && <XNumberLiteralImpl>' cannot be resolved to an item or type.

Here is my small script:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule "RTCU Status Rez Repas"
when
    Item RTCU_Rez_Repas_Status changed
then
    var Number state = RTCU_Rez_Repas_Status.state
    var Number status = state && 0x0F
    postUpdate(RTCU_Rez_Repas_Mode, status)
end

As someone a working example with these operators??? I'm using OpenHAB 1.3. Thank you.

Regards,
Cyril

Cyril Jaquier

unread,
Jan 18, 2014, 11:44:55 AM1/18/14
to ope...@googlegroups.com
Nobody using modulo or and operators???

Birgit Engelmann

unread,
Jan 18, 2014, 12:55:17 PM1/18/14
to ope...@googlegroups.com
Hi Cyril,

if I understand it correctly you are trying to do an bitwise and. Xtend supports this by using 3.bitwiseAnd(0x0F) where 3 can be an arbitrary Integer or a variable of the type Integer. It will not work for a Number.
The % operator also only works for Integer, not for Number.

Regards,
Birgit

Cyril Jaquier

unread,
Jan 18, 2014, 8:36:22 PM1/18/14
to ope...@googlegroups.com
Hi Birgit,

Many thanks. I finally got it working (after many tries) with:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule "RTCU Status Rez Repas"
when
    Item RTCU_Rez_Repas_Status changed
then
    var Integer state = (RTCU_Rez_Repas_Status.state as DecimalType).intValue
    var Integer status = state.bitwiseAnd(0x0F)
    postUpdate(RTCU_Rez_Repas_Mode, status)
end

Thank you again.

Regards,
Cyril
Reply all
Reply to author
Forward
0 new messages