Callback Functions

Callback functions are special functions that execute in the non real-time part of the controller. For example, if the controller is running in a real-time operating system, it cannot access files on the PC. Thus, when the controller encounters a file access function, it pauses the AeroScript program and triggers the execution of the command in the non real-time environment. There is a full list of callback commands in the Callback Functions table at the end of this page.

Callback Function Execution

The steps that follow include the order in which the controller executes a callback function.

  1. The controller pauses the AeroScript program that is currently running.

  2. The controller generates a callback interrupt.

  3. The communication service, running in the non real-time environment, gets the callback interrupt and sends a signal to the controller that it received the callback interrupt.

  4. IMPORTANT: If this step does not occur quickly enough, the controller will supply a CallbackNotRegistered error, which means that there is no application registered to handle the callback.

  5. A host application retrieves the callback data and does the applicable function.

  6. When the callback command is completed, the host application tells the controller to continue.

  7. The controller continues to execute the AeroScript program.

Custom Callback

Use custom callbacks to pass execution to a process external to the controller that will be handled by the .NET API. The .NET API exposes the ability to handle callbacks of a specific callback identification number.

When the custom callback function is called from AeroScript, program execution waits for any registered .NET callback handler to execute. These handlers read the specified input arguments and if applicable, they do actions based on the input arguments (such as pass some data as an argument to a file or send data over the network). Execution of the AeroScript program continues when the callback handler returns in the .NET API. The callback handler can return a combination of double, integer, and/or string values to the AeroScript program.

For information about how to use the Callback() AeroScript function with the .NET API, see the Handle AeroScript Callbacks section of the .NET Tasks page.

function Callback($id as integer, $integerInputs[] as integer, $realInputs[] as real, $stringInputs[] as string, ref $integerOutputs[] as integer, ref $realOutputs[] as real, ref $stringOutputs[] as string)

Triggers a custom callback to be handled by an external process.

Arguments

$id  The id number of the callback.

$integerInputs  A list of integers to be provided to the external callback function.

$realInputs  A list of reals to be provided to the external callback function.

$stringInputs  A list of strings to be provided to the external callback function.

ref $integerOutputs  A list of integers returned from the external callback function.

ref $realOutputs  A list of reals returned from the external callback function.

ref $stringOutputs  A list of strings returned from the external callback function.

Callback Functions

The table that follows includes a full list of callback functions.

Table: Callback Functions

Function Name

Description

Callback()

Raises a custom callback that the C, .NET, or Python API handles.

ProgramLoad()

Loads a program to the specified task.

ProgramRun()

Runs a program on the specified task.

DateTimeGet()

Gets the current time on the controller.

DateTimeExtract*()

Extracts the specified time component from the given epoch time.

FileOpenBinary() / FileOpenText()

Opens a file for binary or text I/O.

FileClose()

Closes the specified file.

FileSetByteOffset()

Sets the current byte offset for reading and writing in the specified file.

FileGetByteOffset()

Gets the current byte offset for reading and writing in the specified file.

FileIsEndOfFile()

Returns whether the current reading offset is at the end of the file.

FileSize()

Returns the size of the specified file.

FileTextReadLine() / FileTextReadString()

Reads a line or string from a text file.

FileTextWriteString()

Writes a string to a text file.

FileBinaryRead*()

Returns data from a binary file interpreted as the specified data type.

FileBinaryWrite*()

Converts data to a specified data type and writes it to the specified file.

DirectoryCount()

Returns the number of subdirectories within the specified directory.

DirectoryFileCopy()

Copy the specified file.

DirectoryFileCount()

Returns the number of files within the specified directory.

DirectoryFileDelete()

Deletes the specified file.

DirectoryFileExists()

Returns whether the specified file exists.

DirectoryFileGetFileName()

Returns the name of the file with the specified index within the specified directory.

DirectoryFileMove()

Moves the specified file.

DirectoryGetName()

Returns the name of the subdirectory with the specified index within the specified directory.

DataCollectionAddAxisSignal() / DataCollectionAddSystemSignal() / DataCollectionAddTaskSignal()

Adds an axis, task, or system status item to the data collection configuration.

DataCollectionReset()

Resets the data collection configuration.

DataCollectionStart()

Starts real-time data collection.

DataCollectionStop()

Stops real-time data collection.

AppDataCollectionAddAxisSignal() / AppDataCollectionAddSystemSignal() / AppDataCollectionAddTaskSignal()

Adds an axis, task, or system status item to the data collection configuration.

AppDataCollectionReset()

Resets the data collection configuration.

AppDataCollectionConfigure()

Configures application data collection.

AppDataCollectionAutoSaveOn() / AppDataCollectionAutoSaveOff()

Enables/disables automatic saving of data collected through AppDataCollectionSnapshot().

CalibrationLoad()

Loads and activates the specified axis calibration file or galvo power correction file.

CalibrationUnload()

Deactivates and unloads the calibration for the specified calibration type.

AppIndicatorOn()

Turns on all indicators with the specified ID.

AppIndicatorOff()

Turns off all indicators with the specified ID.

AppMessageBox()

Displays a message box that shows the user information with a specified severity.

AppMessageDisplay()

Displays the specified message.

AppMessageDisplayDismiss()

Clears all application message notifications.

AppMessageFileOpen()

Displays a dialog box that is used to select a file to open.

AppMessageFileSave()

Displays a dialog box that is used to select a file to save.

AppMessageInputBox()

Displays a message box that retrieves input data.

AppMessageMenu()

Displays a list of items that can be selected.

AppFrequencyResponsePerformStabilityAnalysis() Does a stability analysis on a saved frequency response file and returns the stability metrics.
AppFrequencyResponseTriggerSinusoid()

Triggers a Sinusoidal frequency response transmission on the specified axis.

AppFrequencyResponseTriggerMultisine()

Triggers a Multisine frequency response transmission on the specified axis.

AppFrequencyResponseTriggerWhiteNoise()

Triggers a WhiteNoise frequency response transmission on the specified axis.