Skip to content

Accessing ray data within a SCP or CCL macro

Question

I would like to get paraxial PY and PUY at different surfaces as well as real ray trace values. How do I extract ray data within a CCL or SCP macro command? Please note that OSLO contains two macro-programming languages:

CCL - Compiled Command Language (a compiled programming language)
SCP - Star Command Program (an interpreted programming language)

Virtually anything you can do from the user interface can be accomplished through the OSLO programming languages. Both are based on the "C" programming language. Although similar, CCL is more full-featured than SCP (SCP could be considered to be almost a subset of CCL). If you plan on spending the time to learn one OSLO programming language, it is recommended that you learn CCL.

Synopsis

Accessing ray data within an SCP or CCL macro

 

Workaround

In lieu of global variables, the current situation is that the user can access ray data through the "Spreadsheet Buffer". The concept is that any non-integer numeric data that is sent to the text window is also sent to the Spreadsheet Buffer. Data in the Spreadsheet Buffer can then be accessed by CCL and SCP commands. This arrangement creates a very powerful and flexible situation: Virtually any data that gets printed to the text window can be re-used by the user in custom CCL or SCP programs. For further explanation of the available Global Variables that can be accessed through OSLO program commands, go to the on-line help item:
 Contents>>Programming>>Accessing Data>>CCL Global Data
For further explanation of the Spreadsheet Buffer and how it can be implemented, go to the on-line help item:
 Contents>>Programming>>Accessing Data>>Spreadsheet Buffer
Information about programming in CCl and SCP is sprinkled throughout the OSLO documentation (the OSLO manuals, the OSLO on-line help, and the Lambda web site). The basics of the CCL and SCP language cna be found in the on-line help pages:
 Contents>>Programming>>CCL Programming Contents>>Programming>>CCL Programming>>CCL Language Elements
and,
 Contents>>Programming>>SCP Programming Contents>>Programming>>SCP Programming>>SCP Language Elements

Solution

Below are examples of how to access paraxial ray data in both CCL and SCP program code using the Spreadsheet Buffer. From looking at the examples, it should be evident how to extend them to access real ray data and virtually any other numeric data that gets printed to the text window:

CCL CODE EXAMPLE:cmd get_pxraydata(int surfnum){int ssb_row_sav;double py, pu, pyc, puc;// Turn off output to the text window (but not the spreadsheet buffer)set_preference(outp, off);// Save current state of spreadsheet bufferssb_row_sav = sbrow;// Reset the origin of the spreadsheet buffer // and clear image_surface+1 rows in advance (accounting for surface 0)ssbuf_reset(ssb_row_sav, ims+1);// Trace paraxial ray for a given surfaceparaxial_trace(all);// Extract the data and put into local variables:// Note that ssb(1,5) returns the numeric data in row=1, column=5// The data in this particular cell of the spreadsheet buffer // can also be accessed via the global variable E1 py = ssb(surfnum+1, 1); // pypu = ssb(surfnum+1, 2); // pupyc = ssb(surfnum+1, 4); // pycpuc = ssb(surfnum+1, 5); // puc// Restore spreadsheet buffer to previous statessbuf_reset(-ssb_row_sav, ims+1);// Turn on the output to the text windowset_preference(output_text, on); print("Paraxial Ray Data on surface", surfnum, ": ", py, pu, pyc, puc);}

SCP CODE EXAMPLE:*get_pxraydata // Surface number should be entered as argument #1 (Arg1)// Arg1 and all the letters of the alphabet are pre-defined global variables//// Redefine real variable, Arg1, as integer variable, i i = r2int(Arg1); // Turn off output to the text window (but not the spreadsheet buffer)set_preference(outp, off);// Save current state of spreadsheet bufferk = sbrow;// Reset the origin of the spreadsheet buffer // and clear image_surface+1 rows in advance (accounting for surface 0)ssbuf_reset(k, ims+1);// Trace paraxial ray for all surfacesparaxial_trace(all);// Extract the data and put into local variables:// Note that ssb(1,5) returns the numeric data in row=1, column=5// the data in this particular cell of the spreadsheet buffer // can also be accessed via the global variable E1 a = ssb(i+1, 1); // pyb = ssb(i+1, 2); // puc = ssb(i+1, 4); // pycd = ssb(i+1, 5); // puc// Restore spreadsheet buffer to previous statessbuf_reset(-k, ims+1);// Turn on the output to the text windowset_preference(output_text, on); //print("Paraxial Ray Data on surface", i, ": ", a, b, c, d);