I have two tags with datatype Dataset and a function to compare the value of a column exists in both of them. but i can't pass the two tags to the functions as a dataset they are passed as string.
what should i do?
I have two tags with datatype Dataset and a function to compare the value of a column exists in both of them. but i can't pass the two tags to the functions as a dataset they are passed as string.
what should i do?
You need to call system.tag.readBlocking to actually... Read the tag values
Otherwise, you're just dealing with a literal string.
thank you.
I did it but this error appears. I can't use dataset functions in the project script library right?
Something is not the type your program is expecting.
This error does not line up with any of the code that you have previously shown. Show the code as it is now, in a preformatted text block. Also, would be nice to know how these two tags are configured, and what the data in their value looks like.
Wrong. Your error indicates you tried to use a dataset method on an object that is an ArrayList, not a dataset.
the two tags I'm using are:
BOMList : Query tag (Dataset [20R5C]) data is queried from the database
BookedMaterialList : Memory tag (Dataset [23R6C]) operator is entering the data manually.
def datasets(dataset1, dataset2):
colindex= dataset1.getColumnIndex("MaterialID")
product_ids = dataset1.getColumnAsList(colindex)
for row in dataset2.getRowCount():
product_id = BOM.getValueAt(row, "MaterialID")
if product_id in product_ids:
upadate = {"Validated":1}
system.dataset.updateRow(dataset2, row, update)
else:
update = {"Validated":0}
system.dataset.updateRow(dataset2, row, update)
return dataset2
You're sending a List of qualified values, not the dataset. Thus the error. To properly get the value you need something like:
value = system.tag.readBlocking(listOfTagPaths)[indexOfPath].value
Your value change event should be:
datasets = [qv.value for qv in system.tag.readBlocking(['[.]BOMList','[.]BookedMaterialList'])]
compare.datasets(datasets[0],datasets[1])
Although, I will say this isn't the best way to approach this. As Phil would say "The dragons are circling".
Tags are global - what happens if two operators are attempting to update the booked material list at the same time?
I wouldn't expect a library method named compare.datasets
to require a specific input shape of dataset, either; should probably have a more useful name.
Nit: I like unpacking for situations like this:
bomList, bookedList = [qv.value for qv in system.tag.readBlocking(['[.]BOMList','[.]BookedMaterialList'])]
compare.datasets(bomList, bookedList)
If two clients are trying to update the list, I think both actions will be taken, but we are already checking if the entry is validated before starting the process.
Is there a way to use client tags in perspective?
No, but Perspective's session custom properties serve the same purpose.
Thanks all for your help, I really appreciate it.