summaryrefslogtreecommitdiff
path: root/src/LaserDev.hpp
blob: 8d4830f524658d115e1203f97691bc0ad69d236c (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*
 * Copyright (C) 2016 Dhiraj Salian
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
 */
#ifndef LASERDEV_HPP
#define LASERDEV_HPP

#include <QtSerialPort/QSerialPortInfo>
#include <QtSerialPort/QSerialPort>
#include <QTextStream>
#include <QCoreApplication>
#include <QString>
#include <QObject>
#include <QThread>
#include <QTime>
#include "SerialCom.hpp"

//! This class is used for funtions related to motion and turning the laser on and off.
class LaserDev : public QObject
{
    Q_OBJECT
public:
	/**
	 *	Class constructor.
	 */
    LaserDev(QObject *parent=0);

	/**
	 *	Class destructor.
	 */
    ~LaserDev();

	/**
	*	function for setting the portName
	*	\param s port name
	*/
    void setPortName(const QString &s);
    void releasePort();
signals:

	/**
	*	Sending the debug signal
	*/
    void debug_send(QString s);

	/**
	*	Recieving the position from arduino
	*/
    void pos_received(QString,QString);
private:
	
	/**
	*	Constant for counting the motion in stpper motor.
	*/
    int move_count;

	/**
	*	Constant string for azimuth recieved from servo.
	*/
    QString ac;

	/**
	*	Constant string for altitude recieved from servo.
	*/
    QString alt;

	/**
	*	Constant for sending string.
	*/

    QString intense;

      /**
      *    Constant string for varying the intensity of LASER.
      */
	QString comm;

	/**
	*	Constant double for azimuth recieved from servo.
	*/
    double dac;

	/**
	*	Constant double for altitude recieved from servo.
	*/
	double dalt;

	/**
	*	Object for using serial class.
	*/
    SerialCom thread;

	/**
	*	Constant string for serial port name.
	*/
    QString osp_serialPort;

    QByteArray osp_ba;

public slots:

	/**
	*	This function is called to get the current position of the telescope in radians
	*/
    void getPos();

	/**
	*	slot for the error, sends the signal to OSPMainDialog
	*/
    void processError(const QString &s);

	/**
	*	slot for the timeout , sends the signal to OSPMainDialog
	*/
    void processTimeout(const QString &s);

	/**
	*	This function is called after writing to the serial port. This function performs various steps like echoData, getSteps, getHorizontalCoords, getVerticalCoords
	*/
	void sread(const QString &s);

    /**
	*	sends the "init" command to the device and after "done_init" is received from the device, emits "init_received" signal
	*/
	void init();

    /**
    *	sends the "clos" command to the device to reset the hardware
    */
    void closeWindow();

	/**
	*	Sends the telescope coordinates to the device
	* \param x Azimuth fed to arduino.
	* \param y Altitude fed to arduino.
	*/
    void move(double x,double y);

	/**
	*	To move the laser in x direction depending on signDir
	*/
    void movx(int signDir);

	/**
	*	To move the laser in y direction depending on signDir
	*	/param signDir 0 to move up 1 to move down
	*/
    void movy(int signDir);

	/**
	*	to stop the laser movements in either of the direction x or y
	*	/param signDir 0 to move up 1 to move down
	*/
    void stop();

	/**
	*	to turn the laser on
	*/
    void laserOn();

	/**
	*	To turn the laser off
	*/
    void laserOff();

       /**    To set the intensity of the laser
        */
     void setIntensity(int x);

    /**
    *	To hard reset the arduino
    */
    void resetAll();

    /**
        *	to turn the motor's high speed on
        */
        void CoarseAdj();

        /**
        *	To turn the motor's high speed off
        */
        void FineAdj();
};



#endif // LASERDEV_HPP