Cat
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MSOxxxx Class Reference

#include <MSOxxxx.h>

Inheritance diagram for MSOxxxx:
Element Hierarchy Object Attrib

Public Member Functions

 MSOxxxx ()
 
void configTCPIP (string ip, int port)
 
StatusCode open ()
 
void closeConnection ()
 
void setDebugMode (bool debug)
 
StatusCode channelScale (int ch, double value)
 
StatusCode channelOffset (int ch, double value)
 
StatusCode channelDisplay (int ch, bool display)
 
StatusCode channelDisplayName (int ch, string name)
 
StatusCode timeBaseScale (double secsPerDiv)
 
StatusCode timeBaseOffset (double seconds)
 
StatusCode triggerAuto ()
 
StatusCode triggerConfig (bool slope, int ch, double level)
 
StatusCode setupJitter (int ch)
 
StatusCode setupAvgVoltage (int ch)
 
StatusCode setupDeltaTime (int chA, int chB, int edge)
 
PyObject * getStatistics (int nMinMeas)
 
StatusCode labelDisplay (bool display)
 
PyObject * waveformCapture (int ch)
 
PyObject * id ()
 
StatusCode run ()
 
StatusCode stop ()
 
 ~MSOxxxx ()
 
void help ()
 
StatusCode init ()
 
void reset ()
 
void update ()
 
- Public Member Functions inherited from Element
 Element ()
 Standard constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
void recursiveInitElement ()
 
void recursiveInitCommunications ()
 
StatusCode setConnection (Hierarchy *)
 
Hierarchyconnection ()
 
- Public Member Functions inherited from Hierarchy
 Hierarchy ()
 Standard constructor. More...
 
virtual ~Hierarchy ()
 Destructor. More...
 
void clear ()
 
void setParent (Hierarchy *parent)
 
Hierarchyparent ()
 
Hierarchyparent (std::string)
 
Hierarchyorigin ()
 
virtual void addChild (Hierarchy *element)
 
std::vector< Hierarchy * > children ()
 
Hierarchychild (std::string)
 
HierarchychildTyped (std::string)
 
unsigned long numberOfChildren ()
 
bool hasChildren ()
 
void delChild (Hierarchy *)
 
void delChild (std::string)
 
std::string path (std::string=std::string(""))
 
std::string pathTyped (std::string=std::string(""))
 
void tree (std::string indent=std::string(""))
 
void tree ()
 
- Public Member Functions inherited from Object
 Object ()
 Standard constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
std::string name () const
 
std::string type ()
 
unsigned char id ()
 
std::string title ()
 
void msgSvc (int level, std::string msg, std::string name)
 
void msg (std::string mymsg)
 
void verbose (std::string mymsg)
 
void debug (std::string mymsg)
 
void info (std::string mymsg)
 
void warning (std::string mymsg)
 
void error (std::string mymsg)
 
void fatal (std::string mymsg)
 
void msg (std::string mymsg, std::string name)
 
void verbose (std::string mymsg, std::string name)
 
void debug (std::string mymsg, std::string name)
 
void info (std::string mymsg, std::string name)
 
void warning (std::string mymsg, std::string name)
 
void error (std::string mymsg, std::string name)
 
void fatal (std::string mymsg, std::string name)
 
void setName (std::string name)
 
void setType (std::string type)
 
void setId (unsigned char id)
 
void setTitle (std::string title)
 
void setDllName (std::string dllName)
 
std::string dllName ()
 
- Public Member Functions inherited from Attrib
 Attrib ()
 Standard constructor. More...
 
virtual ~Attrib ()
 Destructor. More...
 
bool is (int attribut)
 
void add (int attribut)
 
void remove (int attribut)
 
std::string attributs ()
 

Private Member Functions

bool getTimeBase (double *xInc, double *xOrg)
 
bool send (string msg)
 
int recv (string *rxItems, string spacer)
 
int split (string str, string *splitStr, string delimiter)
 
string ftos (double)
 

Private Attributes

string ipAddress
 
int portNumber
 
int sockfd
 
char rxBuffer [10485760]
 
string rxItems [65536]
 
bool debugMode
 
bool err
 

Additional Inherited Members

- Public Types inherited from Attrib
enum  Attribut {
  UNDEFINED, PASSIVE, ACTIVE, INTERFACE,
  IO, IODATA, ELEMENT, HARDWARE,
  PROCESSUS, SOFTWARE
}
 
