Changeset 9007 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
07/17/08 16:12:18 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9006 r9007  
    8585     - use telescope number as argument
    8686     - simplified and improved
     87
     88   * datacenter/macros/filldotrun.C:
     89     - some changes to output
     90     - skip comment line at the beginning
     91     - skip the line with the telescope number
     92     - removed ISNULL from telescope/run/file check
     93     - added fPriority to RunProcessStatus
     94     - added telescope und file number to RunData and RunProcessStatus
    8795
    8896
  • trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C

    r8996 r9007  
    4444//
    4545/////////////////////////////////////////////////////////////////////////////
    46 
    4746#include <iostream>
    4847#include <iomanip>
    4948#include <fstream>
    5049
    51 #include <TSQLRow.h>
    52 #include <TSQLResult.h>
     50#include <TPRegexp.h>
    5351
    54 #include "MSQLServer.h"
     52#include "MSQLMagic.h"
    5553
    5654using namespace std;
    5755
    58 
    59 int resetallruns(TString filename, TString column)
     56int resetallruns(TString filename, TString column, Bool_t dummy=kTRUE)
    6057{
    61     MSQLServer serv("sql.rc");
     58    MSQLMagic serv("sql.rc");
    6259    if (!serv.IsConnected())
    6360    {
     
    6562        return 0;
    6663    }
     64
    6765    cout << "resetallruns" << endl;
    6866    cout << "------------" << endl;
     
    7068    cout << "Connected to " << serv.GetName() << endl;
    7169    cout << endl;
     70    cout << "File:   " << filename << endl;
     71    cout << "Column: " << column << endl;
     72    cout << endl;
    7273
    73     //reset column to NULL
    74     TString query(Form("UPDATE RunProcessStatus SET %s=NULL",
    75                        column.Data()));
    76     //if the column is fCaCoFileAvail, reset also the column fCaCoFileFound
     74    serv.SetIsDummy(dummy);
     75
     76    //reset column to NULL, if the column is fCaCoFileAvail,
     77    //reset also the column fCaCoFileFound
     78    TString vars(column);
     79    vars += "=NULL";
    7780    if (column.Contains("CaCo"))
    78         query+=", fCaCoFileFound=NULL";
     81        vars += ", fCaCoFileFound=NULL";
    7982
    80     cout << "q: " << query << endl;
    81 
    82     TSQLResult *res = serv.Query(query);
    83     if (!res)
    84     {
    85         cout << "updating (setting " << column.Data() << "= NULL) didn't work " << endl;
    86         return 0;
    87     }
    88     delete res;
    89 
     83    if (serv.Update("RunProcessStatus", vars)==kFALSE)
     84        return 2;
    9085
    9186    //read in file
     
    9388    if (!fin)
    9489    {
    95         cout << "file: " << filename << " missing!" << endl;
    96         return 0;
     90        cout << "ERROR - File " << filename << " missing!" << endl;
     91        return 2;
    9792    }
     93
     94    TPRegexp regtel("^_M[0-9]_");
     95    TPRegexp regrun("_[0-9]{5,8}");
     96    TPRegexp regfile("[.][0-9]{3,5}_$");
    9897    while (1)
    9998    {
    10099        //get runnumber
    101         TString runnumber;
    102         runnumber.ReadLine(fin);
     100        TString str;
     101        str.ReadLine(fin);
    103102        if (!fin)
    104103            break;
    105104
     105        const TString tel  = str(regtel);
     106        const TString run  = str(regrun);
     107        const TString file = str(regfile);
     108
     109        const UInt_t ntel  = tel.IsNull()  ? 1 : atoi(tel.Data()+2);
     110        const UInt_t nfile = file.IsNull() ? 0 : atoi(file.Data()+1);
     111        const UInt_t nrun  = atoi(run.Data()+1);
     112
     113        if (nrun>999999 && (tel.IsNull() || file.IsNull()))
     114        {
     115            cout << "ERROR - Run number " << nrun << ">999999 and telescope and/or run-number missing!" << endl;
     116            cout << str << endl;
     117            continue;
     118        }
     119
     120        const UInt_t id = nrun*1000+nfile;
     121
    106122        //build query and set status for this run to Now()
    107         TString query(Form("UPDATE RunProcessStatus SET %s=Now()", column.Data()));
     123        TString vars2(column);
     124        vars2 += "=Now()";
     125        if (column.Contains("CaCo"))
     126            vars2 += Form(", fCaCoFileFound=%d", id);
    108127
    109         if (column.Contains("CaCo"))
    110             query+=Form(", fCaCoFileFound=%d", atoi(runnumber));
     128        TString where = Form("fTelescopeNumber=%d AND fRunNumber=%d AND fFileNumber=%d ",
     129                             ntel, nrun, nfile);
    111130
    112         query+=Form(" WHERE fRunNumber=%d ", atoi(runnumber));
    113 
    114         cout << "q2: " << query << endl;
    115 
    116         res = serv.Query(query);
    117         if (!res)
    118         {
    119             cout << "updating (setting " << column.Data() << " = Now()) for run# " << atoi(runnumber) << ") didn't work " << endl;
    120             return 0;
    121         }
    122         delete res;
     131        if (serv.Update("RunProcessStatus", vars2, where)==kFALSE)
     132            return 2;
    123133    }
    124134
    125135    return 1;
    126136}
    127 
    128 
Note: See TracChangeset for help on using the changeset viewer.