Does something like this work?
(io331 & 8) > 0
Thank you Anton,
Will check this and revert.
My appreciations
Hi Anton,
See error below I am having:
For input string: "bf" - NumberFormatException (... < ComputedAttributesHandler:102 < AttributeResource:57 < ...)
I am using io331 ? (io331 & 8) > 0 ? "doorOpen" : "doorClosed" : null
What is "bf"?
Its the value of io331 from the eye sensor in hex.
When converted to binary is 10111111 and the bit 3 (lsb) is 1 which is what I need to determine open or close.
I see. In that case you need something like
(parseInt(io331, 16) & 8) > 0
assuming parseInt
works.
Yes, this seems to work
io331 ? (new("java.lang.Integer", 0).parseInt(io331, 16) & 8) > 0? "doorClosed" : "doorOpen" : null
I will monitor it for a while.
Many thanks Anton.
Hello, Someone Helps me to solve.I import formula substr(x,2,1) for door sensor and i setup for 0 and 1 for closed and opened.After all setup ,sever show me that while sensor is 0 is NaN.Why they show thant Nan instead of close.Someone help me with this.Best Regards.
I don't think substr
returns a number.
what formula should i use.Can you tell me.Sir.
Regards,
Actually my formula is work but in user interface they show that NaN instead of close .If you have time,help me to solve it.
Best Regards,
Hello All,
We have teltonika eye sensors and they report in hex. To detect door open/close, we need to convert the hex value to binary and check the value of bit 3 (LSB). Door is closed if the bit is set and open otherwise.
In GPSGate, we use something like flag = parseInt(io331, 16).toString(2).substr(4,1) ) to get the value of bit 3.
We have tried io331 ? ( parseInt(io331, 16).toString(2).substr(4,1) ) == 0 ? "doorOpen" : "doorClosed" : null in traccar computed attributes but it does not work.
Any assistance will be appreciated.