dvaughn
September 14, 2020, 7:03pm
1
I am working on building a Gateway Module for Ignition version 8.0.15 and I am running into an issue when I try to write tags to a Tag Provider.
The record
variable below is of type RecordData and context
is of type GatewayContext .
List<TagPath> tagPaths = new ArrayList<>();
List<QualifiedValue> values = new ArrayList<>();
tagPaths.add(new BasicTagPath(record.topic));
values.add(new BasicQualifiedValue(record.value, QualityCode.Good, record.timestamp));
List<QualityCode> results = context.getTagManager().getTagProvider(tagProvider)
.writeAsync(tagPaths, values, SecurityContext.systemContext()).get();
public class RecordData {
public String topic;
public Object value;
public Date timestamp;
}
If I log out everything, this is what I get.
logger(tagPaths); // [[ACGE-23/level]]
logger(values); // [[0.85033414125612, Good, Thu Aug 27 22:34:31 UTC 2020 (1598567671005)]]
logger(results); // [Bad_Unsupported]
I don’t understand why I am getting back Bad_Unsupported
. Looking through the javadocs, all I can find is the interface of the methods.
Any help would be greatly appreciated!
What kind of tag are you writing to?
dvaughn
September 14, 2020, 8:58pm
3
I’ve tried it without the tag existing and as a memory tag.
Ah, don’t write QualifiedValues, write the actual value itself from record.value
.
And don’t expect writing to a tag that doesn’t exist to succeed. The memory tag should work.
dvaughn
September 14, 2020, 9:21pm
5
According the the javadocs writeAsync takes a List of QualifiedValues. Am I missing an overload or something?
Oops, you’re right. I was looking at the API for TagManager
.
Try turning the log level for “tags.management.provider” to DEBUG and see if there’s any additional information after you write.
https://docs.inductiveautomation.com/display/DOC80/Diagnostics+-+Logs#Diagnostics-Logs-ChangingLoggingLevels
dvaughn
September 14, 2020, 9:42pm
7
Set the logger to TRACE and this is the extra info I get:
Starting write, paths=[[NFBA-23/level]], values=[[0.85033414125612, Good, Thu Aug 27 22:34:31 UTC 2020 (1598567671005)]]
Async write of 1 values completed in 0 ms
Hmm. Is this just a standard tag provider? Not really sure what’s going wrong yet. Best guess is that the tag at path “NFBA-23/level” is not a standard memory tag but rather a folder or UDT or something else…
Oh, try creating your tag path like this instead. TagPathParser.parse(record.topic)
dvaughn
September 14, 2020, 9:58pm
10
That did it! Thanks for all the help!