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

* Reimplemented the 'PurgeEvent' command using 'RDCatchEvent'.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2022-10-30 16:02:46 -04:00
parent d65517215b
commit de49ba6cd9
9 changed files with 91 additions and 11 deletions

View File

@ -1 +0,0 @@
fredg@frozone.paravelsystems.com.26763:1666465399

View File

@ -23572,3 +23572,5 @@
2022-10-30 Fred Gleason <fredg@paravelsystems.com>
* Reimplemented the 'Request Deck Status' command using
'RDCatchEvent'.
2022-10-30 Fred Gleason <fredg@paravelsystems.com>
* Reimplemented the 'PurgeEvent' command using 'RDCatchEvent'.

View File

@ -576,8 +576,42 @@
</tgroup>
</table>
</sect3>
</sect2>
<sect2 xml:id="sect.rdcatch_purge_event">
<title>Purge Event Operation</title>
<para>
Emitted by <command>rdcatch</command><manvolnum>1</manvolnum> to
report purging of a one-shot event.
</para>
<table xml:id="table.rdcatch_purge_event" frame="all" pgwide="0">
<title>RDCatch Event Request Fields</title>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<colspec colname="Field" colwidth="2.0*"/>
<colspec colname="Value" colwidth="2.0*"/>
<tbody>
<row>
<entry>Field</entry>
<entry>Value</entry>
</row>
<row>
<entry>Hostname</entry>
<entry>String, from STATIONS.NAME</entry>
</row>
<row>
<entry>Operation</entry>
<entry>Integer. 4 [RDCatchEvent::PurgeEventOp]</entry>
</row>
<row>
<entry>Event ID</entry>
<entry>
Unsigned Integer, from RECORDINGS.ID.
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1>
</article>

View File

@ -318,14 +318,14 @@ void RDCatchConnect::DispatchCommand()
}
emit eventUpdated(id);
}
/*
if(!strcmp(args[0],"PE")) { // Purge Event
if(sscanf(args[1],"%d",&id)!=1) {
return;
}
emit eventPurged(id);
}
*/
if(!strcmp(args[0],"HB")) { // Heartbeat
cc_heartbeat_timer->stop();
cc_heartbeat_timer->start(CC_HEARTBEAT_INTERVAL);

View File

@ -141,6 +141,8 @@ bool RDCatchEvent::isValid() const
bool RDCatchEvent::read(const QString &str)
{
printf("RDCatchEvent::read(\"%s\")\n",str.toUtf8().constData());
RDCatchEvent::Operation op=RDCatchEvent::NullOp;
QStringList f0=str.split(" ");
bool ok=false;
@ -214,6 +216,19 @@ bool RDCatchEvent::read(const QString &str)
}
}
if(ok&&(op==RDCatchEvent::PurgeEventOp)) {
if(f0.size()!=4) {
return false;
}
unsigned id=f0.at(3).toUInt(&ok);
if(ok) {
d_operation=op;
d_host_name=f0.at(1);
d_event_id=id;
return true;
}
}
return false;
}
@ -246,6 +261,10 @@ QString RDCatchEvent::write() const
ret+=QString::asprintf(" %d",d_cut_number);
break;
case RDCatchEvent::PurgeEventOp:
ret+=QString::asprintf(" %u",d_event_id);
break;
case RDCatchEvent::DeckStatusQueryOp:
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
@ -288,6 +307,11 @@ QString RDCatchEvent::dump() const
ret+=QString::asprintf("cut number: %d\n",d_cut_number);
break;
case RDCatchEvent::PurgeEventOp:
ret+="operation: RDCatchEvent::PurgeEventOpOp\n";
ret+=QString::asprintf("event id: %u\n",d_event_id);
break;
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;

View File

@ -31,7 +31,7 @@ class RDCatchEvent
public:
enum Operation {NullOp=0,DeckEventProcessedOp=1,
DeckStatusQueryOp=2,DeckStatusResponseOp=3,
LastOp=4};
PurgeEventOp=4,LastOp=5};
RDCatchEvent(RDDeck::Status status);
RDCatchEvent();
Operation operation() const;

View File

@ -208,9 +208,11 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
connect(catch_connect.back()->connector(),
SIGNAL(eventUpdated(int)),
this,SLOT(eventUpdatedData(int)));
/*
connect(catch_connect.back()->connector(),
SIGNAL(eventPurged(int)),
this,SLOT(eventPurgedData(int)));
*/
/*
connect(catch_connect.back()->connector(),
SIGNAL(deckEventSent(int,int,int)),
@ -799,6 +801,20 @@ void MainWidget::catchEventReceivedData(RDCatchEvent *evt)
{
printf("catchEventReceivedData()\n");
printf("%s\n",evt->dump().toUtf8().constData());
switch(evt->operation()) {
case RDCatchEvent::PurgeEventOp:
catch_recordings_model->removeRecord(evt->eventId());
printf("removed event %u\n",evt->eventId());
break;
case RDCatchEvent::DeckEventProcessedOp:
case RDCatchEvent::DeckStatusQueryOp:
case RDCatchEvent::DeckStatusResponseOp:
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;
}
}
@ -1012,12 +1028,12 @@ void MainWidget::eventUpdatedData(int id)
nextEventData();
}
/*
void MainWidget::eventPurgedData(int id)
{
catch_recordings_model->removeRecord(id);
}
*/
void MainWidget::heartbeatFailedData(int id)
{

View File

@ -103,7 +103,7 @@ class MainWidget : public RDMainWindow
void clockData();
void midnightData();
void eventUpdatedData(int id);
void eventPurgedData(int id);
// void eventPurgedData(int id);
void heartbeatFailedData(int id);
void quitMainWidget();

View File

@ -2436,9 +2436,14 @@ void MainObject::PurgeEvent(int event)
{
QString sql=QString::asprintf("delete from `RECORDINGS` where `ID`=%d",
catch_events[event].id());
RDSqlQuery *q=new RDSqlQuery(sql);
delete q;
BroadcastCommand(QString::asprintf("PE %d!",catch_events[event].id()));
RDSqlQuery::apply(sql);
RDCatchEvent *evt=new RDCatchEvent();
evt->setOperation(RDCatchEvent::PurgeEventOp);
evt->setEventId(catch_events[event].id());
rda->ripc()->sendCatchEvent(evt);
delete evt;
switch(catch_events[event].type()) {
case RDRecording::Recording:
rda->syslog(LOG_INFO,"purged event %d, Type: recording, Cut: %s",