Revenir à la page d'accueil
Plan du site   |   Plan d’accès   |   UTBM
  
Projets Européens
Réseaux d'Excellence
Projets Nationaux
Contrats Industriels
Projets thématiques
    ASPECS Methodology
       Introduction
       A quick overview of ASPECS
       System Requirements Analysis
       Agent Society Design
       Implementation
          Holon Architecture Definition
          Code Reuse
          Code Production of Organisations and Roles
          Organisations and Roles Unit Tests
          Code Production of Holons
          Holon Unit Tests
       Deployment
       References
       Comparisons with existing Agent-Oriented Methodologies
Conférences
Séminaires
Accueil > Activités et projets > Projets thématiques > ASPECS Methodology > Implementation > Code Production of Organisations and Roles
Code Production of Organisations and Roles

Code Production of Organisations and Roles

Goal

This activity aims at producing the code for organisations and roles. They are the most elementary building blocks of the Janus platform; actually each role and organisation becomes a class in the code and they are grouped in specific packages (one for each organisation).


Input

The structure of the solution code is provided by the output of the Holarchy Design activity while the dynamics of roles is defined in the Role Behaviour Description.


Output

Code of roles and organisations (one class for each one).


Work to be done

Starting from the structural and dynamical representation of roles and organisations the programmer can code their implementation using the Janus primitives. It is part of our future works to provide tools for the automatic generation of these portions of code from design diagrams.


Example

Part of the code of the JPlayersSimulator role of our Robot soccer simulator is reported in figure 30. This role class inherits from the Janus Abstract-ParallelRole class that provides an abstract definition of role with a task-composed behaviour. It also provides the definition of the Task interface. The behaviour of the JPlayersSimulator role is decomposed into two different tasks: the Manage-PlayersTask and ManageMessageTask ones. The behaviour of each of these tasks was previously described in the Role Behaviour Description using a statechart. This corresponding code representation of this task behaviour is putted inside execute method.

1 package janus.demos.robotsimulator.teamsimulation;
2 /* ... */
3 public class JPlayersSimulator extends AbstractParallelRole {
4 /* ... */
5 public void initTasks() {
6 this.addTask(new ManagePlayersTask());
7 this.addTask(new ManageMessageTask());
8 }
9
10 public void behavior() {
11 super.scheduleTasks();
12 }
13
14 private class ManagePlayersTask implements RoleTask {
15 private int current = 1; // the current state
16 public ManagePlayersTask() { }
17
18 public int execute() {
19 switch (current){
20 /* ... State Chart Implementation */
21 default : return 0;
22 }
23 }
24 }
25
26 private class ManageMessageTask implements RoleTask {
27 private Message m = null;
28 private int current = 1; // the current state
29 public ManageMessageTask() { }
30
31 public int execute() {
32 switch (current) {
33 case 1 : m = getNextMessage();
34 if ( m != null) return 2;
35 return 1;
36
37 /* ... State Chart Implementation */
38 default : return 0;
39 }
40 }
41 }
42 }
Figure 30: Part of the code of the JPlayersSimulator role

  90010 Belfort cedex - Tél : +33 (0)3 84 58 33 19 - Fax : +33 (0)3 84 58 33 42 - Mentions légales