// on creation of the object including the loop counter
System.Console.WriteLine(objectInfoForThread.ToString() + ": " + i.ToString());
// reduce the computation requirements by setting the current thread
// into sleep mode for a few milliseconds
Thread.Sleep(10);
i++;
}
}
}; // end of class
// create two object of type ThreadTest. Supply each object
// with additional information
var threadOne : ThreadTest = new ThreadTest("Erster Thread");
var threadTwo : ThreadTest = new ThreadTest("Zweiter Thread");
// start both threads
threadOne.StartThread();
threadTwo.StartThread();
// The JScript will run until both threads terminate.
// NOTE: the main thread of the JScript will terminate immediatelly
// after the two worker threads are started. Therefore the script
// dialog will ’think’ the JScript already terminated! If you want
// to avoid this, its necessary to wait here in the main thread until
// all worker thread have been terminated.
// uncomment the following lines to see the difference
threadOne.WaitThreadFinished();
threadTwo.WaitThreadFinished();
System.Console.WriteLine("Main thread ends now!");
12.6
Controlling Mini-MAX-DOAS (MiniDOAS) instru-
ments with JScript
This is the last and the longest script of the tutorial. It was provided by Denis P¨
ohler. It
hasn’t been tested by the author but was applied during several measurement campaigns
exactly in the way it is presented here.
12.6.1
Structure of the program
For that program it would have been of advantage to establish a so JScript project (see
section 4.2). The script can be divided into three parts:
1. The declaration of variables.
2. The main()-function.
3. The different functions used in the main()-function
Each of these three parts could have been placed in a separate JScript file and then called
from a JScript project file. This way the variables and functions would still be available for
73
further JScripts.
The main()-function only takes about one page out of the ten pages of the entire code. In
the main()-function the different functions declared towards the end of script are called.
The basic tasks of the Script can already understood by reading the main()-function only,
since all the other functions reveal their functionality more or less by their name. It is very
important that the main()-function itself is called at the end of the script.
12.6.2
Description of the tasks
The basic task of the script is very simple:
The MiniDOAS device changes the elevation angle of its line of sight in a predefined way
and records a spectrum for each elevation angle.
However, the script includes many special functions of different tasks:
• It continuously logs the voltage, current and temperature of the instrument (see
function WriteToLog()
• It calculates the solar zenith angle (SZA) (see function aurinko())for each measure-
ment for two reasons:
1. To interrupt the “normal” measurement mode after sunset and from that time
onwards only measure offset and dark current in a fixed position.
2. To save the SZA in the properties of the spectrum for later evaluation purposes.
• The function TakeSpectrum() automatically adapts the integration time to the cur-
rent light conditions by running several test scans and prolonging or shortening the
integration time according to the saturation of the spectrum.
12.6.3
Prerequisites
In the script several “ActiveXObjects” are used:
• WinDoasIO.FileIO
• WinDoasMath.DoasMath
• WinDoasTools.DoasTools
• Scripting.FileSystemObject
• HMTUSB.PDZControl
These can be understood a separate “programs” (such as Microsoft Excel, see section 12.1.1)
which can be accessed via JScript by ActiveXObjects. Therefore different drivers and pro-
grams must be installed. It showed in the past that as well the order of installation is
important. Here a list of the required drivers in the right order:
1. Ocean Optics software
2. InstallerHMTUSBDriver
3. InstallerHMTActiveXControll
4. DOASIS
5. If required Mini-Max Software (Udo Friess)
6. VNC
74
Of course the different file and path names mentioned in the script have to be adapted
accordingly.
import System;
import DoasCore;
import DoasCore.IO;
import DoasCore.Spectra;
import DoasCore.Math;
import DoasCore.Device;
// ************* Declarations of variables ***********************************
// controls the file handling similar to the AutoFileName() class in DOASIS
var dispIO = new ActiveXObject("WinDoasIO.FileIO");
// tool e.g. to correct offset and to calculate solar zenith angle
var dispMath = new ActiveXObject("WinDoasMath.DoasMath");
// tool for spectrum handling
var dispTools = new ActiveXObject("WinDoasTools.DoasTools");
// provides message boxes
var window = new DoasCore.HMI.OldUI();
// create an object which enables to store data in a text file
var dispFileSystem = new ActiveXObject("Scripting.FileSystemObject");
// provides access to "Hoffmann Messtechnik Elektronik (HMT)" which
// the stepper motors
var dispHMTUSB = new ActiveXObject("HMTUSB.PDZControl");
var serialHMT = "13291";
// serial of HMT hardware
var serialUSBHMT = "2E7150";
// serial saved in HMT hardware
var serialUSB2000 = "2E4670";
// serial of USB2000
var MeasSite = "Joelle_1";
var CampInit = "a1";
var Latitude = 42.0;
// south is negative
var Longitude = 8.0;
// west is negative
var ViewingAzimuth = 200;
// 0 is north
var SZAnight = 96;
var Tini=0;
// detector temperature
var CalOrder = 2;
var CalZero = 302.74;
var CalFirst : double = 0.087134;
var CalSecond : double = -9.0073e-6
var straylight = new Array();
var AngleSeries = new Array(90,20,10,5,2,1);
// multiples of 0.9
var AngleTimes
= new Array(1,1,1,1,1,1);
// reps for each angle
var MotorHorizontalPosition = 6000;
// horizontal was 6200
var MotorFrequency = 740;
// typical MiniDOAS = 740
var MotorOSDCPosition = -10;
// offset dark current position in degree
var MotorStep90 = 10000
// number of steps per 90
◦
var s;
var smin = 1;
// at least one scan
var tmax = 10000;
// maximum time per scan in ms
var smax = 1000;
// maximum number of scans
var t = 100;
// initial integration time
75