Пример #1
0
void Bt16x1::processCommand(RDMacro *cmd)
{
  char str[9];

  switch(cmd->command()) {
      case RDMacro::ST:
	if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()!=1)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(1).toInt()==0) {
	  sprintf(str,"*m\x0d");
	  bt_device->writeBlock(str,3);
	}
	else {
	  sprintf(str,"*%02d\x0d",cmd->arg(1).toInt());
	  bt_device->writeBlock(str,4);
	}
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #2
0
void RossNkScp::processCommand(RDMacro *cmd)
{
  char str[11];

  switch(cmd->command()) {
      case RDMacro::ST:
	if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>ross_inputs)||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>ross_outputs)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	sprintf(str,"X%03d,%03d,%d\x0d",cmd->arg(2).toInt()-1,
		cmd->arg(1).toInt()-1,ross_breakaway);
	syslog(LOG_WARNING,"sent: %s\n",str);
	ross_device->writeBlock(str,11);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #3
0
void Unity4000::processCommand(RDMacro *cmd)
{
  char str[256];
  char route;
  int input=cmd->arg(1).toInt()-1;
  int output=cmd->arg(2).toInt()-1;

  if((input<-1)||(input>=unity_inputs)||
     (output<0)||(output>=unity_outputs)) {
    cmd->acknowledge(false);
    emit rmlEcho(cmd);
    return;
  }
  switch(unity_feed[input].mode()) {
      case RDMatrix::Left:
	route='1';
	break;
	
      case RDMatrix::Right:
	route='2';
	break;
	
      default:
	route='S';
	break;
  }
  switch(cmd->command()) {
      case RDMacro::ST:
	if(input==-1) {
	  sprintf(str,"\x0DMUTE A/%d\x0D",output+1);
	  unity_device->writeBlock(str,strlen(str));
	}
	else {
	  sprintf(str,"\x0DUNMUTE A/%d\x0D",output+1);
	  unity_device->writeBlock(str,strlen(str));
	  sprintf(str,"\x0DSETAUDIO %d %c %s\x0D",
		  output+1,
		  route,
		  (const char *)unity_feed[input].feed());
	  unity_device->writeBlock(str,strlen(str));
	}
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;
	
      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #4
0
void SoftwareAuthority::processCommand(RDMacro *cmd)
{
  QString str;

  switch(cmd->command()) {
      case RDMacro::ST:
	if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>swa_inputs)||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>swa_outputs)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	SendCommand(QString().sprintf("activateroute %d %d %d",swa_card,
				      cmd->arg(2).toInt(),cmd->arg(1).toInt()));
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::GO:
	if(((cmd->arg(1).toString().lower()!="i")&&
	    (cmd->arg(1).toString().lower()!="o"))||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>swa_gpos)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(1).toString().lower()=="i") {
	  str="triggergpi";
	}
	else {
	  str="triggergpo";
	}
	str+=QString().sprintf(" %d",swa_card);
	str+=QString().sprintf(" %d ",
		      1+(cmd->arg(2).toInt()-1)/RD_LIVEWIRE_GPIO_BUNDLE_SIZE);
	str+=BundleString((cmd->arg(2).toInt()-1)%RD_LIVEWIRE_GPIO_BUNDLE_SIZE,
			  cmd->arg(3).toInt()!=0);
	if(cmd->arg(4).toInt()>0) {   // Momentary
	  str+=QString().sprintf(" %d",cmd->arg(4).toInt());
	}
	SendCommand(str);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #5
0
void Sas32000::SendCommand(RDMacro *cmd,const char *format)
{
  char str[8];

  if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>sas_inputs)||
     (cmd->arg(2).toInt()<0)||(cmd->arg(2).toInt()>sas_outputs)) {
    cmd->acknowledge(false);
    emit rmlEcho(cmd);
  }
  sprintf(str,format,cmd->arg(1).toInt(),cmd->arg(2).toInt());
  sas_commands.push(QString(str));
  if(!sas_timer->isActive()) {
    sas_timer->start(SAS32000_COMMAND_DELAY);
  }
  cmd->acknowledge(true);
  emit rmlEcho(cmd);
}
Пример #6
0
void StarGuide3::processCommand(RDMacro *cmd)
{
  char str[256];
  char route;
  int input=cmd->arg(1).toInt()-1;
  int output=cmd->arg(2).toInt()-1;

  if((input<0)||(input>=sg_inputs)||
     (output<0)||(output>=sg_outputs)) {
    cmd->acknowledge(false);
    emit rmlEcho(cmd);
    return;
  }
  switch(sg_feed[input].mode()) {
      case RDMatrix::Left:
	route='1';
	break;
	
      case RDMatrix::Right:
	route='2';
	break;
	
      default:
	route='0';
	break;
  }
  switch(cmd->command()) {
      case RDMacro::ST:
	sprintf(str,"SP A,P,%d\rSP A,S,%d\rAM %c,0%c\r",
		sg_feed[input].providerId(),
		sg_feed[input].serviceId(),
		output+'A',
		route);
	sg_device->writeBlock(str,strlen(str));
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;
	
      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #7
0
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);
}
Пример #8
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);
}
Пример #9
0
void Sas32000::processCommand(RDMacro *cmd)
{
  char str[9];
  char sign='1';

  switch(cmd->command()) {
      case RDMacro::ST:
	SendCommand(cmd,"DT1%02d%02d");
	break;

      case RDMacro::SA:
	SendCommand(cmd,"DS1%02d%02d");
	break;

      case RDMacro::SR:
	SendCommand(cmd,"DS0%02d%02d");
	break;

      case RDMacro::SL:
	if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>sas_inputs)||
	   (cmd->arg(2).toInt()<SAS32000_MIN_GAIN)||
	   (cmd->arg(2).toInt()>SAS32000_MAX_GAIN)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	}
	if(cmd->arg(2).toInt()<0) {
	  sign='0';
	}
	sprintf(str,"DL%02d%c%03d",cmd->arg(1).toInt(),sign,
		10*abs(cmd->arg(2).toInt()));
	sas_device->writeBlock(str,8);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #10
0
void BtSs42::processCommand(RDMacro *cmd)
{
  char str[9];

  switch(cmd->command()) {
      case RDMacro::GO:
	if((cmd->argQuantity()!=5)||
	   ((cmd->arg(1).toString().lower()!="i")&&
	    (cmd->arg(1).toString().lower()!="o"))||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(3).toInt()>bt_gpos)||
	   (cmd->arg(2).toInt()>bt_gpos)||
	   ((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
	    (cmd->arg(1).toString().lower()!="i"))||
	   ((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
	    (cmd->arg(3).toInt()!=-1)&&(cmd->arg(1).toString().lower()=="i"))||
	   (cmd->arg(4).toInt()<0)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(3).toInt()==0) {  // Turn OFF
	  if(cmd->arg(4).toInt()==0) {
	    if(cmd->arg(1).toString().lower()=="i") {
	      if(bt_gpi_state[cmd->arg(2).toInt()-1]) {
		emit gpiChanged(bt_matrix,cmd->arg(2).toInt()-1,false);
		bt_gpi_state[cmd->arg(2).toInt()-1]=false;
	      }
	      bt_gpi_mask[cmd->arg(2).toInt()-1]=true;
	    }
	    if(cmd->arg(1).toString().lower()=="o") {
	      if(cmd->arg(2).toInt()<=4) {
		sprintf(str,"*%dOO%dF",BTSS42_UNIT_ID,cmd->arg(2).toInt());
	      }
	      else {
		sprintf(str,"*%dOR%dF",BTSS42_UNIT_ID,cmd->arg(2).toInt()-4);
	      }
	      bt_device->writeBlock(str,6);
	      emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,false);
	    }
	  }
	  else {
	    if(cmd->echoRequested()) {
	      cmd->acknowledge(false);
	      emit rmlEcho(cmd);
	    }
	    return;
	  }
	}
	else {
	  if(cmd->arg(3).toInt()==-1) {  // Clear input
	    bt_gpi_mask[cmd->arg(2).toInt()-1]=false;
	    bt_device->writeBlock("*0SPA",5);
	  }
	  else { 
	    if(cmd->arg(4).toInt()==0) {  // Turn ON
	      if(cmd->arg(1).toString().lower()=="i") {
		if(!bt_gpi_state[cmd->arg(2).toInt()-1]) {
		  emit gpiChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
		  bt_gpi_state[cmd->arg(2).toInt()-1]=true;
		}
		bt_gpi_mask[cmd->arg(2).toInt()-1]=true;
	      }
	      if(cmd->arg(1).toString().lower()=="o") {
		if(cmd->arg(2).toInt()<=4) {
		  sprintf(str,"*%dOO%dL",BTSS42_UNIT_ID,cmd->arg(2).toInt());
		}
		else {
		  sprintf(str,"*%dOR%dL",BTSS42_UNIT_ID,cmd->arg(2).toInt()-4);
		}
		bt_device->writeBlock(str,6);
		emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
	      }
	    }
	    else {  // Pulse
	      if(cmd->arg(1).toString().lower()=="i") {
		if(!bt_gpi_state[cmd->arg(2).toInt()-1]) {
		  emit gpiChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
		  bt_gpi_state[cmd->arg(2).toInt()-1]=true;
		}
		bt_gpi_mask[cmd->arg(2).toInt()-1]=true;
		bt_gpi_oneshot->start(cmd->arg(2).toInt()-1,500);
	      }
	      if(cmd->arg(1).toString().lower()=="o") {
		if(cmd->arg(2).toInt()<=4) {
		  sprintf(str,"*%dOO%dP",BTSS42_UNIT_ID,cmd->arg(2).toInt());
		}
		else {
		  sprintf(str,"*%dOR%dP",BTSS42_UNIT_ID,cmd->arg(2).toInt()-4);
		}
		bt_device->writeBlock(str,6);
		emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
		bt_gpo_oneshot->start(cmd->arg(2).toInt()-1,500);
	      }
	    }
	  }
	}
	if(cmd->echoRequested()) {
	  cmd->acknowledge(true);
	  emit rmlEcho(cmd);
	}
	break;

      case RDMacro::SA:
	if((cmd->arg(1).toInt()<1)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>2)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	sprintf(str,"*%d%02d%d",BTSS42_UNIT_ID,
		cmd->arg(1).toInt(),cmd->arg(2).toInt());
	bt_device->writeBlock(str,5);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::SR:
	if((cmd->arg(1).toInt()<1)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>2)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	sprintf(str,"*%d%02dM%d",BTSS42_UNIT_ID,
		cmd->arg(1).toInt(),cmd->arg(2).toInt());
	bt_device->writeBlock(str,6);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::ST:
	if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>2)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(1).toInt()==0) {
	  sprintf(str,"*%dM%d",BTSS42_UNIT_ID,cmd->arg(2).toInt());
	  bt_device->writeBlock(str,4);
	}
	else {
	  sprintf(str,"*%d%02d%d",BTSS42_UNIT_ID,
		  cmd->arg(1).toInt(),cmd->arg(2).toInt());
	  bt_device->writeBlock(str,5);
	  for(int i=1;i<cmd->arg(1).toInt();i++) {
	    sprintf(str,"*%d%02dM%d",BTSS42_UNIT_ID,
		    i,cmd->arg(2).toInt());
	    bt_device->writeBlock(str,6);
	  }
	  for(int i=cmd->arg(1).toInt()+1;i<5;i++) {
	    sprintf(str,"*%d%02dM%d",BTSS42_UNIT_ID,
		    i,cmd->arg(2).toInt());
	    bt_device->writeBlock(str,6);
	  }
	}
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #11
0
void Harlond::processCommand(RDMacro *cmd)
{
  switch(cmd->command()) {
  case RDMacro::FS:      // Fire Salvo
    if(cmd->argQuantity()<2) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    if(!ProcessSalvo(cmd->rollupArgs(1))) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    cmd->acknowledge(true);
    emit rmlEcho(cmd);
    break;


  case RDMacro::GO:      // GPO Set
    if(cmd->argQuantity()!=5) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    if(!ProcessGpo(cmd->arg(2).toInt(),cmd->arg(3).toBool(),
		   cmd->arg(4).toInt())) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    cmd->acknowledge(true);
    emit rmlEcho(cmd);
    break;

  case RDMacro::SL:     // Switch Level
    if(cmd->argQuantity()!=3) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    if(!SetInputLevel(cmd->arg(1).toInt(),cmd->arg(2).toInt())) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    cmd->acknowledge(true);
    emit rmlEcho(cmd);
    break;

  case RDMacro::SA:     // Switch Add
  case RDMacro::SR:     // Switch Remove
  case RDMacro::ST:     // Switch Take
    if(cmd->argQuantity()!=3) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    if(!ProcessCrosspoint(cmd->command(),cmd->arg(1).toInt(),
			  cmd->arg(2).toInt())) {
      cmd->acknowledge(false);
      emit rmlEcho(cmd);
      return;
    }
    cmd->acknowledge(true);
    emit rmlEcho(cmd);
    break;

  default:
    break;
  }
}
Пример #12
0
void LocalAudio::processCommand(RDMacro *cmd)
{
  switch(cmd->command()) {
      case RDMacro::ST:
	if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(1).toInt()==0) {
	  for(int i=0;i<bt_inputs;i++) {
	    rdcae->
	      setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
	  }
	}
	else {
	  rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
				      cmd->arg(2).toInt()-1,0);
	  for(int i=0;i<(cmd->arg(1).toInt()-1);i++) {
	    rdcae->
	      setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
	  }
	  for(int i=cmd->arg(1).toInt();i<bt_inputs;i++) {
	    rdcae->
	      setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000);
	  }
	}
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::SA:
	if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
				    cmd->arg(2).toInt()-1,0);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::SR:
	if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
				    cmd->arg(2).toInt()-1,RD_MUTE_DEPTH);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::SX:
	if((cmd->arg(1).toInt()<=0)||(cmd->arg(1).toInt()>bt_inputs)||
	   (cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)||
	   (cmd->arg(3).toInt()<RD_MUTE_DEPTH)||(cmd->arg(3).toInt()>0)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1,
				    cmd->arg(2).toInt()-1,cmd->arg(3).toInt());
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #13
0
void ModemLines::processCommand(RDMacro *cmd)
{
  switch(cmd->command()) {
      case RDMacro::GO:
	if((gpio_fd<0)||(cmd->argQuantity()!=5)||
	   ((cmd->arg(1).toString().lower()!="i")&&
	    (cmd->arg(1).toString().lower()!="o"))||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>gpio_gpos)||
	   ((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
	    (cmd->arg(3).toInt()!=-1))||(cmd->arg(4).toInt()<0)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(1).toString().lower()=="i") {
	  if(cmd->arg(3).toInt()==0) {
	    emit gpiChanged(gpio_matrix,cmd->arg(2).toInt()-1,false);
	    gpio_gpi_mask[cmd->arg(2).toInt()-1]=true;
	    if(cmd->arg(4).toInt()>0) {
	      gpio_gpi_oneshot->
		start(cmd->arg(2).toInt()-1,cmd->arg(4).toInt());
	    }
	  }
	  else {
	    if(cmd->arg(3).toInt()==1) {
	      emit gpiChanged(gpio_matrix,cmd->arg(2).toInt()-1,true);
	      gpio_gpi_mask[cmd->arg(2).toInt()-1]=true;
	      if(cmd->arg(4).toInt()>0) {
		gpio_gpi_oneshot->
		  start(cmd->arg(2).toInt()-1,cmd->arg(4).toInt());
	      }
	    }
	    else {
	      gpiOneshotData(cmd->arg(2).toInt()-1);
	    }
	  }
	  cmd->acknowledge(true);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(1).toString().lower()=="o") {
	  if(cmd->arg(3).toInt()==0) {
	    ioctl(gpio_fd,TIOCMBIC,&gpio_gpo_table[cmd->arg(2).toInt()-1]);
	    if(cmd->arg(4).toInt()>0) {
	      gpio_gpo_timers[cmd->arg(2).toInt()-1]->
		start(cmd->arg(4).toInt(),true);
	      gpio_gpo_pending_states[cmd->arg(2).toInt()-1]=true;
	    }
	  }
	  else {
	    if(cmd->arg(3).toInt()==1) {
	      ioctl(gpio_fd,TIOCMBIS,&gpio_gpo_table[cmd->arg(2).toInt()-1]);
	      if(cmd->arg(4).toInt()>0) {
		gpio_gpo_timers[cmd->arg(2).toInt()-1]->
		  start(cmd->arg(4).toInt(),true);
		gpio_gpo_pending_states[cmd->arg(2).toInt()-1]=false;
	      }
	    }
	    else {
	      cmd->acknowledge(false);
	      emit rmlEcho(cmd);
	      return;
	    }
	  }
	  cmd->acknowledge(true);
	  emit rmlEcho(cmd);
	  return;
	}
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #14
0
void BtSrc8Iii::processCommand(RDMacro *cmd)
{
  char str[9];

  switch(cmd->command()) {
      case RDMacro::GO:
	if((cmd->argQuantity()!=5)||
	   ((cmd->arg(1).toString().lower()!="i")&&
	    (cmd->arg(1).toString().lower()!="o"))||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(3).toInt()>bt_gpos)||
	   (cmd->arg(2).toInt()>bt_gpos)||
	   ((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
	    (cmd->arg(1).toString().lower()!="i"))||
	   ((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
	    (cmd->arg(3).toInt()!=-1)&&(cmd->arg(1).toString().lower()=="i"))||
	   (cmd->arg(4).toInt()<0)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(3).toInt()==0) {  // Turn OFF
	  if(cmd->arg(4).toInt()==0) {
	    if(cmd->arg(1).toString().lower()=="i") {
	      if(bt_gpi_state[cmd->arg(2).toInt()-1]) {
		emit gpiChanged(bt_matrix,cmd->arg(2).toInt()-1,false);
		bt_gpi_state[cmd->arg(2).toInt()-1]=false;
	      }
	      bt_gpi_mask[cmd->arg(2).toInt()-1]=true;
	    }
	    if(cmd->arg(1).toString().lower()=="o") {
	      sprintf(str,"*%dOR%dF\r\n",BTSRC8III_UNIT_ID,cmd->arg(2).toInt());
	      bt_device->writeBlock(str,8);
	      emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,false);
	    }
	  }
	  else {
	    if(cmd->echoRequested()) {
	      cmd->acknowledge(false);
	      emit rmlEcho(cmd);
	    }
	    return;
	  }
	}
	else {
	  if(cmd->arg(3).toInt()==-1) {  // Clear input
	    bt_gpi_mask[cmd->arg(2).toInt()-1]=false;
	    bt_device->writeBlock("*0SPA\r\n",7);
	  }
	  else { 
	    if(cmd->arg(4).toInt()==0) {  // Turn ON
	      if(cmd->arg(1).toString().lower()=="i") {
		if(!bt_gpi_state[cmd->arg(2).toInt()-1]) {
		  emit gpiChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
		  bt_gpi_state[cmd->arg(2).toInt()-1]=true;
		}
		bt_gpi_mask[cmd->arg(2).toInt()-1]=true;
	      }
	      if(cmd->arg(1).toString().lower()=="o") {
		sprintf(str,"*%dOR%dL\r\n",
			BTSRC8III_UNIT_ID,cmd->arg(2).toInt());
		bt_device->writeBlock(str,8);
		emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
	      }
	    }
	    else {  // Pulse
	      if(cmd->arg(1).toString().lower()=="i") {
		if(!bt_gpi_state[cmd->arg(2).toInt()-1]) {
		  emit gpiChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
		  bt_gpi_state[cmd->arg(2).toInt()-1]=true;
		}
		bt_gpi_mask[cmd->arg(2).toInt()-1]=true;
		bt_gpi_oneshot->start(cmd->arg(2).toInt()-1,500);
	      }
	      if(cmd->arg(1).toString().lower()=="o") {
		sprintf(str,"*%dOR%dP%02d\r\n",
			BTSRC8III_UNIT_ID,cmd->arg(2).toInt(),
			cmd->arg(4).toInt()/100+1);
		bt_device->writeBlock(str,10);
		emit gpoChanged(bt_matrix,cmd->arg(2).toInt()-1,true);
		bt_gpo_oneshot->start(cmd->arg(2).toInt()-1,500);
	      }
	    }
	  }
	}
	if(cmd->echoRequested()) {
	  cmd->acknowledge(true);
	  emit rmlEcho(cmd);
	}
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}
Пример #15
0
void Sas64000Gpi::processCommand(RDMacro *cmd)
{
  char str[9];
  char cmd_byte;

  switch(cmd->command()) {
      case RDMacro::ST:
	if((cmd->arg(1).toInt()<1)||(cmd->arg(1).toInt()>sas_inputs)||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>sas_outputs)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	sprintf(str,"\xFE%c%c%c%c%c\xFF",
		(char)((cmd->arg(2).toInt()-1)/16)&0x0F,
		(char)((cmd->arg(2).toInt()-1)%16)&0x0F,
		(char)((cmd->arg(1).toInt()-1)%128),
		(char)((cmd->arg(1).toInt()-1)/128),
		(char)(((cmd->arg(1).toInt()-1)%128)+
		((cmd->arg(1).toInt()-1)/128))&0x7F);
	sas_device->writeBlock(str,7);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      case RDMacro::GO:
	if((cmd->arg(1).toString().lower()!="o")||
	   (cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>sas_gpos)) {
	  cmd->acknowledge(false);
	  emit rmlEcho(cmd);
	  return;
	}
	if(cmd->arg(4).toInt()==0) {   // Latch
	  if(cmd->arg(3).toInt()==0) {   // Off
	    cmd_byte=0xF9;
	    emit gpoChanged(sas_matrix,cmd->arg(2).toInt()-1,false);
	  }
	  else {
	    cmd_byte=0xFA;
	    emit gpoChanged(sas_matrix,cmd->arg(2).toInt()-1,true);
	  }
	}
	else {  // Pulse
	  if(cmd->arg(3).toInt()==0) {
	    cmd->acknowledge(false);
	    emit rmlEcho(cmd);
	    return;
	  }
	  cmd_byte=0xFB;
	  sas_gpo_oneshot->start((void *)(cmd->arg(2).toInt()-1),500);
	  emit gpoChanged(sas_matrix,cmd->arg(2).toInt()-1,true);
	}
	sprintf(str,"%c%c\xFF",cmd_byte,cmd->arg(2).toInt()-1);
	sas_device->writeBlock(str,3);
	cmd->acknowledge(true);
	emit rmlEcho(cmd);
	break;

      default:
	cmd->acknowledge(false);
	emit rmlEcho(cmd);
	break;
  }
}