#!/usr/bin/perl # Jaideep Singh # October 2003 #INPUT: a tab seperated file with the run numbers and the corresponding file name of the run summary halog html file #in this case the file is called "right.end" # #if your run summary file has a different format, then you'll need to modify this file to match the format that your file has use strict "subs"; #checking to see if EPICS data is corrupt sub checkval { $in = $_[0]; if ($in =~ /\!\!WARNING\!\! The executable \"caRepeater\" couldnt be located because of errno \= \"No such file or directory\" You may need to modify your PATH environment variable\. Creating CA repeater with fork\(\) system call\. Repeater will inherit parents process name and resources\. Duplicate resource consumption may occur\.\s*(.*)$/) {$in = $1}; if ((!($in))&&(!($in =~ /^0$/))) {$out = "\?"} else {$out = $in}; # print "the cv is $in\n"; return $out; }; #subroutine to calculate the time in seconds from a timestamp #note that the @mon2day array is true only for 2003 sub jtime { ($sec, $min, $hr, $day, $mon) = @_; # (31,28,31,30,31,30,31,31,30,31,30,31); @mon2day = (0,31,59,90,120,151,181,212,243,273,304,334); $totsec = $sec + 60*($min + 60*($hr + 24*($day -1 + $mon2day[$mon-1]))); return $totsec; }; #setting up a month name to number hash table %mon2num = ( "January" => "01", "February" => "02", "March" => "03", "April" => "04", "May" => "05", "June" => "06", "July" => "07", "August" => "08", "September" => "09", "October" => "10", "November" => "11", "December" => "12", "Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04", "May" => "05", "Jun" => "06", "Jul" => "07", "Aug" => "08", "Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12" ); #counting the number of run summary files for each run (sometimes there are multiple summaries) @recount = (0) x 5000; my @rend; open(RUNLIST,") { /(\d+)\t(.*)/; $rend[$1][$recount[$1]] = $2; $recount[$1]++; }; close(RUNLIST); #defining the reference time as April 20 my $tzero = jtime(0,0,0,20,4); my $firstrun = 999; my $lastrun = 4218; #number of variables to be recorded my $numdata = 284; #looping over every run number from $firstrun to $lastrun open(RUNOUT,">rightend.raw"); print RUNOUT "
\n";
RUN: for ($runnum=$firstrun;$runnum<=$lastrun;$runnum++) 
{for ($subrun=0;$subrun < $recount[$runnum];$subrun++)
  {
  open(TESTFILE,"<$rend[$runnum][$subrun]");
  $ld1 = $rd1 = $tiefa = $getcomm = 0;
  @data = ("\?") x $numdata;
#looping over ever line in the file
  LINE: while () 
	{
	$data[0] = $runnum;
	if (/User name ([^<]*)$temp<\/a>"; 
  $data[280] = jtime($data[3],$data[2],$data[1],$data[5],$data[4])-$tzero;
  $data[281] = jtime($data[110],$data[109],$data[108],$data[107],$data[106])-$tzero;
  $data[283] = 1+$subrun;
  close(TESTFILE);
  for ($j=0;$j<($numdata-1);$j++) {print RUNOUT "$data[$j]\t"};
  print RUNOUT "$data[283]\n";
  print "$data[0]\t$data[283]\n";
  };
};
close(RUNOUT);