Please enable JavaScript to use RhodeCode Enterprise
##// END OF EJS Templates
kaveh
- Thu, 24 Apr 2014 18:28:21
Show More
0
src/ucomport.cpp
src/ucomport.cpp
created
644
+54
0
@@
-0,0
+1,54
1
#include "ucomport.h"
2
3
UComPort :: UComPort ()
4
{
5
this -> p_portMutex = new QMutex ();
6
this -> p_opened = false ;
7
}
8
9
QString UComPort :: portName ()
10
{
11
QMutexLocker locker ( this -> p_portMutex );
12
return p_PortName ;
13
}
14
15
int UComPort :: speed ()
16
{
17
QMutexLocker locker ( this -> p_portMutex );
18
return p_speed ;
19
}
20
21
void UComPort :: setPortName ( const QString & name )
22
{
23
QMutexLocker locker ( this -> p_portMutex );
24
this -> p_PortName = name ;
25
}
26
27
void UComPort :: setSpeed ( int speed )
28
{
29
QMutexLocker locker ( this -> p_portMutex );
30
this -> p_speed = speed ;
31
}
32
33
bool UComPort :: open ()
34
{
35
QMutexLocker locker ( this -> p_portMutex );
36
if ( p_opened )
37
{
38
rs232close ( this -> p_port );
39
this -> p_opened = false ;
40
}
41
this -> p_port = rs232open (( char * ) p_PortName . toStdString (). c_str ());
42
if ( this -> p_port != badPortValue )
43
{
44
rs232setup ( this -> p_port , 8 , this -> p_speed , rs232parityNo , rs232OneStop );
45
p_opened = true ;
46
}
47
}
48
49
bool UComPort :: open ( const QString & name , int speed )
50
{
51
setPortName ( name );
52
setSpeed ( speed );
53
return open ();
54
}
0
src/ucomport.h
src/ucomport.h
created
644
+29
0
@@
-0,0
+1,29
1
#ifndef UCOMPORT_H
2
#define UCOMPORT_H
3
4
#include <QObject>
5
#include <RS232.h>
6
#include <QMutex>
7
#include <QMutexLocker>
8
9
class UComPort
10
{
11
public :
12
explicit UComPort ();
13
QString portName ();
14
int speed ();
15
virtual void setPortName ( const QString & name );
16
virtual void setSpeed ( int speed );
17
bool open ();
18
bool open ( const QString & name );
19
bool open ( const QString & name , int speed );
20
private :
21
rs232port_t p_port ;
22
QString p_PortName ;
23
int p_speed ;
24
QMutex * p_portMutex ;
25
bool p_opened ;
26
27
};
28
29
#endif // UCOMPORT_H
0
src/uprobeprotocol.cpp
src/uprobeprotocol.cpp
created
644
+31
0
@@
-0,0
+1,31
1
#include "uprobeprotocol.h"
2
3
UProbeProtocol :: UProbeProtocol ( QObject * parent ) :
4
QThread ( parent ), UComPort ()
5
{
6
moveToThread (( QThread * ) this );
7
}
8
9
UProbeProtocol ::~ UProbeProtocol ()
10
{
11
this -> requestInterruption ();
12
while ( isRunning ());
13
}
14
15
void UProbeProtocol :: run ()
16
{
17
while ( ! this -> isInterruptionRequested ())
18
{
19
20
}
21
}
22
23
void UProbeProtocol :: setPortName ( const QString & name )
24
{
25
UComPort :: setPortName ( name );
26
}
27
28
void UProbeProtocol :: setSpeed ( int speed )
29
{
30
UComPort :: setSpeed ( speed );
31
}
0
src/uprobeprotocol.h
src/uprobeprotocol.h
created
644
+27
0
@@
-0,0
+1,27
1
#ifndef UPROBEPROTOCOL_H
2
#define UPROBEPROTOCOL_H
3
4
#include <QObject>
5
#include <QThread>
6
#include <QMutex>
7
#include <QSemaphore>
8
#include <ucomport.h>
9
10
class UProbeProtocol : public QThread , public UComPort
11
{
12
Q_OBJECT
13
public :
14
explicit UProbeProtocol ( QObject * parent = 0 );
15
~ UProbeProtocol ();
16
void run ();
17
18
signals :
19
20
public slots :
21
void setPortName ( const QString & name );
22
void setSpeed ( int speed );
23
24
private :
25
};
26
27
#endif // UPROBEPROTOCOL_H
0
Uprobe.pro
Uprobe.pro
+16
-2
@@
-1,22
+1,36
1
#-------------------------------------------------
1
#-------------------------------------------------
2
#
2
#
3
# Project created by QtCreator 2014 - 04 - 24 T18 : 30 : 27
3
# Project created by QtCreator 2014 - 04 - 24 T18 : 30 : 27
4
#
4
#
5
#-------------------------------------------------
5
#-------------------------------------------------
6
6
7
QT += core gui
7
QT += core gui
8
8
9
greaterThan ( QT_MAJOR_VERSION , 4 ) : QT += widgets
9
greaterThan ( QT_MAJOR_VERSION , 4 ) : QT += widgets
10
10
11
TARGET = Uprobe
11
TARGET = Uprobe
12
TEMPLATE = app
12
TEMPLATE = app
13
13
14
14
15
SOURCES += main . cpp\
15
SOURCES += main . cpp\
16
mainwindow . cpp \
16
mainwindow . cpp \
17
src / uprobe . cpp
17
src / uprobe . cpp \
18
src / uprobeprotocol . cpp \
19
src / ucomport . cpp
20
21
########## LPP Serial Port stuff ######################
22
win32: SOURCES += src / lppserial / src / RS232_win . c
23
unix : SOURCES += src / lppserial / src / RS232_unix . c
24
debug : DEFINES += RS232_debug
25
#######################################################
26
27
INCLUDEPATH += src \
28
src / lppserial / src
18
29
19
HEADERS += mainwindow . h \
30
HEADERS += mainwindow . h \
20
src / uprobe . h
31
src / uprobe . h \
32
src / lppserial / src / RS232 . h \
33
src / uprobeprotocol . h \
34
src / ucomport . h
21
35
22
FORMS += mainwindow . ui
36
FORMS += mainwindow . ui
0
src/uprobe.cpp
src/uprobe.cpp
+11
0
@@
-1,6
+1,17
1
#include "uprobe.h"
1
#include "uprobe.h"
2
2
3
UProbe :: UProbe ( QObject * parent ) :
3
UProbe :: UProbe ( QObject * parent ) :
4
QObject ( parent )
4
QObject ( parent )
5
{
5
{
6
6
}
7
}
8
9
bool UProbe :: setPortName ( const QString & name )
10
{
11
12
}
13
14
bool UProbe :: setPortSpeed ( int speed )
15
{
16
17
}
0
src/uprobe.h
src/uprobe.h
+8
0
@@
-1,18
+1,26
1
#ifndef UPROBE_H
1
#ifndef UPROBE_H
2
#define UPROBE_H
2
#define UPROBE_H
3
3
4
#include <QObject>
4
#include <QObject>
5
#include <uprobeprotocol.h>
5
6
6
class UProbe : public QObject
7
class UProbe : public QObject
7
{
8
{
8
Q_OBJECT
9
Q_OBJECT
9
public :
10
public :
10
explicit UProbe ( QObject * parent = 0 );
11
explicit UProbe ( QObject * parent = 0 );
11
12
12
signals :
13
signals :
14
void updateChannelCount ( int count );
15
void sendWaveFormData ( int channel , float * data , int count );
13
16
14
public slots :
17
public slots :
18
bool setPortName ( const QString & name );
19
bool setPortSpeed ( int speed );
20
21
private :
22
UProbeProtocol p_proto ;
15
23
16
};
24
};
17
25
18
#endif // UPROBE_H
26
#endif // UPROBE_H
Site-wide shortcuts
/
Use quick search box
g h
Goto home page
g g
Goto my private gists page
g G
Goto my public gists page
g 0-9
Goto bookmarked items from 0-9
n r
New repository page
n g
New gist page
Repositories
g s
Goto summary page
g c
Goto changelog page
g f
Goto files page
g F
Goto files page with file search activated
g p
Goto pull requests page
g o
Goto repository settings
g O
Goto repository access permissions settings
t s
Toggle sidebar on some pages