當前位置: 首頁>>代碼示例>>Java>>正文


Java Subscriber類代碼示例

本文整理匯總了Java中com.rti.dds.subscription.Subscriber的典型用法代碼示例。如果您正苦於以下問題:Java Subscriber類的具體用法?Java Subscriber怎麽用?Java Subscriber使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Subscriber類屬於com.rti.dds.subscription包,在下文中一共展示了Subscriber類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import com.rti.dds.subscription.Subscriber; //導入依賴的package包/類
@Before
public void setUp() {
  DomainParticipant domainParticipant = mock(DomainParticipant.class);
  Subscriber subscriber = mock(Subscriber.class);
  dataReader = mock(DataReader.class);

  doThrow(new RETCODE_NOT_ENABLED()).when(domainParticipant)
      .get_discovered_participants(new InstanceHandleSeq());
  when(domainParticipant.get_builtin_subscriber()).thenReturn(subscriber);
  when(subscriber.lookup_datareader(BUILTIN_TOPIC_NAME))
      .thenReturn(dataReader);

  mockStatic(Executors.class);
  executorService = mock(ExecutorService.class);
  when(Executors.newSingleThreadExecutor()).thenReturn(executorService);

  builtinTopicObserver = new BuiltinTopicObserver(
      domainParticipant,
      BUILTIN_TOPIC_NAME
  );
}
 
開發者ID:aguther,項目名稱:dds-examples,代碼行數:22,代碼來源:BuiltinTopicObserverTest.java

示例2: setUp

import com.rti.dds.subscription.Subscriber; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
  DomainParticipant domainParticipant = mock(DomainParticipant.class);
  Subscriber subscriber = mock(Subscriber.class);
  dataReader = mock(DataReader.class);

  Whitebox.setInternalState(
      PublicationBuiltinTopicDataTypeSupport.class,
      "PUBLICATION_TOPIC_NAME",
      "PublicationBuiltinTopicName"
  );

  publicationBuiltinTopicData = mock(PublicationBuiltinTopicData.class);
  publicationBuiltinTopicData.topic_name = "Square";
  publicationBuiltinTopicData.type_name = "ShapeType";
  PowerMockito.whenNew(PublicationBuiltinTopicData.class).withAnyArguments().thenReturn(
      publicationBuiltinTopicData);

  publicationBuiltinTopicDataSeq = mock(PublicationBuiltinTopicDataSeq.class);
  PowerMockito.whenNew(PublicationBuiltinTopicDataSeq.class).withAnyArguments().thenReturn(
      publicationBuiltinTopicDataSeq);

  sampleInfo = mock(SampleInfo.class);
  Whitebox.setInternalState(sampleInfo, "instance_handle", InstanceHandle_t.HANDLE_NIL);
  PowerMockito.whenNew(SampleInfo.class).withAnyArguments().thenReturn(sampleInfo);

  sampleInfoSeq = mock(SampleInfoSeq.class);
  PowerMockito.whenNew(SampleInfoSeq.class).withAnyArguments().thenReturn(sampleInfoSeq);

  when(domainParticipant.get_builtin_subscriber()).thenReturn(subscriber);
  when(subscriber.lookup_datareader(anyString()))
      .thenReturn(dataReader);

  publicationObserver = new PublicationObserver(domainParticipant);

  publicationObserverListener = mock(PublicationObserverListener.class);
  publicationObserver.addListener(publicationObserverListener, false);
}
 
開發者ID:aguther,項目名稱:dds-examples,代碼行數:39,代碼來源:PublicationObserverTest.java

示例3: setUp

import com.rti.dds.subscription.Subscriber; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
  DomainParticipant domainParticipant = mock(DomainParticipant.class);
  Subscriber subscriber = mock(Subscriber.class);
  dataReader = mock(DataReader.class);

  Whitebox.setInternalState(
      SubscriptionBuiltinTopicDataTypeSupport.class,
      "SUBSCRIPTION_TOPIC_NAME",
      "SubscriptionBuiltinTopicName"
  );

  subscriptionBuiltinTopicData = mock(SubscriptionBuiltinTopicData.class);
  subscriptionBuiltinTopicData.topic_name = "Square";
  subscriptionBuiltinTopicData.type_name = "ShapeType";
  PowerMockito.whenNew(SubscriptionBuiltinTopicData.class).withAnyArguments().thenReturn(
      subscriptionBuiltinTopicData);

  subscriptionBuiltinTopicDataSeq = mock(SubscriptionBuiltinTopicDataSeq.class);
  PowerMockito.whenNew(SubscriptionBuiltinTopicDataSeq.class).withAnyArguments().thenReturn(
      subscriptionBuiltinTopicDataSeq);

  sampleInfo = mock(SampleInfo.class);
  Whitebox.setInternalState(sampleInfo, "instance_handle", InstanceHandle_t.HANDLE_NIL);
  PowerMockito.whenNew(SampleInfo.class).withAnyArguments().thenReturn(sampleInfo);

  sampleInfoSeq = mock(SampleInfoSeq.class);
  PowerMockito.whenNew(SampleInfoSeq.class).withAnyArguments().thenReturn(sampleInfoSeq);

  when(domainParticipant.get_builtin_subscriber()).thenReturn(subscriber);
  when(subscriber.lookup_datareader(anyString()))
      .thenReturn(dataReader);

  subscriptionObserver = new SubscriptionObserver(domainParticipant);

  subscriptionObserverListener = mock(SubscriptionObserverListener.class);
  subscriptionObserver.addListener(subscriptionObserverListener, false);
}
 
