Ksetiwatch API Documentation


SetiLoc Class Reference

Represents a SETI@home location. More...

#include <setiloc.h>

Inherits SetiContainer.

Inheritance diagram for SetiLoc:

Inheritance graph
[legend]
Collaboration diagram for SetiLoc:

Collaboration graph
[legend]
List of all members.

Public Types

enum  GraphIds

Signals

void newWorkUnit (WorkUnitData wud, const QString &locname, const QColor &col)
void workUnitLogged (SetiLoc *loc)

Public Methods

 SetiLoc (const QString &dir=QString::null, const QString &loc=QString::null, const QColor &col=QColor::QColor(Qt::red))
 ~SetiLoc ()
const QStringid () const
void setOptions (const LocSettings &ls)
LocSettings options () const
QString description () const
QColor color () const
bool optionStartSeti () const
bool optionStopSeti () const
bool optionKeepClientAlive () const
void setTimestamp (const QString &ts)
QString timestamp () const
QString logDirectory ()
void showGraph (int id)
bool isGraphVisible (int id) const
bool startClient ()
int stopClient ()
bool isStoppedNormally ()
void initMaxScore ()
void setMaxScore (const WUScore &score)
const WUScoremaxScore () const
void storeTripletData (const TripletScore &triplet)
void checkWUStatus ()

Static Public Methods

SpikeScore loggedSpikeSignal (QString &line)
GaussianScore loggedGaussianSignal (QString &line)
PulseScore loggedPulseSignal (QString &line)
TripletScore loggedTripletSignal (QString &line)

Protected Slots

void slotInitMaxScore (WorkUnitData wud)
void slotDumpClientOutput (KProcess *, char *, int)

Protected Methods

void logWorkUnit ()
QString constructEntry (const QString &entry, int type)
void logResults ()
QString loggedTripletProfile (const QString &tdata)

Static Protected Methods

int calcGaussianFFTIndex (GaussianScore *g)

Protected Attributes

QString thisId
LocSettings sets
QString sresult_timestamp
KProcess client
KProcess stopProc
WUScore mymax
KTextBrowserclientOutput
bool stoppedNormally

Detailed Description

Represents a SETI@home location.

This is a central class in the Ksetiwatch application. For every S@h location the user wishes to monitor, an object based on this class is created. It extends the features of the SetiContainer class (which basically does the monitoring of the sah files and data structures of the client) by the ability to start and stop the S@h client, and to log the results of completed work units.

Upon creation of a SetiLoc object, a unique identifier string is generated. This is because S@h locations can in principle have the same name, but different working directories. Use the ID string (obtained via id()) to distinguish between the different locations.

Definition at line 117 of file setiloc.h.


Member Enumeration Documentation

enum SetiLoc::GraphIds
 

Identifiers for the three different graph widgets.

Definition at line 172 of file setiloc.h.


Constructor & Destructor Documentation

SetiLoc::SetiLoc const QString   dir = QString::null,
const QString   loc = QString::null,
const QColor   col = QColor::QColor(Qt::red)
 

The constructor.

Parameters:
dir  The working directory of the SETI@home client.
loc  A descriptive name of the S@h location.
col  The color which is used for the WU markers on the skymap.

Definition at line 138 of file setiloc.cpp.

References client, clientOutput, LocSettings::color, QObject::connect(), LocSettings::description, LocSettings::directory, initMaxScore(), QFontMetrics::lineSpacing(), newWorkUnit(), QString::number(), sets, slotDumpClientOutput(), slotInitMaxScore(), sresult_timestamp, thisId, and QFontMetrics::width().

SetiLoc::~SetiLoc  
 

The destructor.

Definition at line 169 of file setiloc.cpp.

References clientOutput.


Member Function Documentation

const QString & SetiLoc::id  
 

Returns the unique ID string.

Upon creation of a SetiLoc object, a unique identifier string is generated. This ID string can be used to safely identify the correct location.

Definition at line 175 of file setiloc.cpp.

References thisId.

