Vuo  1.0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
VuoRuntime.c File Reference

Description

VuoRuntime implementation.

Functions

static void stopComposition (void)
 This function may only be called on dispatch queue VuoControlQueue.
 
void vuoControlReplySend (enum VuoControlReply reply, zmq_msg_t *messages, unsigned int messageCount)
 This function may only be called on dispatch queue VuoControlQueue.
 
void vuoTelemetrySend (enum VuoTelemetry type, zmq_msg_t *messages, unsigned int messageCount)
 This function may be called from any thread.
 
void vuoInit (int argc, char **argv)
 Parses command-line arguments, then calls vuoInitInProcess().
 
void vuoInitInProcess (void *_ZMQContext, const char *controlURL, const char *telemetryURL, bool _isPaused, pid_t _runnerPid)
 Sets up ZMQ control and telemetry sockets, then calls the generated function setup().
 
void sendNodeExecutionStarted (char *nodeIdentifier)
 Constructs and sends a message on the telemetry socket, indicating that a node has started execution.
 
void sendNodeExecutionFinished (char *nodeIdentifier)
 Constructs and sends a message on the telemetry socket, indicating that a node has finished execution.
 
void sendInputPortsUpdated (char *portIdentifier, bool receivedEvent, bool receivedData, char *portDataSummary)
 Constructs and sends a message on the telemetry socket, indicating that an input port has received an event or data.
 
void sendOutputPortsUpdated (char *portIdentifier, bool sentData, char *portDataSummary)
 Constructs and sends a message on the telemetry socket, indicating that an output port has transmitted or fired an event.
 
void sendEventDropped (char *portIdentifier)
 Constructs and sends a message on the telemetry socket, indicating that a trigger port has dropped an event.
 
void sendError (const char *message)
 Constructs and sends a message on the telemetry socket, indicating that an uncaught error has occurred.
 
char * vuoTranscodeToGraphvizIdentifier (const char *originalString)
 Replaces '"' with '"' and '\' with '\' in a string.
 
bool isNodeInBothCompositions (const char *nodeIdentifier)
 Returns true if the node is found in both the old and the new composition, when replacing compositions for live coding.
 
void mapFromReplacementNodeAndPort (const char *newNodeIdentifier, const char *newPortIdentifier, char **oldNodeIdentifier, char **oldPortIdentifier)
 If the new node and port have a mapping from the old composition, when replacing compositions for live coding, finds the old node and port that they map from.
 
graph_topenGraphvizGraph (const char *graphString)
 Returns a Graphviz graph constructed from the given Graphviz-format string.
 
void closeGraphvizGraph (graph_t *graph)
 Cleans up a Graphviz graph when it is no longer in use.
 
const char * getConstantValueFromGraphviz (graph_t *graph, const char *node, const char *port)
 Returns the constant value of the input port in the serialized composition, or null if it is not found.
 
void vuoStopComposition (void)
 Cleanly stops the composition.
 
void vuoFini (void)
 Cleans up composition execution: closes the ZMQ sockets and dispatch source and queues.
 
void setup (void)
 Initializes the reference-counting system.
 
void cleanup (void)
 Initializes the reference-counting system.
 
void nodeInstanceInit (void)
 Initializes the reference-counting system.
 
void nodeInstanceFini (void)
 Initializes the reference-counting system.
 
void nodeInstanceTriggerStart (void)
 Initializes the reference-counting system.
 
void nodeInstanceTriggerStop (void)
 Initializes the reference-counting system.
 
void setInputPortValue (char *portIdentifier, char *valueAsString, int shouldUpdateCallbacks)
 Initializes the reference-counting system.
 
void fireTriggerPortEvent (char *portIdentifier)
 Initializes the reference-counting system.
 
char * getInputPortValue (char *portIdentifier, int shouldUseInterprocessSerialization)
 Initializes the reference-counting system.
 
char * getOutputPortValue (char *portIdentifier, int shouldUseInterprocessSerialization)
 Initializes the reference-counting system.
 
char * getInputPortSummary (char *portIdentifier)
 Initializes the reference-counting system.
 
char * getOutputPortSummary (char *portIdentifier)
 Initializes the reference-counting system.
 
unsigned int getPublishedInputPortCount (void)
 Initializes the reference-counting system.
 
unsigned int getPublishedOutputPortCount (void)
 Initializes the reference-counting system.
 
char ** getPublishedInputPortNames (void)
 Initializes the reference-counting system.
 
char ** getPublishedOutputPortNames (void)
 Initializes the reference-counting system.
 
char ** getPublishedInputPortTypes (void)
 Initializes the reference-counting system.
 
char ** getPublishedOutputPortTypes (void)
 Initializes the reference-counting system.
 
char ** getPublishedInputPortDetails (void)
 Initializes the reference-counting system.
 
char ** getPublishedOutputPortDetails (void)
 Initializes the reference-counting system.
 
int getPublishedInputPortConnectedIdentifierCount (char *name)
 Initializes the reference-counting system.
 
int getPublishedOutputPortConnectedIdentifierCount (char *name)
 Initializes the reference-counting system.
 
