Read / Write to Tags from a Module

Hi all, are there any up to date examples of Reading / Writing to Tags in a Module. For my case, it is likely better to not subscribe and instead do a single "read" every time I need to (as it likely wont be often).

However, an example with both would be ideal, if there are any resources I am missing please let me know but looking at the Ignition SDK Examples, I couldn't see anything that was particularly what I was looking for. I have also looked on the forums but I am not completely sure what some posters mean (I couldn't navigate around the wording) and all posts seem to be a fair bit older and from what I can tell a fair bit seems to have changed.

Thanks for any help in advanced,

MG3.

There may be a better way but I am using GatewayTagManager.readAsync

GatewayTagManager tagManager = this.gatewayContext.getTagManager();
TagPath tPath = TagPathParser.parse("[default]MyTag");
            values = tagManager.readAsync(Arrays.asList(tPath),
                    SecurityContext.emptyContext()).get(30,
                            TimeUnit.SECONDS);
            QualifiedValue qv = values.get(0);
            String tagId = qv.getValue() != null ? qv.getValue().toString() : "null";
2 Likes

Hi Benhamin, I am looking at doing something really very similar to this, I am currently just figuring out how to call it from a Component that is being implemented (as this is the end goal).

Will let you know how it goes for me, thanks!

Couldnt you just have a property that the user drives? A tag binding would be a good use for this. Otherwise if that tag doesn't exist what would you do to handle that? Just a thought.

Unfortunately, that will not be possible. It's hard to explain what I'm doing without giving it away completely (currently can't disclose) but there would be a dynamic number of tags that need reading so properties and bindings won't particularly work. Especially as the component is more like a template and will be given data via a vision client and not using designer.