Esempio n. 1
0
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);
}
Esempio n. 2
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);
}
Esempio n. 3
0
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(&macro);
        }
    }
    delete rmt_station;
    done(0);
}
Esempio n. 4
0
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(&macro);
	    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(&macro);
      }
    }
  }
}
Esempio n. 5
0
void MainObject::DispatchCommand(int ch)
{
  QString default_name;
  char str[RD_RML_MAX_LENGTH];
  RDMacro macro;
  char buffer[RD_RML_MAX_LENGTH];
  char cmd[RD_RML_MAX_LENGTH+4];
  int echo=0;
  QHostAddress addr;

  //
  // Common Commands
  // Authentication not required to execute these!
  //
  if(!strcmp(args[ch][0],"DC")) {  // Drop Connection
    socket[ch]->close();
    KillSocket(ch);
    return;
  }
  if(!strcmp(args[ch][0],"PW")) {  // Password Authenticate
    if(!strcmp(args[ch][1],ripcd_config->password())) {
      auth[ch]=true;
      EchoCommand(ch,"PW +!");
      return;
    }
    else {
      auth[ch]=false;
      EchoCommand(ch,"PW -!");
      return;
    }
  }

  //
  // Priviledged Commands
  // Authentication required to execute these!
  //
  if(!auth[ch]) {
    EchoArgs(ch,'-');
    return;
  }

  if(!strcmp(args[ch][0],"RU")) {  // Request User
    EchoCommand(ch,(const char *)QString().
		sprintf("RU %s!",(const char *)rdstation->userName()));
    return;
  }

  if(!strcmp(args[ch][0],"SU")) {  // Set User
    SetUser(args[ch][1]);
  }

  if(!strcmp(args[ch][0],"MS")) {  // Send RML Command
    if(argnum[ch]<4) {
      return;
    }
    strcpy(str,args[ch][3]);
    for(int i=4;i<argnum[ch];i++) {
      strcat(str," ");
      strcat(str,args[ch][i]);
    }
    strcat(str,"!");
  }
  if(macro.parseString(str,strlen(str))) {
    addr.setAddress(args[ch][1]);
    macro.setAddress(addr);
    macro.setRole(RDMacro::Cmd);

/*
  char temp[RD_RML_MAX_LENGTH];
  macro.generateString(temp,RD_RML_MAX_LENGTH);
  LogLine(QString().sprintf("RECEIVED: %s  ADDR: %s\n",temp,(const char *)macro.address().toString()));
*/

    if(!macro.address().isNull()) {
      if(macro.address()==rdstation->address()) {  // Local Loopback
	macro.generateString(buffer,RD_RML_MAX_LENGTH);
	if(macro.echoRequested()) {
	  echo=1;
	}
	sprintf(cmd,"MS %s %d %s",(const char *)macro.address().toString(),
		echo,buffer);
	RunLocalMacros(&macro);
	BroadcastCommand(cmd);
      }
      else {
	sendRml(&macro);
      }
    }
  }

  if(!strcmp(args[ch][0],"ME")) {  // Send RML Reply
    if(argnum[ch]<4) {
      return;
    }
    strcpy(str,args[ch][3]);
    for(int i=4;i<argnum[ch];i++) {
      strcat(str," ");
      strcat(str,args[ch][i]);
    }
    strcat(str,"!");
  }
  if(macro.parseString(str,strlen(str))) {
    QHostAddress addr;
    addr.setAddress(args[ch][1]);
    macro.setAddress(addr);
    macro.setRole(RDMacro::Reply); 
    if(macro.address()==rdstation->address()) {  // Local Loopback
      macro.generateString(buffer,RD_RML_MAX_LENGTH);
      sprintf(cmd,"ME %s 0 %s",(const char *)macro.address().toString(),
	      buffer);
      BroadcastCommand(cmd);
    }
    else {
      sendRml(&macro);
    }
  }

  if(!strcmp(args[ch][0],"RG")) {  // Reload the GPI Table
    LoadGpiTable();
  }

  if(!strcmp(args[ch][0],"GI")) {  // Send Complete GPI Status
    int matrix;
    sscanf(args[ch][1],"%d",&matrix);
    SendGpi(ch,matrix);
  }

  if(!strcmp(args[ch][0],"GO")) {  // Send Complete GPO Status
    int matrix;
    sscanf(args[ch][1],"%d",&matrix);
    SendGpo(ch,matrix);
  }

  if(!strcmp(args[ch][0],"GM")) {  // Send Complete GPI Mask States
    int matrix;
    sscanf(args[ch][1],"%d",&matrix);
    SendGpiMask(ch,matrix);
  }

  if(!strcmp(args[ch][0],"GN")) {  // Send Complete GPI Mask States
    int matrix;
    sscanf(args[ch][1],"%d",&matrix);
    SendGpoMask(ch,matrix);
  }

  if(!strcmp(args[ch][0],"GC")) {  // Send Complete GPI Cart Assignments
    int matrix;
    sscanf(args[ch][1],"%d",&matrix);
    SendGpiCart(ch,matrix);
  }

  if(!strcmp(args[ch][0],"GD")) {  // Send Complete GPO Cart Assignments
    int matrix;
    sscanf(args[ch][1],"%d",&matrix);
    SendGpoCart(ch,matrix);
  }

  if(!strcmp(args[ch][0],"TA")) {  // Send Onair Flag State
    EchoCommand(ch,QString().sprintf("TA %d!",ripc_onair_flag));
  }
}
Esempio n. 6
0
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);
}