char ** getPublishedInputPortConnectedIdentifiers (char *name)
 Initializes the reference-counting system.
 
char ** getPublishedOutputPortConnectedIdentifiers (char *name)
 Initializes the reference-counting system.
 
void firePublishedInputPortEvent (char *name)
 Initializes the reference-counting system.
 
void setPublishedInputPortValue (char *portIdentifier, char *valueAsString)
 Initializes the reference-counting system.
 
char * getPublishedInputPortValue (char *portIdentifier, int shouldUseInterprocessSerialization)
 Initializes the reference-counting system.
 
char * getPublishedOutputPortValue (char *portIdentifier, int shouldUseInterprocessSerialization)
 Initializes the reference-counting system.
 
void VuoHeap_init ()
 Initializes the reference-counting system.
 
void VuoHeap_fini ()
 Cleans up the reference-counting system.
 

Variables

bool hasZMQConnection = false
 True if the ZMQControl and ZMQTelemetry sockets are connected to something.
 
dispatch_queue_t VuoControlQueue
 Dispatch queue for protecting access to the ZMQControl socket.
 
dispatch_queue_t VuoTelemetryQueue
 Dispatch queue for protecting access to the ZMQTelemetry socket.
 
void * ZMQContext
 The context used to initialize sockets.
 
void * ZMQControl
 The control socket. Use only on VuoControlQueue.
 
void * ZMQTelemetry = 0
 The telemetry socket. Use only on VuoControlQueue.
 
bool hasBeenUnpaused
 True if node execution was unpaused initially, or if it has since been unpaused.
 
bool isPaused
 True if node execution is currently paused.
 
bool isStopped
 True if composition execution has stopped.
 
bool isStopRequested
 True if vuoStopComposition() has been called.
 
dispatch_source_t telemetryTimer
 Timer for sending telemetry messages.
 
dispatch_source_t controlTimer
 Timer for receiving control messages.
 
dispatch_source_t waitForStopTimer = NULL
 Timer for checking if the runner will stop the composition.
 
dispatch_semaphore_t telemetryCanceledSemaphore
 Signaled when telemetry events are no longer being processed.
 
dispatch_semaphore_t controlCanceledSemaphore
 Signaled when control events are no longer being processed.
 
dispatch_semaphore_t waitForStopCanceledSemaphore
 Signaled when no longer checking if the runner will stop the composition.
 
static pid_t runnerPid
 Process ID of the runner that started the composition.
 
gvplugin_library_t gvplugin_dot_layout_LTX_library
 Reference to the statically-built Graphviz Dot library.
 
gvplugin_library_t gvplugin_core_LTX_library
 Reference to the statically-built Graphviz core library.
 
const char * compositionDiff = NULL
 A string representation of the differences between the old and new composition, when replacing compositions for live coding.
 
GVC_t * graphvizContext = NULL
 The context used when working with a Graphviz graph.
 

Function Documentation

void cleanup ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void closeGraphvizGraph ( graph_t graph)

Cleans up a Graphviz graph when it is no longer in use.

void firePublishedInputPortEvent ( char *  name)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void fireTriggerPortEvent ( char *  portIdentifier)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

const char* getConstantValueFromGraphviz ( graph_t graph,
const char *  node,
const char *  port 
)

Returns the constant value of the input port in the serialized composition, or null if it is not found.

The input port is looked up from the Graphviz graph, using any mappings of old-to-new nodes and ports in the composition diff.

char* getInputPortSummary ( char *  portIdentifier)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char* getInputPortValue ( char *  portIdentifier,
int  shouldUseInterprocessSerialization 
)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char* getOutputPortSummary ( char *  portIdentifier)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char* getOutputPortValue ( char *  portIdentifier,
int  shouldUseInterprocessSerialization 
)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

int getPublishedInputPortConnectedIdentifierCount ( char *  name)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedInputPortConnectedIdentifiers ( char *  name)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

unsigned int getPublishedInputPortCount ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedInputPortDetails ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedInputPortNames ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedInputPortTypes ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char* getPublishedInputPortValue ( char *  portIdentifier,
int  shouldUseInterprocessSerialization 
)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

int getPublishedOutputPortConnectedIdentifierCount ( char *  name)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedOutputPortConnectedIdentifiers ( char *  name)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

unsigned int getPublishedOutputPortCount ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedOutputPortDetails ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedOutputPortNames ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char** getPublishedOutputPortTypes ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

char* getPublishedOutputPortValue ( char *  portIdentifier,
int  shouldUseInterprocessSerialization 
)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

bool isNodeInBothCompositions ( const char *  nodeIdentifier)

Returns true if the node is found in both the old and the new composition, when replacing compositions for live coding.

This needs to be kept in sync with VuoCompilerComposition::diffAgainstOlderComposition().

void mapFromReplacementNodeAndPort ( const char *  newNodeIdentifier,
const char *  newPortIdentifier,
char **  oldNodeIdentifier,
char **  oldPortIdentifier 
)

If the new node and port have a mapping from the old composition, when replacing compositions for live coding, finds the old node and port that they map from.

