Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
udi [2014/09/09 19:05] endler [Architecture] |
udi [2015/03/31 10:47] rafael [Usage] |
||
---|---|---|---|
Line 23: | Line 23: | ||
this.dds.createDataReader(groupDefinerDDSListener, | this.dds.createDataReader(groupDefinerDDSListener, | ||
+ | this.dds.createDataWriter(messageTopic); | ||
</ | </ | ||
E o listener do exemplo acima recebe objetos do tipo //Message// e precisa implementar o callback // | E o listener do exemplo acima recebe objetos do tipo //Message// e precisa implementar o callback // | ||
Line 36: | Line 37: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Para utilizar os Extensible and Dynamic Topic Types for DDS (DDS-XTypes), | ||
+ | |||
+ | Um tópico dinâmico é representação por uma estrutura do tipo chave-valor, | ||
+ | |||
+ | O código abaixo inicializa a UDI usando RTI no domínio " | ||
+ | |||
+ | <code java> | ||
+ | this.dds = UniversalDDSLayerFactory.getInstance(SupportedDDSVendors.RTI); | ||
+ | this.dds.createParticipant(this._domainId); | ||
+ | </ | ||
+ | |||
+ | Para verificar se o tópico dinâmico " | ||
+ | |||
+ | <code java> | ||
+ | private void startApplication() | ||
+ | { | ||
+ | _metadata = this.dds.getMetadataByName(" | ||
+ | | ||
+ | if(_metadata == null) | ||
+ | { | ||
+ | System.out.println(" | ||
+ | return; | ||
+ | } | ||
+ | | ||
+ | System.out.println(" | ||
+ | | ||
+ | // Creates a (or uses an existing) dynamic topic with this Metadata | ||
+ | DynamicDDSTopic dynamicDDSTopic = dds.createDynamicDDSTopic(_metadata); | ||
+ | dynamicDDSTopic.subscribe(this); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void onNewDynamicData(String topicName, HashMap< | ||
+ | { | ||
+ | System.out.println(" | ||
+ | } | ||
+ | | ||
+ | private void writeData() | ||
+ | } | ||
+ | HashMap< | ||
+ | |||
+ | newInstance.put(" | ||
+ | |||
+ | dynamicDDSTopic.publish(newInstance); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | Para criar um novo tópico dinâmico, pode-se utilizar o seguinte código: | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | private void createEntities() | ||
+ | { | ||
+ | Metadata newMetadata = createSDDLLocationMetadata(); | ||
+ | | ||
+ | System.out.println(" | ||
+ | | ||
+ | // Adds the entity on the service | ||
+ | // | ||
+ | dds.addMetadata(newMetadata); | ||
+ | } | ||
+ | |||
+ | private static Metadata createSDDLLocationMetadata() | ||
+ | { | ||
+ | String | ||
+ | String | ||
+ | String | ||
+ | boolean enabled = true; | ||
+ | | ||
+ | Metadata newMetadata = new Metadata(name, | ||
+ | | ||
+ | ArrayList< | ||
+ | | ||
+ | MetadataMember stringUUIDMember | ||
+ | members.add(stringUUIDMember); | ||
+ | | ||
+ | //... | ||
+ | | ||
+ | // Adds all the members to the new entity | ||
+ | newMetadata.addMembers(members); | ||
+ | | ||
+ | return newMetadata; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Para criar o listener do tópico dinâmico, a classe deve implementar a interface " | ||
Mais detalhes podem ser obtidos do UDI Developer Guide ({{: | Mais detalhes podem ser obtidos do UDI Developer Guide ({{: |