示例#1
0
// Implement the command interface
void ARec::ExecCommand(const string & cmdname)
{
   char buf[100];

   if (cmdname == "start")
	   StartCmd();
   else if (cmdname == "stop")
	   StopCmd();
   else if (cmdname == "setmode")
	   SetModeCmd();
   else if (cmdname == "usegrp")
	   UseGrpCmd();
   else if (cmdname == "setnbest") {
	   if(nBest==0) {
		   CreateHeap(&ansHeap,"Lattice heap",MSTAK,1,0.0,4000,4000);
		   CreateHeap(&altHeap,"Lattice heap",MSTAK,1,0.0,4000,4000);
	   }
	   int nb;
	   if (!GetIntArg(nb, 1, 100000))
		   HPostMessage(HThreadSelf(),"Setnbest, n-best num expected\n");
	   nBest=nb;
   }
   else {
	   sprintf(buf,"Unknown command %s\n", cmdname.c_str());
	   HPostMessage(HThreadSelf(),buf);
   }
}
示例#2
0
void
PerformIO ( struct AHIRequest *ioreq,
            struct AHIBase *AHIBase )
{
  struct AHIDevUnit *iounit;

  iounit = (struct AHIDevUnit *) ioreq->ahir_Std.io_Unit;
  ioreq->ahir_Std.io_Error = 0;

  // Just to make sure TermIO won't free a bad address
  ioreq->ahir_Extras = NULL;

  switch(ioreq->ahir_Std.io_Command)
  {
    case NSCMD_DEVICEQUERY:
      Devicequery(ioreq, AHIBase);
      break;
    case CMD_RESET:
      ResetCmd(ioreq, AHIBase);
      break;
    case CMD_READ:
      ReadCmd(ioreq, AHIBase);
      break;
    case CMD_WRITE:
      if(iounit->StopCnt)
      {
        AddTail((struct List *) &iounit->RequestQueue,(struct Node *) ioreq);
      }
      else
      {
        WriteCmd(ioreq, AHIBase);
      }
      break;
    case CMD_STOP:
      StopCmd(ioreq, AHIBase);
      break;
    case CMD_START:
      StartCmd(ioreq, AHIBase);
      break;
    case CMD_FLUSH:
      FlushCmd(ioreq, AHIBase);
      break;
    default:
      ioreq->ahir_Std.io_Error = IOERR_NOCMD;
      TermIO(ioreq, AHIBase);
      break;
  }
}