# 
LockTimeout  = 3000;
ReplyTimeout = 3000;
ReadTimeout  = 3000;

Terminator = "\n";
InTerminator = "\n";
OutTerminator = "\n";

Separator = ";";
ExtraInput    = Ignore;

# 
qIDN {  out "*IDN?;"; in "%39c";}

debug{
	ExtraInput = Ignore;
	out "%s"; in "%39c";
}

SetAcqType{ out "ACQ:TYPE %{NORM|AVER|HRES|PEAK}";	}

GetAcqType{ out "ACQ:TYPE?;"; in "%{NORM|AVER|HRES|PEAK}";}

SetAcqMode{ out "ACQ:MODE %{RTIM|ETIM}";	}

GetAcqMode{ out "ACQ:MODE?;"; in "%{RTIM|ETIM}";}

GetAcqPoints{ out "ACQ:POIN?;"; in "%u";}

#
RUN{  out "RUN;"; }

STOP{ out "STOP;"; }

SINGLE{
	out ":WAV:FORM WORD;:WAV:POIN:MODE MAX;";
	out ":WAV:POIN %(\$1.VAL)+u;";
	out "SINGLE;"
}

digitize{
  out ":DIG %{CHAN1,CHAN2,CHAN3,CHAN4|CHAN1|CHAN2|CHAN3|CHAN4|FUNC|MATH|SUBS};";
}

#
StatusCHAN{ out ":STAT? CHAN\${1};"; in "%u";  }

#Trigger Event Register

qTER{ out ":TER?;"; in "%u"; }

qSTB{ out "*STB?;"; in "%u" }

qOPC { out "*OPC?;";  in  "%{yes|no}";}

GetSREMask{ out "*SRE?;"; in "%u"}

SetSREMask{ out "*SRE %u;"; }

SetPoints{  out ":WAV:POIN %+u;"; }

GetPoints{ out ":WAV:POIN?;"; in "%u"; }

SetPointsMode{
	out ":WAV:POIN:MODE %{NORM|MAX|RAW};";
}

GetPointsMode{
	out ":WAV:POIN:MODE?;";
	in "%{NORM|MAX|RAW}";
}

getWave{
	Separator = "";	
	out ":WAV:SOUR CHAN\${1};";
	out ":WAV:FORM WORD;";# Binary(WORD) format for wave data
	out ":WAV:POIN:MODE MAX;";
	out ":WAV:POIN %(\${2}.VAL)+u;";
	out ":WAV:SOUR CHAN\${1};:WAV:DATA?;";	
	in "#8%*8c%2r";
}

getWaveBytes{
	Separator = "";	
	out ":WAV:FORM BYTE;";
	out ":WAV:POIN:MODE MAX;"; # Binary(WORD) format for wave data
	out ":WAV:POIN %(\${2}.VAL)+u;";
	out ":WAV:SOUR CHAN\${1};:WAV:DATA?;";
	in "#8%*8c%r";
}

getWaveAscii{
	Separator = ",";	
	out ":WAV:SOUR CHAN\${1};";
	out ":WAV:FORM ASCII;";
	out ":WAV:POIN:MODE MAX;"; # Binary(WORD) format for wave data
	out ":WAV:POIN %(\${2}.VAL)+u;";
	out ":WAV:SOUR CHAN\${1};:WAV:DATA?;";
	in "#8%*8c%f"; 
}

getPreamble{
	Separator = "";
	out ":WAV:SOUR CHAN%(VAL)d;";	
	out ":WAV:PRE?;";
	in  "%(\${1}:PRE:FMT)d,",
	    "%(\$1:PRE:TYP)d,",
	    "%(\$1:PRE:PNT)d,",
	    "%(\$1:PRE:CNT)d,",
	    "%(\$1:PRE:XINC)f,",
	    "%(\$1:PRE:XORG)f,",
	    "%(\$1:PRE:XREF)f,",
	    "%(\$1:PRE:YINC)f,", # voltage = [(data value - yreference) * yincrement] + yorigin
	    "%(\$1:PRE:YORG)f,",
	    "%(\$1:PRE:YREF)f";
}

# TRIGER commands

GetTrigerLevel{
	out ":TRIG:LEV?;";
	in "%f";
}

SetTrigerLevel{
	out ":TRIG:LEV %f;"; # or ":TRIG:LEV %f,CHAN<n>;"
}

GetTrigerSource{
   out ":TRIG:SOUR?;";
   in "%{CHAN1|CHAN2|CHAN3|CHAN4|EXT}";
   }

SetTrigerSource{
   out ":TRIG:SOUR %{CHAN1|CHAN2|CHAN3|CHAN4|EXT}";
   }

GetTrigerCoupling{
   out ":TRIG:COUP?;";
   in "%{AC|DC|LFR}";
}

SetTrigerCoupling{
   out ":TRIG:COUP %{AC|DC|LFR}";
}

GetTrigerReject{
   out ":TRIG:REJ?;";
   in "%{OFF|LFR|HFR}";
}

SetTrigerReject{
   out ":TRIG:REJ %{OFF|LFR|HFR};";
}

GetTrigerSlope{
   out ":TRIG:SLOP?;";
   in "%{NEG|POS|EITH|ALT}"
}

SetTrigerSlope{
  out ":TRIG:SLOP %{NEG|POS|EITH|ALT};";
}

GetSystemSetup{
  Separator = "";
  out ":SYST:SET?;";
  in  "#8%*8r%r";
}

LearnDevSetup{
  Separator = "";
  out "*LRN?;";
  in ":SYST:SET #8%*8r%r";
}