News:

  • September 26, 2026, 12:02:34 PM

Login with username, password and session length

Author Topic: Casting via the REST API  (Read 7351 times)

Bolt

  • Hero Member
  • *****
  • Posts: 598
Casting via the REST API
« on: December 09, 2020, 05:45:53 PM »
Thank you for getting this implemented, this is going to be great!

Now, not to stare a gift horse in the mouth, but is there a way to access casts via the API?  Previously, I have been accessing all the data via modbusphp.  As such, I have hundreds of data points in MHR data, many casted as : D or :RD, depending on need.  To transition things to the API, it would be easiest to begin by simply referencing the existing locations, such as
Code: [Select]
/data/json?dataPoint=MHR400:RD, but I am presented with a "Bad Request" response.  Is there a simple workaround?

Again, not poo-pooing on your implementation, but I'm so eager to start implementing this that I don't want to re-write my program to contain everything in "real" double word or real address locations.

Thanks!
« Last Edit: December 09, 2020, 06:02:58 PM by Bolt »

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Casting via the REST API
« Reply #1 on: December 09, 2020, 06:19:34 PM »
Thank you for getting this implemented, this is going to be great!

Now, not to stare a gift horse in the mouth, but is there a way to access casts via the API?  Previously, I have been accessing all the data via modbusphp.  As such, I have hundreds of data points in MHR data, many casted as : D or :RD, depending on need.  To transition things to the API, it would be easiest to begin by simply referencing the existing locations, such as
Code: [Select]
/data/json?dataPoint=MHR400:RD, but I am presented with a "Bad Request" response.  Is there a simple workaround?

Again, not poo-pooing on your implementation, but I'm so eager to start implementing this that I don't want to re-write my program to contain everything in "real" double word or real address locations.

Thanks!

The symbol processor handles it, but it may be an issue at the URL level. I?ll check tomorrow.

One thing that might work is to nickname the cast element, then reference the nickname.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Casting via the REST API
« Reply #2 on: December 10, 2020, 09:55:56 AM »
After digging a bit, the symbol processor does not handle it. Honestly not sure why. I coded it, and the code is clearly handling bit casts, but is also clearly not handling any other form of cast. Possibly an oversight, but I always worry about stuff like that. When I'm elbow deep in it, decisions get made, time passes, and the reasoning gets lost...which is sometimes a bad thing when I come back second guessing. Sometimes there was no reasoning...just got missed. I'll ponder some more.

And in other bad news, I checked the nicknaming of a cast...that doesn't work either. Sorry.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Casting via the REST API
« Reply #3 on: December 11, 2020, 09:19:39 AM »
Well, this data belongs in a UDT anyways, not an array of Modbus Registers, that is becoming cumbersome.  I'll work that direction.  Thanks for clarifying.