2022-10-28 Fred Gleason <fredg@paravelsystems.com>

* Added an 'RDCatchEvent' class.
	* Reimplemented the 'Deck Event Processed' command using
	'RDCatchEvent'.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-10-28 09:26:37 -04:00
parent 751600dd5d
commit d38349cf39
21 changed files with 863 additions and 153 deletions

View File

@@ -83,6 +83,7 @@ dist_librd_la_SOURCES = dbversion.h\
rdcastsearch.cpp rdcastsearch.h\
rdcatch_conf.cpp rdcatch_conf.h\
rdcatch_connect.cpp rdcatch_connect.h\
rdcatchevent.cpp rdcatchevent.h\
rdcutlistmodel.cpp rdcutlistmodel.h\
rdcddblookup.cpp rdcddblookup.h\
rdcdplayer.cpp rdcdplayer.h\
@@ -315,6 +316,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdcartfilter.cpp\
moc_rdcartslot.cpp\
moc_rdcatch_connect.cpp\
moc_rdcatchevent.cpp\
moc_rdcddblookup.cpp\
moc_rdcdplayer.cpp\
moc_rdcdripper.cpp\

View File

@@ -57,6 +57,7 @@ SOURCES += rdcart_search_text.cpp
SOURCES += rdcartdrag.cpp
SOURCES += rdcartfilter.cpp
SOURCES += rdcatch_connect.cpp
SOURCES += rdcatchevent.cpp
SOURCES += rdcddblookup.cpp
SOURCES += rdcdplayer.cpp
SOURCES += rdcutlistmodel.cpp
@@ -246,13 +247,10 @@ HEADERS += rdcart_search_text.h
HEADERS += rdcartdrag.h
HEADERS += rdcartfilter.h
HEADERS += rdcatch_connect.h
HEADERS += rdcatchevent.h
HEADERS += rdcddblookup.h
HEADERS += rdcdplayer.h
HEADERS += rdcutlistmodel.h
HEADERS += rddatapacer.h
HEADERS += rddiscrecord.h
HEADERS += rddisclookup.h
HEADERS += rddateedit.h
HEADERS += rdcheck_version.h
HEADERS += rdclock.h
HEADERS += rdclockmodel.h
@@ -268,6 +266,8 @@ HEADERS += rdcueeditdialog.h
HEADERS += rdcut_dialog.h
HEADERS += rdcut_path.h
HEADERS += rdcut.h
HEADERS += rddatapacer.h
HEADERS += rddateedit.h
HEADERS += rddatedecode.h
HEADERS += rddatedialog.h
HEADERS += rddatepicker.h
@@ -281,6 +281,8 @@ HEADERS += rddialog.h
HEADERS += rddisclookup.h
HEADERS += rddisclookup_factory.h
HEADERS += rddiscmodel.h
HEADERS += rddiscrecord.h
HEADERS += rddisclookup.h
HEADERS += rddropbox.h
HEADERS += rddropboxlistmodel.h
HEADERS += rddummylookup.h

247
lib/rdcatchevent.cpp Normal file
View File

@@ -0,0 +1,247 @@
// rdcatchevent.cpp
//
// A container class for a Rivendell Catch Event message.
//
// (C) Copyright 2022 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 <QStringList>
#include "rdcatchevent.h"
#include "rdapplication.h"
RDCatchEvent::RDCatchEvent(RDDeck::Status status)
{
clear();
d_operation=RDCatchEvent::DeckEventProcessedOp;
d_deck_status=status;
}
RDCatchEvent::RDCatchEvent()
{
clear();
}
RDCatchEvent::Operation RDCatchEvent::operation() const
{
return d_operation;
}
void RDCatchEvent::setOperation(RDCatchEvent::Operation op)
{
d_operation=op;
}
int RDCatchEvent::eventNumber() const
{
return d_event_number;
}
void RDCatchEvent::setEventNumber(int num)
{
d_event_number=num;
}
QString RDCatchEvent::hostName() const
{
return d_host_name;
}
void RDCatchEvent::setHostName(const QString &str)
{
d_host_name=str;
}
unsigned RDCatchEvent::deckChannel() const
{
return d_deck_channel;
}
void RDCatchEvent::setDeckChannel(unsigned chan)
{
d_deck_channel=chan;
}
RDDeck::Status RDCatchEvent::deckStatus() const
{
return d_deck_status;
}
void RDCatchEvent::setDeckStatus(RDDeck::Status status)
{
d_deck_status=status;
}
bool RDCatchEvent::isValid() const
{
return true;
}
bool RDCatchEvent::read(const QString &str)
{
QStringList f0=str.split(" ");
bool ok=false;
clear();
//
// Common Fields
//
if((f0.size()<3)||(f0.at(0)!="CATCH")) {
return false;
}
//
// Operation-specific Fields
//
if(f0.at(2)==
RDCatchEvent::operationString(RDCatchEvent::DeckEventProcessedOp)) {
if(f0.size()!=5) {
return false;
}
unsigned chan=f0.at(3).toUInt(&ok);
if(!ok) {
return false;
}
unsigned num=f0.at(4).toUInt(&ok);
if(ok) {
d_operation=RDCatchEvent::DeckEventProcessedOp;
d_host_name=f0.at(1);
d_deck_channel=chan;
d_event_number=num;
return true;
}
}
/*
if(f0.at(2)==
RDCatchEvent::operationString(RDCatchEvent::DeckEventProcessedOp)) {
if(f0.size()!=5) {
return false;
}
unsigned chan=f0.at(3).toUInt(&ok);
if(!ok) {
return false;
}
unsigned val=f0.at(4).toUInt(&ok);
if(ok&&(val<RDDeck::LastStatus)) {
d_operation=RDCatchEvent::DeckEventProcessedOp;
d_host_name=f0.at(1);
d_deck_channel=chan;
d_deck_status=(RDDeck::Status)val;
return true;
}
}
*/
return false;
}
QString RDCatchEvent::write() const
{
QString ret;
//
// Common Fields
//
ret+="CATCH ";
ret+=d_host_name+" ";
//
// Operation-specific Fields
//
ret+=RDCatchEvent::operationString(d_operation);
switch(d_operation) {
case RDCatchEvent::DeckEventProcessedOp:
ret+=QString::asprintf(" %u",d_deck_channel);
ret+=QString::asprintf(" %u",d_event_number);
break;
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;
}
return ret;
}
QString RDCatchEvent::dump() const
{
QString ret;
//
// Common Fields
//
ret+="hostName: "+d_host_name+"\n";
//
// Operation-specific Fields
//
ret+="operation: "+RDCatchEvent::operationString(d_operation)+"\n";
switch(d_operation) {
case RDCatchEvent::DeckEventProcessedOp:
ret+=QString::asprintf("deck channel: %u\n",d_deck_channel);
ret+=QString::asprintf("event number: %u\n",d_event_number);
break;
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;
}
return ret;
}
void RDCatchEvent::clear()
{
d_operation=RDCatchEvent::NullOp;
d_host_name=rda->station()->name();
d_deck_channel=0;
d_event_number=0;
d_deck_status=RDDeck::Offline;
}
QString RDCatchEvent::operationString(Operation op)
{
QString ret="UNKNOWN";
switch(op) {
case RDCatchEvent::DeckEventProcessedOp:
ret="DE";
break;
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;
}
return ret;
}

61
lib/rdcatchevent.h Normal file
View File

@@ -0,0 +1,61 @@
// rdcatchevent.h
//
// A container class for a Rivendell Catch Event message.
//
// (C) Copyright 2022 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 RDCATCHEVENT_H
#define RDCATCHEVENT_H
#include <QString>
#include <QVariant>
#include <rddeck.h>
class RDCatchEvent
{
public:
enum Operation {NullOp=0,DeckEventProcessedOp=1,LastOp=2};
RDCatchEvent(RDDeck::Status status);
RDCatchEvent();
Operation operation() const;
void setOperation(Operation op);
QString hostName() const;
void setHostName(const QString &str);
unsigned deckChannel() const;
void setDeckChannel(unsigned chan);
int eventNumber() const;
void setEventNumber(int num);
RDDeck::Status deckStatus() const;
void setDeckStatus(RDDeck::Status status);
bool isValid() const;
bool read(const QString &str);
QString write() const;
QString dump() const;
void clear();
static QString operationString(Operation op);
private:
Operation d_operation;
QString d_host_name;
unsigned d_deck_channel;
int d_event_number;
RDDeck::Status d_deck_status;
};
#endif // RDCATCHEVENT_H

View File

@@ -30,7 +30,7 @@
class RDDeck
{
public:
enum Status {Offline=0,Idle=1,Ready=2,Recording=3,Waiting=4};
enum Status {Offline=0,Idle=1,Ready=2,Recording=3,Waiting=4,LastStatus=5};
RDDeck(QString station,unsigned channel,bool create=false);
bool isActive() const;
QString station() const;

View File

@@ -2,7 +2,7 @@
//
// Connection to the Rivendell Interprocess Communication Daemon
//
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 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
@@ -147,6 +147,13 @@ void RDRipc::sendNotification(const RDNotification &notify)
}
void RDRipc::sendCatchEvent(RDCatchEvent *evt)
{
SendCommand("ON "+evt->write()+"!");
rda->syslog(LOG_NOTICE,"sent catch event: %s\n",evt->write().toUtf8().constData());
}
void RDRipc::sendOnairFlag()
{
SendCommand(QString::asprintf("TA %d!",ripc_onair_flag));
@@ -406,12 +413,24 @@ void RDRipc::DispatchCommand()
msg+=QString(cmds[i])+" ";
}
msg=msg.left(msg.length()-1);
RDNotification *notify=new RDNotification();
if(!notify->read(msg)) {
QStringList f0=msg.split(" ",QString::SkipEmptyParts);
if(f0.at(0)=="NOTIFY") {
RDNotification *notify=new RDNotification();
if(!notify->read(msg)) {
delete notify;
return;
}
emit notificationReceived(notify);
delete notify;
return;
}
emit notificationReceived(notify);
delete notify;
if(f0.at(0)=="CATCH") {
RDCatchEvent *evt=new RDCatchEvent();
if(!evt->read(msg)) {
delete evt;
return;
}
emit catchEventReceived(evt);
delete evt;
}
}
}

View File

@@ -2,7 +2,7 @@
//
// Connection to the Rivendell Interprocess Communication Daemon
//
// (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 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
@@ -18,21 +18,19 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qsqldatabase.h>
#include <qstring.h>
#include <qobject.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qtcpsocket.h>
#ifndef RDRIPC_H
#define RDRIPC_H
#include <QLabel>
#include <QTimer>
#include <QTcpSocket>
#include <rdcatchevent.h>
#include <rdconfig.h>
#include <rdmacro.h>
#include <rdnotification.h>
#include <rdstation.h>
#ifndef RDRIPC_H
#define RDRIPC_H
#define RIPC_MAX_ARGS 100
#define RIPC_MAX_LENGTH 256
#define RIPC_START_DELAY 2000
@@ -58,6 +56,7 @@ class RDRipc : public QObject
void sendNotification(RDNotification::Type type,
RDNotification::Action action,const QVariant &id);
void sendNotification(const RDNotification &notify);
void sendCatchEvent(RDCatchEvent *evt);
void sendOnairFlag();
void sendRml(RDMacro *macro);
void reloadHeartbeat();
@@ -72,6 +71,7 @@ class RDRipc : public QObject
void gpiCartChanged(int matrix,int line,int off_cartnum,int on_cartnum);
void gpoCartChanged(int matrix,int line,int off_cartnum,int on_cartnum);
void notificationReceived(RDNotification *notify);
void catchEventReceived(RDCatchEvent *evt);
void onairFlagChanged(bool state);
void rmlReceived(RDMacro *rml);