HELP
How does it work?
When you submit a javascript to the server, it will be executed
on a sandbox on the server. Before the event is loaded from a file
and made available within the sandbox. Generally, the sandbox
can easily be enhanced, e.g. with algorithms available in php.
This can be done on request. After execution, the result returned
by the script is then displayed in the camera display.
Why Javascript?
Simply for security reasons. To avoid tranferring the event to the client's
browser, the script must be executed on the server side. Also Python
and PHP offer the possibility to execute scripts within a program,
they do not have any security feature to avoid for exmple access to the
local disk. The V8 Javascript engine however, is very limited in
functionality and therefore ideally suited for a sandboxed and
therefore safe excution on the server. Any other solution is welcome.
Javascript hints!
Please note that in Javascript only basic data typed (number, etc)
are copied in an assignment. In all other cases, only a reference
is copied. For example, the following code snippet does not return 2
as you might expect but 7!
var arr = [ 0, 1, 2, 3 ];
var cpy = arr;
cpy[2] = 7;
print(arr[2]);
To avoid that, the global namespace implements a clone function.
For exmaple, the following code snippet will return the expected output:
var arr = [ 0, 1, 2, 3 ];
var cpy = $.clone(arr);
cpy[2] = 7;
print(arr[2]);
The global object $
The environment provides a global object (namesapce) called $ with the following members:
$.event | The event header information as obtained from the file |
$.event.numEvents | Number of events in the file |
$.event.numRoi | Number of samples per pixel |
$.event.numPix | Number of pixels |
$.event.eventNumber | Event number |
$.event.triggerNumber | Trigger number |
$.event.triggerType | Trigger type |
$.event.unixTime[2] | Timestamp when the event arrived at the event builder |
$.data[numPix][numRoi] | Theevent data |
Editor 1 (proc)
proc can return an array with numRoi entries or an array with up to
four sub-arrays each of nRoi entries. They will be displayed in the graph.
The chosel pixel is available as
pixel.
The most simple is to just return the selected pixel data unprocssed:
return $.data[pixel];
Editor 2 (main)
main should return extracted data per pixel. As
proc it can
return a single array or an array with up to four sub-arrays each with
numPix entries. They are displayed in the camera displays. The function
implemented as
proc is accessible as
proc(i) with
i
being available in
proc as
pixel. A very simple extractor
could be to return just the sample at the trigger position
var rc = [];
for (var i=0; i<$.event.numPix; i++)
rc[i] = $.data[i][60];
return rc;
or taking the data pre-procesed by the code of the
proc-function:
var rc = [];
for (var i=0; i<$.event.numPix; i++)
rc[i] = proc(i)[60];
return rc;
Note that the precise access to the result of proc might depend on what
exactly is retruned by proc (an array, or an array with sub-arrays).
What is the data?
The data are all data files found in disks in La Palma (to be precise:
on daq's disks). The data is raw-data but with the most recent
DRS calibration (only the 1024-cell offset calibration)
applied, while the application is done in intergers, i.e. the
fractional part of the calibration constant is removed.
(This is basically what is written in our FITS files as part of the
lossless compression process). No spike or jump removal is applied.
The editor
Key bindings of the editor can be found at
Codemirror.
In addition the following binding are defined: Tab - Auto indent;
F11 - Switch to fullscreen; Esc - In fullscreen mode to
leave fullscreen; Ctrl-r - replace; Ctrl-y - Delete the line under the cursor;
Ctrl-. (dot) - Fold code; Ctrl-Down (cursor down) - Autocomplete.
How to change the file?
Start typing the date in the filename field. The available files
will be filtered as you type. To select a file you need to select
it fom the pull down.
How to change the displayed pixel?
Enter the pixel number on the corresponding field or its hwardware
address. As soon as you acknowledge your change (e.g. remove focus
by clicking somewhere else) the pixel contents gets displayed.
How to Save/Load a script?
To load a file choose a file fro your local hard drive via the
file selection dialog. To save the contents of the editor, press
Save.
Submit
If you have changed the script and you want to run it on the current event
press Submit. The Javascript will be executed for this event on
the server.
Pixel value
To display the value returned for a pixel just click on the pixel.
The value will be displayed in the Pixel field. This will also
display the corresponding waveform in the graph.
Min/max values
Min and max values for the plot and the graph can be determined
automatically or manully. To set the to a fixed value, enable the
min and/or max field and enter the value of your choice. It will
survive changing files, events or pixel.
Why is loading the page so slow?
The total contents of the javascript libraries is about 1MB which
all have to be treasferred to the browser. In addition the loading
and processing of the event takes up to 1s so that the loading
time of the page might be untypically slow. Once finished,
the amaount of code to load can be decreased.
How to unzoom the plot?
Double click on the plot.