The following parameters for the configuration of SPRAY simulations can be set by OLE automation controllers:
Number of rays/spectral point:
This parameter is set using the photons property (integer). The command
spray.photons = 2000
sets the number of rays/spectral point to 2000. You can read the current value this way:
a_variable = spray.photons
Minimum of spectral range:
Change this parameter using the spectral_min property (float). The command
spray.spectral_min = 435.3
sets the spectral minimum to 453.3 . You can read the current value this way:
a_variable = spray.spectral_min
Maximum of spectral range:
This parameter is set using the spectral_max property (float). The command
spray.spectral_max = 1100
sets the spectral maximum to 1100. You can read the current value this way:
a_variable = spray.spectral_max
Number of spectral points:
The property (integer) 'spectral_points' has to be used when the number of spectral points for SPRAY computations is to be modified:
spray.spectral_points = 120
The current value of this parameter is obtained this way:
a_variable = spray.spectral_points
Doing the simulation:
Ray-tracing simulations may take a long time. Some OLE automation clients like Excel do not wait long enough for lengthy computations to be finished, and raise a warning dialog which blocks the execution of the VisualBasic code. This behaviour completely destroys the automation: You have to click the OK button of the dialog every 10 minutes or so to continue in the VisualBasic code.
In order to avoid this problem SPRAY creates a simulation thread which does the ray-tracing work in the background. In the foreground, SPRAY will continue to listen to OLE commands. Hence you can start the SPRAY simulation, and then let Excel execute a loop until SPRAY has finished its work. The SPRAY property status gives information about the number of processed rays. If it is negative, SPRAY has finished the simulation and Excel can close its waiting loop.
The following few VisualBasic lines implement this strategy:
dim rays as long ' variable holding the number of processed rays
Spray.start_simulation 'Start the SPRAY simulation
Do
Application.Wait Now + TimeSerial(0, 0, 2) 'Excel waits for 2 seconds
rays = Spray.Status 'Excel reads the number of processed rays
Application.StatusBar = rays 'Excel indicates the number of rays in the status bar
Loop While (rays > -1) 'Loop finished if SPRAY has done its work
You could now start routines that readout the results from detectors or screens.