Cat
MSOxxxx.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // Package : MSOxxxx
4 //
5 // Description:
6 //
7 // Author(s) : Joan Mauricio
8 // Date : 2014/06/05
9 //
10 //------------------------------------------------------------------------------
11 
12 #ifndef __MSOxxxx_H_
13 #define __MSOxxxx_H_
14 
15 #include "Element.h"
16 #include "Register.h"
17 #include <stdlib.h>
18 #include <string>
19 #include <Python.h>
20 #include <iostream>
21 #include <fstream>
22 #include <time.h>
23 #include <sstream>
24 #include <iomanip>
25 
26 #include <sys/socket.h>
27 #include <sys/types.h>
28 #include <netinet/in.h>
29 #include <netdb.h>
30 
31 using namespace std;
32 
33 #define DEFAULT_IP_ADDRESS "192.168.131.186"
34 #define DEFAULT_PORT 5025
35 #define DEBUG_MODE false
36 
37 #define MAX_LEN 32768
38 
39 class MSOxxxx : public Element {
40 public:
41 
42  //Constructor
43  MSOxxxx();
44 
45  //IP settings and connection...
46  void configTCPIP(string ip, int port);
47  StatusCode open();
48  void closeConnection(){ close(sockfd); info("Connection closed.","MSOxxxx::close"); }
49 
50  //If debugMode is enabled, some extra info messages will appear.
51  void setDebugMode(bool debug){ debugMode = debug; }
52 
53  //Channel functions.
54  StatusCode channelScale (int ch, double value);
55  StatusCode channelOffset (int ch, double value);
56  StatusCode channelDisplay (int ch, bool display);
57  StatusCode channelDisplayName(int ch, string name);
58 
59  //Time base configuration.
60  StatusCode timeBaseScale(double secsPerDiv);
61  StatusCode timeBaseOffset(double seconds);
62 
63  //Trigger configuration.
64  StatusCode triggerAuto();
65  StatusCode triggerConfig(bool slope, int ch, double level);
66 
67  //Measuremente configurations.
68  StatusCode setupJitter (int ch);
69  StatusCode setupAvgVoltage(int ch);
70  StatusCode setupDeltaTime (int chA,int chB,int edge);
71  PyObject* getStatistics (int nMinMeas);
72 
73  //Display configuration.
74  StatusCode labelDisplay(bool display);
75 
76  //Waveform Acquisition.
77  PyObject* waveformCapture(int ch);
78 
79  //Tools.
80  PyObject* id();
81  StatusCode run();
82  StatusCode stop();
83 
85  }
86 
90  void help() { info("MSOxxxx "+name()+". No help.","MSOxxxx::help"); };
91 
98  return StatusCode::SUCCESS;
99  };
100 
108  void reset();
109 
113  void update () {
114 
115  };
116 
117 private:
118 
119  string ipAddress; //The IP Address of the Oscilloscope.
120  int portNumber; //The port number of the Oscilloscope.
121  int sockfd; //The file descriptor of the socket.
122 
123  char rxBuffer[10485760]; //1-MByte data buffer to read oscilloscope.
124  string rxItems[65536]; //rxBuffer bytes are converted to items in a string array.
125 
126  bool debugMode;
127  bool err;
128 
129  bool getTimeBase(double *xInc, double *xOrg); //These parameters helps to reconstruct time vector.
130 
131  bool send(string msg); //Sends a message to the oscilloscope.
132  int recv(string *rxItems, string spacer); //Receives a message from the oscilloscope.
133 
134  int split(string str, string *splitStr, string delimiter);
135  string ftos(double); //This converts a double to a string (overloaded function).
136 };
137 
138 #endif
139 
void update()
Definition: MSOxxxx.h:113
std::string ftos(float)
Definition: Tools.cpp:53
StatusCode init()
Definition: MSOxxxx.h:97
int portNumber
Definition: MSOxxxx.h:120
string ipAddress
Definition: MSOxxxx.h:115
def run(processus, element, nevt)
Definition: shell.py:237
bool debugMode
Definition: MSOxxxx.h:126
void setDebugMode(bool debug)
Definition: MSOxxxx.h:51
void closeConnection()
Definition: MSOxxxx.h:48
void help()
Definition: MSOxxxx.h:90
bool err
Definition: MSOxxxx.h:127
def reset(path='')
Definition: shell.py:212
~MSOxxxx()
Definition: MSOxxxx.h:84
int sockfd
Definition: MSOxxxx.h:121