Were you able to find anything out about this?
No, swamped.
A quick check with v8.1.28 and toolkit v2.0.15 shows no problem (event driven). Can you share a sample dataset that shows the problem?
Try this in an expression tag, with the tag data type set to string:
view(
"Select repr(binding) as value",
unionAll(
asMap('value', 'str'),
asList(asList('dummy'))
)
)[0,0]
I get this:
ExpressionTagActor{listener=ExecutableTag[name=ViewTest, id=6af33706-5ee2-41e0-a476-b63d07f7a029, actors=2, valid=true], lastPublished=[null, Uncertain_InitialValue, Mon Apr 01 13:32:17 EDT 2024 (1711992737381)]}
Same results. I didn't know about the tag diagnostics until today but in there I'm seeing a parse errors Unknown function: 'view' and Unknown function: 'asMap'.
I have your integration tool kit installed and running -
There should be entries in the gateway log for failures to install these functions. Please restart the module and show any log entries that result.
Possibly also restart the whole gateway.
Restarting the Module I see this.
Unable to restart the entire gateway at this moment but all the functions still working as expression bindings
There must be some nuance to the older gateway version you are using. I'll spin up a copy tomorrow.
Did you make some changes? This has started working for me sometime in the past day.
No. And if I did, you'd have to install a new module version.
Ahh, forgot I actually restarted the gateway yesterday. I'm guessing that's what did it
I'm trying to use the globalVarMap()
function. The documentation for this states:
- Implements attribute-to-key translation, where jython syntax like
bvm.someAttr
performs the same operation asbvm.get("someAttr")
This only works for me in the Gateway scope, but fails in Designer and Client scopes.
See following example from the Script Console:
1 from com.automation_pros.simaids.persist import BindableVarMap
2 bvm = BindableVarMap()
3 bvm.name = "Hello"
4 print bvm.name
Output:
Traceback (most recent call last):
File "<input>", line 3, in <module>
AttributeError: 'com.automation_pros.simaids.persist.BindableVarMap' object has no attribute 'name'
The exact same script run under a Gateway tag change event executes succesfully.
Does that happen when the bvm
comes from system.util.globalVarMap()
, or only when you import the class yourself?
Meanwhile, does this work:
from com.automation_pros.simaids.persist import BindableVarMap
bvm = BindableVarMap()
bvm['name'] = "Hello"
print bvm.name
Same issue when I use system.util.globalVarMap()
and it works if I use
bvm['name'] = "Hello"
A quick look at the code says that you must use system.util.globalVarMap()
at least once for jython to be "primed" for attribute access to divert to dictionary keys as intended. After that, using the import should also work.
Probably once for every designer script console session, too. (Maybe).
Tested this in a designer script console:
bvm1 = system.util.globalVarMap('somekey')
bvm1.name = "Hello World!"
print bvm1.name
from com.automation_pros.simaids.persist import BindableVarMap
bvm2 = BindableVarMap()
bvm2.name = "Cruel World!"
print bvm2.name
Got this:
>>>
Hello World!
Cruel World!
>>>
I copied your example and ran it in the designer script console, but it doesn't work for me. Still the same error
I guess I'll just use the other method to read from the bvm.
Did you restart your designer? These classes dig their hooks into the JVM to ensure persistence. You almost certainly have to ensure that you've called system.util.globalVarMap()
before you ever import BindableVarMap
.
(I should ask: you are using the latest version?)
I'm using v2.0.15, I think that is the latest version.
It actually works after restarting the designer. Makes sense now, I'll just make sure to call system.util.globalVarMap("someKey")
on client startup.
I create a bvm on Gateway Startup using system.util.globalVarMap()
and the Client then reads it in from the Gateway via Message Handling. This is where I ran into that issue. The Client never ran system.util.globalVarMap()
.
Huh. Never thought of that usage. Consider not passing that class over the network. You can pass it to dict()
to get a plain jython dictionary with the same content, with which you can .update()
one the client gets from `system.util.globalVarMap().
If anything in the gateway uses the globalVarMap()
expression function in a binding, the listener attached to the BVM will likely break serialization in your messaging. I don't explicitly mark the class as serializable.
Also keep in mind that the "bindable" nature of these really depends on them coming from system.util.globalVarMap()
.