Changeset 17727


Ignore:
Timestamp:
Apr 29, 2014, 4:15:57 PM (6 years ago)
Author:
tbretz
Message:
Read more data from getevent; some simplification to the global structure; decode trigger pattern
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/viewer/index.php

    r17722 r17727  
    111111    switch ($format)
    112112    {
     113    case 'd': $size = 8; break;
    113114    case 'L': $size = 4; break;
    114115    case 'S': $size = 2; break;
     
    143144$filename = "/daq/raw/".$y."/".$m."/".$d."/".$y.$m.$d."_".$r.".fits.fz";
    144145
     146if (!file_exists($filename))
     147    return header("HTTP/1.0 400 File '".$file."' not found.");
     148
    145149$file = popen("/home/fact/FACT++/getevent ".$filename." ".$event." 2> /dev/null", "r");
    146150if (!$file)
    147     return header('HTTP/1.0 400 Could not open file.');
     151    return header('HTTP/1.0 400 Could not open pipe.');
    148152
    149153$evt = array();
    150 
    151 $evt['numEvents']     = get($file, "L");
     154$fil = array();
     155
     156$fil['runType']       = fread($file, 80);
     157$fil['runStart']      = get($file, "d");
     158$fil['runEnd']        = get($file, "d");
     159$fil['drsFile']       = get($file, "s");
     160$fil['numEvents']     = get($file, "L");
    152161$evt['numRoi']        = get($file, "L");
    153162$evt['numPix']        = get($file, "L");
     
    161170    // Read the data and copy it from an associative array to an Array
    162171    // (this is just nicer and seems more logical)
    163     //$data   = array();
    164172    $binary = array();
    165173    for ($i=0; $i<$evt['numPix']; $i++)
     
    176184}
    177185
    178 //if (feof($file))
    179 //   return;
     186if (feof($file))
     187   return header('HTTP/1.0 400 Data from file incomplete.');
    180188
    181189pclose($file);
    182190
    183 if ($evt['numEvents']==0)
     191if ($fil['numEvents']==0)
    184192    return header('HTTP/1.0 400 Could not read event.');
    185193
    186 // =============================== Copy waveform =============================
    187 
     194// =========================== Decode trigger type ===========================
     195
     196$typ = $evt['triggerType'];
     197$evt['trigger'] = array();
     198if ($typ!=0 && ($typ & 0x8703)==0)
     199    array_push($evt['trigger'], "PHYS");
     200if (($typ&0x0100)!=0)
     201    array_push($evt['trigger'], "LPext");
     202if (($typ&0x0200)!=0)
     203    array_push($evt['trigger'], "LPint");
     204if (($typ&0x0400)!=0)
     205    array_push($evt['trigger'], "PED");
     206if (($typ&0x8000)!=0)
     207    array_push($evt['trigger'], "TIM");
     208if (($typ&0x0001)!=0)
     209    array_push($evt['trigger'], "EXT1");
     210if (($typ&0x0002)!=0)
     211    array_push($evt['trigger'], "EXT2");
     212
     213// =============================== Some data =================================
     214
     215require_once("neighbors.php");
     216
     217$rc['neighbors'] = $neighbors;
    188218$rc['event'] = $evt;
     219$rc['file']  = $fil;
    189220$rc['event']['index'] = $event;
    190221$rc['event']['pixel'] = $pixel;
     
    237268    //$v8->test   = array();;
    238269    //$v8->data   = array();
    239     $v8->event  = $evt;
    240     $v8->clone  = function($data) { return $data; };
    241     $v8->unpack = function($i)
     270    $v8->nroi      = $evt['numRoi'];
     271    $v8->npix      = $evt['numPix'];
     272    $v8->trigger   = $evt['trigger'];
     273    $v8->event     = $evt;
     274    $v8->file      = $fil;
     275    $v8->neighbors = $neighbors;
     276    $v8->clone     = function($data) { return $data; };
     277    $v8->unpack    = function($i)
    242278    {
    243279        global $binary, $roi;
Note: See TracChangeset for help on using the changeset viewer.