00001 #include "ChipConfigurationStreamer_v1.h"
00002 #include "../ChipConfiguration.h"
00003 #include "Sct/LogicErrors.h"
00004 #include <CommonWithDsp/sctStructure.h>
00005
00006 namespace SctData {
00007 namespace IO {
00008
00009 unsigned ChipConfigurationStreamer_v1::s_version=1;
00010
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
00020
00021
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
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 << data.basic.vthr << data.basic.vcal << data.basic.delay << data.basic.preamp << data.basic.shaper;
00036 out.put(data.basic.mask, 4);
00037
00038
00039 out << data.caldata.rc_function;
00040 out.put(data.caldata.rc_params, 3);
00041 out << data.caldata.c_factor;
00042 out.put(data.trim, Sct::nChannelChip);
00043 }
00044
00045 void ChipConfigurationStreamer_v1::read(IStream& in, Streamable& ob, const IOManager& manager) const throw(LogicError, IoError) {
00046 ChipConfiguration& config = dynamic_cast<ChipConfiguration&>(ob);
00047 ABCDChip& data=config.getConfig();
00048
00049 in >> data.active >> data.address >> data.target;
00050
00051
00052
00053
00054 UINT16 temp = 0;
00055 in >> temp;
00056 data.basic.config.readoutMode = temp;
00057 in >> temp;
00058 data.basic.config.calibMode = temp;
00059 in >> temp;
00060 data.basic.config.trimRange = temp;
00061 in >> temp;
00062 data.basic.config.edgeDetect = temp;
00063 in >> temp;
00064 data.basic.config.mask = temp;
00065 in >> temp;
00066 data.basic.config.accumulate = temp;
00067 in >> temp;
00068 data.basic.config.inputBypass = temp;
00069 in >> temp;
00070 data.basic.config.outputBypass = temp;
00071 in >> temp;
00072 data.basic.config.master = temp;
00073 in >> temp;
00074 data.basic.config.end = temp;
00075 in >> temp;
00076 data.basic.config.feedThrough = temp;
00077
00078 in >> data.basic.vthr >> data.basic.vcal >> data.basic.delay >> data.basic.preamp >> data.basic.shaper;
00079 in.get(data.basic.mask, 4);
00080
00081
00082 in >> data.caldata.rc_function;
00083
00084 in.get(data.caldata.rc_params, 3);
00085 in >> data.caldata.c_factor;
00086
00087 in.get(data.trim, Sct::nChannelChip);
00088 }
00089
00090 }
00091 }