ChipConfigurationStreamer_v1.cpp

00001 #include "ChipConfigurationStreamer_v1.h"
00002 #include "../ChipConfiguration.h"
00003 #include "Sct/LogicErrors.h"
00004 #include <Sct/AbcdModule.h>
00005 
00006 namespace SctData {
00007 namespace IO {
00008 
00009 unsigned ChipConfigurationStreamer_v1::s_version=1;
00010 /* READ NOTES ON STREAMERS AND VERSIONS BEFORE EDITING THIS FILE! */
00011 
00012 ChipConfigurationStreamer_v1::ChipConfigurationStreamer_v1() throw() {}
00013     
00014 bool ChipConfigurationStreamer_v1::inMap = IOManager::addToMap("SctData::ChipConfiguration",  std::auto_ptr<Streamer>(new ChipConfigurationStreamer_v1()));
00015 
00016 
00017 shared_ptr<Streamable> ChipConfigurationStreamer_v1::read(IStream& in, const IOManager& manager) const throw(LogicError, IoError) {
00018   throw Sct::IllegalStateError("Can't create a ChipConfiguration from scratch, since constructor requires ABCDChip reference.", __FILE__, __LINE__);
00019   //    shared_ptr<Streamable> m (new ChipConfiguration());
00020   //  read(in, *m, manager);
00021   //  return m;
00022 }
00023 
00024 void ChipConfigurationStreamer_v1::write(OStream& out, const Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00025     const ChipConfiguration& config = dynamic_cast<const ChipConfiguration&>(ob);
00026     const ABCDChip& data=config.getConfig();
00027     out << data.active << data.address << data.target;
00028 
00029     //Config values
00030     out << (UINT16)data.basic.config.readoutMode << (UINT16)data.basic.config.calibMode << (UINT16)data.basic.config.trimRange;
00031     out << (UINT16)data.basic.config.edgeDetect << (UINT16)data.basic.config.mask << (UINT16)data.basic.config.accumulate;
00032     out << (UINT16)data.basic.config.inputBypass << (UINT16)data.basic.config.outputBypass << (UINT16)data.basic.config.master;
00033     out << (UINT16)data.basic.config.end << (UINT16)data.basic.config.feedThrough;
00034     
00035     out << (UINT8)data.basic.vthr << (UINT8)data.basic.vcal << (UINT8)data.basic.delay 
00036     << (UINT8)data.basic.preamp << (UINT8)data.basic.shaper;
00037     out.put(data.basic.mask, 4);
00038     
00039     //ABCDCalData
00040     out << data.caldata.rc_function;
00041     out.put(data.caldata.rc_params, 3);
00042     out << data.caldata.c_factor;
00043     out.put(data.trim, Sct::nChannelChip);    
00044 }
00045 
00046 void ChipConfigurationStreamer_v1::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00047     ChipConfiguration& config = dynamic_cast<ChipConfiguration&>(ob);
00048     ABCDChip& data=config.getConfig();
00049 
00050     in >> data.active >> data.address >> data.target;
00051     
00052     //ABCDBasic stuff:
00053     
00054     //Config values    
00055     UINT16 temp = 0;
00056     in >> temp;
00057     data.basic.config.readoutMode = temp;
00058     in >> temp;
00059     data.basic.config.calibMode = temp;
00060     in >> temp;
00061     data.basic.config.trimRange = temp;
00062     in >> temp;
00063     data.basic.config.edgeDetect = temp;
00064     in >> temp;
00065     data.basic.config.mask = temp;
00066     in >> temp;
00067     data.basic.config.accumulate = temp;
00068     in >> temp;
00069     data.basic.config.inputBypass = temp;
00070     in >> temp;
00071     data.basic.config.outputBypass = temp;
00072     in >> temp;
00073     data.basic.config.master = temp;
00074     in >> temp;
00075     data.basic.config.end = temp;
00076     in >> temp;
00077     data.basic.config.feedThrough = temp;
00078     
00079     in >> data.basic.vthr >> data.basic.vcal >> data.basic.delay >> data.basic.preamp >> data.basic.shaper;
00080     in.get(data.basic.mask, 4);
00081     
00082     //ABCDCalData
00083     in >> data.caldata.rc_function;
00084     //cout << "rc_function: " << (int)data.caldata.rc_function << endl;
00085     in.get(data.caldata.rc_params, 3);
00086     in >> data.caldata.c_factor;
00087     
00088     in.get(data.trim, Sct::nChannelChip);    
00089 }
00090 
00091 }
00092 }

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