Channel.cpp

00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "Channel.h"
00004 
00005 namespace SCTDAL {
00006   const std::string Channel::s_class_name("Channel");
00007 
00008     // the constructor
00009 
00010   Channel::Channel(::Configuration& db, ::ConfigObject& o) :
00011     DalObject(db, o)  {
00012   }
00013 
00014 
00015   void Channel::print(unsigned int indent, bool print_header, std::ostream& s) const
00016   {
00017     std::string str(indent, ' ');
00018 
00019     if(print_header) {
00020       s
00021         << str << "SCTDAL Channel object:\n"
00022         << str << "  id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00023     }
00024 
00025 
00026       // print direct attributes
00027 
00028     s << str << "  id: " << id() << std::endl;
00029     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00030     s << str << "  outputCurrent: " << outputCurrent() << std::endl;
00031     s.setf(std::ios::dec, std::ios::basefield);
00032     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00033     s << str << "  outputDelay: " << outputDelay() << std::endl;
00034     s.setf(std::ios::dec, std::ios::basefield);
00035     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00036     s << str << "  outputMarkSpace: " << outputMarkSpace() << std::endl;
00037     s.setf(std::ios::dec, std::ios::basefield);
00038     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00039     s << str << "  stream0Threshold: " << stream0Threshold() << std::endl;
00040     s.setf(std::ios::dec, std::ios::basefield);
00041     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00042     s << str << "  stream0Delay: " << stream0Delay() << std::endl;
00043     s.setf(std::ios::dec, std::ios::basefield);
00044     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00045     s << str << "  stream0ErrMask: " << stream0ErrMask() << std::endl;
00046     s.setf(std::ios::dec, std::ios::basefield);
00047     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00048     s << str << "  stream1Threshold: " << stream1Threshold() << std::endl;
00049     s.setf(std::ios::dec, std::ios::basefield);
00050     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00051     s << str << "  stream1Delay: " << stream1Delay() << std::endl;
00052     s.setf(std::ios::dec, std::ios::basefield);
00053     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00054     s << str << "  stream1ErrMask: " << stream1ErrMask() << std::endl;
00055     s.setf(std::ios::dec, std::ios::basefield);
00056     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00057     s << str << "  outputFibre: " << outputFibre() << std::endl;
00058     s.setf(std::ios::dec, std::ios::basefield);
00059     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00060     s << str << "  stream0Fibre: " << stream0Fibre() << std::endl;
00061     s.setf(std::ios::dec, std::ios::basefield);
00062     s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00063     s << str << "  stream1Fibre: " << stream1Fibre() << std::endl;
00064     s.setf(std::ios::dec, std::ios::basefield);
00065   }
00066 
00067 
00068   std::ostream&
00069   operator<<(std::ostream& s, const Channel * obj)
00070   {
00071     s << '\'';
00072 
00073     if(obj == 0) {
00074       s << "(null)";
00075     }
00076     else {
00077       obj->config_object().print_ptr(s);
00078     }
00079     s << '\'';
00080 
00081     return s;
00082   }
00083 
00084 
00085   std::ostream&
00086   operator<<(std::ostream& s, const Channel & obj)
00087   {
00088     if(&obj == 0) {
00089       s << "(null)";
00090     }
00091     else {
00092       obj.print(0, true, s);
00093     }
00094 
00095     return s;
00096   }
00097 
00098 
00099   void Channel::update(::Configuration& conf, const ::ConfigurationChange * change)
00100   {
00101     conf.update<Channel>(change->get_modified_objs(), change->get_removed_objs());
00102   }
00103 
00104 
00105   void Channel::reset(::Configuration& conf, bool re_initialise_obj)
00106   {
00107     conf.reset_objects<Channel>(re_initialise_obj);
00108   }
00109 
00110 
00111   void Channel::init(bool /* init_children */)
00112   {
00113     p_was_read = true;
00114     increment_read();
00115     static const char * env = ::getenv("TDAQ_REPORT_DAL_OBJECT_READ");
00116     if(env) { std::cout << "DEBUG: read object " << this << std::endl; }
00117 
00118     if(!p_obj.get("id",m_id)) {
00119       std::cerr << "ERROR: could not find attribute 'id'\n";
00120     }
00121     else {
00122       p_db.convert(m_id, p_obj, "id");
00123     }
00124 
00125     if(!p_obj.get("outputCurrent",m_outputCurrent)) {
00126       std::cerr << "ERROR: could not find attribute 'outputCurrent'\n";
00127     }
00128     else {
00129       p_db.convert(m_outputCurrent, p_obj, "outputCurrent");
00130     }
00131 
00132     if(!p_obj.get("outputDelay",m_outputDelay)) {
00133       std::cerr << "ERROR: could not find attribute 'outputDelay'\n";
00134     }
00135     else {
00136       p_db.convert(m_outputDelay, p_obj, "outputDelay");
00137     }
00138 
00139     if(!p_obj.get("outputMarkSpace",m_outputMarkSpace)) {
00140       std::cerr << "ERROR: could not find attribute 'outputMarkSpace'\n";
00141     }
00142     else {
00143       p_db.convert(m_outputMarkSpace, p_obj, "outputMarkSpace");
00144     }
00145 
00146     if(!p_obj.get("stream0Threshold",m_stream0Threshold)) {
00147       std::cerr << "ERROR: could not find attribute 'stream0Threshold'\n";
00148     }
00149     else {
00150       p_db.convert(m_stream0Threshold, p_obj, "stream0Threshold");
00151     }
00152 
00153     if(!p_obj.get("stream0Delay",m_stream0Delay)) {
00154       std::cerr << "ERROR: could not find attribute 'stream0Delay'\n";
00155     }
00156     else {
00157       p_db.convert(m_stream0Delay, p_obj, "stream0Delay");
00158     }
00159 
00160     if(!p_obj.get("stream0ErrMask",m_stream0ErrMask)) {
00161       std::cerr << "ERROR: could not find attribute 'stream0ErrMask'\n";
00162     }
00163     else {
00164       p_db.convert(m_stream0ErrMask, p_obj, "stream0ErrMask");
00165     }
00166 
00167     if(!p_obj.get("stream1Threshold",m_stream1Threshold)) {
00168       std::cerr << "ERROR: could not find attribute 'stream1Threshold'\n";
00169     }
00170     else {
00171       p_db.convert(m_stream1Threshold, p_obj, "stream1Threshold");
00172     }
00173 
00174     if(!p_obj.get("stream1Delay",m_stream1Delay)) {
00175       std::cerr << "ERROR: could not find attribute 'stream1Delay'\n";
00176     }
00177     else {
00178       p_db.convert(m_stream1Delay, p_obj, "stream1Delay");
00179     }
00180 
00181     if(!p_obj.get("stream1ErrMask",m_stream1ErrMask)) {
00182       std::cerr << "ERROR: could not find attribute 'stream1ErrMask'\n";
00183     }
00184     else {
00185       p_db.convert(m_stream1ErrMask, p_obj, "stream1ErrMask");
00186     }
00187 
00188     if(!p_obj.get("outputFibre",m_outputFibre)) {
00189       std::cerr << "ERROR: could not find attribute 'outputFibre'\n";
00190     }
00191     else {
00192       p_db.convert(m_outputFibre, p_obj, "outputFibre");
00193     }
00194 
00195     if(!p_obj.get("stream0Fibre",m_stream0Fibre)) {
00196       std::cerr << "ERROR: could not find attribute 'stream0Fibre'\n";
00197     }
00198     else {
00199       p_db.convert(m_stream0Fibre, p_obj, "stream0Fibre");
00200     }
00201 
00202     if(!p_obj.get("stream1Fibre",m_stream1Fibre)) {
00203       std::cerr << "ERROR: could not find attribute 'stream1Fibre'\n";
00204     }
00205     else {
00206       p_db.convert(m_stream1Fibre, p_obj, "stream1Fibre");
00207     }
00208 
00209     p_obj.clear(); // clear resources used by implementation
00210   }
00211 
00212   Channel::~Channel()
00213   {
00214   }
00215 
00216 }

Generated on Mon Feb 6 14:01:17 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6