I'm quite new to Ignition. I apologize in advance for not finding the forum or manual blurb that is the answer to my problem.
Situation:
I have many motors so making a template. I'm mimicking "UDTs and Template Views" from IA University.
Problem:
My onActionPerformed Script for my Primary Button is not turning on my UDT instance tag.
I've read quite a bit in the Perspective 8.1 manual and read and tried a lot from the forum but haven't found the solution. (BTW-a huge thank you to all contributors to the forum!)
I'm on my 400th variation of the script and so far, no joy. I don't get errors anymore and thought, "that's good". But in this case, no news isn't good news.
You are creating a dictionary. system.tag.writeBlocking requires a list.
system.tag.writeBlocking("startPath", "true")
Two problems here. You are passing literal strings into the function instead of variables. "startPath" is not the same as startPath. Similarly "true" is not the same as True.
It also appears that self.view.params.SimpleMtr.Start_SCADA is the value of the Start SCADA tag, not the path.
I would restructure this view so that the only param is a tag path to a simple motor UDT. Then add a custom prop called SimpleMtr which has an indirect tag binding to that tag path param.
Sorry for late response. Was busy trying suggestion and the myriad of variations, none of which worked. I got the below "string error" as a result of the above script.
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File "<function:runAction>", line 4, in runAction
TypeError: expected a str
caused by org.python.core.PyException
Traceback (most recent call last):
File "<function:runAction>", line 4, in runAction
TypeError: expected a str
I'm actually working toward a dropConfig with my SimpleMtr template. I had problems getting it to work so I backed up to where I am now. I'm finding that I am unable to get the correct onClick script syntax for the button of my template instance to work.
I think you're right about the value being passed instead of the path. This works but I can't figure out how to get it to interact via the view.params... path.
Find your UDT instance, right click, copy path
Paste the path into the param value in the embedded View. In the view you'll then need to append onto this udt instance path the relative path to the tag within the UDT instance.
Still new to JSON and Python. Simple braces didn't occur to me until I stared at the previous post.
That said, I'd like to pass in the provider. Not all of my tags are in [default]. (Still sorting out the ramifications of where I put tags.)
Not sure why you surround this in braces, but these aren't needed. Braces usually define a tuple (a type of immutable array), but only when there are 2 or more values, or you add a comma to the end of a single value. You don't have a comma at the end so I think it's just effectively returning the string value into the variable. In any case, it could be super confusing to someone looking at it, so I'd remove them.
Also, I'd recommend getting used to using the str.format function as it handles converting values passed to it into strings for you rather than having to explicitly do this yourself