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

* Reimplemented the 'Request Deck Status' command using
	'RDCatchEvent'.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-10-30 14:54:29 -04:00
parent d38349cf39
commit d65517215b
14 changed files with 413 additions and 72 deletions

View File

@@ -316,7 +316,6 @@ 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

@@ -234,10 +234,10 @@ void RDCatchConnect::DispatchCommand()
int deck;
int channel;
int level;
unsigned chan;
int status;
// unsigned chan;
// int status;
int id;
int number;
// int number;
if(!strcmp(args[0],"PW")) { // Password Response
if(args[1][0]=='+') {
@@ -248,7 +248,7 @@ void RDCatchConnect::DispatchCommand()
emit connected(cc_serial,false);
}
}
/*
if(!strcmp(args[0],"DE")) { // Deck Event
if(sscanf(args[1],"%d",&deck)!=1) {
return;
@@ -297,7 +297,7 @@ void RDCatchConnect::DispatchCommand()
}
return;
}
*/
if(!strcmp(args[0],"RM")) { // Meter Level
if(sscanf(args[1],"%d",&deck)!=1) {
return;

View File

@@ -67,7 +67,7 @@ class RDCatchConnect : public QObject
void meterLevel(int serial,int deck,int chan,int level);
void eventUpdated(int id);
void eventPurged(int id);
void deckEventSent(int serial,int chan,int number);
// void deckEventSent(int serial,int chan,int number);
void heartbeatFailed(int id);
private slots:

View File

@@ -73,6 +73,42 @@ void RDCatchEvent::setHostName(const QString &str)
}
unsigned RDCatchEvent::eventId() const
{
return d_event_id;
}
void RDCatchEvent::setEventId(unsigned id)
{
d_event_id=id;
}
unsigned RDCatchEvent::cartNumber() const
{
return d_cart_number;
}
void RDCatchEvent::setCartNumber(unsigned cartnum)
{
d_cart_number=cartnum;
}
int RDCatchEvent::cutNumber() const
{
return d_cut_number;
}
void RDCatchEvent::setCutNumber(int cutnum)
{
d_cut_number=cutnum;
}
unsigned RDCatchEvent::deckChannel() const
{
return d_deck_channel;
@@ -105,6 +141,7 @@ bool RDCatchEvent::isValid() const
bool RDCatchEvent::read(const QString &str)
{
RDCatchEvent::Operation op=RDCatchEvent::NullOp;
QStringList f0=str.split(" ");
bool ok=false;
@@ -116,12 +153,12 @@ bool RDCatchEvent::read(const QString &str)
if((f0.size()<3)||(f0.at(0)!="CATCH")) {
return false;
}
op=(RDCatchEvent::Operation)f0.at(2).toUInt(&ok);
//
// Operation-specific Fields
//
if(f0.at(2)==
RDCatchEvent::operationString(RDCatchEvent::DeckEventProcessedOp)) {
if(ok&&(op==RDCatchEvent::DeckEventProcessedOp)) {
if(f0.size()!=5) {
return false;
}
@@ -131,33 +168,52 @@ bool RDCatchEvent::read(const QString &str)
}
unsigned num=f0.at(4).toUInt(&ok);
if(ok) {
d_operation=RDCatchEvent::DeckEventProcessedOp;
d_operation=op;
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) {
if(ok&&(op==RDCatchEvent::DeckStatusQueryOp)) {
if(f0.size()!=3) {
return false;
}
unsigned chan=f0.at(3).toUInt(&ok);
if(!ok) {
d_operation=op;
d_host_name=f0.at(1);
return true;
}
if(ok&&(op==RDCatchEvent::DeckStatusResponseOp)) {
if(f0.size()!=8) {
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;
int chan=f0.at(3).toUInt(&ok);
if(ok&&(chan<255)) {
RDDeck::Status status=(RDDeck::Status)f0.at(4).toUInt(&ok);
if(ok&&(status<RDDeck::LastStatus)) {
unsigned id=f0.at(5).toUInt(&ok);
if(ok) {
unsigned cartnum=f0.at(6).toUInt(&ok);
if(ok&&(cartnum<=RD_MAX_CART_NUMBER)) {
int cutnum=f0.at(7).toInt(&ok);
if(ok&&(cutnum>=0)&&(cutnum<=RD_MAX_CUT_NUMBER)) {
d_operation=op;
d_host_name=f0.at(1);
d_deck_channel=chan;
d_deck_status=status;
d_event_id=id;
d_cart_number=cartnum;
d_cut_number=cutnum;
return true;
}
}
}
}
}
}
*/
return false;
}
@@ -171,17 +227,26 @@ QString RDCatchEvent::write() const
//
ret+="CATCH ";
ret+=d_host_name+" ";
ret+=QString::asprintf("%u",d_operation);
//
// 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::DeckStatusResponseOp:
ret+=QString::asprintf(" %u",d_deck_channel);
ret+=QString::asprintf(" %u",d_deck_status);
ret+=QString::asprintf(" %u",d_event_id);
ret+=QString::asprintf(" %u",d_cart_number);
ret+=QString::asprintf(" %d",d_cut_number);
break;
case RDCatchEvent::DeckStatusQueryOp:
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;
@@ -203,13 +268,26 @@ QString RDCatchEvent::dump() const
//
// Operation-specific Fields
//
ret+="operation: "+RDCatchEvent::operationString(d_operation)+"\n";
switch(d_operation) {
case RDCatchEvent::DeckEventProcessedOp:
ret+="operation: RDCatchEvent::DeckEventProcessedOp\n";
ret+=QString::asprintf("deck channel: %u\n",d_deck_channel);
ret+=QString::asprintf("event number: %u\n",d_event_number);
break;
case RDCatchEvent::DeckStatusQueryOp:
ret+="operation: RDCatchEvent::DeckStatusQueryOp\n";
break;
case RDCatchEvent::DeckStatusResponseOp:
ret+="operation: RDCatchEvent::DeckStatusResponseOp\n";
ret+=QString::asprintf("deck channel: %u\n",d_deck_channel);
ret+=QString::asprintf("deck status: %u\n",d_deck_status);
ret+=QString::asprintf("event id: %u\n",d_event_id);
ret+=QString::asprintf("cart number: %u\n",d_cart_number);
ret+=QString::asprintf("cut number: %d\n",d_cut_number);
break;
case RDCatchEvent::NullOp:
case RDCatchEvent::LastOp:
break;
@@ -223,25 +301,10 @@ void RDCatchEvent::clear()
{
d_operation=RDCatchEvent::NullOp;
d_host_name=rda->station()->name();
d_event_id=0;
d_cart_number=0;
d_cut_number=0;
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;
}

View File

@@ -29,13 +29,21 @@
class RDCatchEvent
{
public:
enum Operation {NullOp=0,DeckEventProcessedOp=1,LastOp=2};
enum Operation {NullOp=0,DeckEventProcessedOp=1,
DeckStatusQueryOp=2,DeckStatusResponseOp=3,
LastOp=4};
RDCatchEvent(RDDeck::Status status);
RDCatchEvent();
Operation operation() const;
void setOperation(Operation op);
QString hostName() const;
void setHostName(const QString &str);
unsigned eventId() const;
void setEventId(unsigned id);
unsigned cartNumber() const;
void setCartNumber(unsigned cartnum);
int cutNumber() const;
void setCutNumber(int cutnum);
unsigned deckChannel() const;
void setDeckChannel(unsigned chan);
int eventNumber() const;
@@ -47,11 +55,13 @@ class RDCatchEvent
QString write() const;
QString dump() const;
void clear();
static QString operationString(Operation op);
private:
Operation d_operation;
QString d_host_name;
unsigned d_event_id;
unsigned d_cart_number;
int d_cut_number;
unsigned d_deck_channel;
int d_event_number;
RDDeck::Status d_deck_status;

View File

@@ -250,7 +250,7 @@ void RDRipc::DispatchCommand()
RDMacro macro;
QString str;
// printf("RDRipc::DispatchCommand: %s\n",(const char *)ripc_accum.toUtf8());
// printf("RDRipc::DispatchCommand: %s\n",ripc_accum.toUtf8().constData());
QStringList cmds=ripc_accum.split(" ",QString::SkipEmptyParts);
if(cmds.size()==0) {