void ListGpis::okData() { QString sql; RDSqlQuery *q; RDMacro rml; sql=QString().sprintf("delete from %s where (STATION_NAME=\"%s\")&&\ MATRIX=%d", (const char *)list_tablename, (const char *)list_matrix->station(), list_matrix->matrix()); q=new RDSqlQuery(sql); delete q; RDStation *station=new RDStation(list_matrix->station()); rml.setCommand(RDMacro::GI); rml.setRole(RDMacro::Cmd); rml.setArgQuantity(5); rml.setArg(0,list_matrix->matrix()); switch(list_type) { case RDMatrix::GpioInput: rml.setArg(1,"I"); break; case RDMatrix::GpioOutput: rml.setArg(1,"O"); break; } rml.setAddress(station->address()); rml.setEchoRequested(false); delete station; QListViewItem *item=list_list_view->firstChild(); while(item!=NULL) { sql=QString().sprintf("insert into %s set STATION_NAME=\"%s\",\ MATRIX=%d,NUMBER=%d,MACRO_CART=%d,OFF_MACRO_CART=%d", (const char *)list_tablename, (const char *)list_matrix->station(), list_matrix->matrix(), item->text(0).toInt(), item->text(1).toInt(), item->text(3).toInt()); q=new RDSqlQuery(sql); delete q; rml.setArg(2,item->text(0).toInt()); rml.setArg(3,true); rml.setArg(4,item->text(1).toInt()); rdripc->sendRml(&rml); rml.setArg(3,false); rml.setArg(4,item->text(3).toInt()); rdripc->sendRml(&rml); item=item->nextSibling(); } done(0); }
void MainObject::ExecCart(int cartnum) { RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); rml.setAddress(rdstation->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); sendRml(&rml); }
void Switcher::executeMacroCart(unsigned cartnum) { RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); rml.setAddress(rdstation->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); emit rmlEcho(&rml); }
void SoftwareAuthority::ExecuteMacroCart(unsigned cartnum) { RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); rml.setAddress(rda->station()->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); emit rmlEcho(&rml); }
void MainObject::ReadRmlSocket(QSocketDevice *dev,RDMacro::Role role, bool echo) { char buffer[RD_RML_MAX_LENGTH]; char cmd[RD_RML_MAX_LENGTH+4]; QString output; int n; QHostAddress peer_addr; RDMacro macro; while((n=dev->readBlock(buffer,RD_RML_MAX_LENGTH))>0) { buffer[n]=0; if(macro.parseString(buffer,n)) { macro.setRole(role); macro.setAddress(dev->peerAddress()); macro.setEchoRequested(echo); macro.generateString(buffer,RD_RML_MAX_LENGTH); switch(role) { case RDMacro::Cmd: sprintf(cmd,"MS %s %d %s",(const char *)macro.address().toString(), echo,buffer); RunLocalMacros(¯o); BroadcastCommand(cmd); break; case RDMacro::Reply: sprintf(cmd,"ME %s %d %s",(const char *)macro.address().toString(), echo,buffer); break; default: break; } } else { LogLine(RDConfig::LogWarning, QString().sprintf("received malformed rml: \"%s\" from %s:%u", buffer, (const char *)dev->peerAddress().toString(), dev->peerPort())); if(echo) { macro.setRole(RDMacro::Reply); macro.setCommand(RDMacro::NN); macro.setArg(0,"-"); macro.setArgQuantity(1); macro.setAddress(dev->peerAddress()); sendRml(¯o); } } } }
void ListMatrices::closeData() { RDStation *rmt_station=new RDStation(list_station); QHostAddress addr=rmt_station->address(); RDMacro macro; macro.setCommand(RDMacro::SZ); macro.setRole(RDMacro::Cmd); macro.setEchoRequested(false); macro.setArgQuantity(1); for(int i=0; i<MAX_MATRICES; i++) { if(list_matrix_modified[i]) { macro.setAddress(rmt_station->address()); macro.setArg(0,i); rdripc->sendRml(¯o); } } delete rmt_station; done(0); }