This needs to be kept in sync with VuoCompilerComposition::diffAgainstOlderComposition().

void nodeInstanceFini ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void nodeInstanceInit ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void nodeInstanceTriggerStart ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void nodeInstanceTriggerStop ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

graph_t* openGraphvizGraph ( const char *  graphString)

Returns a Graphviz graph constructed from the given Graphviz-format string.

void sendError ( const char *  message)

Constructs and sends a message on the telemetry socket, indicating that an uncaught error has occurred.

void sendEventDropped ( char *  portIdentifier)

Constructs and sends a message on the telemetry socket, indicating that a trigger port has dropped an event.

void sendInputPortsUpdated ( char *  portIdentifier,
bool  receivedEvent,
bool  receivedData,
char *  portDataSummary 
)

Constructs and sends a message on the telemetry socket, indicating that an input port has received an event or data.

void sendNodeExecutionFinished ( char *  nodeIdentifier)

Constructs and sends a message on the telemetry socket, indicating that a node has finished execution.

void sendNodeExecutionStarted ( char *  nodeIdentifier)

Constructs and sends a message on the telemetry socket, indicating that a node has started execution.

void sendOutputPortsUpdated ( char *  portIdentifier,
bool  sentData,
char *  portDataSummary 
)

Constructs and sends a message on the telemetry socket, indicating that an output port has transmitted or fired an event.

void setInputPortValue ( char *  portIdentifier,
char *  valueAsString,
int  shouldUpdateCallbacks 
)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void setPublishedInputPortValue ( char *  portIdentifier,
char *  valueAsString 
)

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void setup ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

static void stopComposition ( void  )
static

This function may only be called on dispatch queue VuoControlQueue.

void vuoControlReplySend ( enum VuoControlReply  reply,
zmq_msg_t *  messages,
unsigned int  messageCount 
)

This function may only be called on dispatch queue VuoControlQueue.

void vuoFini ( void  )

Cleans up composition execution: closes the ZMQ sockets and dispatch source and queues.

Assumes the composition has received and replied to a VuoControlRequestCompositionStop message.

void VuoHeap_fini ( void  )

Cleans up the reference-counting system.

To be called once, after all other reference-counting function calls.

void VuoHeap_init ( void  )

Initializes the reference-counting system.

To be called once, before any other reference-counting function calls.

void vuoInit ( int  argc,
char **  argv 
)

Parses command-line arguments, then calls vuoInitInProcess().

void vuoInitInProcess ( void *  _ZMQContext,
const char *  controlURL,
const char *  telemetryURL,
bool  _isPaused,
pid_t  _runnerPid 
)

Sets up ZMQ control and telemetry sockets, then calls the generated function setup().

If the composition is not paused, also calls nodeInstanceInit() and nodeInstanceTriggerStart().

void vuoStopComposition ( void  )

Cleanly stops the composition.

void vuoTelemetrySend ( enum VuoTelemetry  type,
zmq_msg_t *  messages,
unsigned int  messageCount 
)

This function may be called from any thread.

Todo:
https://b33p.net/kosada/node/5567
char* vuoTranscodeToGraphvizIdentifier ( const char *  originalString)

Replaces '"' with '"' and '\' with '\' in a string.

Variable Documentation

const char* compositionDiff = NULL

A string representation of the differences between the old and new composition, when replacing compositions for live coding.

dispatch_semaphore_t controlCanceledSemaphore

Signaled when control events are no longer being processed.

dispatch_source_t controlTimer

Timer for receiving control messages.

GVC_t* graphvizContext = NULL

The context used when working with a Graphviz graph.

gvplugin_library_t gvplugin_core_LTX_library

Reference to the statically-built Graphviz core library.

gvplugin_library_t gvplugin_dot_layout_LTX_library

Reference to the statically-built Graphviz Dot library.

bool hasBeenUnpaused

True if node execution was unpaused initially, or if it has since been unpaused.

bool hasZMQConnection = false

True if the ZMQControl and ZMQTelemetry sockets are connected to something.

bool isPaused

True if node execution is currently paused.

bool isStopped

True if composition execution has stopped.

True if the composition has stopped.

bool isStopRequested

True if vuoStopComposition() has been called.

pid_t runnerPid
static

Process ID of the runner that started the composition.

dispatch_semaphore_t telemetryCanceledSemaphore

Signaled when telemetry events are no longer being processed.

dispatch_source_t telemetryTimer

Timer for sending telemetry messages.

dispatch_queue_t VuoControlQueue

Dispatch queue for protecting access to the ZMQControl socket.

dispatch_queue_t VuoTelemetryQueue

Dispatch queue for protecting access to the ZMQTelemetry socket.

dispatch_semaphore_t waitForStopCanceledSemaphore

Signaled when no longer checking if the runner will stop the composition.

dispatch_source_t waitForStopTimer = NULL

Timer for checking if the runner will stop the composition.

void* ZMQContext

The context used to initialize sockets.

void* ZMQControl

The control socket. Use only on VuoControlQueue.

void* ZMQTelemetry = 0

The telemetry socket. Use only on VuoControlQueue.