I am working on a module with a couple of blocks, I have block A accepting a string, when the string changes I fire the onExecute method and I would like to do a couple of things.
pass the string value to block B
invoke an action on block B
Just wondering if this is possible and if anyone can share some example code to give me a hint on how I can achieve this.
Thanks in advance for you time guys, have a great day.
If this is a program object, you when you add a slot, you can select âexecute on changeâ This will trigger the onExecute method in the program object.
If this is a module and youâre extending from BComponentt, you can use the doExecute or Changed method
Hi @Charles_Johnson, it is a module I am working on. I have the module working with both blocks in the palette and I can drop them on the wire sheet.
What I want to know is, can I trigger an action pin on block B if for example the string value of block A is equal to a certain value?
Appreciate any help you can offer, thanks.
Sounds like 1 and 2 can be done in a single action:
you want something like this:
make an action slot named sendInt
add a parameter to the input.
private BInteger i;
public void onSendInt(BInteger i) throws Exception
{
this.i = i; //sets global int to the value of incoming int
}
In this case, executing the action manually prompts a user input. If the action is executed programatically (onSendInt(10)), then it will fire the a trigger as well as send the â10â to whatever the set is connected to.
Remember that the sending and receiving action slot also needs to take BInteger is a parameter input.
I did this with a BInteger but you can simply switch to BString. I sent the integer example as i have used it before and can confirm that it works.
This sounds about right. Sorry, been entertaining a potentially huge customer. I was thinking of using the onExecute to do something which then fires a topic slot, to connect to an action on another object.
Thanks for all your help, I have managed to get it working as @Boba suggested with a topic firing an action on the other block, had to leave it there on Thursday but back on it tomorrow and will modify the code to pass the string over.
Will I pass the string as a parameter form my topic and accept a string as a parameter on my action on the other block? How do you define these parameters so slotomatic can do its stuff?
Thanks everyone for your help so far
Can find this in the niagara docs module://docDeveloper/doc/slot-o-matic.html#niagara-annotations
@NiagaraAction
/**
* This is my action. This comment will be included in the slot definition. Please note that this is a javaDoc comment.
*/
@NiagaraAction
(
name = "myOnlyAction", //REQUIRED Name of the action.
flags = Flags.HIDDEN, //Any flags the action my have. Note that multiple flags are grouped together with the "|" symbol.
parameterType = "baja:RelTime", //Parameter type of the action. Supports "Module:Type" typespec format (preferred) or full name. Example: "baja:RelTime" or "BRelTime" are valid.
defaultValue = "BRelTime.makeSeconds(5)", //The default value of the action.
returnType = "baja:RelTime", //Return type of the action. Supports "Module:Type" typespec format (preferred) or full name. Example: "baja:RelTime" or "BRelTime" are valid.
facets = //Any facets that the action may have. The facet annotation works as a name-value pair.
{
@Facet(name = "BFacets.MIN", value = "BRelTime.makeSeconds(0)"),
@Facet(name = "BFacets.MAX", value = "BRelTime.makeSeconds(60)")
}
)
A @NiagaraAction annotation defines a single Action on a BComplex. A BComplex can have any number of actions, each declared in a separate @NiagaraAction annotation.
A @NiagaraAction annotation has the following attributes, in addition to the standard attributes detailed above:
parameterType: The type of the actionâs single argument, as a String. Optional. If left blank, the action is assumed to take no argument. This can be a Baja typespec, a Class name, or a Java primitive.
returnType: The type of the value returned by the action. Optional. If left blank, the action is assumed to return âvoidâ. This can be a Baja typespec, a Class name, or a Java primitive.
defaultValue: The default value for the action parameter. Required for actions which take a parameter.
@NiagaraTopic
/**
* This is my topic. This comment will be included in the slot definition. Please note that this is a javaDoc comment.
*/
@NiagaraTopic
(
name = "myFirstTopic", //REQUIRED Name of the topic.
flags = Flags.USER_DEFINED_1, //Any flags the topic my have. Note that multiple flags are grouped together with the "|" symbol.
eventType = "int", //Event type of the topic. Supports "Module:Type" typespec format (preferred) or full name. Example: "baja:RelTime" or "BRelTime" are valid.
facets = //Any facets that the topic may have. The facet annotation works as a name-value pair.
{
@Facet(name = "BFacets.MIN", value = "1"),
@Facet(name = "BFacets.MAX", value = "40")
}
)
A @NiagaraTopic annotation defines a single Topic of a BComplex. A BComplex can have any number of topics, each declared in a separate @NiagaraTopic annotation.
A @NiagaraTopic annotation has the following attribute, in addition to the standard attributes detailed above:
eventType: Event type for the topic, as a String. Optional. If left blank, defaults to âvoidâ. This can be a Baja typespec, a Class name, or a Java primitive.
Hi guys,
Thanks for all your help, with @Boba âs suggestion and the input from @Giantsbane I managed to pass my string value from my topic slot on one block to my action shot on another all through the single link.
All I need to figure out now are some rules for dropping the two blocks, one is actually a service so that is easy but the other needs to go on the wiresheet but only allow the drop if the service is installed, then a bit of auto-linking and we are away for some load testing.