porting implementation of packet utilization standard from ada to java annelie hultman (tec-eme)...
TRANSCRIPT
Porting Implementation of Packet Utilization Standard
from ADA to JAVA
Annelie Hultman (TEC-EME)Donata Pedrazzani (TEC-EMS)
ESA/ESTEC 2004
JPUS de-briefing
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 2
Introduction
- Final presentation of the YGT period
- Ported part of the PUS Ada framework to Java
- Aim of presentation- De-briefing of key findings which may be interesting
for the sections
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 3
Outline• Architecture issues
- Ada packages versus Java OO
- Encapsulation of data/visibility
- Reusability concepts
- Polymorphism
• Low-level operations• Porting strategies
- Porting of types
- Porting of Ada generic package
- Porting of protected objects and protected entries
- Conclusion
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 4
Outline• Architecture issuesArchitecture issues
- Ada packages versus Java OOAda packages versus Java OO
- Encapsulation of data/visibilityEncapsulation of data/visibility
- Reusability conceptsReusability concepts
- PolymorphismPolymorphism
• Low-level Low-level operationsoperations• Porting strategiesPorting strategies
- Porting of typesPorting of types
- Porting of Ada generic packagePorting of Ada generic package
- Porting of protected objects and protected entriesPorting of protected objects and protected entries
- ConclusionConclusion
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 5
Ada packages vs Java OO
Ada
Unit of encapsulation: package
Java
Unit of encapsulation: classPackage: repository for classes, host-environment
facility which contains compiled class files
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 6
Encapsulation of data/visibility
Ada
Physical separation between unit’s specification and body
Accessibility given by location of declaration
Java
No separation of a class into specification and bodyAccess control modifiers
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 7
Encapsulation of data/visibility(2)
A B C DAccessible by c2 yes -Accessible by c3 -Accessible by c4 - -Accessible by c5 - - -
class c1 {public int A;
protected int B;int C;
private int D;}
class c3 {...
}
class c5 {...
}
class c4 extends c1 {...
}
class c2 extends c1 {...
}
yesyesyes
yesyesyes
yesyes
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 8
Reusability concepts
Ada
Specification and compiled units
Java
javadoc documentation and bytecode (compiled .class files)
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 9
Polymorphism
Def: ability for references and collections to hold objects of different types
AdaExplicit: use of tagged types
JavaImplicit from the language
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 12
Outline• Architecture issuesArchitecture issues
- Ada packages versus Java OOAda packages versus Java OO- Encapsulation of data/visibilityEncapsulation of data/visibility- Reusability conceptsReusability concepts- PolymorphismPolymorphism
• Low-level Low-level operationsoperations• Porting strategiesPorting strategies
- Porting of typesPorting of types- Porting of Ada generic packagePorting of Ada generic package- Porting of protected objects and protected entriesPorting of protected objects and protected entries
• ConclusionConclusion
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 13
Low-level operations
• Java cannot directly control hardware: programs must declare native methods (i.e. using JNI) and implement such operations in another language
• Encoding/decoding to communication link in the framework
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 15
Outline• Architecture issuesArchitecture issues
- Ada packages versus Java OOAda packages versus Java OO- Encapsulation of data/visibilityEncapsulation of data/visibility- Reusability conceptsReusability concepts- PolymorphismPolymorphism
• Low-level Low-level operationsoperations
• Porting strategiesPorting strategies- Porting of types- Porting of Ada generic package- Porting of protected objects and protected entries
- ConclusionConclusion
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 16
Porting Strategies
• Porting of types• Porting of Ada generic package• Porting of protected objects and protected entries
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 17
Porting of Types
• New scalar types • Enumeration types• Arrays• Heterogeneous data structures (records)
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 18
Porting of Types Arrays and Records
• ArraysAn array is in Java encapsulated in a class together with the operations on the array. This solution is not strictly necessary to carry out the porting, but it is more object oriented.
• Heterogeneous data structures (records)A record in Ada is replaced by a class in Java. The operations on the variables of the record type in Ada are in Java implemented inside the class.
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 19
Porting of Types Example Arrays and Records (1)
subtype Command_Index is Natural range 1 .. Schedule_Size;
type Command_Schedule is array (Command_Index) of Optional_Command_Schedule_Info;
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 20
Porting of Types Example Arrays and Records (2)
type Optional_Command_Schedule_Info(Void : Boolean := True) is
record case Void is when True => null; when False => Cmd_Schedule_Info :
Command_Schedule_Info; end case; end record;
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 21
Porting of Types Example Arrays and Records (3)
type Command_Schedule_Info isrecord
TC_Packet : PUS.PUS_Packet;Sub_Schedule_ID_Inf :
Sub_Schedule_ID;Scheduling_Event_Spec_Inf :
Scheduling_Event_Spec; Time_Tag : On_Board_Scheduling_Types.CUC_Time; Actual_Schedule_Time :
Optional_On_Board_Time;end record;
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 22
Porting of Types Example Arrays and Records (4)
1
*
packet : TCPacket
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 23
Porting of Ada generic package
An Ada generic package is a template, which can be parameterized, and from which corresponding nongeneric packages (instances) can be obtained.
In Java a class serves as a template for creating objects (instances).
• Generic Subprogram Parameters• Generic Value Parameters • Generic Type Parameters
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 24
Generic Subprogram Parameters
• Ada: The implementation of the actual subprogram is given at the instantiation of the generic package.
• Java: The generic Ada package is ported to an Java abstract class. The actual subprogram is implemented in the subclass inheriting from the abstract class.
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 25
Generic Value Parameters
• Ada: generic value parameters are used for passing values or variables to a generic package
• Java: passing the parameters via the constructor.
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 26
Generic Value ParametersExample
Public class CommandSchedule {
// Attributes
private CommandScheduleInfo [] cmdSchedule;
private final int schSize;
//Constructor.
public CommandSchedule(int scheduleSize){
schSize = scheduleSize;
cmdSchedule = new CommandScheduleInfo[schSize];
}
// Methods…
}
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 27
Generic Type Parameters
• Discrete types– Ada: Which discrete type is defined at the instantiation
– Java: Integer
• Private types– Ada: Any type where assignment and comparison is
allowed
– Java: PUSPacket class, or more general, Object class
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 28
Generic Type ParametersExample Discrete Types
type Sub_Schedule_ID is (< >).
The range of the type is used for indexation of arrays. type Sub_Schedule_Times_Type is array
(Sub_Schedule_ID)of PUS_Data_Types.On_Board_Time;
Sub_Schedule_Times : Sub_Schedule_Times_Type; In Java: integer type. The array indexation is made by having the number
of sub schedules as a constant in e.g. the class MissionParameters.java. private int[] subScheduleTimes =
new int[MissionParameters.NUMBER_OF_SUBSCHEDULES];
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 29
Porting of Protected objects and Protected entries
• Protected objects in Ada are implemented in Java by using synchronized methods.
• Protected entries in Ada are implemented in Java by using the wait/notify construction in Java
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 30
Outline• Architecture issuesArchitecture issues
- Ada packages versus Java OOAda packages versus Java OO- Encapsulation of data/visibilityEncapsulation of data/visibility- Reusability conceptsReusability concepts- PolymorphismPolymorphism
• Low-level Low-level operationsoperations• Porting strategiesPorting strategies
- Porting of typesPorting of types- Porting of Ada generic packagePorting of Ada generic package- Porting of protected objects and protected entriesPorting of protected objects and protected entries
- ConclusionConclusion
05/05/2004May 04 ESA/ESTEC - JPUS de-briefing 31
Conclusion
Porting:• need of a model to understand the Ada code (i.e.:UML)
• need of a well-defined porting strategy:– Ada 83 procedural language
– Ada 95 has some object-based features
– Java object oriented language
Some issues to address: • direct communication with the hardware
• how to represent low level data types with Java