Referenced by Ksetiwatch::Ksetiwatch(), logResults(), UserInfo::refreshList(), DataInfo::refreshList(), Analysis::refreshList(), UserInfo::refreshListItem(), DataInfo::refreshListItem(), showGraph(), Analysis::slotAdjustAllStatusIcons(), CompletedWUList::slotSelect(), UserInfo::slotUpdateList(), DataInfo::slotUpdateList(), Analysis::slotUpdateList(), Analysis::updateAnalysisList(), CompletedWUList::updateList(), Analysis::updateListItemGaussianData(), Analysis::updateListItemPulseData(), Analysis::updateListItemSpikeData(), Analysis::updateListItemTimeData(), Analysis::updateListItemTripletData(), and Analysis::updateStateIcon().

void SetiLoc::setOptions const LocSettings   ls
 

Sets all options of the location.

Parameters:
ls  A structure containing the new settings.

Definition at line 181 of file setiloc.cpp.

References LocSettings::arguments, LocSettings::directory, initMaxScore(), SetiContainer::setDirectory(), sets, and QString::simplifyWhiteSpace().

Referenced by Analysis::handlePopupCommand(), and Ksetiwatch::readConfig().

LocSettings SetiLoc::options   const [inline]
 

Returns the settings of the location.

Definition at line 146 of file setiloc.h.

Referenced by CompletedWUList::checkForRedirect(), Analysis::handlePopupCommand(), and Ksetiwatch::saveConfig().

QString SetiLoc::description   const [inline]
 

Returns the descriptive name of the location.

Definition at line 148 of file setiloc.h.

References LocSettings::description, and sets.

Referenced by SkyMap::addLocation(), CompletedWUList::addLoggedWU(), CompletedWUList::fillSigSumList(), CompletedWUList::fillTotalList(), Ksetiwatch::getLocation(), CompletedWUList::handleSigListDoubleClick(), CompletedWUList::handleSigListPopupCommand(), CompletedWUList::handleWUListPopupCommand(), TripletPlot::init(), PulsePlot::init(), GaussianPlot::init(), logWorkUnit(), CompletedWUList::refreshList(), UserInfo::refreshListItem(), DataInfo::refreshListItem(), Ksetiwatch::saveConfig(), slotInitMaxScore(), CompletedWUList::updateList(), Analysis::updateListItemTimeData(), Analysis::updateMaxScore(), and DockWidget::updateState().

QColor SetiLoc::color   const [inline]
 

Returns the color used for the location.

Definition at line 150 of file setiloc.h.

References LocSettings::color, and sets.

Referenced by SkyMap::addLocation(), CompletedWUList::addLoggedWU(), CompletedWUList::handleWUListPopupCommand(), TelescopePath::setLocation(), slotInitMaxScore(), and TelescopePath::TelescopePath().

bool SetiLoc::optionStartSeti   const [inline]
 

Returns TRUE, if the S@h client is started at start-up of Ksetiwatch.

Definition at line 153 of file setiloc.h.

References sets, and LocSettings::startSeti.

Referenced by Ksetiwatch::startClients().

bool SetiLoc::optionStopSeti   const [inline]
 

Returns TRUE, if the S@h client is stopped at shut-down of Ksetiwatch.

Definition at line 156 of file setiloc.h.

References sets, and LocSettings::stopSeti.

Referenced by Ksetiwatch::stopClients().

bool SetiLoc::optionKeepClientAlive   const [inline]
 

Returns TRUE, if the S@h client shall be restarted whenevever it shuts down unexpectedly.

Definition at line 159 of file setiloc.h.

References LocSettings::keepClientAlive, and sets.

Referenced by Analysis::updateStateIcon().

void SetiLoc::setTimestamp const QString   ts [inline]
 

Sets the time stamp of the last WU logged by Ksetiwatch.

The time stamp is used to prevent multiple logging of the same WU.

Parameters:
ts  A string containing the time stamp.

Definition at line 166 of file setiloc.h.

References sresult_timestamp.

Referenced by checkWUStatus(), and Ksetiwatch::readConfig().

QString SetiLoc::timestamp   const [inline]
 

Returns the time stamp of the last WU logged by Ksetiwatch.

Definition at line 168 of file setiloc.h.

References sresult_timestamp.

Referenced by checkWUStatus(), and Ksetiwatch::saveConfig().

