1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-06 17:46:07 +01:00
LibrePilot/ground/openpilotgcs/src/plugins/notify/NotificationItem.h

179 lines
5.4 KiB
C
Raw Normal View History

2011-09-14 23:38:18 +02:00
/**
******************************************************************************
*
* @file NotificationItem.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Notify Plugin configuration header
* @see The GNU Public License (GPL) Version 3
* @defgroup notifyplugin
* @{
*
*****************************************************************************/
/*
* 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 3 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef NOTIFICATION_ITEM_H
#define NOTIFICATION_ITEM_H
#include <coreplugin/iuavgadgetconfiguration.h>
#include "qsettings.h"
#include <qstringlist.h>
#include <QTimer>
using namespace Core;
#define DECLARE_SOUND(number) \
QString getSound##number() const { return _sound##number; } \
void setSound##number(QString text) { _sound##number = text; } \
2011-09-29 19:26:46 +02:00
class UAVDataObject;
class UAVObjectField;
2011-09-14 23:38:18 +02:00
class NotificationItem : public QObject
{
Q_OBJECT
2011-09-14 23:38:18 +02:00
public:
2011-09-29 19:26:46 +02:00
enum { eDefaultTimeout = 15 }; // in sec
explicit NotificationItem(QObject *parent = 0);
void copyTo(NotificationItem*) const;
DECLARE_SOUND(1)
DECLARE_SOUND(2)
DECLARE_SOUND(3)
2011-09-29 19:26:46 +02:00
QString range() const { return _rangeLimit; }
void setRange(QString text) { _rangeLimit = text; }
QString getSayOrder() const { return _sayOrder; }
void setSayOrder(QString text) { _sayOrder = text; }
2011-09-14 23:38:18 +02:00
2011-09-29 19:26:46 +02:00
double singleValue() const { return _singleValue; }
void setSingleValue(double value) { _singleValue = value; }
2011-09-14 23:38:18 +02:00
2011-09-29 19:26:46 +02:00
double valueRange2() const { return _valueRange2; }
void setValueRange2(double value) { _valueRange2 = value; }
2011-09-14 23:38:18 +02:00
QString getDataObject() const { return _dataObject; }
void setDataObject(QString text) { _dataObject = text; }
2011-09-14 23:38:18 +02:00
QString getObjectField() const { return _objectField; }
void setObjectField(QString text) { _objectField = text; }
2011-09-14 23:38:18 +02:00
QString getSoundCollectionPath() const { return _soundCollectionPath; }
void setSoundCollectionPath(QString path) { _soundCollectionPath = path; }
2011-09-14 23:38:18 +02:00
QString getCurrentLanguage() const { return _currentLanguage; }
void setCurrentLanguage(QString text) { _currentLanguage = text; }
2011-09-14 23:38:18 +02:00
QStringList getMessageSequence() const { return _messageSequence; }
void setMessageSequence(QStringList sequence) { _messageSequence = sequence; }
2011-09-14 23:38:18 +02:00
2011-09-18 23:30:57 +02:00
QString retryString() const { return _repeatString; }
void setRetryString(QString value) { _repeatString = value; }
2011-09-14 23:38:18 +02:00
2011-09-18 23:30:57 +02:00
int lifetime() const { return _expireTimeout; }
void setLifetime(int value) { _expireTimeout = value; }
2011-09-14 23:38:18 +02:00
2011-09-18 23:30:57 +02:00
bool mute() const { return _mute; }
void setMute(bool value) { _mute = value; }
2011-09-14 23:38:18 +02:00
void saveState(QSettings* settings) const;
void restoreState(QSettings* settings);
2011-09-14 23:38:18 +02:00
2011-09-18 23:30:57 +02:00
2011-09-29 19:26:46 +02:00
UAVDataObject* getUAVObject(void);
UAVObjectField* getUAVObjectField(void);
2011-09-18 23:30:57 +02:00
void seriaize(QDataStream& stream);
void deseriaize(QDataStream& stream);
QString parseNotifyMessage();
2011-09-14 23:38:18 +02:00
QTimer* getTimer() const { return _timer; }
void startTimer(int value);
void stopTimer();
void disposeTimer();
2011-09-14 23:38:18 +02:00
QTimer* getExpireTimer() const { return _expireTimer; }
void startExpireTimer();
void stopExpireTimer();
2011-09-14 23:38:18 +02:00
void disposeExpireTimer();
2011-09-14 23:38:18 +02:00
bool isNowPlaying;
bool firstStart;
2011-09-14 23:38:18 +02:00
private:
2011-09-29 19:26:46 +02:00
void checkSoundFilesExisting(bool& missed1, bool& missed2, bool& missed3);
private:
QTimer* _timer;
//! time from putting notification in queue till moment when notification became out-of-date
//! NOTE: each notification has it lifetime, this time setups individually for each notification
//! according to its priority
QTimer* _expireTimer;
QStringList _messageSequence;
2011-09-14 23:38:18 +02:00
//! path to folder with sound files
QString _soundCollectionPath;
2011-09-14 23:38:18 +02:00
//! language in what notifications will be spelled
QString _currentLanguage;
2011-09-14 23:38:18 +02:00
//! one UAV object per one notification
QString _dataObject;
2011-09-14 23:38:18 +02:00
//! one field value change can be assigned to one notification
QString _objectField;
2011-09-14 23:38:18 +02:00
2011-09-29 19:26:46 +02:00
//! fire condition for UAV field value (lower, greater, in range)
QString _rangeLimit;
2011-09-14 23:38:18 +02:00
//! possible sounds(at least one required to play notification)
QString _sound1;
QString _sound2;
QString _sound3;
2011-09-14 23:38:18 +02:00
//! order in what sounds 1-3 will be played
QString _sayOrder;
2011-09-14 23:38:18 +02:00
2011-09-29 19:26:46 +02:00
//! one-side range, value maybe lower or greater
double _singleValue;
//! both-side range, value should be inside the range
//double _valueRange1;
double _valueRange2;
2011-09-14 23:38:18 +02:00
//! how often or what periodicaly notification should be played
2011-09-18 23:30:57 +02:00
QString _repeatString;
2011-09-14 23:38:18 +02:00
//! time after event occured till notification became invalid
//! and will be removed from list
int _expireTimeout;
2011-09-14 23:38:18 +02:00
//! enables/disables playing of current notification
2011-09-18 23:30:57 +02:00
bool _mute;
2011-09-14 23:38:18 +02:00
};
Q_DECLARE_METATYPE(NotificationItem*)
#endif // NotificationItem_H