開發者ID:aguther,項目名稱:dds-examples,代碼行數:39,代碼來源:SubscriptionObserverTest.java

示例4: creaLector

import com.rti.dds.subscription.Subscriber; //導入依賴的package包/類
@Override
public DynamicDataReader creaLector(DataReaderQos qos) {
    if (qos == null)
        qos = Subscriber.DATAREADER_QOS_DEFAULT;

    DynamicDataReader reader = (DynamicDataReader)this.getParticipante()
            .create_datareader(
                topico,
                qos,
                null,
                StatusKind.STATUS_MASK_NONE);

    this.readers.add(reader);
    return reader;
}
 
開發者ID:Prometheus-ETSIIT,項目名稱:locaviewer,代碼行數:16,代碼來源:TopicoControlDinamico.java

示例5: iniciaDds

import com.rti.dds.subscription.Subscriber; //導入依賴的package包/類
private static void iniciaDds() {
     //Dominio 0
    DomainParticipant participant = DomainParticipantFactory.get_instance().create_participant(
            1, // ID de dominio 1
            DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT,
            null, // listener
            StatusKind.STATUS_MASK_NONE);
    if (participant == null) {
        System.err.println("No se pudo obtener el dominio.");
        return;
    }

    // Crea el tópico
    Topic topic = participant.create_topic(
            "test_cam",
            BytesTypeSupport.get_type_name(),
            DomainParticipant.TOPIC_QOS_DEFAULT,
            null, // listener
            StatusKind.STATUS_MASK_NONE);
    if (topic == null) {
        System.err.println("No se pudo crear el tópico");
        return;
    }

    // Crea el suscriptor
    BytesDataReader dataReader = (BytesDataReader) participant.create_datareader(
            topic,
            Subscriber.DATAREADER_QOS_DEFAULT,
            new FakeStreaming(PORT),         // Listener
            StatusKind.DATA_AVAILABLE_STATUS);
    if (dataReader == null) {
        System.err.println("Unable to create DDS Data Reader");
        return;
    }
}
 
開發者ID:Prometheus-ETSIIT,項目名稱:locaviewer,代碼行數:36,代碼來源:Cliente.java

示例6: Participante

import com.rti.dds.subscription.Subscriber; //導入依賴的package包/類
/**
 * Crea una nueva instancia de participante en tópico.
 *
 * @param partName Nombre del participante en el XML
 *  (BibliotecaParticipantes::NombreParticipante).
 */
private Participante(final String name) {
    // Buscamos si ya está creado el participante para recuperarlo.
    // Aunque esto tiene poco sentido en este entorno, puede que DDS
    // por algún mecanismo lo haya creado previamente (según la conf. de XML).
    String simpleName = name.substring(name.indexOf("::") + 2);
    this.participante = DomainParticipantFactory.get_instance()
            .lookup_participant_by_name(simpleName);

    // No ha sido creado previamente -> Crea un participante de dominio.
    if (this.participante == null) {
        // Lo creamos deshabilitado para que a los listener lleguen todos los datos.
        DomainParticipantFactoryQos qos = new DomainParticipantFactoryQos();
        DomainParticipantFactory.get_instance().get_qos(qos);
        qos.entity_factory.autoenable_created_entities = false;
        DomainParticipantFactory.get_instance().set_qos(qos);

        // Creamos el participante
        this.participante = DomainParticipantFactory.get_instance()
                    .create_participant_from_config(name);

        // No ha habido forma de crearlo :(
        if (this.participante == null) {
            System.err.println("[DDStheus::Participante] No se pudo crear.");
            System.exit(1);
        }

        // Modicamos el QoS por defecto para aumentar el tamaño de USER_DATA
        // y configurar RTI WAN Server.
        DomainParticipantQos partQos = new DomainParticipantQos();
        this.participante.get_qos(partQos);

        // Aumentamos el tamaño para USER_DATA
        partQos.resource_limits.participant_user_data_max_length = 256;
        partQos.resource_limits.reader_user_data_max_length = 256;
        partQos.resource_limits.writer_user_data_max_length = 256;

        // Configura RTI WAN Server
        String activate_wan = System.getenv("ACTIVATE_RTI_WAN_SERVER");
        if (activate_wan != null && activate_wan.equals("true")) {
            System.out.println("Activando RTI WAN Server");
            ConfiguraRtiWanServer(partQos);
        }

        this.participante.set_qos(partQos);

        // Volvemos a habilitarlo para dejarlo en su valor por defecto.
        qos.entity_factory.autoenable_created_entities = true;
        DomainParticipantFactory.get_instance().set_qos(qos);
    }

    // Establece los discovery listener
    Subscriber spSubs = this.participante.get_builtin_subscriber();

    this.discovWriter = spSubs.lookup_datareader(PublicationBuiltinTopicDataTypeSupport.PUBLICATION_TOPIC_NAME);
    this.discovWriterListener = new DiscoveryWriters(this.discovWriter);
    this.discovWriterThread = new Thread(this.discovWriterListener);
    this.discovWriterThread.start();

    this.discovReader = spSubs.lookup_datareader(SubscriptionBuiltinTopicDataTypeSupport.SUBSCRIPTION_TOPIC_NAME);
    this.discovReaderListener = new DiscoveryReaders(this.discovReader);
    this.discovReaderThread = new Thread(this.discovReaderListener);
    this.discovReaderThread.start();

    // Finalmente ya lo podemos habilitar
    this.participante.enable();
}
 
開發者ID:Prometheus-ETSIIT,項目名稱:locaviewer,代碼行數:73,代碼來源:Participante.java


注:本文中的com.rti.dds.subscription.Subscriber類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。