How would you debug scripts in gateway event?
In script console, i use print. (displayed on the same window)
In perspective components scripts, I use system.perspective.print (displayed on designer's console)
What is the normal practice, to test script on the gateway event?
- if I use timer script - I would need to save project every time, script will run i an loop
- should I use message handler, and invoke by sending via util.sendRequest via script console? and return something from script?
- Is executing script in script console same as executing it from gateway events?
- when I use
<loggerName>.info('something') on gateway events - does this create a txt file where you can download share open and scroll, with timestamp? Or is this normally meant for viewing (there is only one place to view it, that is on Gateway->Status Tab)
If you want to test code intended to be used in gateway scope, put it in a project library script function, then create a gateway message handler that will call that function on your behalf (and return its return value). You may need a little bit of "glue" code to extract items from a payload to supply to the library function as if it were being called from the normal source.
Then you can use
system.util.sendRequest() in the designer script console, with suitable payload, to call that function indirectly and get the return value into your console.
Use loggers in everything that will run in gateway scope.
print just goes to the wrapper log file, which is not very convenient.
I read the manual, but wasn't clear to me, when would I want to use logger? Also how do I export logger to text for sharing purpose?
Always. Don't use bare
print. It has pathological behaviors in some cases.
In gateway or Perspective scope, logged information goes into the gateway logs (!) accessible from the gateway web interface. It also goes to the wrapper log file.
In Designer or Vision Client scopes, logged information is available in the diagnostics window, and is also typically copied to the console.
From the log viewers. Or from the corresponding text output (wrapper log, designer/vision console).
Is it possible to run
system.util.sendRequest from designer, binding script.
I see that I am not receiving return from gateway.
binding on table's props.data:
ds, numOfTags = system.util.sendRequest(project, messageHandler, payload)
self.view.custom.numOfTags = numOfTags
messageHandler on gateway event script:
results = system.tag.query(provider, query)
#convert results to dataset
headers = ['tagPath']
rows = 
for r in results:
#count number of rows
numOfTags = len(rows)
return system.dataset.toDataSet(headers, rows), numOfTags
I did not use library script
Perspective scripts run in the gateway. Don't use a message handler.
Always do put your code in a library script.
(Events and transform scripts should be very short, with calls to library scripts.)
Transform scripts don't run at all if the source data doesn't change. Show the whole binding.
system.util.sendRequest() works perfect in designer as well.
I got error on the input argument which was null.
I am invoking
system.tag.query to return 10,000 tags - for users to select a subset.
I found that when table's pager is off, UI will freeze.
It works smooth as butter when pager is on.
How should I do, to allow User able to enable/disable quering/polling of data:
Don't use a script transform. Use a "search" button that calls a project library script with that code, and returns the list. The calling action in the button would assign it to a view custom property, which then drives the table.
The table will update each time they click the search button.
Or something similiar.
You might think script transforms are a convenient place to write your scripts, but they are terrible for controlling data flow, and have more overhead than
You mean to say, for best performance, no heavy for loop in script transform only assignments.
No, I mean avoid using them. If you have an expression binding, and think you need a script transform, just use
runScript() within the binding to process the result of the sub-expression. Less overhead.
Any jython that's more than a trivial one or two lines should be in your project script library.
i am following. but I got a weird error.
when using script transform (calling to project script) - I got no error.
But when using runScript(), calling to project script returned error.
I debugged. Seems the error is in project script line 111:
I don't know why runScript throws an error on line 111.
Attach is the project script..
TagMonitoring_Project_Script.zip (1.5 KB)
"[default]Practice Alarming/Alarm Tag 1",
"[default]Practice Tags/Expression Tag"
Show the error. (As text. Use the "preformatted text" button in the comment editor for code or error backtraces.)
Sorry, how do I display this error, and errors on script library?
I can't even screenshot the popup.