QString SetiLoc::logDirectory  
 

Returns the path to the log directory.

Definition at line 271 of file setiloc.cpp.

References SetiContainer::directory(), QString::isEmpty(), LocSettings::logDirectory, LocSettings::redirectLog, and sets.

Referenced by CompletedWUList::addLoggedWU(), CompletedWUList::checkForRedirect(), CompletedWUList::fillSigList(), CompletedWUList::fillSigSumList(), CompletedWUList::fillTotalList(), CompletedWUList::fillWUList(), loggedTripletProfile(), logResults(), logWorkUnit(), LoggedSigs::readLoggedSigs(), slotInitMaxScore(), and storeTripletData().

void SetiLoc::showGraph int    id
 

Displays a window with one of the three different signal graphs.

Parameters:
id  The identifier of the graph. See SetiLoc::GraphIds.

Definition at line 191 of file setiloc.cpp.

References clientOutput, and id().

Referenced by Analysis::handleShowPopupCommand().

bool SetiLoc::isGraphVisible int    id const [inline]
 

Returns the state of the graph widget specified by identifier id.

Parameters:
id  The identifier of the graph. See SetiLoc::GraphIds.

Definition at line 182 of file setiloc.h.

bool SetiLoc::startClient  
 

Starts the SETI@home client.

Returns:
TRUE if started successfully, otherwise FALSE.

Definition at line 612 of file setiloc.cpp.

References LocSettings::arguments, KProcess::clearArguments(), client, QFile::close(), QDir::currentDirPath(), LocSettings::customStartExe, SetiContainer::directory(), LocSettings::email, QFile::exists(), SetiContainer::getClientPid(), LocSettings::graphics, SetiContainer::isClientRunning(), QString::isEmpty(), QString::number(), QFile::open(), LocSettings::priority, LocSettings::proxyPort, LocSettings::proxyServer, QFile::remove(), QDir::setCurrent(), sets, QStringList::split(), KProcess::start(), LocSettings::stopAfterProcess, LocSettings::stopAfterSend, stoppedNormally, LocSettings::useCustomStartExe, and LocSettings::useProxy.

Referenced by DockWidget::handlePopupCommand(), Analysis::handlePopupCommand(), Analysis::slotStartAll(), Ksetiwatch::startClients(), and Analysis::updateStateIcon().

int SetiLoc::stopClient  
 

Stops the SETI@home client.

Todo:
For consistency reasons, change the return to boolean values.

Returns:
0 if stopped successfully, otherwise -1.

Definition at line 694 of file setiloc.cpp.

References KProcess::clearArguments(), client, LocSettings::customStopExe, QString::isEmpty(), sets, QStringList::split(), KProcess::start(), stoppedNormally, stopProc, and LocSettings::useCustomStopExe.

Referenced by DockWidget::handlePopupCommand(), Analysis::handlePopupCommand(), Analysis::slotStopAll(), and Ksetiwatch::stopClients().

bool SetiLoc::isStoppedNormally   [inline]
 

TRUE if the client has been stopped upon user request.

Definition at line 196 of file setiloc.h.

Referenced by Analysis::updateStateIcon().

void SetiLoc::initMaxScore  
 

Initializes the structure that stores the score of the best signals of the WU in progress.

Definition at line 219 of file setiloc.cpp.

References WUScore::gaussian, SetiContainer::initWUScore(), mymax, SpikeScore::power, WUScore::pulse, TripletScore::score, PulseScore::score, GaussianScore::score, WUScore::spike, and WUScore::triplet.

Referenced by SetiLoc(), setOptions(), and Analysis::slotUpdateList().

void SetiLoc::setMaxScore const WUScore   score [inline]
 

Sets the structure containing the best signals to score.

Parameters:
score  A WUScore structure with the new signal parameters.

Definition at line 204 of file setiloc.h.

References mymax.

Referenced by Analysis::updateMaxScore().

const WUScore& SetiLoc::maxScore   const [inline]
 

Returns a structure with the parameters of the best signals found in the WU in progress.

Definition at line 207 of file setiloc.h.

Referenced by Analysis::updateMaxScore().

void SetiLoc::storeTripletData const TripletScore   triplet
 