- Protected Attributes inherited from Element
Hierarchym_connection
 
- Protected Attributes inherited from Attrib
std::string m_attribString [10]
 

Detailed Description

Definition at line 39 of file MSOxxxx.h.

Constructor & Destructor Documentation

◆ MSOxxxx()

MSOxxxx::MSOxxxx ( )

Definition at line 16 of file MSOxxxx.cpp.

References Attrib::add(), Object::debug(), DEBUG_MODE, debugMode, DEFAULT_IP_ADDRESS, DEFAULT_PORT, Attrib::ELEMENT, Attrib::HARDWARE, ipAddress, portNumber, Object::setId(), and Object::setType().

17 {
18  setType("MSOxxxx");
19  setId(0);
20 
22  debug("MSOxxxx built.","MSOxxxx::MSOxxxx");
23 
24  ipAddress = DEFAULT_IP_ADDRESS; //We configure a default IP here. User can change it afterwards.
27 
28 }
#define DEFAULT_PORT
Definition: MSOxxxx.h:34
int portNumber
Definition: MSOxxxx.h:120
void add(int attribut)
Definition: Attrib.h:67
string ipAddress
Definition: MSOxxxx.h:115
bool debugMode
Definition: MSOxxxx.h:126
void setType(std::string type)
Definition: Object.h:52
void setId(unsigned char id)
Definition: Object.h:53
void debug(std::string mymsg)
Definition: Object.h:37
#define DEBUG_MODE
Definition: MSOxxxx.h:35
#define DEFAULT_IP_ADDRESS
Definition: MSOxxxx.h:33

◆ ~MSOxxxx()

MSOxxxx::~MSOxxxx ( )
inline

Definition at line 84 of file MSOxxxx.h.

84  {
85  }

Member Function Documentation

◆ channelDisplay()

StatusCode MSOxxxx::channelDisplay ( int  ch,
bool  display 
)

Definition at line 151 of file MSOxxxx.cpp.

References StatusCode::FAILURE, itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

