-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreceiver_copy1.h
69 lines (59 loc) · 1.85 KB
/
receiver_copy1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef RECIEVER_H
#define RECIEVER_H
#include <QObject>
#include <QThread>
#include <stdio.h>
/* For IPC_CREAT */
#include <sys/msg.h>
/* For int32_t */
#include <stdint.h>
/* Header for handling signals (definition of SIGINT) */
#include <signal.h>
/* For pid_t and getpid() */
#include <unistd.h>
#include <sys/types.h>
/* For using real-time scheduling policy (FIFO) and sched_setaffinity */
#include <sched.h>
/* For locking the program in RAM (mlockall) to prevent swapping */
#include <sys/mman.h>
#include "robotstate.h"
class Receiver : public QThread
{
Q_OBJECT
private:
static FILE *fp;
static int qID;
unsigned int messageCounter=0;
/*after each "", a message is emitted*/
unsigned int emitFrequency=300;
/* Assuming an update rate of exactly 1 ms, number of cycles for 24h = 24*3600*1000. */
long NUMBER_OF_CYCLES =86400000;
/* Flush the data every ... cycle */
int FLUSH_CYCLE =60000;
int NUMBER_OF_motorpulse=524287;
int GEARBOX_RATIO=10;
void run();
public:
explicit Receiver(QObject *parent = nullptr);
void print_config(void);
static void signal_handler()
{
printf("Removing the queue...\n");
if (!(msgctl(qID, IPC_RMID, NULL)))
printf("The queue was successfully removed.\n");
/* close the file */
if (!fclose(fp))
printf("The log file was successfully closed.\n");
pid_t pid = getpid();
kill(pid, SIGKILL);
}
~Receiver();
double motor_to_degree_position(int32_t point) ;
void calculate_motor_to_degree_array(int32_t points[4],double *ret_data);
void calculate_motor_to_degree_vector(int32_t points[4], QVector<double>* retval);
void receiverBase();
signals:
void newMessage(unsigned int key,QVector<double> actualPosition,QVector<double> targetPosition);
public slots:
};
#endif // RECIEVER_H