Writes triplet data (power, period, and profile) to a temporary file.

This information will be merged into the result log later on.

Parameters:
triplet  A pointer to the triplet score structure.

Definition at line 292 of file setiloc.cpp.

References QFile::close(), TripletScore::data, logDirectory(), QFile::open(), TripletScore::period, TripletScore::power, QString::sprintf(), TripletScore::tpotind0_0, TripletScore::tpotind1_0, and TripletScore::tpotind2_0.

Referenced by Analysis::updateMaxScore().

void SetiLoc::checkWUStatus  
 

Checks if the client has completed a work unit.

If the client has created the file result.sah, and result_header.sah and work_unit.sah are missing, the WU will be logged.

Definition at line 250 of file setiloc.cpp.

References QFileInfo::lastModified(), LocSettings::log, logResults(), logWorkUnit(), sets, setTimestamp(), timestamp(), QDateTime::toString(), and workUnitLogged().

Referenced by Analysis::updateStateIcon().

SpikeScore SetiLoc::loggedSpikeSignal QString   line [static]
 

Returns the parameters of a logged spike signal.

The S@h client stores the parameters of signals which are to be returned to the server in a single line of the form "spike: power=...". This method parses such a line and extracts the parameters and optionally the profile of the signal

This method can be applied to lines in the files outfile.sah and result.sah (created by the S@h client), and SETIResult.log (created by Ksetiwatch).

Parameters:
line  The line containing the parameters of the spike.
Returns:
A SpikeScore structure with the parameters extracted from line.

Definition at line 797 of file setiloc.cpp.

References SpikeScore::chirprate, SpikeScore::dec, SpikeScore::fft_len, SpikeScore::frequency, SetiContainer::initWUScore(), SpikeScore::power, SpikeScore::ra, SetiContainer::readEntry(), QString::replace(), WUScore::spike, QStringList::split(), QString::toDouble(), and QString::toInt().

Referenced by CompletedWUList::fillSigList(), CompletedWUList::fillSigSumList(), and LoggedSigs::readLoggedSigs().

GaussianScore SetiLoc::loggedGaussianSignal QString   line [static]
 

Returns the parameters of a logged gaussian signal.

See loggedSpikeSignal() for details.

Parameters:
line  The line containing the parameters of the gaussian.
Returns:
A GaussianScore structure with the parameters extracted from line.

Definition at line 819 of file setiloc.cpp.

References calcGaussianFFTIndex(), GaussianScore::chirprate, GaussianScore::chisq, GaussianScore::data, GaussianScore::data_len, GaussianScore::dec, GaussianScore::fft_index, GaussianScore::fft_len, GaussianScore::frequency, WUScore::gaussian, SetiContainer::initWUScore(), GaussianScore::power, GaussianScore::ra, SetiContainer::readDataString(), SetiContainer::readEntry(), QString::replace(), GaussianScore::score, GaussianScore::sigma, QStringList::split(), QString::toDouble(), QString::toInt(), and GaussianScore::true_mean.

Referenced by CompletedWUList::fillSigList(), CompletedWUList::fillSigSumList(), and LoggedSigs::readLoggedSigs().

PulseScore SetiLoc::loggedPulseSignal QString   line [static]
 

Returns the parameters of a logged pulse signal.

See loggedSpikeSignal() for details.

Parameters:
line  The line containing the parameters of the pulse.
Returns:
A PulseScore structure with the parameters extracted from line.

Definition at line 891 of file setiloc.cpp.

References PulseScore::chirprate, PulseScore::data, PulseScore::data_len, PulseScore::dec, PulseScore::fft_len, PulseScore::frequency, SetiContainer::initWUScore(), PulseScore::mean, PulseScore::period, PulseScore::power, WUScore::pulse, PulseScore::ra, SetiContainer::readDataString(), SetiContainer::readEntry(), QString::replace(), PulseScore::score, QStringList::split(), QString::toDouble(), and QString::toInt().

Referenced by CompletedWUList::fillSigList(), CompletedWUList::fillSigSumList(), and LoggedSigs::readLoggedSigs().

TripletScore SetiLoc::loggedTripletSignal QString   line [static]
 

