mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-29 15:12:34 +02:00
2021-09-23 Fred Gleason <fredg@paravelsystems.com>
* Removed the 'STATIONS.TIME_STAMP' field from the database. * Incremented the database version to 357. * Removed the 'RDStation::isOnline()' method. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
34dc526c66
commit
eb27824e8a
@ -22456,3 +22456,7 @@
|
|||||||
system.
|
system.
|
||||||
* Added code to ripcd(8) to provide system presence information.
|
* Added code to ripcd(8) to provide system presence information.
|
||||||
* Removed vestigal exit monitor code from rdcatchd(8).
|
* Removed vestigal exit monitor code from rdcatchd(8).
|
||||||
|
2021-09-23 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Removed the 'STATIONS.TIME_STAMP' field from the database.
|
||||||
|
* Incremented the database version to 357.
|
||||||
|
* Removed the 'RDStation::isOnline()' method.
|
||||||
|
@ -255,6 +255,19 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<sect3 xml:id="sect.object_types.station_presence.notes">
|
||||||
|
<title>Notes</title>
|
||||||
|
<para>
|
||||||
|
Upon reception of a <userinput>STATION_PRESENCE</userinput>
|
||||||
|
notification with an action of <userinput>ADD</userinput>,
|
||||||
|
a receiving host should reply via unicast UDP with their own
|
||||||
|
<userinput>STATION_PRESENCE</userinput> with an action of
|
||||||
|
<userinput>MODIFY</userinput> to the originating IP address,
|
||||||
|
such replies to be randomly delayed by 10 - 20 seconds after
|
||||||
|
reception of the <userinput>ADD</userinput> notification.
|
||||||
|
</para>
|
||||||
|
</sect3>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* Current Database Version
|
* Current Database Version
|
||||||
*/
|
*/
|
||||||
#define RD_VERSION_DATABASE 356
|
#define RD_VERSION_DATABASE 357
|
||||||
|
|
||||||
|
|
||||||
#endif // DBVERSION_H
|
#endif // DBVERSION_H
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#ifndef RDNOTIFICATION_H
|
#ifndef RDNOTIFICATION_H
|
||||||
#define RDNOTIFICATION_H
|
#define RDNOTIFICATION_H
|
||||||
|
|
||||||
|
#include <QHostAddress>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
@ -45,25 +45,6 @@ bool RDStation::exists() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RDStation::isOnline() const
|
|
||||||
{
|
|
||||||
bool ret=false;
|
|
||||||
|
|
||||||
QString sql=QString("select ")+
|
|
||||||
"`TIME_STAMP` "+ // 00
|
|
||||||
"from `STATIONS where "+
|
|
||||||
"`NAME`='"+RDEscapeString(station_name)+"'";
|
|
||||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
|
||||||
if(q->first()) {
|
|
||||||
ret=(!q->value(0).isNull())&&
|
|
||||||
(q->value(0).toDateTime().addSecs(30)>QDateTime::currentDateTime());
|
|
||||||
}
|
|
||||||
delete q;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString RDStation::name() const
|
QString RDStation::name() const
|
||||||
{
|
{
|
||||||
return station_name;
|
return station_name;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Abstract a Rivendell Workstation
|
// Abstract a Rivendell Workstation
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License version 2 as
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@ -37,7 +37,6 @@ class RDStation
|
|||||||
~RDStation();
|
~RDStation();
|
||||||
QString name() const;
|
QString name() const;
|
||||||
bool exists() const;
|
bool exists() const;
|
||||||
bool isOnline() const;
|
|
||||||
QString shortName() const;
|
QString shortName() const;
|
||||||
void setShortName(const QString &str) const;
|
void setShortName(const QString &str) const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
|
@ -65,6 +65,7 @@ dist_ripcd_SOURCES = acu1p.cpp acu1p.h\
|
|||||||
modbus.cpp modbus.h\
|
modbus.cpp modbus.h\
|
||||||
modemlines.cpp modemlines.h\
|
modemlines.cpp modemlines.h\
|
||||||
quartz1.cpp quartz1.h\
|
quartz1.cpp quartz1.h\
|
||||||
|
presence.cpp presence.h\
|
||||||
ripcd.cpp ripcd.h globals.h\
|
ripcd.cpp ripcd.h globals.h\
|
||||||
ripcd_connection.cpp ripcd_connection.h\
|
ripcd_connection.cpp ripcd_connection.h\
|
||||||
rossnkscp.cpp rossnkscp.h\
|
rossnkscp.cpp rossnkscp.h\
|
||||||
@ -113,6 +114,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
|
|||||||
moc_local_gpio.cpp\
|
moc_local_gpio.cpp\
|
||||||
moc_modbus.cpp\
|
moc_modbus.cpp\
|
||||||
moc_modemlines.cpp\
|
moc_modemlines.cpp\
|
||||||
|
moc_presence.cpp\
|
||||||
moc_quartz1.cpp\
|
moc_quartz1.cpp\
|
||||||
moc_ripcd.cpp\
|
moc_ripcd.cpp\
|
||||||
moc_rossnkscp.cpp\
|
moc_rossnkscp.cpp\
|
||||||
|
79
ripcd/presence.cpp
Normal file
79
ripcd/presence.cpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// presence.cpp
|
||||||
|
//
|
||||||
|
// Presence data for a Rivendell station
|
||||||
|
//
|
||||||
|
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <rdapplication.h>
|
||||||
|
|
||||||
|
#include "presence.h"
|
||||||
|
|
||||||
|
Presence::Presence(const QString &name,QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
d_name=name.toLower();
|
||||||
|
rda->syslog(LOG_DEBUG,"adding presence record for \"%s\"",
|
||||||
|
name.toUtf8().constData());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Presence::~Presence()
|
||||||
|
{
|
||||||
|
rda->syslog(LOG_DEBUG,"removing presence record for \"%s\"",
|
||||||
|
d_name.toUtf8().constData());
|
||||||
|
if(d_timer!=NULL) {
|
||||||
|
delete d_timer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Presence::name() const
|
||||||
|
{
|
||||||
|
return d_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QHostAddress Presence::hostAddress() const
|
||||||
|
{
|
||||||
|
return d_host_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Presence::setHostAddress(const QHostAddress &addr)
|
||||||
|
{
|
||||||
|
d_host_address=addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Presence::updateLocalId()
|
||||||
|
{
|
||||||
|
if(d_timer!=NULL) {
|
||||||
|
delete d_timer;
|
||||||
|
}
|
||||||
|
d_timer=new QTimer(this);
|
||||||
|
d_timer->setSingleShot(true);
|
||||||
|
connect(d_timer,SIGNAL(timeout()),this,SLOT(timeoutData()));
|
||||||
|
d_timer->start(10000+(long long)random*10000/RAND_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Presence::timeoutData()
|
||||||
|
{
|
||||||
|
emit sendLocalId(d_name);
|
||||||
|
d_timer->deleteLater();
|
||||||
|
d_timer=NULL;
|
||||||
|
}
|
53
ripcd/presence.h
Normal file
53
ripcd/presence.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// presence.h
|
||||||
|
//
|
||||||
|
// Presence data for a Rivendell station
|
||||||
|
//
|
||||||
|
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
|
// published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef PRESENCE_H
|
||||||
|
#define PRESENCE_H
|
||||||
|
|
||||||
|
#include <QHostAddress>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
class Presence : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Presence(const QString &name,QObject *parent=0);
|
||||||
|
~Presence();
|
||||||
|
QString name() const;
|
||||||
|
QHostAddress hostAddress() const;
|
||||||
|
void setHostAddress(const QHostAddress &addr);
|
||||||
|
void updateLocalId();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sendLocalId(const QString &name);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void timeoutData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString d_name;
|
||||||
|
QHostAddress d_host_address;
|
||||||
|
QTimer *d_timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PRESENCE_H
|
@ -202,10 +202,15 @@ MainObject::MainObject(QObject *parent)
|
|||||||
//
|
//
|
||||||
// Presence
|
// Presence
|
||||||
//
|
//
|
||||||
|
/*
|
||||||
ripcd_presence_timer=new QTimer(this);
|
ripcd_presence_timer=new QTimer(this);
|
||||||
connect(ripcd_presence_timer,SIGNAL(timeout()),this,SLOT(presenceData()));
|
connect(ripcd_presence_timer,SIGNAL(timeout()),this,SLOT(presenceData()));
|
||||||
presenceData();
|
presenceData();
|
||||||
ripcd_presence_timer->start(15000);
|
ripcd_presence_timer->start(15000);
|
||||||
|
*/
|
||||||
|
Presence *pres=new Presence(rda->station()->name());
|
||||||
|
pres->setHostAddress(rda->station()->address());
|
||||||
|
ripcd_presences[pres->name()]=pres;
|
||||||
RDNotification *notify=
|
RDNotification *notify=
|
||||||
new RDNotification(RDNotification::StationPresenceType,
|
new RDNotification(RDNotification::StationPresenceType,
|
||||||
RDNotification::AddAction,rda->station()->name());
|
RDNotification::AddAction,rda->station()->name());
|
||||||
@ -252,6 +257,7 @@ void MainObject::newConnectionData()
|
|||||||
void MainObject::notificationReceivedData(const QString &msg,
|
void MainObject::notificationReceivedData(const QString &msg,
|
||||||
const QHostAddress &addr)
|
const QHostAddress &addr)
|
||||||
{
|
{
|
||||||
|
Presence *pres=NULL;
|
||||||
RDNotification *notify=new RDNotification();
|
RDNotification *notify=new RDNotification();
|
||||||
|
|
||||||
if(!notify->read(msg)) {
|
if(!notify->read(msg)) {
|
||||||
@ -260,6 +266,34 @@ void MainObject::notificationReceivedData(const QString &msg,
|
|||||||
delete notify;
|
delete notify;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update presence database
|
||||||
|
//
|
||||||
|
if(notify->type()==RDNotification::StationPresenceType) {
|
||||||
|
if((notify->action()==RDNotification::AddAction)||
|
||||||
|
(notify->action()==RDNotification::ModifyAction)) {
|
||||||
|
if((pres=ripcd_presences.value(notify->id().toString()))==NULL) {
|
||||||
|
pres=new Presence(notify->id().toString(),this);
|
||||||
|
connect(pres,SIGNAL(sendLocalId(const QString &)),
|
||||||
|
this,SLOT(sendLocalIdData(const QString &)));
|
||||||
|
ripcd_presences[pres->name()]=pres;
|
||||||
|
}
|
||||||
|
pres->setHostAddress(addr);
|
||||||
|
if(notify->action()==RDNotification::AddAction) {
|
||||||
|
pres->updateLocalId();
|
||||||
|
}
|
||||||
|
// Notify stack!!
|
||||||
|
}
|
||||||
|
if(notify->action()==RDNotification::DeleteAction) {
|
||||||
|
if((pres=ripcd_presences.value(notify->id().toString()))!=NULL) {
|
||||||
|
// Notify stack!
|
||||||
|
delete pres;
|
||||||
|
ripcd_presences.remove(notify->id().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RunLocalNotifications(notify);
|
RunLocalNotifications(notify);
|
||||||
BroadcastCommand("ON "+msg+"!");
|
BroadcastCommand("ON "+msg+"!");
|
||||||
|
|
||||||
@ -501,6 +535,21 @@ void MainObject::presenceData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainObject::sendLocalIdData(const QString &name)
|
||||||
|
{
|
||||||
|
Presence *pres=ripcd_presences.value(name);
|
||||||
|
|
||||||
|
if(pres!=NULL) {
|
||||||
|
RDNotification *notify=
|
||||||
|
new RDNotification(RDNotification::StationPresenceType,
|
||||||
|
RDNotification::ModifyAction,name);
|
||||||
|
ripcd_notification_mcaster->
|
||||||
|
send(notify->write(),pres->hostAddress(),RD_NOTIFICATION_PORT);
|
||||||
|
delete notify;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::SetUser(QString username)
|
void MainObject::SetUser(QString username)
|
||||||
{
|
{
|
||||||
rda->station()->setUserName(username);
|
rda->station()->setUserName(username);
|
||||||
|
@ -23,14 +23,13 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
#include <qobject.h>
|
#include <QString>
|
||||||
#include <qstring.h>
|
#include <QSignalMapper>
|
||||||
#include <qsignalmapper.h>
|
#include <QTcpServer>
|
||||||
#include <qtcpserver.h>
|
#include <QTimer>
|
||||||
#include <qtimer.h>
|
#include <QUdpSocket>
|
||||||
#include <qudpsocket.h>
|
|
||||||
|
|
||||||
#ifdef JACK
|
#ifdef JACK
|
||||||
#include <jack/jack.h>
|
#include <jack/jack.h>
|
||||||
@ -46,9 +45,10 @@
|
|||||||
#include <rdmulticaster.h>
|
#include <rdmulticaster.h>
|
||||||
#include <rdtty.h>
|
#include <rdtty.h>
|
||||||
|
|
||||||
#include <ripcd_connection.h>
|
#include "globals.h"
|
||||||
#include <globals.h>
|
#include "presence.h"
|
||||||
#include <switcher.h>
|
#include "ripcd_connection.h"
|
||||||
|
#include "switcher.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Global RIPCD Definitions
|
// Global RIPCD Definitions
|
||||||
@ -84,7 +84,8 @@ class MainObject : public QObject
|
|||||||
void garbageData();
|
void garbageData();
|
||||||
void startJackData();
|
void startJackData();
|
||||||
void presenceData();
|
void presenceData();
|
||||||
|
void sendLocalIdData(const QString &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetUser(QString username);
|
void SetUser(QString username);
|
||||||
void ExecCart(int cartnum);
|
void ExecCart(int cartnum);
|
||||||
@ -137,6 +138,7 @@ class MainObject : public QObject
|
|||||||
unsigned ripc_macro_cart[RD_MAX_MACRO_TIMERS];
|
unsigned ripc_macro_cart[RD_MAX_MACRO_TIMERS];
|
||||||
RDMulticaster *ripcd_notification_mcaster;
|
RDMulticaster *ripcd_notification_mcaster;
|
||||||
QTimer *ripcd_garbage_timer;
|
QTimer *ripcd_garbage_timer;
|
||||||
|
QMap<QString,Presence *> ripcd_presences;
|
||||||
#ifdef JACK
|
#ifdef JACK
|
||||||
jack_client_t *ripcd_jack_client;
|
jack_client_t *ripcd_jack_client;
|
||||||
QTimer *ripcd_start_jack_timer;
|
QTimer *ripcd_start_jack_timer;
|
||||||
|
@ -41,6 +41,22 @@ bool MainObject::RevertSchema(int cur_schema,int set_schema,QString *err_msg)
|
|||||||
// NEW SCHEMA REVERSIONS GO HERE...
|
// NEW SCHEMA REVERSIONS GO HERE...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Revert 357
|
||||||
|
//
|
||||||
|
if((cur_schema==357)&&(set_schema<cur_schema)) {
|
||||||
|
sql=QString("alter table `STATIONS` ")+
|
||||||
|
"add column `TIME_STAMP` datetime after `DESCRIPTION`";
|
||||||
|
if(!RDSqlQuery::apply(sql,err_msg)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WriteSchemaVersion(--cur_schema);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Revert 356
|
// Revert 356
|
||||||
//
|
//
|
||||||
|
@ -160,7 +160,7 @@ void MainObject::InitializeSchemaMap() {
|
|||||||
global_version_map["3.4"]=317;
|
global_version_map["3.4"]=317;
|
||||||
global_version_map["3.5"]=346;
|
global_version_map["3.5"]=346;
|
||||||
global_version_map["3.6"]=347;
|
global_version_map["3.6"]=347;
|
||||||
global_version_map["4.0"]=356;
|
global_version_map["4.0"]=357;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10967,6 +10967,12 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
|
|||||||
WriteSchemaVersion(++cur_schema);
|
WriteSchemaVersion(++cur_schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((cur_schema<357)&&(set_schema>cur_schema)) {
|
||||||
|
DropColumn("STATIONS","TIME_STAMP");
|
||||||
|
|
||||||
|
WriteSchemaVersion(++cur_schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NEW SCHEMA UPDATES GO HERE...
|
// NEW SCHEMA UPDATES GO HERE...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user