Tutorial: Analysis of a script

This tutorial analyses the Trajectory script, one of the simplest script example provided with the NanoFrazor.

The script performs the trajectory at various pixel timing. The code of the script is here.

#pragma rtGlobals=3
#pragma moduleName=NFScriptTrajectory
#pragma hide=0
#pragma version=0.0.0
#pragma authors="SwissLitho AG"
#pragma IgorVersion=6.3

//=============================================================================
// This script runs a series of trajectory optimizations.
//
// Use:
//
// 1) Copy and rename this file into the Igor Pro User Files "User Procedures"
//    folder which can be found via "Help" -> "Show Igor Pro User Files".
//
// 2) Edit the moduleName pragma to reflect the new filename.
//
// 3) Edit the parameters and functions for your needs.
//
// 4) Edit the "Start()" function for your needs. Use the new module name for
//    operations from this module.
//
// 5) Launch the script by calling the main routine "moduleName#Start()".
//    Replace "moduleName" by the actual name of the module.
//
//    Optionally, load the script along with the NanoFrazor package.
//    See: "NanoFrazor" -> "Script Examples" -> "Template: Macros"
//
//=============================================================================

#include "NanoFrazorAPI"

//=============================================================================

Static Constant kFirstPixelTiming=80
Static Constant kPixelTimingStep=-10

//=============================================================================
// Private routines
//=============================================================================

Static Function SetTrajectory()

    Variable currentRunIndex=NFGetMAOCurrentRunIndex()

    Variable pixelTiming=kFirstPixelTiming-kPixelTimingStep*currentRunIndex

    NFSetPixelTiming(0,pixelTiming)

    //

    NFMAOMoveRelativeToOperation(1)

    return 0
End

//=============================================================================
// Main routines
//=============================================================================

Static Function Start()

    //
    // Main task
    //

    NFMAOInit(numRuns=6)

    NFMAOAdd(0,0,"NFScriptTrajectory#SetTrajectory")

    NFMAOAdd(0,1,"NanoFrazorMAO#StartTrajectory")
    NFMAOAdd(0,2,"NanoFrazorMAO#WaitTrajectory")

    NFMAOAdd(0,3,"NanoFrazorMAO#Exit")

    //
    // Start
    //

    NFMAOStart()
End

Clarifications of the most important parts of the script are given below.

Start Function

Static Function Start()
    .
    .
    .
End

The Start() function initialize the script. It creates the list of operation that the NanoFrazor will perform and starts the operations.

NFMAOInit(numRuns=6)

Initialize the data folder in MAO that contains information about the script background task.

NFMAOAdd(0,0,"NFScriptTrajectory#SetTrajectory")

Adds the SetTrajectory function to the list of operations. This function is defined in this module (NFScriptTrajectory).

NFMAOAdd(0,1,"NanoFrazorMAO#StartTrajectory")
NFMAOAdd(0,2,"NanoFrazorMAO#WaitTrajectory")

Adds NanoFrazorMAO API functions to the list of operations.

NFMAOAdd(0,3,"NanoFrazorMAO#Exit")

Call to the NanoFrazorMAO#Exit Function. This function terminates the script once called numRuns times. The user can write his own Exit function (return 0 to continue the script, anything else stops the script, see MAO Framework for more details.

NFMAOStart()

Starts the background task that executes the functions in the list of operations.

Definition of constants

Static Constant kFirstPixelTiming=80
Static Constant kPixelTimingStep=-10

This part defines the constant used by the script.

Private routines

//=============================================================================
// Private routines
//=============================================================================

Static Function SetTrajectory()

    Variable currentRunIndex=NFGetMAOCurrentRunIndex()

    Variable pixelTiming=kFirstPixelTiming-kPixelTimingStep*currentRunIndex

    NFSetPixelTiming(0,pixelTiming)

    //

    NFMAOMoveRelativeToOperation(1)

    return 0
End

The Private routines are function written by the users. They are added to the list of operations, or they are called by functions in the list of operations. Typically they are functions that set parameters, analyze the data, and take decisions about how the script should proceed.

Static Function SetTrajectory()
    .
    .
    .
End

Function defined as Static with no parameters. Only functions with no parameter can be called directly by the MAO background task. Parameters are set by separate functions.

NFSetPixelTiming(0,pixelTiming)

Call to NanoFrazor API function, it sets the Pixel timing. It is equivalent to set the pixel timing from the NanoFrazor GUI.

NFMAOMoveRelativeToOperation(1)

Instructs MAO to continue with the next operation in the list of operations of the script.

return 0

return 0, means successful operation, the script can continue.