Returns the parameters of a logged triplet signal.

See loggedSpikeSignal() for details.

Parameters:
line  The line containing the parameters of the triplet.
Returns:
A TripletScore structure with the parameters extracted from line.

Definition at line 929 of file setiloc.cpp.

References TripletScore::chirprate, TripletScore::data, TripletScore::data_len, TripletScore::dec, TripletScore::fft_len, TripletScore::frequency, SetiContainer::initWUScore(), TripletScore::mean, TripletScore::period, TripletScore::power, TripletScore::ra, SetiContainer::readDataString(), SetiContainer::readEntry(), QString::replace(), TripletScore::score, QStringList::split(), QString::toDouble(), QString::toInt(), TripletScore::tpotind0_0, TripletScore::tpotind0_1, TripletScore::tpotind1_0, TripletScore::tpotind1_1, TripletScore::tpotind2_0, TripletScore::tpotind2_1, and WUScore::triplet.

Referenced by CompletedWUList::fillSigList(), CompletedWUList::fillSigSumList(), and LoggedSigs::readLoggedSigs().

void SetiLoc::logWorkUnit   [protected]
 

Logs all important results of a processed WU.

The results are written to the file SETILog.csv. This file is compatible to the csv file generated by SETIWatch.

Definition at line 319 of file setiloc.cpp.

References QString::arg(), QFile::atEnd(), SetiContainer::clientVersion(), QFile::close(), CSVDataBase::columnCount(), constructEntry(), QDate::currentDate(), QTime::currentTime(), QDateTime::date(), QDate::day(), description(), KMessageBox::error(), SetiContainer::exists(), QFile::exists(), QDateTime::isValid(), QFileInfo::lastModified(), QString::left(), QString::length(), logDirectory(), QDate::month(), QFile::open(), QFile::putch(), SetiContainer::readEntry(), QTextStream::readLine(), QString::sprintf(), QDateTime::time(), QTime::toString(), QIODevice::writeBlock(), and QDate::year().

Referenced by checkWUStatus().

QString SetiLoc::constructEntry const QString   entry,
int    type
[protected]
 

Creates a string that can be appended to a line of the log file SETILog.csv.

This is a helper method for logWorkUnit(). It takes a string obtained from a sah file by readEntry(), and prepares it in a way that it can be added to the log file.

Parameters:
entry  A string obtained by reading an item from a sah file.
type  Either 0 for a numerical value, or 1 for a string.
Returns:
A string containing an element prepared for the csv file.

Definition at line 522 of file setiloc.cpp.

References QString::append(), QString::insert(), and QString::isEmpty().

Referenced by logWorkUnit().

void SetiLoc::logResults   [protected]
 

Logs the signals found in the result file result.sah.

The information about the signals ( a one-line string) is copied verbatim to the file SETIResult.log. The actual numerical parameters can be parsed with loggedSpikeSignal(), loggedGaussianSignal(), loggedPulseSignal(), and loggedTripletSignal().

Definition at line 545 of file setiloc.cpp.

References QFile::atEnd(), QFile::close(), QFile::exists(), QString::find(), id(), SetiContainer::key(), QString::left(), logDirectory(), loggedTripletProfile(), QString::mid(), QFile::open(), SetiContainer::readEntry(), QTextStream::readLine(), and QString::sprintf().

Referenced by checkWUStatus().

QString SetiLoc::loggedTripletProfile const QString   tdata [protected]
 

Takes the given string with triplet data and compares it with the triplets stored in .triplets.dat.

