Macros - Default & Events
Home ] Up ] Basic Concepts ] Serial Connection ] Plotting Basics ] Logging, Saving and Printing ] Interactive Control ] Macro Basics ] [ Macros - Default & Events ] Macro Math Discussion ] Defined Macro Buttons/Menus ] Drawing Basics ] Media and Paths ] Drawing Coordinate Modes ] Plot Objects ] Macro Editor ] Using Templates ] External Applications ] Historical/Logged Data ] Internet ] Binary and Special Data ]


In version 3, the use of plot object events may be used instead of default macro and events (licenses for Pro recommended).

bulletDefault Macro
A macro may be defined as being the 'Default macro', that is, the if the Default Routine is used (below), or if other macros are called, the default macro is the one which will be ran for processing incoming data.
To specify a macro as being default, use either:
!DEFS macro_name
or, from within the macro,
!DEFS (ME)
bulletMacro Events
A Macro Event is a macro routine in the default macro which is automatically triggered when a specified event takes place.  All event routines must end with an ENDMAC instruction.
bulletStart-Up Macro
Ran when StampPlot is loaded.  Specified with the Macro menu option:
The FIRST routine in the macro will be run. Typically named INIT:
The Start-Up macro may also be called using:
!MACS

bulletNew Plot
A New plot is begun (new plot menu option, or !NEWP
Enabled using:
!NPSU ON/OFF
The FIRST routine in the macro will be run. Typically named INIT:

bulletAnalog Data Arrives (default) Routine
Comma-separated data will be parsed into data markers beginning at %m0 for as many as there exists up to %m99. Non-numeric data may be sent, but the value MUST must be numeric.
Enabled using:
!USED ON/OFF
The DEFAULT: routine will be run. 

bulletPlot Double-Click Routine
Ran when the main plot is double-clicked.  
Enabled using:
!USEC ON/OFF
The DBLCLICK: routine will be run.

bulletTimer Interval Routine
Ran when the specified timer interval expires (0-60 seconds)
Enabled using:
!USET ON/OFF
Interval can be set for 0-60 seconds:
!INTT 20
The TIMER: routine will be run

bulletReset Routine
Ran when the plot is reset.
Enabled using:
!USER ON/OFF
The RESET: Routine will be run.

bulletAnalog data arriving is normally plotted. To prevent automatic plotting in order to perform data manipulation or other actions, you may specify that the analog data will be used for the macro only.
!USEA ON

bulletNOTE:  When using analog data for the macro, the automatic logging feature will not function. To manually send a log entry for values, use the !LOGD instruction:
!LOGD (AINVAL0),(AINVAL1),anything else

bulletThe following is a simple macro using all the events.
bulletUse the Macro Menu, Edit Macro using Notepad, save as events
bulletRun the macro from the macro menu.
bulletUse the CLI to enter values such as 10,50,90.... etc
bulletDouble-click on the plot area
bulletReset your plot
bulletStart a new plot

*********************************

'  Save as EVENTS.TXT

'  Called when macro is started
INIT:
'  clear plot objects
!POBJ Clear
'  Define as default macro
!DEFS (ME)
'  Run default macro on new plot
!NPSU ON
'  Use dblClick routine
!USEC ON
'  Use interval Timer
!USET ON
'  Set interval to 5 seconds
!INTT 5
'  Use Reset routine
!USER ON
'  Use default routine
!USED ON
'  Start plotting
!PLOT ON
'  Post a heading on plot
^Text 20a,105a,2,9,New Plot Started!
ENDMAC

'  Called when analog data arrives, data parsed into %m0 on
Default:
'  Place X and value at point of data
^TEXT T0,%m0,.8,(BLUE),X-%m0
ENDMAC

'  Called when a double-click takes place on plot
DBLCLICK:
'  Place a circle at the point of double-click
~FCIR (XR),(YR),2a,(RED)
'  Sound a wav file
~IWAV punch.wav
ENDMAC

'Called when interval timer times out
TIMER:
'  Erase old time with white box
~FREC 70a,101a,100a,110a,(WHITE)
'  Show current time in red
~TEXT 80a,105a,1,(RED),Time is: (RTIME)
ENDMAC

'Called when plot resets
RESET:
^Text 20a,105a,2,(GREEN),Plot Reset!
^PWAV flush.wav
ENDMAC


*************************