152 {
153  bool ok;
154  if(display)
155  ok = send(":CHANNEL" + itos(ch) + ":DISPLAY ON \n");
156  else
157  ok = send(":CHANNEL" + itos(ch) + ":DISPLAY OFF \n");
158  if(ok) return StatusCode::SUCCESS;
159  else return StatusCode::FAILURE;
160 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ channelDisplayName()

StatusCode MSOxxxx::channelDisplayName ( int  ch,
string  name 
)

Definition at line 162 of file MSOxxxx.cpp.

References StatusCode::FAILURE, itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

163 {
164  bool ok = send(":CHANNEL" + itos(ch) + ":LABEL \"" + name + "\" \n");
165  if(ok) return StatusCode::SUCCESS;
166  else return StatusCode::FAILURE;
167 }
std::string itos(int)
Definition: Tools.cpp:46
std::string name() const
Definition: Object.h:28
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ channelOffset()

StatusCode MSOxxxx::channelOffset ( int  ch,
double  value 
)

Definition at line 144 of file MSOxxxx.cpp.

References StatusCode::FAILURE, ftos(), itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

145 {
146  bool ok = send(":CHANNEL" + itos(ch) + ":OFFSET " + ftos(value) + "\n");
147  if(ok) return StatusCode::SUCCESS;
148  else return StatusCode::FAILURE;
149 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83
string ftos(double)
Definition: MSOxxxx.cpp:420

◆ channelScale()

StatusCode MSOxxxx::channelScale ( int  ch,
double  value 
)

Definition at line 137 of file MSOxxxx.cpp.

References StatusCode::FAILURE, ftos(), itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

138 {
139  bool ok = send(":CHANNEL" + itos(ch) + ":SCALE " + ftos(value) + "\n");
140  if(ok) return StatusCode::SUCCESS;
141  else return StatusCode::FAILURE;
142 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83
string ftos(double)
Definition: MSOxxxx.cpp:420

◆ closeConnection()

void MSOxxxx::closeConnection ( )
inline

Definition at line 48 of file MSOxxxx.h.

Referenced by BOOST_PYTHON_MODULE().

48 { close(sockfd); info("Connection closed.","MSOxxxx::close"); }
void info(std::string mymsg)
Definition: Object.h:38
int sockfd
Definition: MSOxxxx.h:121

◆ configTCPIP()

void MSOxxxx::configTCPIP ( string  ip,
int  port 
)

Definition at line 34 of file MSOxxxx.cpp.

References ipAddress, and portNumber.

Referenced by BOOST_PYTHON_MODULE().

35 {
36  if(ip!= "DEFAULT") //IP is only changed when the input string is different to "DEFAULT".
37  ipAddress = ip;
38  if(port > 0) //Port is only changed when the input value is greater than 0.
39  portNumber = port;
40 }
int portNumber
Definition: MSOxxxx.h:120
string ipAddress
Definition: MSOxxxx.h:115

◆ ftos()

string MSOxxxx::ftos ( double  f)
private

Definition at line 420 of file MSOxxxx.cpp.

References cat::f.

Referenced by channelOffset(), channelScale(), timeBaseOffset(), timeBaseScale(), and triggerConfig().

421 {
422  std::ostringstream buffer;
423  buffer << std::setprecision(7) << std::scientific << f;
424  return buffer.str();
425 }
f
Definition: cat.py:54

◆ getStatistics()

PyObject * MSOxxxx::getStatistics ( int  nMinMeas)

Definition at line 311 of file MSOxxxx.cpp.

References Object::error(), recv(), rxItems, and send().

Referenced by BOOST_PYTHON_MODULE().

312 {
313  bool ok = true;
314  int nRxItems=7, nMeas=0;
315  PyObject* statistics = PyList_New(0);
316 
317  //We do that until we have enough statistics and everything is ok.
318  while(ok && nRxItems == 7 && nMeas < nMinMeas)
319  {
320  sleep(1); //Wait 1 second...
321  ok |= send(":MEASure:Results?\n"); //Ask for the statistics.
322  nRxItems = recv(rxItems); //Statistics are received.
323  nMeas = (int) atof(rxItems[6].c_str()); //The last item contains #Measurements.
324  }
325  if(!ok || nRxItems != 7) //The number of Rx params is incorrect or read error.
326  {
327  error("Malformed packet. Try it again!","MSOxxxx::getJitter");
328  }
329  else //At this point everything is ok. Let's return a Python list with all the statistics.
330  {
331  PyList_Append(statistics, PyFloat_FromDouble(atof(rxItems[2].c_str()))); //Min
332  PyList_Append(statistics, PyFloat_FromDouble(atof(rxItems[3].c_str()))); //Max
333  PyList_Append(statistics, PyFloat_FromDouble(atof(rxItems[4].c_str()))); //Mean
334  PyList_Append(statistics, PyFloat_FromDouble(atof(rxItems[5].c_str()))); //Stdev
335  }
336  return statistics;
337 }
void error(std::string mymsg)
Definition: Object.h:40
string rxItems[65536]
Definition: MSOxxxx.h:124
bool send(string msg)
Definition: MSOxxxx.cpp:83
int recv(string *rxItems, string spacer)
Definition: MSOxxxx.cpp:97

◆ getTimeBase()

bool MSOxxxx::getTimeBase ( double *  xInc,
double *  xOrg 
)
private

Definition at line 187 of file MSOxxxx.cpp.

References recv(), rxItems, and send().

Referenced by waveformCapture().

188 {
189  bool ok;
190  int nRxItems;
191 
192  ok = send(":WAVeform:XINCrement?\n");
193  nRxItems = recv(rxItems);
194  if(ok && nRxItems > 0)
195  {
196  *xInc = atof(rxItems[0].c_str());
197  send(":WAVeform:XORigin?\n");
198  nRxItems = recv(rxItems);
199 
200  if(ok && nRxItems > 0)
201  {
202  *xOrg = atof(rxItems[0].c_str());
203  return true;
204  }
205  else return false;
206  }
207  else return false;
208 }
string rxItems[65536]
Definition: MSOxxxx.h:124
bool send(string msg)
Definition: MSOxxxx.cpp:83
int recv(string *rxItems, string spacer)
Definition: MSOxxxx.cpp:97

◆ help()

void MSOxxxx::help ( )
inlinevirtual

printout help for the element

Implements Element.

Definition at line 90 of file MSOxxxx.h.

90 { info("MSOxxxx "+name()+". No help.","MSOxxxx::help"); };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ id()

PyObject * MSOxxxx::id ( )

Definition at line 370 of file MSOxxxx.cpp.

References Object::info(), recv(), rxItems, and send().

Referenced by BOOST_PYTHON_MODULE().

371 {
372  bool ok;
373  int nRxItems;
374  PyObject* idList = PyList_New(0);
375 
376  ok = send("*IDN? \n");
377  if(ok) nRxItems = recv(rxItems);
378  if(ok && nRxItems == 4)
379  {
380  info("Oscilloscope : " + rxItems[0],"MSOxxxx::id");
381  info("Model : " + rxItems[1],"MSOxxxx::id");
382  info("Serial Number: " + rxItems[2],"MSOxxxx::id");
383  info("SW Version : " + rxItems[3],"MSOxxxx::id");
384  for(int i=0; i<4; i++)
385  PyList_Append(idList, PyString_FromString(rxItems[i].c_str()));
386  }
387  return idList;
388 }
void info(std::string mymsg)
Definition: Object.h:38
string rxItems[65536]
Definition: MSOxxxx.h:124
bool send(string msg)
Definition: MSOxxxx.cpp:83
int recv(string *rxItems, string spacer)
Definition: MSOxxxx.cpp:97

◆ init()

StatusCode MSOxxxx::init ( )
inlinevirtual

init the component

Returns
void

Implements Element.

Definition at line 97 of file MSOxxxx.h.

References shell::reset(), and StatusCode::SUCCESS.

97  {
98  return StatusCode::SUCCESS;
99  };

◆ labelDisplay()

StatusCode MSOxxxx::labelDisplay ( bool  display)

Definition at line 355 of file MSOxxxx.cpp.

References StatusCode::FAILURE, send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

356 {
357  bool ok;
358  if(display)
359  ok = send(":DISPLAY:LABEL ON \n");
360  else
361  ok = send(":DISPLAY:LABEL OFF \n");
362  if(ok) return StatusCode::SUCCESS;
363  else return StatusCode::FAILURE;
364 }
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ open()

StatusCode MSOxxxx::open ( )

Definition at line 42 of file MSOxxxx.cpp.

References Object::error(), StatusCode::FAILURE, Object::info(), ipAddress, itos(), portNumber, sockfd, and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

43 {
44  struct hostent *server;
45  struct sockaddr_in servAddr;
46 
47  info("IP address / TCP Port: " + ipAddress + " / " + itos(portNumber),"MSOxxxx::open");
48 
49  sockfd = socket(AF_INET, SOCK_STREAM, 0);
50  if (sockfd < 0)
51  {
52  error("ERROR opening socket","MSOxxxx::open");
53  return StatusCode::FAILURE;
54  }
55  else
56  {
57  server = gethostbyname(ipAddress.c_str());
58  if (server == NULL)
59  {
60  error("No such host.","MSOxxxx::open");
61  return StatusCode::FAILURE;
62  }
63  else
64  {
65  bzero((char *) &servAddr, sizeof(servAddr));
66  servAddr.sin_family = AF_INET;
67  bcopy((char *)server->h_addr, (char *)&servAddr.sin_addr.s_addr, server->h_length);
68  servAddr.sin_port = htons(portNumber);
69 
70  if (connect(sockfd,(struct sockaddr *) &servAddr,sizeof(servAddr)) < 0) //Socket is opened here.
71  {
72  error("Connection could not be established.","MSOxxxx::open");
73  return StatusCode::FAILURE;
74  }
75  else
76  info("Connection established.","MSOxxxx::open");
77  return StatusCode::SUCCESS;
78  }
79  }
80 }
void info(std::string mymsg)
Definition: Object.h:38
std::string itos(int)
Definition: Tools.cpp:46
int portNumber
Definition: MSOxxxx.h:120
string ipAddress
Definition: MSOxxxx.h:115
void error(std::string mymsg)
Definition: Object.h:40
int sockfd
Definition: MSOxxxx.h:121

◆ recv()

int MSOxxxx::recv ( string *  rxItems,
string  spacer = "," 
)
private

Definition at line 97 of file MSOxxxx.cpp.

References debugMode, Object::error(), Object::info(), MAX_LEN, rxBuffer, sockfd, and split().

Referenced by getStatistics(), getTimeBase(), id(), and waveformCapture().

98 {
99  string rxMsg;
100  int nRead, nItems, buffPos=0;
101  bool endData=false;
102 
103  do //Data is stored in 'rxBuffer', a 1-MByte private char*.
104  {
105  nRead = read(sockfd,rxBuffer+buffPos,MAX_LEN); //Data is appended to 'rxBuffer'
106  buffPos += nRead;
107  if(nRead > 0) //until '\n' is found, or error.
108  {
109  if(rxBuffer[buffPos-1] == '\n') endData = true;
110  }
111  else endData = true;
112  }
113  while(!endData);
114 
115  if(nRead == -1) //Error handling.
116  {
117  error("Socket read error.","MSOxxxx::recv");
118  return -1;
119  }
120  else //The char* is converted to an array of strings.
121  {
122  rxBuffer[buffPos-1] = '\0'; //IMPORTANT!!! char* delimiter!!!
123  rxMsg = string(rxBuffer); //To string.
124  nItems = split(rxMsg,msgItems,spacer); //To an array of strings.
125 
126  if(debugMode)
127  info(rxMsg,"MSOxxxx::recv");
128 
129  return nItems;
130  }
131 }
void info(std::string mymsg)
Definition: Object.h:38
int split(string str, string *splitStr, string delimiter)
Definition: MSOxxxx.cpp:405
bool debugMode
Definition: MSOxxxx.h:126
void error(std::string mymsg)
Definition: Object.h:40
#define MAX_LEN
Definition: MSOxxxx.h:37
int sockfd
Definition: MSOxxxx.h:121
char rxBuffer[10485760]
Definition: MSOxxxx.h:123

◆ reset()

void MSOxxxx::reset ( )
virtual

Resets the Element so that is is in a standard and safe situation. Different from Element::init which configure the Element. Element::reset() is more an Emergency pull. It is often/usually called by the recursiveInitElement method at the start of the program.

Implements Element.

Definition at line 427 of file MSOxxxx.cpp.

428 {
429 
430 }

◆ run()

StatusCode MSOxxxx::run ( )

Definition at line 390 of file MSOxxxx.cpp.

References StatusCode::FAILURE, send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

391 {
392  bool ok = send(":RUN \n");
393  if(ok) return StatusCode::SUCCESS;
394  else return StatusCode::FAILURE;
395 }
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ send()

bool MSOxxxx::send ( string  msg)
private

Definition at line 83 of file MSOxxxx.cpp.

References debugMode, Object::error(), Object::info(), and sockfd.

Referenced by channelDisplay(), channelDisplayName(), channelOffset(), channelScale(), getStatistics(), getTimeBase(), id(), labelDisplay(), run(), setupAvgVoltage(), setupDeltaTime(), setupJitter(), stop(), timeBaseOffset(), timeBaseScale(), triggerAuto(), triggerConfig(), and waveformCapture().

84 {
85  if(debugMode)
86  info(msg,"MSOxxxx::send");
87 
88  int n = write(sockfd,msg.c_str(),msg.length());
89  if (n < 0)
90  {
91  error("Socket write error.","MSOxxxx::send");
92  return false;
93  }
94  else return true;
95 }
void info(std::string mymsg)
Definition: Object.h:38
bool debugMode
Definition: MSOxxxx.h:126
void error(std::string mymsg)
Definition: Object.h:40
void msg(std::string mymsg)
Definition: Object.h:35
int sockfd
Definition: MSOxxxx.h:121

◆ setDebugMode()

void MSOxxxx::setDebugMode ( bool  debug)
inline

Definition at line 51 of file MSOxxxx.h.

References shell::run().

Referenced by BOOST_PYTHON_MODULE().

51 { debugMode = debug; }
bool debugMode
Definition: MSOxxxx.h:126
void debug(std::string mymsg)
Definition: Object.h:37

◆ setupAvgVoltage()

StatusCode MSOxxxx::setupAvgVoltage ( int  ch)

Definition at line 265 of file MSOxxxx.cpp.

References StatusCode::FAILURE, itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

266 {
267  bool ok;
268  ok = send(":MEASure:CLEar\n");
269  ok |= send(":SYSTem:HEADer OFF\n");
270  ok |= send(":MEASure:STATistics ON\n");
271  ok |= send(":MEASURE:VAVERAGE DISPLAY,CHANNEL"+itos(ch)+"\n");
272 
273  if(ok) return StatusCode::SUCCESS;
274  else return StatusCode::FAILURE;
275 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ setupDeltaTime()

StatusCode MSOxxxx::setupDeltaTime ( int  chA,
int  chB,
int  edge 
)

Definition at line 252 of file MSOxxxx.cpp.

References StatusCode::FAILURE, itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

253 {
254  bool ok;
255  ok = send(":MEASure:CLEar\n");
256  ok |= send(":MEASure:DELTatime:DEFine RISing,1,MIDDle,RISing,"+itos(edge)+",MIDDle\n");
257  ok |= send(":MEASure:STATistics ON\n");
258  ok |= send(":MEASure:DELTatime CHANNel"+itos(chA)+",CHANNel"+itos(chB)+"\n");
259 
260  if(ok) return StatusCode::SUCCESS;
261  else return StatusCode::FAILURE;
262 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ setupJitter()

StatusCode MSOxxxx::setupJitter ( int  ch)

Definition at line 238 of file MSOxxxx.cpp.

References StatusCode::FAILURE, itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

239 {
240  bool ok;
241  //Previous measures are cleared, and period measurement in statistics mode is configured.
242  ok = send(":MEASure:CLEar\n");
243  ok |= send(":SYSTem:HEADer OFF\n");
244  ok |= send(":MEASure:STATistics ON\n");
245  ok |= send(":MEASure:PERiod CHAnnel"+itos(ch)+"\n");
246 
247  if(ok) return StatusCode::SUCCESS;
248  else return StatusCode::FAILURE;
249 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ split()

int MSOxxxx::split ( string  str,
string *  splitStr,
string  delimiter 
)
private

Definition at line 405 of file MSOxxxx.cpp.

Referenced by recv().

406 {
407  unsigned int delimPos = str.find(delimiter);
408  int nStrings = 0;
409 
410  while(delimPos != string::npos) //While there is a "," , "." , " " or whatever...
411  {
412  splitStr[nStrings++] = str.substr(0,delimPos); //We put the previous characters to the delimiter to a string array.
413  str = str.substr(delimPos+1,string::npos); //We remove that characters and the delimiter.
414  delimPos = str.find(delimiter); //The new position of the delimiter in the string.
415  }
416  splitStr[nStrings++] = str; //The last string (with no more delimitters) are put to the last string array.
417  return nStrings;
418 }

◆ stop()

StatusCode MSOxxxx::stop ( )

Definition at line 397 of file MSOxxxx.cpp.

References StatusCode::FAILURE, send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

398 {
399  bool ok = send(":STOP \n");
400  if(ok) return StatusCode::SUCCESS;
401  else return StatusCode::FAILURE;
402 }
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ timeBaseOffset()

StatusCode MSOxxxx::timeBaseOffset ( double  seconds)

Definition at line 180 of file MSOxxxx.cpp.

References StatusCode::FAILURE, ftos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

181 {
182  bool ok = send(":TIMEBASE:POSITION " + ftos(seconds) + " \n");
183  if(ok) return StatusCode::SUCCESS;
184  else return StatusCode::FAILURE;
185 }
bool send(string msg)
Definition: MSOxxxx.cpp:83
string ftos(double)
Definition: MSOxxxx.cpp:420

◆ timeBaseScale()

StatusCode MSOxxxx::timeBaseScale ( double  secsPerDiv)

Definition at line 173 of file MSOxxxx.cpp.

References StatusCode::FAILURE, ftos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

174 {
175  bool ok = send(":TIMEBASE:SCALE " + ftos(secsPerDiv) + " \n");
176  if(ok) return StatusCode::SUCCESS;
177  else return StatusCode::FAILURE;
178 }
bool send(string msg)
Definition: MSOxxxx.cpp:83
string ftos(double)
Definition: MSOxxxx.cpp:420

◆ triggerAuto()

StatusCode MSOxxxx::triggerAuto ( )

Definition at line 214 of file MSOxxxx.cpp.

References StatusCode::FAILURE, send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

215 {
216  bool ok = send(":TRIGger:SWEep AUTO\n");
217  if(ok) return StatusCode::SUCCESS;
218  else return StatusCode::FAILURE;
219 }
bool send(string msg)
Definition: MSOxxxx.cpp:83

◆ triggerConfig()

StatusCode MSOxxxx::triggerConfig ( bool  slope,
int  ch,
double  level 
)

Definition at line 221 of file MSOxxxx.cpp.

References StatusCode::FAILURE, ftos(), itos(), send(), and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

222 {
223  bool ok;
224 
225  if(slope) ok = send(":TRIGger:EDGE:SLOpe POSitive\n");
226  else ok = send(":TRIGger:EDGE:SLOpe NEGative\n");
227  ok |= send(":TRIGger:EDGE:SOURce CHANnel" + itos(ch) + " \n");
228  ok |= send(":TRIGger:LEVel CHANnel" + itos(ch) + "," + ftos(level) + " \n");
229  if(ok) return StatusCode::SUCCESS;
230  else return StatusCode::FAILURE;
231 }
std::string itos(int)
Definition: Tools.cpp:46
bool send(string msg)
Definition: MSOxxxx.cpp:83
string ftos(double)
Definition: MSOxxxx.cpp:420

◆ update()

void MSOxxxx::update ( )
inlinevirtual

◆ waveformCapture()

PyObject * MSOxxxx::waveformCapture ( int  ch)

Definition at line 277 of file MSOxxxx.cpp.

References getTimeBase(), itos(), recv(), rxItems, and send().

Referenced by BOOST_PYTHON_MODULE().

278 {
279  PyObject* waveform = PyList_New(0);
280  double xOrigin, xIncrement;
281  int nRxItems, iItems;
282  bool ok;
283 
284  ok = getTimeBase(&xIncrement, &xOrigin);
285  ok |= send(":RUN \n"); //We get sure that oscilloscope is in RUN mode.
286  ok |= send(":DIGitize CHANnel"+itos(ch)+"\n"); //Select channel
287  ok |= send(":CHANnel"+itos(ch)+":DISPlay ON\n"); //Enable display of channel
288  ok |= send(":WAVeform:FORMat ASCii\n"); //Setup transfer format
289  ok |= send(":WAVeform:BYTeorder LSBFirst\n");
290  ok |= send(":WAVeform:SOURce CHANnel"+itos(ch)+"\n"); //Waveform data source channel
291  ok |= send(":WAVeform:STReaming 1\n"); //Turn on waveform streaming of data
292  ok |= send(":WAVeform:DATA?\n"); //Retrieves data.
293 
294  nRxItems = recv(rxItems); //Data is received here.
295  ok |= send(":RUN \n"); //Once done, let's push 'run' button again.
296 
297  if(ok)
298  {
299  for(iItems=0 ; iItems<nRxItems-1 ; iItems++)
300  {
301  //Pair list items are timestamps.
302  //Odd list items are amplitude values.
303  PyList_Append(waveform, PyFloat_FromDouble(((double)iItems * xIncrement) + xOrigin));
304  PyList_Append(waveform, PyFloat_FromDouble(atof(rxItems[iItems].c_str())));
305  }
306  }
307  return waveform;
308 }
std::string itos(int)
Definition: Tools.cpp:46
string rxItems[65536]
Definition: MSOxxxx.h:124
bool getTimeBase(double *xInc, double *xOrg)
Definition: MSOxxxx.cpp:187
bool send(string msg)
Definition: MSOxxxx.cpp:83
int recv(string *rxItems, string spacer)
Definition: MSOxxxx.cpp:97

Member Data Documentation

◆ debugMode

bool MSOxxxx::debugMode
private

Definition at line 126 of file MSOxxxx.h.

Referenced by MSOxxxx(), recv(), and send().

◆ err

bool MSOxxxx::err
private

Definition at line 127 of file MSOxxxx.h.

◆ ipAddress

string MSOxxxx::ipAddress
private

Definition at line 115 of file MSOxxxx.h.

Referenced by configTCPIP(), MSOxxxx(), and open().

◆ portNumber

int MSOxxxx::portNumber
private

Definition at line 120 of file MSOxxxx.h.

Referenced by configTCPIP(), MSOxxxx(), and open().

◆ rxBuffer

char MSOxxxx::rxBuffer[10485760]
private

Definition at line 123 of file MSOxxxx.h.

Referenced by recv().

◆ rxItems

string MSOxxxx::rxItems[65536]
private

Definition at line 124 of file MSOxxxx.h.

Referenced by getStatistics(), getTimeBase(), id(), and waveformCapture().

◆ sockfd

int MSOxxxx::sockfd
private

Definition at line 121 of file MSOxxxx.h.

Referenced by open(), recv(), and send().


The documentation for this class was generated from the following files: