[Logo] Mango M2M Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Need Javascript help for metadata point  XML
Forum Index -> User help
Author Message
mhradom

Initiate
[Avatar]

Joined: 18/11/2009 10:37:54
Messages: 15
Location: Virgina, USA
Offline

I have 1-wire DS2450 A/D numerical data available I would like to convert to binary for simple on/off notification. Can someone please give me some direction as to the proper script to do this for a metadata point?

For example:

If the input is <= 0.5 then output 0 binary
If the input is >0.5 then output 1 binary

I am not familiar with JS programming and syntax (last programming I did was 30 years ago in FORTRAN) and have tried several things with no success.

Thanks in advance!

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." A. Einstein
mlohbihler


[Avatar]

Joined: 01/03/2007 22:48:52
Messages: 899
Online

Hi Mike,

Try this (assuming "x" is the var name you give the point):

Code:
 if (x.value <= 0.5)
     return false;
 return true;
 


... and set the meta point to be a binary. That ought to do it.

Best regards,
Matthew Lohbihler
mhradom

Initiate
[Avatar]

Joined: 18/11/2009 10:37:54
Messages: 15
Location: Virgina, USA
Offline

Thanks Matthew.

I actually got it figured out by myself like this:

Code:
if (p33.value<=0.5)
    {
 return false 
    }
 else 
    {
 return true
     }


I see so many different styles of coding for JavaScript on the web, I don't know what is actually required and what is personal preference. Do you know a good resource to learn more?

Anyway if works perfectly. I continue to be amazed at the flexibility and capability of Mango! Now I just need to get my 1-wire network more stable.

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." A. Einstein
mlohbihler


[Avatar]

Joined: 01/03/2007 22:48:52
Messages: 899
Online

Thanks. Re Javascript, just ask Google. There's a ton of resources around.

Best regards,
Matthew Lohbihler
 
Forum Index -> User help
Go to:   
Powered by JForum 2.1.7 © JForum Team