Perspective module - reading/writing to predefined tags outside of binding

I have a handful of tags that are created automatically on every gateway in our system. Since the path for each tag is static between every gateway, I’d like to build a component that reads/writes to these tags without needing to go into the designer and bind each tag to the component’s property tree.

Is there a “best” way to go about it? My initial thought is to use a data endpoint to parse data from each of the tags into a JsonObject, then use a delegate to handle writes back to the tags. Is there a better way to replicate a hard coded tag binding?

Do you want to expose the live values of these tags in your component’s property tree, or do you just want to have a display only component that automatically displays the values of these tags and is kept up to date?

The latter! Although some of the tags (maybe 5%) will need some write capability.

Hm. My initial thought would be to subscribe to the tags you’re interested in in your ComponentModelDelegate subclass, something like:

You’d still have to marshal your tags into some JSON structure and push them down to the frontend though. You can call fireEvent (from the backend) to send a custom message and payload to the frontend, then read it accordingly in your ComponentStoreDelegate implementation on the frontend.

If you had more data to read, then you could use Perspective’s Fetchable mechanism to do something like what you mentioned in your first post (so that the large chunk of data isn’t going over the websocket), but for a few tag values that shouldn’t be necessary.

I read through the javadoc for the FetchableCacheImpl class… it looks like the link it generates for the fetchable data disappears after the first access?

I’m not sure that would work for this particular use case… the number of tags would only be on the order of ~100 mostly float tags, but there could be multiple (4-6) clients using the component to read the data, and data refresh I’d expect to be on the order of 2-5hz. Would you expect Fetchable to be able to keep up?

I don’t think you need fetchable. Since you’re sending relatively little data relatively often, I think it would be fine to go on the websocket. Just fireEvent from the Java side with your latest values, and unpack them in the component.

1 Like