new BaseNode( [id])
initalize the node and its id. members are initialized for default values.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
id |
string |
<optional> |
Members
-
category :string
-
Node category. Must be `b3.COMPOSITE`, `b3.DECORATOR`, `b3.ACTION` `b3.CONDITION` or b3.MLMODEL. This is defined automatically be inheriting the correspondent class.
Type:
- string
-
contextManager :ContextManager
-
ContextManager reference. Defaults to null if no context manager on this node
Type:
- ContextManager
-
description :string
-
Type:
- string
-
id :string
-
Node Id (typically a GUID)
Type:
- string
-
name :string
-
Node name. Must be a unique identifier, preferable the same name of the class. You have to set the node name in the prototype.
Type:
- string
-
parameters :Object
-
A dictionary (key, value) describing the node parameters. Useful for defining parameter values in the visual editor. Note: this is only useful for nodes when loading trees from JSON files.
Type:
- Object
-
properties :Object
-
editor node properties
Type:
- Object
Methods
-
<protected> _close(tick [, status])
-
Wrapper for close method.
Parameters:
Name Type Argument Description tick
Tick A tick instance. status
TickStatus <optional>
-
_closeMe(tick [, status])
-
closes the node
Parameters:
Name Type Argument Description tick
Tick status
TickStatus <optional>
-
<protected> _enter(tick)
-
Wrapper for enter method.
Parameters:
Name Type Description tick
Tick A tick instance. -
<protected> _execute(tick)
-
This is the main method to propagate the tick signal to this node. This method calls all callbacks: `enter`, `open`, `tick`, `close`, and `exit`. It only opens a node if it is not already open. In the same way, this method only close a node if the node returned a status different of `b3.RUNNING()`.
Parameters:
Name Type Description tick
Tick A tick instance. Returns:
The tick state.- Type
- TickStatus
-
<protected> _exit(tick)
-
Wrapper for exit method.
Parameters:
Name Type Description tick
Tick A tick instance. -
<protected> _open(tick)
-
Wrapper for open method.
Parameters:
Name Type Description tick
Tick A tick instance. -
<protected> _tick(tick)
-
Wrapper for tick method.
Parameters:
Name Type Description tick
Tick A tick instance. Returns:
A state constant.- Type
- TickStatus
-
alldata(tick, compositeFieldName,, fieldValue)
-
Parameters:
Name Type Argument Description tick
Tick compositeFieldName,
string <nullable>
a field name composed of . eg context.myname fieldValue
string <nullable>
-
assert(tick, cond, message)
-
assert the condition and present node's summary and message if false
Parameters:
Name Type Description tick
Tick cond
Boolean message
string -
clearAllContexts(tick)
-
clear all the sibling contexts of this node
Parameters:
Name Type Description tick
Tick -
clearContext(tick)
-
find the direct context of this node and clear it
Parameters:
Name Type Description tick
Tick -
closeAllContexts(tick)
-
find the current context and close its children
Parameters:
Name Type Description tick
* -
collectContextsUpToRoot(tick)
-
returns an object that is a merge between all contexts up to the root lower context members override the upper ones
Parameters:
Name Type Description tick
Tick -
context(tick [, key] [, value])
-
sets context data. pass only tick to get all context mem pass explicit null key to replace data all with value
Parameters:
Name Type Argument Default Description tick
Tick key
string <optional>
null value
string <optional>
null if non-null, sets the value -
contextProperties()
-
Returns:
- Type
- Array
-
countMatchingEntities(tick, msgObj, curCtxParam)
-
if already haas a context selected, give search the **curent** context by the entities override if the search needs to be different
Parameters:
Name Type Description tick
Tick msgObj
MessageModel curCtxParam
Object Returns:
- match counter- Type
- number
-
createParentTick(tick)
-
create a new tick object that is relevant to the tree ABOVE this node
Parameters:
Name Type Description tick
Tick -
debugLog(tick, status)
-
logger function to run if debug-log is truthy
Parameters:
Name Type Description tick
Tick status
TickStatus -
enter(tick)
-
Enter method, override this to use. It is called every time a node is asked to execute, before the tick itself. if return undefined, will now enter into tick - disregarding the node
Parameters:
Name Type Description tick
Tick A tick instance. Returns:
- Type
- void
-
error(tick, message, ex)
-
structured error report
Parameters:
Name Type Description tick
Tick message
* ex
* -
findContextManagerEntities(tick)
-
Searches up to tree root and return the first contextManager entities found
Parameters:
Name Type Description tick
Tick Returns:
-
findCurrentWaitNode(tick, node)
-
find the last ticked leaf which decendent of this node
Parameters:
Name Type Description tick
Tick node
BaseNode Returns:
-
get(tick, property)
-
get volatile memory property for a RUNNING instance of THIS NODE
Parameters:
Name Type Description tick
Tick property
string -
global(tick [, key] [, value])
-
get/set process data
Parameters:
Name Type Argument Default Description tick
Tick key
string <optional>
null value
string <optional>
null if non-null, sets the value -
handleBreakpoint(tick, status, type)
-
Parameters:
Name Type Description tick
Tick status
TickStatus type
string -
handleTimeout()
-
default timeout handling
-
imageDataArrayName()
-
returns the memory field name for an array object that contains data for the images
Returns:
- Type
- Array
-
images()
-
returns the properties.image or images
Returns:
- Type
- string
-
incrementRetries(tick)
-
increment number Retries
Parameters:
Name Type Description tick
Tick Returns:
retries couont- Type
- number
-
isLeaf()
-
node is a leaf?
-
isLeafTimeout(tick)
-
true if this is a leaf which timeouts (and we are not sitting on a breakpoint)
Parameters:
Name Type Description tick
Tick Returns:
- Type
- boolean
-
isNodeTimeout(tick)
-
true if this node timeouted
Parameters:
Name Type Description tick
* Returns:
- Type
- boolean
-
local(tick [, key] [, value])
-
set/get local node memory
Parameters:
Name Type Argument Default Description tick
Tick key
string <optional>
null value
string | number <optional>
null if non-null, sets the value -
log(tick, text)
-
node log
Parameters:
Name Type Description tick
Tick text
string -
message(tick [, property] [, value])
-
Parameters:
Name Type Argument Default Description tick
Tick property
string <optional>
null value
string <optional>
null if non-null, sets the value -
open(tick)
-
Open method, override this to use. It is called only before the tick callback and only if the not isn't closed. Note: a node will be closed if it returned `b3.RUNNING()` in the tick.
Parameters:
Name Type Description tick
Tick A tick instance. -
outputMessage(tick [, fieldName])
-
output the message base on process data
Parameters:
Name Type Argument Description tick
Tick fieldName
string <optional>
use when building the prompt -
parentEntities(tick)
-
return entities representing the parent;
Parameters:
Name Type Description tick
Tick Returns:
ContextManagerEntities -
payload()
-
returns properties.payload or undefined if empty
Returns:
- Type
- string
-
postConnect()
-
upon tree creation, this method is called after the node has been connected to its parents or children
-
prompt(fieldName)
-
returns the text prompt for the message out. properties.fieldName if any,otherwise properties.prompt
Parameters:
Name Type Description fieldName
string -
removeTargets(tick)
-
remove target from context and tick
Parameters:
Name Type Description tick
Tick -
resetTimeoutRetries(tick)
-
Parameters:
Name Type Description tick
* -
safeOpen(tick)
-
open only if node is not opened
Parameters:
Name Type Description tick
Tick -
searchTarget(tick)
-
Parameters:
Name Type Description tick
Tick Returns:
tick target. its been unused at this time- Type
- Target
-
set(tick, property, value)
-
set volatile memory property for a RUNNING instance of THIS NODE
Parameters:
Name Type Description tick
Tick property
string value
string | number -
setVolatile()
-
set/get volatile memory property for a RUNNING instance of this node
-
summary(tick)
-
node details summary
Parameters:
Name Type Description tick
Tick -
target(tick)
-
return the closest target object up the tree
Parameters:
Name Type Description tick
* -
tickMessage(tick [, fieldName])
-
send a message method. output a message asynchrously
Parameters:
Name Type Argument Description tick
Tick fieldName
string <optional>
to use when building a message. ,instead of prompt Returns:
A state constant.- Type
- TickStatus
-
validators()
-
a base node should have a title defines validation methods to execute at the editor; if one of them fails, a dashed red border is displayed for the node
Returns:
- Type
- Array.<Validator>
-
view()
-
return properties.view
Returns:
- Type
- string
-
volatile(tick, key [, value])
-
Volatile memory get/setter - memory will not persist beyond machine/running restart
Parameters:
Name Type Argument Description tick
Tick key
string value
string | number | Object <optional>
-
wait(fn, args [, timeoutMs])
-
executes fn until timeoutMs reached
Parameters:
Name Type Argument Default Description fn
function function to execute args
Array | Object arguments array timeoutMs
number <optional>
30000 timeout interval -
waitCode(tick [, retcode])
-
getter
Parameters:
Name Type Argument Description tick
Tick retcode
TickStatus <optional>