Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

SummaryWriter.cpp

Go to the documentation of this file.
00001 #include "SummaryWriter.h"
00002 
00003 #include "Sct/SctParameters.h"
00004 #include "Sct/SctNames.h"
00005 #include "SctData/ModuleDefectList.h"
00006 #include "SctData/ModuleDefect.h"
00007 #include "SctData/TestResult.h"
00008 #include "SctData/ConfigurationVariable.h"
00009 #include "SctData/Stat.h"
00010 #include "Sct/Version.h"
00011 #include <boost/date_time/posix_time/posix_time.hpp>
00012 #include <unistd.h>
00013 
00014 using namespace std;
00015 
00016 namespace SctData {
00017     namespace TestSummary{
00018 
00019     SummaryWriter::SummaryWriter() {}
00020 
00021     SummaryWriter::~SummaryWriter() {}
00022         
00023         string getHostName() {
00024             char name[255];
00025         if (gethostname(name, 255)) return "";
00026             return string(name);
00027         }
00028 
00029     void SummaryWriter::writeHeader(const TestResult& r, ostream& out) const throw() {
00030         boost::posix_time::ptime t(boost::posix_time::second_clock::local_time());
00031         out << "#\n%NewTest\n#\n" ;
00032         out << "SERIAL NUMBER    : " << r.getModuleName() <<endl;
00033         out << "TEST MADE BY     : " << SctNames::getUser() << endl;
00034         out << "LOCATION MADE    : " << SctNames::getLocation() << endl;
00035         out << "Run number       : " << r.getRunNumber() << "-" << r.getScanNumberAt(0) << endl;
00036         out << "TEST_DATE        : " << (short)t.date().day() << "/" << (short)t.date().month() << "/" << (short)t.date().year() << endl;
00037         out << "PASSED           : " ;
00038         if (r.getPassed()) out << "YES";
00039         else out << "NO";
00040         out << endl; 
00041         out << "PROBLEM          : ";
00042         if (r.getProblem()) out << "YES";
00043         else out << "NO";
00044         out << endl;
00045         out << "#\n%DAQ_INFO\n#HOST\n\"" << getHostName() << "\"" << endl;
00046         out << "VERSION \n" << Sct::VersionString << endl;
00047         out << "#DUT\n\"module\"" << endl;
00048         out << "#TIME\n\"" << boost::posix_time::to_simple_string(t.time_of_day()) << "\"\n#" << endl;
00049         
00050         vector<string> comments = r.getComments();
00051         out << endl;
00052         for (unsigned int i=0; i<comments.size(); ++i) {
00053         out << "%Comment" << endl << "COMMENT          : " << comments[i] << endl;
00054         }
00055         
00056         if (r.getNScans()>1){
00057         out << "%SCAN_INFO\n#"<<endl;
00058         out << "#POINT_TYPE\n" << r.getTestVariable().getVariableName() << endl;
00059         out << "#N_POINTS\n" << r.getNScans() << endl;
00060         out << "#POINTS";
00061         for (unsigned ipt=0; ipt<r.getNScans(); ++ipt){
00062             if (ipt%8==0) out << "\n";
00063             out << r.getTestPointAt(ipt) << "\t";
00064         }
00065         out << "\n#" << endl;
00066         }
00067     }
00068     
00069     void SummaryWriter::write(const ModuleDefectList& list, std::ostream& out) const throw(Sct::IoError, Sct::LogicError){
00070         const vector< shared_ptr<const ModuleDefect > >& defects = list.getAllDefects(); 
00071 
00072         if ( defects.empty() ){
00073         out << "#No defects found\n#" << endl; return;
00074         }
00075 
00076         unsigned largestDefect=0;
00077 
00078         Stats<int> channels(nChannelModule, Stat<int>(0, true) );
00079 
00080         for (unsigned i=0; i< defects.size() ; ++i ){
00081         const ModuleDefect& d  = *defects[i];
00082         const ModuleElement& e = d.getModuleElement();
00083 
00084         for (unsigned ichannel = e.getFirst(); ichannel <= e.getLast(); ++ichannel ){
00085             channels.modifyAt(ichannel).valid=false;
00086         }
00087         
00088         if (e.getNChannels() > largestDefect) largestDefect=e.getNChannels() ;
00089         
00090         out << "%Defect" << endl;
00091         out << "DEFECT NAME           : " << defects[i]->getName()<<endl;
00092         out << "FIRST CHANNEL         : " << defects[i]->getModuleElement().getFirst()<<endl;
00093         out << "LAST CHANNEL          : " << defects[i]->getModuleElement().getLast()<<endl;
00094         out << "#"<<endl;
00095         }
00096         out << "#" << defects.size() << " defects found" 
00097         << " affecting " << nChannelModule-channels.n() << " strips\n"
00098         <<  "#" << largestDefect << " maximum consecutive defects\n#"<< endl;
00099     }
00100     
00101     string SummaryWriter::getChipName(const unsigned short ichip) throw() {
00102         short unsigned id=ichip;
00103         if (id>=6) id+=2;
00104         switch(id){
00105         case (0) : return string("M0"); break;
00106         case (5) : return string("E5"); break;
00107         case (8) : return string("M8"); break;
00108         case (13) : return string("E13"); break;
00109         default : {
00110         char name[5];
00111         sprintf(name,"S%d",id);
00112         return string(name);
00113         break; 
00114         }
00115         }
00116     }
00117     }
00118 }

Generated on Mon Dec 15 19:36:19 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3