This advanced JSup feature enable a I/O Channel to get its I/O hooks from a JavaCode function that will decide which tag (for instance based according to the tag class) will be bound to which device item and if in read/write only mode.
The JavaCode function must accept an unique parameter: ChannelInfo ch
And must return an Iterable<IOHookCodeCreatedInfo> object.
Its signature should be:
Iterable<IOHookCodeCreatedInfo> functionName ( ChannelInfo ch ) throws JException;
The JavaCode function can determine which tag to include be enumerating the tags that belong to a certain tag class. The following example provides MQTT I/O hook for the tag of tag class named /device/onoff:
final Vector<IOHookCodeCreatedInfo> v = new Vector<>(); for( final TagRef tag : getTagClass( "/device/onoff" ).tags() ) { v.add( new IOHookCodeCreatedInfo.N.Adapter( tag, "/JSupTest/device/onoff/"+tag.getName(), true, false, null, null, false ) ); }
An I/O Channel can have both I/O hooks statically entered in the tag dialog and JavaCode function provided ones.
The name of the JavaCode function that will provide I/O hooks to a channel have to be specified in the Auto I/O hook JavaCode fun: in the I/O channel dialog dialog.