Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Evers committed Aug 13, 2012
0 parents commit 382bc6b
Show file tree
Hide file tree
Showing 15 changed files with 1,280 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
tmp/
*~
Makefile
20 changes: 20 additions & 0 deletions indiprop.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
TARGET = cliq

TEMPLATE = app

CONFIG += thread console
CONFIG -= debug

QT += network xml

DESTDIR = bin

RESOURCES = src/led.qrc

OBJECTS_DIR = tmp
MOC_DIR = tmp
RCC_DIR = tmp

HEADERS += src/indiclient.h src/mainwindow.h
SOURCES += src/indiclient.cpp src/mainwindow.cpp src/main.cpp

674 changes: 674 additions & 0 deletions license.txt

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
indiprop - INDI Property Browser - v0.0
_____________________________________________________________________

This program provides a generic user interface for browsing device
properties published by an INDI compliant server.

Project home: [http://code.google.com/p/indiprop/]

INDI is the Instrument Neutral Distributed Interface. For more
information see the INDI white-paper at:
[http://www.clearskyinstitute.com/INDI/INDI.pdf]
_____________________________________________________________________

Prerequisites:

Building this program requires a Qt4 development environment.
_____________________________________________________________________

Installation:

From the project folder type:

qmake
make

To install the program, optionally type:

cp bin/indiprop $OBSHOME/bin/
_____________________________________________________________________

Copyright © 2012 Aaron Evers

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 version 3 of the License.

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, see [http://www.gnu.org/licenses/].
_____________________________________________________________________
145 changes: 145 additions & 0 deletions src/indiclient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/***********************************************************************
* Copyright © 2012 Aaron Evers
*
* 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 version 3 of the License.
*
* 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, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#include "indiclient.h"

QTextStream qout(stdout);

IndiClient::IndiClient() : mPort(indi::PORT)
{
connect(&mQTcpSocket, SIGNAL(connected()), SLOT(socketConnected()));
connect(&mQTcpSocket, SIGNAL(disconnected()), SLOT(socketDisconnected()));
connect(&mQTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));
connect(&mQTcpSocket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
}

void IndiClient::socketConnect(const QString &hoststring)
{
mPort = indi::PORT;

QStringList hostsplit = hoststring.split(":");
if (hostsplit.size() > 0)
{
if (hostsplit.size() > 1)
mPort = hostsplit[1].toUShort();

mQTcpSocket.disconnectFromHost();
mQTcpSocket.connectToHost(hostsplit[0], mPort);
}
}

void IndiClient::socketConnected()
{
qout << "Connected to indiserver@" << mQTcpSocket.peerName() << ":" << mPort << endl;

/* Subscribe to all properties */
QDomDocument doc("");
QDomElement getProperties = doc.createElement("getProperties");
getProperties.setAttribute("version", indi::VERSION);
doc.appendChild(getProperties);

mQTcpSocket.write(doc.toString().toAscii());
}

bool IndiClient::connected()
{
return mQTcpSocket.isWritable();
}

void IndiClient::socketDisconnected()
{
qout << "Disconnected from indiserver@" << mQTcpSocket.peerName() << ":" << mPort << endl;
}

void IndiClient::socketError(QAbstractSocket::SocketError)
{
qout << "Socket error from indiserver@" << mQTcpSocket.peerName() << ":" << mPort
<< " (" << mQTcpSocket.errorString() << ")" << endl;
}

void IndiClient::socketReadyRead()
{
QDomDocument doc("");
static QByteArray bytes;

while (mQTcpSocket.canReadLine())
{
bytes += mQTcpSocket.readLine();
if (doc.setContent(bytes, false))
{
emit propertyUpdate(doc);
bytes.clear();
}
}
}

QString IndiClient::formatNumber(const QString &format, const QString &number, const bool &sexagesimal)
{
QString text = number;

if (format.size())
{
if (format.endsWith("m") && sexagesimal)
{
QStringList wf = format.mid(1, format.size() - 2).split('.');
int f = 0;
if (wf.size() > 1)
f = wf[1].toInt();

double h = text.toDouble();

text = "";
if (h < 0.0)
text = "-";

h = fabs(h);
double m = (h - floor(h))*60.0;
double s = (m - floor(m))*60.0;

switch (f)
{
case 9:
text += QString("%1:%2:%3").arg(floor(h), 0, 'f', 0, '0').arg(floor(m), 2, 'f', 0, '0').arg(s, 2, 'f', 2, '0');
break;
case 8:
text += QString("%1:%2:%3").arg(floor(h), 0, 'f', 0, '0').arg(floor(m), 2, 'f', 0, '0').arg(s, 2, 'f', 1, '0');
break;
case 6:
text += QString("%1:%2:%3").arg(floor(h), 0, 'f', 0, '0').arg(floor(m), 2, 'f', 0, '0').arg(s, 2, 'f', 0, '0');
break;
case 5:
text += QString("%1:%2").arg(floor(h), 0, 'f', 0, '0').arg(m, 2, 'f', 1, '0');
break;
case 3:
text += QString("%1:%2").arg(floor(h), 0, 'f', 0, '0').arg(m, 2, 'f', 0, '0');
break;
default:
text += QString("%1").arg(h, 0, 'f', f, '0');
break;
}
}
else
{
QString f = format;
f.replace('m', 'f');

text = text.sprintf(f.toAscii(), text.toDouble()).trimmed();
}
}

return text;
}

62 changes: 62 additions & 0 deletions src/indiclient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/***********************************************************************
* Copyright © 2012 Aaron Evers
*
* 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 version 3 of the License.
*
* 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, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifndef INDICLIENT_H
#define INDICLIENT_H

#include <QtCore>
#include <QtNetwork>
#include <QtXml>

#include <QTcpSocket>
#include <QByteArray>

#include <QTextStream>
extern QTextStream qout;

namespace indi
{
static const char * const VERSION = "1.7";
static const unsigned short PORT = 7624;
};

class IndiClient : public QObject
{
Q_OBJECT;

public:
IndiClient();
void socketConnect(const QString &hoststring);
bool connected();

static QString formatNumber(const QString &format, const QString &number, const bool &sexagesimal);

private:
quint16 mPort;
QTcpSocket mQTcpSocket;

signals:
void propertyUpdate(QDomDocument);

private slots:
void socketConnected();
void socketDisconnected();
void socketError(QAbstractSocket::SocketError);
void socketReadyRead();
};

#endif

10 changes: 10 additions & 0 deletions src/led.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>led/blue.png</file>
<file>led/green.png</file>
<file>led/grey.png</file>
<file>led/orange.png</file>
<file>led/red.png</file>
</qresource>
</RCC>

Binary file added src/led/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/led/green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/led/grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/led/orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/led/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/***********************************************************************
* Copyright © 2012 Aaron Evers
*
* 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 version 3 of the License.
*
* 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, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationName("indiprop");
app.setApplicationVersion("0.0");

MainWindow mainWindow;
mainWindow.show();

return app.exec();
}

Loading

0 comments on commit 382bc6b

Please sign in to comment.