If a match is found a string with data describing the triplet profile is returned. The motivation behind this is to provide a possibility to log triplet graph data (which the client itself doesn't offer).

Parameters:
tdata  A string with triplet information as is provided by the result.sah file.
Returns:
A string with additional information about the triplet profile (graph data), or an empty string if no match could be found.

Definition at line 738 of file setiloc.cpp.

References QString::arg(), QTextStream::atEnd(), QFile::close(), QString::isEmpty(), logDirectory(), QFile::open(), SetiContainer::readEntry(), QTextStream::readLine(), QStringList::split(), and QString::toDouble().

Referenced by logResults().

int SetiLoc::calcGaussianFFTIndex GaussianScore   g [static, protected]
 

Determines the index value (i.e the position) of the fitted gaussian.

This is done by calculating the least-square sum over the data set. We need this method because the client doesn't store the index value of logged gaussians (in outfile.sah or result.sah).

Parameters:
g  A pointer to the GaussianScore structure.
Returns:
The index value.

Definition at line 858 of file setiloc.cpp.

References GaussianScore::data, GaussianScore::power, GaussianScore::sigma, and GaussianScore::true_mean.

Referenced by loggedGaussianSignal().

void SetiLoc::slotInitMaxScore WorkUnitData    wud [protected, slot]
 

Initializes the processing of a new WU.

In addition to resetting the structure with the best signal scores, any open graph window is hidden, the hidden temporary file .triplets.dat is deleted, and a signal is sent to the skymap window to update its list of displayed locations.

This slot should only be called when starting the processing of a new (downloaded) WU.

Definition at line 231 of file setiloc.cpp.

References color(), description(), QWidget::hide(), SetiContainer::initWUScore(), logDirectory(), mymax, newWorkUnit(), and QDir::remove().

Referenced by SetiLoc().

void SetiLoc::slotDumpClientOutput KProcess  ,
char *   ,
int   
[protected, slot]
 

No descriptions.

Definition at line 719 of file setiloc.cpp.

References clientOutput, QString::find(), QString::length(), and QString::right().

Referenced by SetiLoc().

void SetiLoc::newWorkUnit WorkUnitData    wud,
const QString   locname,
const QColor   col
[signal]
 

This signal is emitted whenever a new WU has been started.

Arguments are a structure with the new work unit data, the name of the corresponding S@h location, and the color used for the location.

This signal is equivalent to the newWorkUnit() signal of the SetiContainer class, only with extended number of arguments.

Referenced by SetiLoc(), and slotInitMaxScore().

void SetiLoc::workUnitLogged SetiLoc *    loc [signal]
 

This signal is emitted whenever a work unit has been logged.

The argument is a pointer to the SetiLoc object.

Referenced by checkWUStatus().


Member Data Documentation

QString SetiLoc::thisId [protected]
 

The unique id string of the location.

Definition at line 338 of file setiloc.h.

Referenced by id(), and SetiLoc().

LocSettings SetiLoc::sets [protected]
 

The settings and options of the location.

Definition at line 340 of file setiloc.h.

Referenced by checkWUStatus(), color(), description(), logDirectory(), optionKeepClientAlive(), optionStartSeti(), optionStopSeti(), SetiLoc(), setOptions(), startClient(), and stopClient().

QString SetiLoc::sresult_timestamp [protected]
 

The time stamp of the result file.

Required to prevent multiple logging.

Definition at line 343 of file setiloc.h.

Referenced by SetiLoc(), setTimestamp(), and timestamp().

KProcess SetiLoc::client [protected]
 

Controls the SETI@home client.

Definition at line 345 of file setiloc.h.

Referenced by SetiLoc(), startClient(), and stopClient().

KProcess SetiLoc::stopProc [protected]
 

Controls a customized shut-down process.

Definition at line 347 of file setiloc.h.

Referenced by stopClient().

WUScore SetiLoc::mymax [protected]
 

Stores the best signal scores found for the WU in progress.

Definition at line 349 of file setiloc.h.

Referenced by initMaxScore(), setMaxScore(), and slotInitMaxScore().

KTextBrowser* SetiLoc::clientOutput [protected]
 

This widget catches the output of the S@h client.

Definition at line 352 of file setiloc.h.

Referenced by SetiLoc(), showGraph(), slotDumpClientOutput(), and ~SetiLoc().

bool SetiLoc::stoppedNormally [protected]
 

Only TRUE if the client has been stopped via the menu action in the popup menu.

Definition at line 355 of file setiloc.h.

Referenced by startClient(), and stopClient().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Ksetiwatch API Version 2.6.1.
Documentation copyright © 2000-2003 Gordon Machel.
Generated on Fri Jun 6 00:28:59 2003 by doxygen 1.2.18, written by Dimitri van Heesch, © 1997-2002