Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
9fbe575b
Commit
9fbe575b
authored
May 22, 2014
by
filatov
Browse files
merge branch STF462 to the trunk
parents
Changes
208
Expand all
Hide whitespace changes
Inline
Side-by-side
javasrc/CeCILL-C LICENSE.txt
0 → 100644
View file @
9fbe575b
This diff is collapsed.
Click to expand it.
javasrc/adapter/org/etsi/adapter/ITERequired.java
0 → 100644
View file @
9fbe575b
/**
* Test Execution Required interface to be implemented by TE providers.
*
* @author ETSI / STF424
* @version $URL$
* $Id$
*
*/
package
org.etsi.adapter
;
import
org.etsi.ttcn.tci.Value
;
import
org.etsi.ttcn.tri.TriAddress
;
import
org.etsi.ttcn.tri.TriCommunicationTE
;
import
org.etsi.ttcn.tri.TriMessage
;
import
org.etsi.ttcn.tri.TriStatus
;
/**
* Test Execution Required interface to be implemented by TE providers.
*/
public
interface
ITERequired
{
/**
* Gets TriCommunicationTE implementation
* @return TriCommunicationTE implementation
*/
TriCommunicationTE
getCommunicationTE
();
/**
* Creates TriStatus object corresponding to statusCode
* @param statusCode Status value
* @return TriStatus corresponding to statusCode
*/
TriStatus
getTriStatus
(
int
statusCode
);
/**
* Creates TriStatus object corresponding to statusCode (non TRI-standard)
* @param statusCode Status value
* @param message Informational message (Error cause, ...)
* @return TriStatus corresponding to statusCode
*/
TriStatus
getTriStatus
(
int
statusCode
,
String
message
);
/**
* Gets TriAddress
* @param message
* @return TriAddress
*/
TriAddress
getTriAddress
(
byte
[]
message
);
/**
* Gets TriMessage
* @param message
* @return TriMessage
*/
TriMessage
getTriMessage
(
byte
[]
message
);
/**
* Gets Test Adapter configuration parameter (non TRI-standard)
* @param param Name of the configuration parameter
* @return Value associated to the TA parameter
*/
Value
getTaParameter
(
String
param
);
}
javasrc/adapter/org/etsi/adapter/TERFactory.java
0 → 100644
View file @
9fbe575b
/**
* Factory for Test Execution Required implementations.
* Implementations have to register to this factory.
*
* @author ETSI / STF424
* @version $URL$
* $Id$
*
*/
package
org.etsi.adapter
;
/**
* Factory for Test Execution Required implementations.
* Implementations have to register to this factory.
*/
public
class
TERFactory
{
/**
* Registered ITERequired implementation
*/
private
static
ITERequired
instance
;
/**
* Gets the registered ITERequired implementation
* @return Instance of ITERequired implementation registered through setImpl() or null
* @see setImpl
*/
public
static
ITERequired
getInstance
()
{
return
instance
;
}
/**
* Private constructor (Singleton pattern)
*/
private
TERFactory
()
{
//empty
}
/**
* Sets the implementation instance to be returned by the factory
* @param impl Instance of the implementation to be registered
*/
public
static
void
setImpl
(
ITERequired
impl
)
{
instance
=
impl
;
}
}
javasrc/adapter/org/etsi/its/adapter/ComponentMgr.java
0 → 100644
View file @
9fbe575b
/**
* Component manager that handles ports and component creation
*
* @author ETSI / STF424
* @version $URL$
* $Id$
*
*/
package
org.etsi.its.adapter
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Observer
;
import
org.etsi.common.ITuple
;
import
org.etsi.common.Tuple
;
import
org.etsi.its.adapter.ports.IObservable
;
import
org.etsi.its.adapter.ports.IPort
;
import
org.etsi.ttcn.tri.TriComponentId
;
import
org.etsi.ttcn.tri.TriPortId
;
/**
* Component manager that handles ports and component creation
*/
public
class
ComponentMgr
{
/**
* Association Component ID <-> Component reference
*/
private
LinkedHashMap
<
String
,
TriComponentId
>
mapCompNameToTriComp
;
/**
* Association Component ID <-> { (TTCN-3 Port reference / SUT Port reference) }
*/
private
LinkedHashMap
<
String
,
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>>
mapTriPortToTuple
;
/**
* Used to add Observer object
*/
private
TestAdapter
adapter
;
/**
* Constructor
* @param adapter TestAdapter reference, required for Observer/Observable pattern
*/
public
ComponentMgr
(
final
TestAdapter
adapter
)
{
this
.
adapter
=
adapter
;
mapCompNameToTriComp
=
new
LinkedHashMap
<
String
,
TriComponentId
>();
mapTriPortToTuple
=
new
LinkedHashMap
<
String
,
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>>();
}
/**
* Adds a new component
* If the component was already added, nothing is done
* @param component The component to add
*/
public
void
addComponent
(
TriComponentId
component
)
{
// Sanity check
if
(
component
==
null
)
{
System
.
err
.
println
(
"Error: Trying to add null component"
);
return
;
}
if
(!
mapCompNameToTriComp
.
containsKey
(
component
.
getComponentId
()))
{
// Create an entry in the list of Component
mapCompNameToTriComp
.
put
(
component
.
getComponentId
(),
component
);
if
(!
mapTriPortToTuple
.
containsKey
(
component
.
getComponentId
()))
{
// Create an entry in the list of Component/Ports
mapTriPortToTuple
.
put
(
component
.
getComponentId
(),
new
LinkedHashMap
<
String
,
ITuple
<
TriPortId
,
IPort
>>());
}
}
}
/**
* Adds a new port to the specified component
* @param component The component reference
* @param portname The port name
* @param port The port to add
*/
public
void
addPort
(
final
String
componentName
,
final
TriPortId
ttcnPort
,
final
IPort
port
)
{
// Sanity checks
if
(
componentName
.
isEmpty
()
||
(
ttcnPort
==
null
)
||
(
port
==
null
))
{
System
.
err
.
println
(
"Wrong parameters"
);
return
;
}
if
(!
mapCompNameToTriComp
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"Error: Trying to add port to unknown component"
);
return
;
}
if
(!
mapTriPortToTuple
.
containsKey
(
componentName
))
{
// Create an entry in the list of Component/Ports
mapTriPortToTuple
.
put
(
componentName
,
new
LinkedHashMap
<
String
,
ITuple
<
TriPortId
,
IPort
>>());
}
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>
portItem
=
mapTriPortToTuple
.
get
(
componentName
);
if
(!
portItem
.
containsKey
(
ttcnPort
.
getPortName
()))
{
portItem
.
put
(
ttcnPort
.
getPortName
(),
new
Tuple
<
TriPortId
,
IPort
>(
ttcnPort
,
port
));
((
IObservable
)
port
).
addObserver
((
Observer
)
adapter
);
mapTriPortToTuple
.
put
(
componentName
,
portItem
);
}
}
/**
* Gets the component reference from its name
* @param componentName The component name
* @return The component reference if the component exists, null otherwise
*/
public
TriComponentId
getComponent
(
String
componentName
)
{
// Sanity checks
if
(
componentName
==
null
||
componentName
.
isEmpty
())
{
System
.
err
.
println
(
"Invalid component"
);
return
null
;
}
return
mapCompNameToTriComp
.
get
(
componentName
);
}
/**
* Retrieves the TTCN-3 port identifier (TriPortId) from component/port names
* @param componentName The component reference
* @param portName The port name
* @return The TTCN-3 port identifier if the component and the port exists, null otherwise
*/
public
TriPortId
getPortId
(
String
componentName
,
String
portName
)
{
// Sanity checks
if
(
componentName
.
isEmpty
()
||
portName
.
isEmpty
())
{
System
.
err
.
println
(
"Wrong parameters"
);
return
null
;
}
if
(!
mapCompNameToTriComp
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"Unknown component"
);
return
null
;
}
if
(!
mapTriPortToTuple
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"No port list entry"
);
return
null
;
}
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>
portItem
=
mapTriPortToTuple
.
get
(
componentName
);
if
(!
portItem
.
containsKey
(
portName
))
{
return
null
;
}
ITuple
<
TriPortId
,
IPort
>
item
=
portItem
.
get
(
portName
);
return
item
.
getA
();
}
/**
* Retrieves the test adapter port identifier (Port or IAdapterPort) from component/port names
* @param componentName The component owner
* @return The port reference if the component and the port exists, null otherwise
*
* @see Port
* @see IAdapterPort
*/
public
IPort
getPort
(
String
componentName
,
String
portName
)
{
// Sanity checks
if
(
componentName
.
isEmpty
()
||
portName
.
isEmpty
())
{
System
.
err
.
println
(
"Wrong parameters"
);
return
null
;
}
if
(!
mapCompNameToTriComp
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"Unknown component"
);
return
null
;
}
if
(!
mapTriPortToTuple
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"No port list entry"
);
return
null
;
}
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>
portItem
=
mapTriPortToTuple
.
get
(
componentName
);
if
(!
portItem
.
containsKey
(
portName
))
{
return
null
;
}
ITuple
<
TriPortId
,
IPort
>
item
=
portItem
.
get
(
portName
);
return
item
.
getB
();
}
/**
* Removes the specified component
*
* Note that after the port removal, if the component has no more port, it will be removed also
*
* @param component The component reference
*/
public
void
removeComponent
(
String
componentName
)
{
removeAllPorts
();
}
/**
* Removes the specified port
*
* Note that all ports attached to this component will be removed also
*
* @param componentName The component name to remove
*/
public
void
removePort
(
String
componentName
,
String
portName
)
{
// Sanity checks
if
(
componentName
.
isEmpty
()
||
portName
.
isEmpty
())
{
System
.
err
.
println
(
"Wrong parameters"
);
return
;
}
if
(!
mapCompNameToTriComp
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"Unknown component"
);
return
;
}
if
(!
mapTriPortToTuple
.
containsKey
(
componentName
))
{
System
.
err
.
println
(
"No port list entry"
);
return
;
}
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>
portItem
=
mapTriPortToTuple
.
get
(
componentName
);
if
(!
portItem
.
containsKey
(
portName
))
{
return
;
}
// Remove Observers
((
IObservable
)
portItem
.
get
(
portName
).
getB
()).
deleteObservers
();
// Call dispose
((
IPort
)
portItem
.
get
(
portName
).
getB
()).
dispose
();
// Remove item
portItem
.
remove
(
portName
);
if
(
portItem
.
size
()
!=
0
)
{
mapTriPortToTuple
.
put
(
componentName
,
portItem
);
}
else
{
mapTriPortToTuple
.
remove
(
componentName
);
mapCompNameToTriComp
.
remove
(
componentName
);
if
(
mapCompNameToTriComp
.
isEmpty
())
{
mapCompNameToTriComp
.
clear
();
}
}
if
(
mapTriPortToTuple
.
isEmpty
())
{
mapTriPortToTuple
.
clear
();
}
}
/**
* Removes all ports.
*/
public
void
removeAllPorts
()
{
// Remove all ports
for
(
Object
componentName
:
mapTriPortToTuple
.
keySet
().
toArray
())
{
Map
<
String
,
ITuple
<
TriPortId
,
IPort
>>
portItem
=
mapTriPortToTuple
.
get
(
componentName
);
for
(
Object
portName
:
portItem
.
keySet
().
toArray
())
{
removePort
((
String
)
componentName
,
(
String
)
portName
);
}
}
// Remove component mapping
mapCompNameToTriComp
.
clear
();
}
}
javasrc/adapter/org/etsi/its/adapter/IManagementLayers.java
0 → 100644
View file @
9fbe575b
/**
* Management interface for protocol layers
*
* @author ETSI / STF424
* @version $URL$
* $Id$
*
*/
package
org.etsi.its.adapter
;
import
org.etsi.its.adapter.ports.GnPort
;
/**
* Management interface for protocol layers
*/
public
interface
IManagementLayers
{
/**
* Gets the GeoNetworking beacon header to be sent by Test Adapter for the current component
* @return Beacon header, or null if no Beacon shall be sent
*/
public
byte
[]
getGnBeacon
();
/**
* Registers a GN port
*/
public
void
registerGnPort
(
GnPort
gnPort
);
/**
* Gets the GeoNetworking beaconing interval
* @return GeoNetworking beaconing interval in ms
*/
public
int
getGnBeaconInterval
();
/**
* Gets the GeoNetworking beacon header acting as filter for enqueueing Beacons received from neighbours
* @return Beacon header, or null if no Beacon shall be enqueued
*/
public
byte
[]
getGnEnqueueBeacon
();
/**
* Inserts or updates a neighbour position vector in Test Adapter internal tables
* @param mid Mid part of the neighbour's GN_Address
* @param timestamp Timestamp of the carrying message
* @param lpv Long position vector of the neighbour
*/
public
void
gnUpdateLocTable
(
byte
[]
mid
,
long
timestamp
,
byte
[]
lpv
);
/**
* Sets the link layer address of this component
* param linkLayerAddress Link-layer address (6 bytes)
*/
public
void
setLinkLayerAddress
(
byte
[]
linkLayerAddress
);
/**
* Gets the link layer address of this component
* @return Link-layer address (6 bytes)
*/
public
byte
[]
getLinkLayerAddress
();
/**
* Gets the latitude of this component
* @return Latitude
*/
public
byte
[]
getLatitude
();
/**
* Gets the Longitude of this component
* @return Longitude
*/
public
byte
[]
getLongitude
();
}
javasrc/adapter/org/etsi/its/adapter/IManagementTA.java
0 → 100644
View file @
9fbe575b
/**
* Management interface for Test Adapter main class
*
* @author ETSI / STF424
* @version $URL$
* $Id$
*
*/
package
org.etsi.its.adapter
;
/**
* Management interface for Test Adapter main class
*/
public
interface
IManagementTA
{
/**
* Requests Test Adapter to start sending periodic beacons for the current component
* @param beaconHeader Beacon to be sent (TST field will be updated)
*/
public
void
startBeaconing
(
byte
[]
beaconHeader
);
/**
* Requests Test Adapter to stop sending periodic beacons for the current component
*/
public
void
stopBeaconing
();
/**
* Requests Test Adapter to start enqueueing beacon messages on the current component GN port
* @param beaconHeader Only messages matching this beacon header will be enqueued
*/
public
void
startEnqueueingBeacons
(
byte
[]
beaconHeader
);
/**
* Requests Test Adapter to stop enqueueing beacon messages on the current component GN port
*/
public
void
stopEnqueueingBeacons
();
/**
* Requests Test Adapter to start simulating neighbour presence by sending multiple periodic beacons for the current component
* @param beaconHeader Beacon to be sent (TST field will be updated, GN addresses will be random)
* @param nbNeighbours Number of neighbours to simulate
*/
public
void
startMultipleBeaconing
(
byte
[]
beaconHeader
,
int
nbNeighbours
);
/**
* Requests Test Adapter to stop simulating neighbour presence
*/
public
void
stopMultipleBeaconing
();
/**
* Gets the long position vector of a neighbour given its GN_Address
* @param targetGnAddress GN_Address of the target neighbour
* @return Long position vector of the target neighbour as received in its last beacon, or null
*/
public
byte
[]
getLongPositionVector
(
byte
[]
targetGnAddress
);
}
javasrc/adapter/org/etsi/its/adapter/Main.java
0 → 100644
View file @
9fbe575b
/**
* Test and debug module.
* SHALL NOT BE INCLUDED IN RELEASE
*
* @author ETSI / STF424
* @version $URL$
* $Id$
*
*/
package
org.etsi.its.adapter
;
import
org.etsi.its.adapter.ports.ProtocolPort
;
import
org.etsi.its.adapter.ports.ProtocolPortFactory
;
/**
* Test and debug module.
*/
public
class
Main
{
/**
* @param args
*/
public
static
void
main
(
String
[]
args
)
{
}
/**
* Creates CAM port using stack LoopBack/Debug and sends a message
*/
@SuppressWarnings
(
"unused"
)
private
static
void
camTest
()
{
ProtocolPort
port
=
ProtocolPortFactory
.
getInstance
().
createPort
(
"camPort"
,
"toto"
,
"GN/Debug"
,
"ACACACACACAC"
);
port
.
send
(
"CAM MESSAGE !"
.
getBytes
());
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
port
.
dispose
();
}
/**
* Creates BTP port using stack GN/LoopBack/Debug and sends a message
*/
@SuppressWarnings
(
"unused"
)
private
static
void
btpTest
()
{
ProtocolPort
port
=
ProtocolPortFactory
.
getInstance
().
createPort
(
"btpPort"
,
"toto"
,
"GN/Loopback/Debug"
,
"ACACACACACAC"
);
port
.
send
(
"BTP MESSAGE !"
.
getBytes
());
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
port
.
dispose
();
}
/**
* Creates GN port using stack GnSource and sends a message
*/
@SuppressWarnings
(
"unused"
)
private
static
void
gnTest
()
{
byte
[]
gnMsg
=
{(
byte
)
0x00
,
(
byte
)
0x50
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x1f
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0x00
,
(
byte
)
0xff
,
(
byte
)
0x54
,
(
byte
)
0x45
,
(
byte
)
0x53
,
(
byte
)
0x54
,
(
byte
)
0x20
,
(
byte
)
0x31
,
(
byte
)
0x20
,
(
byte
)
0x54
,
(
byte
)
0x45
,
(
byte
)
0x53
,
(
byte
)
0x54
,
(
byte
)
0x20
,
(
byte
)
0x54
,
(
byte
)
0x45
,
(
byte
)
0x53
,
(
byte
)
0x54
,
(
byte
)
0x20
,
(
byte
)
0x54
,
(
byte
)
0x45
,
(
byte
)
0x53
,
(
byte
)
0x54
,
(
byte
)
0x20
,
(
byte
)
0x54
,
(
byte
)
0x45
,
(
byte
)
0x53
,
(
byte
)
0x54
,
(
byte
)
0x20
,
(
byte
)
0x54
,
(
byte
)
0x45
,
(
byte
)
0x53
,
(
byte
)
0x54
};
ProtocolPort
port
=
ProtocolPortFactory
.
getInstance
().
createPort
(
"geoNetworkingPort"
,
"toto"
,
"Loopback/Debug"
,
"ACACACACACAC"
);
port
.
send
(
gnMsg
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
port
.
dispose
();
}
}
javasrc/adapter/org/etsi/its/adapter/Management.java
0 → 100644
View file @
9fbe575b
/**
* This class is used to centralise test adapter configuration and execution parameters
* All settings are component specific (multiton)