groupdefiner

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
groupdefiner [2014/08/21 18:37]
endler [Architecture]
groupdefiner [2014/08/28 15:13]
rafael [Usage]
Line 10: Line 10:
  
 ===== Usage  ===== ===== Usage  =====
-Explicar aqui como utilizar. Quais são as principais interfaceselementos etc Dar um rápido exemplo de como utilizar. Se possível e aplicável fazer um breve "hello world".+O GroupDefiner possui apenas um construtoronde deve ser passado uma implementação do GroupSelectorA interface GroupSelector é mostrada abaixo.
  
-<file java Hello.java> +<file java GroupSelector.java> 
-public class Hello +public interface GroupSelector { 
-   public static void main(String args[]{ +  /** 
-        /Teste +   * Method used by GroupDefiner to obtains the GroupType of the Group Selection Module 
-        double x = 2; +   *  
-   }+   * @return The GroupType of the Group Selection Module 
 +   */ 
 +  public int getGroupType(); 
 + 
 +  /** 
 +   * Processes the Mobile Node´s group membership using the Context Update (CxtU) message 
 +   *  
 +   * @param nodeMessage Context Update (CxtU) message produced by Mobile Node 
 +   * @return A set that holds the Mobile Node´s group membership 
 +   */ 
 +  public Set<Integer> processGroups(Message nodeMessage);
 } }
 </file> </file>
  
-  * ''getService()'' Returns Service +O ID de um grupo é uma chave composta que possui um inteiro representando o tipo do grupo e outro inteiro que representa o grupo. Desta forma é possível criar tipos diferentes de grupos.
  
-  * ''myMethod()'' Returns Service +  * ''getGroupType()'' Retorna o tipo do grupo
  
 +  * ''processGroups()'' Retorna os grupos de um MN 
 +
 +Há ainda a opção de um GroupSelector que possui, além dos métodos acima, o conceito de grupos proibidos. Um grupo proibido pode ser mapeado, por exemplo, como áreas que o MN não deve entrar. O GroupSelector com suporte a grupos proibidos é mostrado abaixo.
 +
 +<file java GroupSelector.java>
 +public interface GroupSelectorSupportingProhibitedGroups extends GroupSelector {
 +
 +  /**
 +   * Processes the Mobile Node´s prohibited group membership using the Context Update (CxtU) message
 +   
 +   * @param nodeMessage Context Update (CxtU) message produced by Mobile Node
 +   * @return A set that holds the Mobile Node´s group membership
 +   */
 +  public Set<Integer> processProhibitedGroups(Message nodeMessage);
 +
 +  /**
 +   * Tests if a group is a prohibited group
 +   
 +   * @param groupId
 +   * @return Return if a group is a prohibited group or not
 +   */
 +  public boolean isProhibitedGroup(int groupId);
 +}
 +</file>
 +
 +Implementado o GroupSelector, é simples utilizar o GroupDefiner. Basta apenas instanciar o GroupDefiner informando a implementação do GroupSelector. Uma vez instanciado, o GroupDefiner se comunica com o Gateway para informar quando um MN entra ou sai de um grupo. Um HelloWorld é mostrado abaixo.
 +
 +<file java GroupDefinerMock.java>
 +public class GroupDefinerMock {
 +
 +  /**
 +   * @param args
 +   */
 +  public static void main(final String[] args) {
 +    new GroupDefiner(new GroupSelectorMock());
 +  }
 +
 +}
 +</file>
 +
 +A classe GroupSelectorMock é como segue:
 +
 +<file java GroupSelectorMock.java>
 +public class GroupSelectorMock implements GroupSelector {
 +
 +  @Override
 +  public int getGroupType() {
 +    return 10;
 +  }
 +
 +  @Override
 +  public Set<Integer> processGroups(final Message nodeMessage) {
 +    System.out.println(nodeMessage.toString());
 +
 +    return new TreeSet<Integer>();
 +  }
 +
 +}
 +</file>
 ===== Architecture ===== ===== Architecture =====
 The GroupDefiner internally consists of a generic message processing part, and an application-specific part, the //Group selection module//. The generic part is responsible for reading any application message disseminated in the DDS domain, recording the current groups associated with the message and handing the message's application object to the Group Selection module. This module will execute an application-specific group mapping algorithm in order to determine all the  context-defined group(s) that the message sender is in, according to the received object's type and attributes. e.g. if a data value is inside a certain interval or within a 2D region. This list of detected groups  is then handed back to the generic processing part of GroupDefiner, which will calculate the G-diff message and write it to the GroupAdvertisement topic in the DDS domain The GroupDefiner internally consists of a generic message processing part, and an application-specific part, the //Group selection module//. The generic part is responsible for reading any application message disseminated in the DDS domain, recording the current groups associated with the message and handing the message's application object to the Group Selection module. This module will execute an application-specific group mapping algorithm in order to determine all the  context-defined group(s) that the message sender is in, according to the received object's type and attributes. e.g. if a data value is inside a certain interval or within a 2D region. This list of detected groups  is then handed back to the generic processing part of GroupDefiner, which will calculate the G-diff message and write it to the GroupAdvertisement topic in the DDS domain
  • groupdefiner.txt
  • Last modified: 2017/07/21 03:08
  • (external edit)