00001 #include "ButtonEvent.h"
00002 #include <sstream>
00003
00004 std::string
00005 ButtonEvent::getDescription(bool , unsigned int verbosity) const {
00006 std::ostringstream logdata;
00007 logdata << getName();
00008 char hexstring[30];
00009 snprintf(hexstring,sizeof(hexstring),"0x%x",getSourceID());
00010 logdata << '\t' << hexstring;
00011 switch(getTypeID()) {
00012 case EventBase::activateETID:
00013 logdata << "\tA"; break;
00014 case EventBase::statusETID:
00015 logdata << "\tS"; break;
00016 case EventBase::deactivateETID:
00017 logdata << "\tD"; break;
00018 case EventBase::numETIDs:
00019 logdata << "\tU"; break;
00020 }
00021 if(verbosity>=1)
00022 logdata << '\t' << getDuration() << '\t' << getTimeStamp();
00023 if(verbosity>=2)
00024 logdata << '\t' << getMagnitude();
00025 return logdata.str();
00026 }
00027
00028 unsigned int
00029 ButtonEvent::getBinSize() const {
00030 unsigned int used=0;
00031 used+=creatorSize("ButtonEvent");
00032 used+=EventBase::getBinSize();
00033 return used;
00034 }
00035
00036 unsigned int
00037 ButtonEvent::LoadBuffer(const char buf[], unsigned int len) {
00038 unsigned int origlen=len;
00039 unsigned int used=0;
00040 if(0==(used=checkCreator("ButtonEvent",buf,len,true))) return 0;
00041 len-=used; buf+=used;
00042 if(0==(used=EventBase::LoadBuffer(buf,len))) return 0;
00043 len-=used; buf+=used;
00044 return origlen-len;
00045 }
00046
00047 unsigned int
00048 ButtonEvent::SaveBuffer(char buf[], unsigned int len) const {
00049 unsigned int origlen=len;
00050 unsigned int used=0;
00051 if(0==(used=saveCreator("ButtonEvent",buf,len))) return 0;
00052 len-=used; buf+=used;
00053 if(0==(used=EventBase::SaveBuffer(buf,len))) return 0;
00054 len-=used; buf+=used;
00055 return origlen-len;
00056 }
00057
00058 void
00059 ButtonEvent::genName() {
00060 if(!nameisgen)
00061 return;
00062 if(genID<numEGIDs) {
00063 stim_id=std::string("Evt_");
00064 stim_id+=EventGeneratorNames[genID];
00065 } else {
00066 stim_id=std::string("Evt_InvalidGen");
00067 stim_id+=genID;
00068 }
00069 stim_id+="::";
00070 char tmp[16];
00071 snprintf(tmp,16,"0x%x",sourceID);
00072 stim_id+=tmp;
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086