Skip to content

Commit

Permalink
Merge pull request #120 from Negusbuk/master
Browse files Browse the repository at this point in the history
various improvements to pump station control
  • Loading branch information
Negusbuk authored Dec 9, 2016
2 parents ab0183c + a080378 commit 4f21cdb
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 71 deletions.
12 changes: 9 additions & 3 deletions documentation/docs/build/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ Do not build code related to the thermal measurement setup.
* <b>--noassembly</b></br>
Do not build code related to the automated module assembly setup.

* <b>--notwitter</b></br>
Do not build with twitter support (only used by thermal measurement software).
* <b>--noplasma</b></br>
Do not build code related to the plasma cleaner.

* <b>--nopumpstation</b></br>
Do not build code related to the CMS DAF pump station.

* <b>--noueye</b></br>
Build without support for uEye cameras.

* <b>--fake</b></br>
Build with fake device support
Build with fake device support.
3 changes: 3 additions & 0 deletions documentation/docs/pumpstation/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Usage

![Screenshot](screenshot.png)
Binary file added documentation/docs/pumpstation/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions documentation/docs/pumpstation/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Setup Instructions for Pump Station Software

The software is supposed to be running on a raspberry pi with Raspbian (Jessie) as operating system.

## Requirements

You should have a running Raspbian Linux installation based on the
[build instructions](../build/RaspbianLinux.md) to start with.
In addition, please install the following packages via

`sudo apt-get install apache2`<br/>
`sudo apt-get install libapache2-mod-webauth`<br/>
`sudo apt-get install libapache2-mod-php5`<br/>

## Installation

Once building the software has successfully finished, install all required libraries and applications via

`sudo make install`

This will also install scripts to automatically start the pump station daemon on system startup.
After a reboot of the system, the daemon will be running as the default raspberry pi user.
4 changes: 3 additions & 1 deletion documentation/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pages:
- defoDAQ Scripting: defo/defoDAQScripting.md
- Assembly: assembly/index.md
- Plasma Cleaner: plasma/index.md
- Pump Station: pumpstation/index.md
- Pump Station:
- setup: pumpstation/setup.md
- usage: pumpstation/index.md

theme: readthedocs
30 changes: 10 additions & 20 deletions pumpstation/controller/Controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ Controller::Controller(QStringList& arguments)

connect(socket_, SIGNAL(connected()), this, SLOT(sendCommand()));
connect(socket_, SIGNAL(readyRead()), this, SLOT(readResponse()));
connect(socket_, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(reportError(QAbstractSocket::SocketError)));

connectToServer();
}

void Controller::connectToServer()
Expand All @@ -43,6 +39,16 @@ void Controller::connectToServer()

socket_->abort();
socket_->connectToHost(ipAddress, port);

if (!socket_->waitForConnected(500)) {
NQLog("controller") << "The following error occurred: " << socket_->errorString().toStdString();

std::cout << "ERR" << std::endl;

socket_->close();
socket_->deleteLater();
QCoreApplication::quit();
}
}

void Controller::sendCommand()
Expand Down Expand Up @@ -90,19 +96,3 @@ void Controller::readResponse()

QCoreApplication::quit();
}

void Controller::reportError(QAbstractSocket::SocketError socketError)
{
switch (socketError) {
case QAbstractSocket::RemoteHostClosedError:
break;
case QAbstractSocket::HostNotFoundError:
NQLogFatal("controller") << "The host was not found. Please check the host name and port settings.";
break;
case QAbstractSocket::ConnectionRefusedError:
NQLogFatal("controller") << "The connection was refused by the peer. Make sure the fortune server is running, and check that the host name and port settings are correct.";
break;
default:
NQLogFatal("controller") << "The following error occurred: " << socket_->errorString().toStdString();
}
}
3 changes: 1 addition & 2 deletions pumpstation/controller/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class Controller : public QObject

Controller(QStringList& arguments);

private slots:
public slots:

void connectToServer();
void sendCommand();
void readResponse();
void reportError(QAbstractSocket::SocketError socketError);

private:

Expand Down
1 change: 1 addition & 0 deletions pumpstation/controller/PumpStationControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ int main(int argc, char *argv[])
}

Controller controller(arguments);
QTimer::singleShot(0, &controller, SLOT(connectToServer()));

return app.exec();
}
7 changes: 7 additions & 0 deletions pumpstation/controller/PumpStationControl.pro.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ greaterThan(QT_MAJOR_VERSION, 4) {
cache()
}

unix {
target.path = /usr/bin
target.from = PumpStationController

INSTALLS += target
}

# Input
HEADERS += Controller.h \
@basepath@/common/ApplicationConfig.h \
Expand Down
4 changes: 1 addition & 3 deletions pumpstation/daemon/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ Makefile
*~
moc_*
PumpStationDaemon
pumpstation
pumpstation.pid

pumpstation.service
4 changes: 2 additions & 2 deletions pumpstation/daemon/PumpStationDaemon.pro.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ unix {
target.path = /usr/bin
target.from = PumpStationDaemon

systemd.path = /etc/init.d
systemd.extra = chmod a+x pumpstation; cp pumpstation /etc/init.d; systemctl enable pumpstation
systemd.path = /etc/systemd/system
systemd.extra = systemctl stop pumpstation; chmod 664 pumpstation.service; cp pumpstation.service /etc/systemd/system; systemctl daemon-reload; systemctl enable pumpstation; systemctl start pumpstation

INSTALLS += target systemd
}
Expand Down
39 changes: 0 additions & 39 deletions pumpstation/daemon/pumpstation.in

This file was deleted.

12 changes: 12 additions & 0 deletions pumpstation/daemon/pumpstation.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Service for pump station daemon
After=network.target

[Service]
ExecStart=/usr/bin/PumpStationDaemon
Type=simple
User=pi
Group=pi

[Install]
WantedBy=multi-user.target
1 change: 0 additions & 1 deletion pumpstation/website/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ all:
clean:

install:
cp -f pumpstation.ini $(DEPLOYMENTPATH)
cp -f pumpstation.ini $(DEPLOYMENTPATH)
cp -f index.php $(DEPLOYMENTPATH)
cp -f ConradSwitch.php $(DEPLOYMENTPATH)
Expand Down

0 comments on commit 4f21cdb

Please sign in to comment.