Reformatted rdcatchd/local_macros.cpp

This commit is contained in:
Fred Gleason 2016-03-29 14:20:26 -04:00
parent 465f6ad79d
commit 49fdde859d

View File

@ -36,131 +36,131 @@ void MainObject::RunLocalMacros(RDMacro *rml)
QDateTime dt; QDateTime dt;
switch(rml->command()) { switch(rml->command()) {
case RDMacro::EX: case RDMacro::EX:
cart=new RDCart(rml->arg(0).toUInt()); cart=new RDCart(rml->arg(0).toUInt());
if(cart->exists()) { if(cart->exists()) {
if(ExecuteMacroCart(cart)) { if(ExecuteMacroCart(cart)) {
if(rml->echoRequested()) { if(rml->echoRequested()) {
rml->acknowledge(true); rml->acknowledge(true);
catch_ripc->sendRml(rml); catch_ripc->sendRml(rml);
}
delete cart;
return;
}
}
else {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
}
} }
delete cart; delete cart;
return; return;
break; }
}
else {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
}
}
delete cart;
return;
break;
case RDMacro::RS: case RDMacro::RS:
// //
// Validate Parameters // Validate Parameters
// //
if(rml->argQuantity()!=4) { if(rml->argQuantity()!=4) {
if(rml->echoRequested()) { if(rml->echoRequested()) {
rml->acknowledge(false); rml->acknowledge(false);
catch_ripc->sendRml(rml); catch_ripc->sendRml(rml);
} }
return; return;
} }
chan=rml->arg(0).toInt(); chan=rml->arg(0).toInt();
cartnum=rml->arg(1).toUInt(); cartnum=rml->arg(1).toUInt();
cutnum=rml->arg(2).toUInt(); cutnum=rml->arg(2).toUInt();
len=rml->arg(3).toUInt(); len=rml->arg(3).toUInt();
if((chan<=0)||(chan>MAX_DECKS)||(cartnum>999999)||(cutnum>999) if((chan<=0)||(chan>MAX_DECKS)||(cartnum>999999)||(cutnum>999)
||len==0) { ||len==0) {
if(rml->echoRequested()) { if(rml->echoRequested()) {
rml->acknowledge(false); rml->acknowledge(false);
catch_ripc->sendRml(rml); catch_ripc->sendRml(rml);
} }
return; return;
} }
cut=new RDCut(cartnum,cutnum); cut=new RDCut(cartnum,cutnum);
deck=new RDDeck(catch_config->stationName(),chan); deck=new RDDeck(catch_config->stationName(),chan);
if((!cut->exists())||(!deck->isActive())) { if((!cut->exists())||(!deck->isActive())) {
delete cut; delete cut;
delete deck; delete deck;
if(rml->echoRequested()) { if(rml->echoRequested()) {
rml->acknowledge(false); rml->acknowledge(false);
catch_ripc->sendRml(rml); catch_ripc->sendRml(rml);
} }
return; return;
} }
delete cut; delete cut;
delete deck; delete deck;
if(catch_record_deck_status[chan-1]!=RDDeck::Idle) { if(catch_record_deck_status[chan-1]!=RDDeck::Idle) {
if(catch_record_aborting[chan-1]&& if(catch_record_aborting[chan-1]&&
(catch_record_pending_cartnum[chan-1]==0)) { (catch_record_pending_cartnum[chan-1]==0)) {
// Cache Event // Cache Event
catch_record_pending_cartnum[chan-1]=cartnum; catch_record_pending_cartnum[chan-1]=cartnum;
catch_record_pending_cutnum[chan-1]=cutnum; catch_record_pending_cutnum[chan-1]=cutnum;
catch_record_pending_maxlen[chan-1]=len; catch_record_pending_maxlen[chan-1]=len;
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
}
return;
}
else {
LogLine(RDConfig::LogWarning,QString().
sprintf("unable to handle RS macro for deck %d: device busy",
chan));
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
}
return;
}
}
//
// Create Event
//
StartRmlRecording(chan,cartnum,cutnum,len);
if(rml->echoRequested()) { if(rml->echoRequested()) {
rml->acknowledge(true); rml->acknowledge(true);
catch_ripc->sendRml(rml); catch_ripc->sendRml(rml);
} }
break; return;
}
case RDMacro::RR: else {
if(rml->argQuantity()!=1) { LogLine(RDConfig::LogWarning,QString().
if(rml->echoRequested()) { sprintf("unable to handle RS macro for deck %d: device busy",
rml->acknowledge(false); chan));
catch_ripc->sendRml(rml);
}
return;
}
chan=rml->arg(0).toInt();
if((chan>0)&&(chan<(MAX_DECKS+1))) {
switch(catch_record_deck_status[chan-1]) {
case RDDeck::Recording:
catch_record_aborting[chan-1]=true;
catch_cae->stopRecord(catch_record_card[chan-1],
catch_record_stream[chan-1]);
break;
case RDDeck::Waiting:
startTimerData(catch_record_id[chan-1]);
break;
default:
break;
}
}
if(rml->echoRequested()) { if(rml->echoRequested()) {
rml->acknowledge(true); rml->acknowledge(false);
catch_ripc->sendRml(rml); catch_ripc->sendRml(rml);
} }
return;
}
}
//
// Create Event
//
StartRmlRecording(chan,cartnum,cutnum,len);
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
}
break;
case RDMacro::RR:
if(rml->argQuantity()!=1) {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
}
return;
}
chan=rml->arg(0).toInt();
if((chan>0)&&(chan<(MAX_DECKS+1))) {
switch(catch_record_deck_status[chan-1]) {
case RDDeck::Recording:
catch_record_aborting[chan-1]=true;
catch_cae->stopRecord(catch_record_card[chan-1],
catch_record_stream[chan-1]);
break;
case RDDeck::Waiting:
startTimerData(catch_record_id[chan-1]);
break; break;
default: default:
break; break;
}
}
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
}
break;
default:
break;
} }
} }