Recommended Posts

I have IO=Link device  Browser can communicate  with device 

http://192.168.1.250/iolinkmaster/port[4]/iolinkdevice/pdin/getdata

 

and gives Json output 

{"cid":-1,"data":{"value":"00D1FF00"},"code":200}

 

How I will interface with steps of DAQFACTORY converting value hexadecimal to decimal to be displayed in its page

Share this post


Link to post
Share on other sites

You can use HTTP.Get() to retrieve the output and store it in a string:

private string in = HTTP.Get("192.168.1.250", "iolinkmaster/port[4]/iolinkdevice/pdin/getdata")

Then I'd just use find() to figure out where it says "value", then get that value.  Once you have the hex value as a string, you can prepend 0x in front and use evaluate:

private string hex = "00D1FF00"

private dec = evaluate("0x" + hex)

 

Share this post


Link to post
Share on other sites

Hi Guru

   I try to use the sequence as below and begin sequence also command alert message The HTTP error and sequence not running.

Thanks

 

CommandAlert.JPG

Sequence.JPG

GetData Browser.JPG

IP_Browser.JPG

Share this post


Link to post
Share on other sites

You didn't follow my example.  You don't want http:// in the URL, nor the closing /.  It should be just like what I showed, with the IP address alone as the first string parameter, and the path as the second one.

Share this post


Link to post
Share on other sites

Hi Guru 

Thanks for reply

 

 

HTTP.Get();
private string in = HTTP.Get("192.168.1.250") 
AL1350.Path ="/iolinkmaster/port[4]/iolinkdevice/pdin/getdata"
Find("value","getdata",0) 
Evaluate("value")

private string hex = "value" 
private dec = evaluate("0x" + hex) 

 

How to display value as channel in page since value is temperature in decimal format


 

Share this post


Link to post
Share on other sites

Don't make "dec" private.  Private means the variable is only available inside that script.  Instead either make it global, or create a Test D/A channel and set that with the result:

myChannel = evaluate("0x" + hex)

Share this post


Link to post
Share on other sites

Hi Guru

 

 

HTTP.Get();
private string in = HTTP.Get("192.168.1.250") 
AL1350.Path ="/iolinkmaster/port[4]/iolinkdevice/pdin/getdata"
Find("value","getdata",0) 

global string hex = "value" 
Evaluate("value")

myChannel = Evaluate("0x" + hex) 


 while(1)
   myChannel.query()
   delay(60)
endwhile

 

Command/Alert shows 

C1040 channel does not have any valid values line 15 uncaught in sequence

Temperature values is not updating and showing 0.0000

 

Regards

 

 

 

Share this post


Link to post
Share on other sites

I'm sorry, but you are still not following my example:

private string in = HTTP.Get("192.168.1.250", "iolinkmaster/port[4]/iolinkdevice/pdin/getdata")
private index = find(in, "value", 0)
if (index != -1)
   in = mid(in, index + 8, 8 )
   myChannel.AddValue(evaluate("0x" + in))
endif

That should get you most of the way there, if not all the way.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now