There is a tag used in a Perspective view that has a script applied to convert it to the "actual number"
How do I recreate this scripting on a derived tag or similar so I can reference the "actual number" in a report?
Where are the values coming from?
Tip: while a screengrab of a code window is useful to give context it means that anyone wanting to correct your code has to type it all out. Post the formatted code as well as the screengrab. See Wiki - how to post code on this forum.
Make the dataset one property and make a second property with an expression of abs({path.to.dataset}[0,1] - {path.to.dataset}[1,1]) * 0.002204623
def transform(self, value, quality, timestamp):
difference = abs(value.getValueAt(1,1) - value.getValueAt(0,1))
pounds = difference * self.parent.custom.CheckWeigh_Conversion
return round(pounds, 1)
Coming from a check weigh scale through then through OPC path
I guess I am bit lost at usage of dataset, for reports I have to access the info via a tag history query.
Though if you know a way to script a derived or reference tag or just another tag with the same OPC source path that's more so what I am trying to figure out.
Thanks.
Can you show the configuration and name of the OPC tag? Is it an array? (You've only shown the transform of the original binding so we have no idea what the binding is or where the data is coming from.)
That's the "Giveaway Weigh Sum" tag. (Advice on the forum is to avoid spaces in tag names. It will catch you out later.)
Where's the other one involved in the subtraction?
It just subtracts its own value in the historian? like
value.getValueAt(0,1) - value.getValueAt(1,1)
because it is bound via a tag history binding to a label.
I need to do the same thing but as a pen on an xy chart in a report.
History / actual value / tags / a pen in a chart ...
I can't figure out what you're trying to do. I think you've come up with a bad solution for something that should be very simple.
Show a mockup of what you've got or the user interface that explains the original problem, the sources of the data and what you want.
It's bedtime in Ireland. Good night!
Sorry for confusion I appreciate your time haha.
as shown in the Screenshots there is a Tag currently bound to a label on a perspective view via a Tag History Binding. That binding converts the tags value to be displayed via a dataset (as history bindings tend to).
The binding Also has a script that makes some changes to the value, one such way is it subtracts the tags value within itself via using
value.getValueAt()
In the report function of ignition, I am not aware of a way to use a tag history binding in the same fashion, that's all I'm trying to figure out is a way to display/ manipulate a tags value the same way as you would with a tag history binding and transform script and not sure if that can even be done at all, is done simply, so on.
Well, the scripting language has functions to perform the exact same tag history queries as a tag history binding. system.tag.queryHistory
Ps
Mini utes is a strange measurement unit! Must be talking about a Subaru Brumby
Yeah, everything about this tag and binding was done by the previous guy. He has... many such examples.
But scripting language is where I am getting lost at, would I script it in a derived tag or somewhere in the report itself?
It depends on what you're wanting.
Just based on the context you've provided you would do this in the data tab of the report. You would create a Tag History Data Source, configure it to get the data you want. Then you can add a Script Data Source (it must be below the Tag History Data Source) and use the script to modify the data in a similar way.
You would use a derived tag to modify the data upon it's arrival to the tag system. Derived Tag Expressions do not have access to previous values as far as I know.
I think this is exactly what I was looking for thank you so much. I was struggling with understanding how to reference the history queried tags in the report data section but should be good now I hope, thank you.
In working with scripts in the report function is there any resources to better show or explain how I would have to go about scripting it to convert a tag to a dataset in the same fashion as a point count tag history binding?
I'm really struggling here, and it doesn't seem like anyone really knows how to do that?
I just need to transform a tag in the same way a history binding would, but with scripting, which should be very possible right?
Thank you for your time and sorry to bother if you don't know
You don't need to do the tag history query in script.
Right now you have a Tag History Binding, in perspective and you're trying to replicate this in the report designer.
Add a Parameter to your report, name it Minutes_Active, you can define an expression that it will use as the default value if the report is run without providing the parameter.
Add another parameter and name it CheckWeigh_Conversion.
Add a Tag History Query to your report, then configure it to match your binding in perspective. That would look something like this:
Don't forget to select the tag paths that you want to pull the history for.
Next Add a script to your data source in the report. In that script, use an equivalent script to what is in your transform. The script must come after the tag history query in the data sources list, otherwise the data pulled from history will not be available to the script.
That would look something like this. Note: there are differences to the script because you have to access and save the data differently in a report.
def updateData(data, sample):
historyDs = data['tag_history']
conversion = data['CheckWeigh_Conversion']
difference = abs(historyDs.getValueAt(1,1) - historyDs.getValueAt(0,1))
pounds = difference * conversion
data['pounds'] = round(pounds,1)
Now you will have a "pounds" data key available in your data sources when you design your report.
Here is the manual entry for a Script Data Source, the manual is your friend: