コード例 #1
0
int GadgetStreamController::open (void)
{

  //We will set up the controllers message queue such that when a packet is enqueued write will be triggered.
  this->notifier_.reactor (this->reactor ());
  this->msg_queue ()->notification_strategy (&this->notifier_);

  ACE_TCHAR peer_name[MAXHOSTNAMELEN];
  ACE_INET_Addr peer_addr;
  if (peer().get_remote_addr (peer_addr) == 0 &&
      peer_addr.addr_to_string (peer_name, MAXHOSTNAMELEN) == 0) {
    GINFO("Connection from %s\n", peer_name);
  }

  //We have to have these basic types to be able to receive configuration file for stream
  readers_.insert(GADGET_MESSAGE_CONFIG_FILE,
		  new GadgetMessageConfigFileReader());

  readers_.insert(GADGET_MESSAGE_CONFIG_SCRIPT,
		  new GadgetMessageScriptReader());

  readers_.insert(GADGET_MESSAGE_PARAMETER_SCRIPT,
		  new GadgetMessageScriptReader());

  GadgetModule *head = 0;
  GadgetModule *tail = 0;

  if (tail == 0) {
    Gadget* eg = new EndGadget();
    if (eg) {
      eg->set_controller(this);
    }
		
    ACE_NEW_RETURN(tail,
		   ACE_Module<ACE_MT_SYNCH>( ACE_TEXT("EndGadget"),
					     eg ),
		   -1);

    stream_.open(0,head,tail);
  }

  this->writer_task_.open();

  return this->activate( THR_NEW_LWP | THR_JOINABLE, 1);

}
コード例 #2
0
  int GadgetInstrumentationStreamController::open()
  {
    GadgetModule *head = 0;
    GadgetModule *tail = 0;
    
    if (tail == 0) {
      Gadget* eg = new EndGadget();
      if (eg) {
	eg->set_controller(this);
      }
      
      ACE_NEW_RETURN(tail,
		     ACE_Module<ACE_MT_SYNCH>( ACE_TEXT("EndGadget"),
					       eg ),
		     -1);
      
      stream_.open(0,head,tail);
    }

    //Adding some gadgets to "capture data and return to the stream"
    if (this->prepend_gadget("ImageFinishFloat","gadgetron_mricore","ImageFinishGadget") != GADGET_OK) return GADGET_FAIL;
    this->find_gadget("ImageFinishFloat")->pass_on_undesired_data(true);

    /*
    if (this->prepend_gadget("ImageFinishCplx","gadgetron_mricore","ImageFinishGadgetCPLX") != GADGET_OK) return GADGET_FAIL;
    this->find_gadget("ImageFinishCplx")->pass_on_undesired_data(true);

    if (this->prepend_gadget("ImageFinishUShort","gadgetron_mricore","ImageFinishGadgetUSHORT") != GADGET_OK) return GADGET_FAIL;
    this->find_gadget("ImageFinishUShort")->pass_on_undesired_data(true);
    */

    if (this->prepend_gadget("AcquisitionFinish","gadgetron_mricore","AcquisitionFinishGadget") != GADGET_OK) return GADGET_FAIL;
    this->find_gadget("AcquisitionFinish")->pass_on_undesired_data(true);


    return GADGET_OK;
  }