// Author: Andrej Filipcic <http://merlot.ijs.si/~andrej/>,Egon Pavlica (documentation) <http://www.ses-ng.si/~pavlica/>
#include "LScopeState.h"
#include "LScope.h"
ClassImp(LScopeState)
LScopeState::LScopeState(const int nchannels) {
fNChan=nchannels;
fVDIV=new float[fNChan];
fOffset=new float[fNChan];
fChanOn=new Bool_t[fNChan];
fTriggerLevel=new float[fNChan];
if(fNChan==8) {
fChanId["C1"]=0;
fChanId["C2"]=1;
fChanId["C3"]=2;
fChanId["C4"]=3;
fChanId["TA"]=4;
fChanId["TB"]=5;
fChanId["TC"]=6;
fChanId["TD"]=7;
} else {
#warning to be done
}
}
LScopeState::~LScopeState() {
delete fVDIV;
delete fOffset;
delete fTriggerLevel;
delete fChanOn;
}
Bool_t LScopeState::Upload(LScope* lscope) {
map<string,int>::iterator mi;
for(mi=fChanId.begin();mi!=fChanId.end();mi++) {
if(fChanOn[mi->second])
lscope->Sendf("%s:TRA ON",kFALSE,mi->first.c_str());
else
lscope->Sendf("%s:TRA OFF",kFALSE,mi->first.c_str());
if(mi->second<4) {
lscope->Sendf("%s:VDIV %f V",kFALSE,mi->first.c_str(),fVDIV[mi->second]);
lscope->Sendf("%s:OFFSET %f V",kFALSE,mi->first.c_str(),fOffset[mi->second]);
lscope->Sendf("%s:TRIG_LEVEL %f V",kFALSE,mi->first.c_str(),fTriggerLevel[mi->second]);
}
}
lscope->Sendf("TRIG_DELAY %s",kFALSE,fTriggerDelay);
lscope->Sendf("TDIV %sS",kFALSE,fTDIV);
return kTRUE;
}
Bool_t LScopeState::Download(LScope* lscope) {
map<string,int>::iterator mi;
char stmp[256];
for(mi=fChanId.begin(); mi!=fChanId.end(); mi++) {
lscope->Sendf("%s:TRA?",kTRUE,mi->first.c_str());
sscanf(lscope->GetStrOut(),"%*s %s",stmp);
fChanOn[mi->second] = !strcmp(stmp,"ON") ? kTRUE : kFALSE;
if(mi->second<4) {
lscope->Sendf("%s:VDIV?",kTRUE,mi->first.c_str());
sscanf(lscope->GetStrOut(),"%*s %f",&fVDIV[mi->second]);
lscope->Sendf("%s:OFFSET?",kTRUE,mi->first.c_str());
sscanf(lscope->GetStrOut(),"%*s %f",&fOffset[mi->second]);
lscope->Sendf("%s:TRIG_LEVEL?",kTRUE,mi->first.c_str());
sscanf(lscope->GetStrOut(),"%*s %f",&fTriggerLevel[mi->second]);
}
}
lscope->Send("TRIG_DELAY?",kTRUE);
sscanf(lscope->GetStrOut(),"%*s %f",&fTriggerDelay);
lscope->Send("TDIV?",kTRUE);
sscanf(lscope->GetStrOut(),"%*s %f",&fTDIV);
PrintIt();
return kTRUE;
}
void LScopeState::PrintIt() {
printf("ScopeState: %f %f\n",fTriggerDelay,fTDIV);
map<string,int>::iterator mi;
for(mi=fChanId.begin(); mi!=fChanId.end(); mi++)
printf("%s %d\n",mi->first.c_str(),mi->second);
for(int i=0;i<fNChan;i++) {
printf("%d %f %f %d %f\n",i,fVDIV[i],fOffset[i],int(fChanOn[i]),fTriggerLevel[i]);
}
// printf("%dn",fChanId.find("C2")->second);
// printf("%dn",fChanId.find("C1")->second);
// printf("%dn",fChanId.find("C3")->second);
// printf("%dn",fChanId.find("TA")->second);
}
int LScopeState::GetChanId(const char* channel) {
int rc= fChanId.find(channel)->second;
// printf("GetChanId %s %dn",channel,rc);
// printf("%dn",fChanId.find("C2")->second);
// printf("%dn",fChanId.find("C1")->second);
// printf("%dn",fChanId.find("C3")->second);
// printf("%dn",fChanId.find("TA")->second);
return rc;
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.