00001 #include <config/ConfigObject.h>
00002 #include <config/Change.h>
00003 #include "SCT_Chip.h"
00004
00005 namespace SCTDAL {
00006 const std::string SCT_Chip::s_class_name("SCT_Chip");
00007
00008
00009
00010 SCT_Chip::SCT_Chip(::Configuration& db, ::ConfigObject& o) :
00011 DalObject(db, o) {
00012 }
00013
00014
00015 void SCT_Chip::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 SCT_Chip object:\n"
00022 << str << " id: \'" << UID() << "\', class name: \'" << class_name() << "\'\n";
00023 }
00024
00025
00026
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 << " address: " << address() << std::endl;
00031 s.setf(std::ios::dec, std::ios::basefield);
00032 s << str << " active: " << active() << std::endl;
00033 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00034 s << str << " vthr: " << vthr() << std::endl;
00035 s.setf(std::ios::dec, std::ios::basefield);
00036 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00037 s << str << " vcal: " << vcal() << std::endl;
00038 s.setf(std::ios::dec, std::ios::basefield);
00039 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00040 s << str << " delay: " << delay() << std::endl;
00041 s.setf(std::ios::dec, std::ios::basefield);
00042 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00043 s << str << " preamp: " << preamp() << std::endl;
00044 s.setf(std::ios::dec, std::ios::basefield);
00045 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00046 s << str << " shaper: " << shaper() << std::endl;
00047 s.setf(std::ios::dec, std::ios::basefield);
00048 s << str << " rc_function: " << rc_function() << std::endl;
00049 s << str << " rc_function_type: " << rc_function_type() << std::endl;
00050 if( !m_config.empty() ) {
00051 s << str << " " << m_config.size() << " value(s) in config: ";
00052 for(std::vector<unsigned short>::const_iterator i = m_config.begin(); i != m_config.end(); ++i) {
00053 if(i != m_config.begin()) s << ", ";
00054 s << *i;
00055 }
00056 s << std::endl;
00057 }
00058 else {
00059 s << str << " config value is empty\n";
00060 }
00061 s << str << " c_factor: " << c_factor() << std::endl;
00062 s << str << " target: " << target() << std::endl;
00063 if( !m_trims.empty() ) {
00064 s << str << " " << m_trims.size() << " value(s) in trims: ";
00065 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00066 for(std::vector<unsigned long>::const_iterator i = m_trims.begin(); i != m_trims.end(); ++i) {
00067 if(i != m_trims.begin()) s << ", ";
00068 s << *i;
00069 }
00070 s.setf(std::ios::dec, std::ios::basefield);
00071 s << std::endl;
00072 }
00073 else {
00074 s << str << " trims value is empty\n";
00075 }
00076 if( !m_mask.empty() ) {
00077 s << str << " " << m_mask.size() << " value(s) in mask: ";
00078 s.setf(std::ios::hex, std::ios::basefield); s.setf(std::ios::showbase);
00079 for(std::vector<unsigned long>::const_iterator i = m_mask.begin(); i != m_mask.end(); ++i) {
00080 if(i != m_mask.begin()) s << ", ";
00081 s << *i;
00082 }
00083 s.setf(std::ios::dec, std::ios::basefield);
00084 s << std::endl;
00085 }
00086 else {
00087 s << str << " mask value is empty\n";
00088 }
00089 }
00090
00091
00092 std::ostream&
00093 operator<<(std::ostream& s, const SCT_Chip * obj)
00094 {
00095 s << '\'';
00096
00097 if(obj == 0) {
00098 s << "(null)";
00099 }
00100 else {
00101 obj->config_object().print_ptr(s);
00102 }
00103 s << '\'';
00104
00105 return s;
00106 }
00107
00108
00109 std::ostream&
00110 operator<<(std::ostream& s, const SCT_Chip & obj)
00111 {
00112 if(&obj == 0) {
00113 s << "(null)";
00114 }
00115 else {
00116 obj.print(0, true, s);
00117 }
00118
00119 return s;
00120 }
00121
00122
00123 void SCT_Chip::update(::Configuration& conf, const ::ConfigurationChange * change)
00124 {
00125 conf.update<SCT_Chip>(change->get_modified_objs(), change->get_removed_objs());
00126 }
00127
00128
00129 void SCT_Chip::reset(::Configuration& conf, bool re_initialise_obj)
00130 {
00131 conf.reset_objects<SCT_Chip>(re_initialise_obj);
00132 }
00133
00134
00135 void SCT_Chip::init(bool )
00136 {
00137 p_was_read = true;
00138 increment_read();
00139 static const char * env = ::getenv("TDAQ_REPORT_DAL_OBJECT_READ");
00140 if(env) { std::cout << "DEBUG: read object " << this << std::endl; }
00141
00142 if(!p_obj.get("id",m_id)) {
00143 std::cerr << "ERROR: could not find attribute 'id'\n";
00144 }
00145 else {
00146 p_db.convert(m_id, p_obj, "id");
00147 }
00148
00149 if(!p_obj.get("address",m_address)) {
00150 std::cerr << "ERROR: could not find attribute 'address'\n";
00151 }
00152 else {
00153 p_db.convert(m_address, p_obj, "address");
00154 }
00155
00156 if(!p_obj.get("active",m_active)) {
00157 std::cerr << "ERROR: could not find attribute 'active'\n";
00158 }
00159 else {
00160 p_db.convert(m_active, p_obj, "active");
00161 }
00162
00163 if(!p_obj.get("vthr",m_vthr)) {
00164 std::cerr << "ERROR: could not find attribute 'vthr'\n";
00165 }
00166 else {
00167 p_db.convert(m_vthr, p_obj, "vthr");
00168 }
00169
00170 if(!p_obj.get("vcal",m_vcal)) {
00171 std::cerr << "ERROR: could not find attribute 'vcal'\n";
00172 }
00173 else {
00174 p_db.convert(m_vcal, p_obj, "vcal");
00175 }
00176
00177 if(!p_obj.get("delay",m_delay)) {
00178 std::cerr << "ERROR: could not find attribute 'delay'\n";
00179 }
00180 else {
00181 p_db.convert(m_delay, p_obj, "delay");
00182 }
00183
00184 if(!p_obj.get("preamp",m_preamp)) {
00185 std::cerr << "ERROR: could not find attribute 'preamp'\n";
00186 }
00187 else {
00188 p_db.convert(m_preamp, p_obj, "preamp");
00189 }
00190
00191 if(!p_obj.get("shaper",m_shaper)) {
00192 std::cerr << "ERROR: could not find attribute 'shaper'\n";
00193 }
00194 else {
00195 p_db.convert(m_shaper, p_obj, "shaper");
00196 }
00197
00198 if(!p_obj.get("rc_function",m_rc_function)) {
00199 std::cerr << "ERROR: could not find attribute 'rc_function'\n";
00200 }
00201 else {
00202 p_db.convert(m_rc_function, p_obj, "rc_function");
00203 }
00204
00205 if(!p_obj.get("rc_function_type",m_rc_function_type)) {
00206 std::cerr << "ERROR: could not find attribute 'rc_function_type'\n";
00207 }
00208 else {
00209 p_db.convert(m_rc_function_type, p_obj, "rc_function_type");
00210 }
00211
00212 if(!p_obj.get("config",m_config)) {
00213 std::cerr << "ERROR: could not find attribute 'config'\n";
00214 }
00215 else {
00216 p_db.convert2(m_config, p_obj, "config");
00217 }
00218
00219 if(!p_obj.get("c_factor",m_c_factor)) {
00220 std::cerr << "ERROR: could not find attribute 'c_factor'\n";
00221 }
00222 else {
00223 p_db.convert(m_c_factor, p_obj, "c_factor");
00224 }
00225
00226 if(!p_obj.get("target",m_target)) {
00227 std::cerr << "ERROR: could not find attribute 'target'\n";
00228 }
00229 else {
00230 p_db.convert(m_target, p_obj, "target");
00231 }
00232
00233 if(!p_obj.get("trims",m_trims)) {
00234 std::cerr << "ERROR: could not find attribute 'trims'\n";
00235 }
00236 else {
00237 p_db.convert2(m_trims, p_obj, "trims");
00238 }
00239
00240 if(!p_obj.get("mask",m_mask)) {
00241 std::cerr << "ERROR: could not find attribute 'mask'\n";
00242 }
00243 else {
00244 p_db.convert2(m_mask, p_obj, "mask");
00245 }
00246
00247 p_obj.clear();
00248 }
00249
00250 SCT_Chip::~SCT_Chip()
00251 {
00252 }
00253
00254 }