当前位置: 首页>>代码示例>>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;未经允许,请勿转载。