Package org.hlacerti.lib
Class HlaReporter
- java.lang.Object
-
- org.hlacerti.lib.HlaReporter
-
public class HlaReporter extends java.lang.Object
This class implements a HLA Reporter which collects and writes several statistics to analyze the correct usage of HLA services. Note: - this class is a simple reformatting of the functions used to write the HLA analysis reports from theHlaManager
; - the usage of StringBuffer[] must be removed.- Since:
- Ptolemy II 11.0
- Version:
- $Id: HlaReporter.java 214 2018-04-01 13:32:02Z j.cardoso $
- Author:
- Gilles Lasnier, Tarciana Cabral de Brito Guerra
- Pt.AcceptedRating:
- Red (glasnier)
- Pt.ProposedRating:
- Yellow (glasnier)
-
-
Field Summary
Fields Modifier and Type Field Description int
_numberOfOtherTicks
Represents the number of the ticks that were not considered in the variable_numberOfTicks
int
_numberOfTAGs
Represents the number of time advance grants this federate has received.java.util.ArrayList<java.lang.Integer>
_numberOfTicks
Array that contains the number of ticks between a NER or TAR and its respective TAG.int
_numberOfTicks2
Represents the number of call to tick2() made by the federate.java.util.ArrayList<java.lang.Double>
_TAGDelay
Array that contains the delays between a NER or TAR and its respective TAG.
-
Constructor Summary
Constructors Constructor Description HlaReporter(java.lang.String folderName, java.lang.String federateName, java.lang.String federationName, java.lang.String modelName)
Construct a HLA analysis reporter object instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
calculateRuntime()
Calculate the duration of the execution of the federation.java.lang.String
displayAnalysisValues()
Display some analysis results as string.double
getTimeOfTheLastAdvanceRequest()
Get the time of the last advance request call.void
incrNumberOfNERs()
Increment the counter of NERs.void
incrNumberOfRAVs()
Increment the counter of RAV.void
incrNumberOfTARs()
Increment the counter of TARs.void
incrNumberOfUAVs()
Increment the counter of UAV.void
initializeAttributesSubscribedToVariables(java.util.HashMap<java.lang.String,java.lang.Object[]> hlaAttributesSubscribedTo)
Initialize variables specific to HLA attribute value subscription.void
initializeAttributesToPublishVariables(java.util.HashMap<java.lang.String,java.lang.Object[]> hlaAttributesToPublish)
Initialize variables specific to HLA attribute value publication.void
initializeReportVariables(double hlaLookAHead, double hlaTimeStep, double hlaTimeUnitValue, double startTime, Time stopTime, java.lang.String federateName, java.lang.String fedFilePath, java.lang.Boolean isCreator, java.lang.Boolean timeStepped, java.lang.Boolean eventBased)
Initialize all variables used in reports.void
setTimeOfTheLastAdvanceRequest(long value)
Set the time of the last advance request call.void
storeTimes(java.lang.String reason, Time hlaCurrentTime, Time ptolemyCurrentTime)
This method records the PTII time and the HLA time as Ptolemy's time.void
updateFolRAVsTimes(Time ravTimeStamp)
This method updates the _folRAVsTimes (StringBuffer) with the RAV's timestamp value.void
updateRAVsInformation(HlaReflectable hs, HlaTimedEvent te, Time ptTime, java.util.HashMap<java.lang.String,java.lang.Object[]> hlaAttributesToSubscribeTo, java.lang.Object value)
This method records in StringBuffer arrays all information about RAVs during the simulation execution.void
updateUAVsInformation(HlaUpdatable hp, Token in, Time hlaTime, Time ptTime, int microstep, certi.rti.impl.CertiLogicalTime uavTimeStamp)
This method records in StringBuffer arrays all information about UAVs during the simulation execution.void
writeDelays()
Write a report containing(in a .csv file_csvFile
), among other informations, the number of ticks, the delay between a NER or a TAR and its respective TAG, the number of UAVs and RAVs.void
writeNumberOfHLACalls()
Write the number of HLA calls of each federate, along with information about the time step and the runtime, in a file.void
writeRAVsInformation()
Write all recorded RAV information to file.void
writeTimes()
Write all time information to file ('...-times.csv').void
writeUAVsInformation()
Write all recorded UAV information to file.
-
-
-
Field Detail
-
_numberOfTAGs
public int _numberOfTAGs
Represents the number of time advance grants this federate has received. Federates have to ask permission to the federation in order to advance in time. If there is no events happening in an inferior time to the proposed one, the federation sends a TAG to the federate and this last one advances in time.
-
_TAGDelay
public java.util.ArrayList<java.lang.Double> _TAGDelay
Array that contains the delays between a NER or TAR and its respective TAG.
-
_numberOfTicks2
public int _numberOfTicks2
Represents the number of call to tick2() made by the federate.
-
_numberOfTicks
public java.util.ArrayList<java.lang.Integer> _numberOfTicks
Array that contains the number of ticks between a NER or TAR and its respective TAG.
-
_numberOfOtherTicks
public int _numberOfOtherTicks
Represents the number of the ticks that were not considered in the variable_numberOfTicks
-
-
Constructor Detail
-
HlaReporter
public HlaReporter(java.lang.String folderName, java.lang.String federateName, java.lang.String federationName, java.lang.String modelName) throws java.io.IOException
Construct a HLA analysis reporter object instance.- Throws:
java.io.IOException
- If the target directory cannot be created.
-
-
Method Detail
-
calculateRuntime
public void calculateRuntime()
Calculate the duration of the execution of the federation.
-
displayAnalysisValues
public java.lang.String displayAnalysisValues()
Display some analysis results as string.
-
incrNumberOfNERs
public void incrNumberOfNERs()
Increment the counter of NERs.
-
incrNumberOfRAVs
public void incrNumberOfRAVs()
Increment the counter of RAV.
-
incrNumberOfUAVs
public void incrNumberOfUAVs()
Increment the counter of UAV.
-
incrNumberOfTARs
public void incrNumberOfTARs()
Increment the counter of TARs.
-
initializeAttributesToPublishVariables
public void initializeAttributesToPublishVariables(java.util.HashMap<java.lang.String,java.lang.Object[]> hlaAttributesToPublish) throws IllegalActionException
Initialize variables specific to HLA attribute value publication.- Parameters:
hlaAttributesToPublish
- the HashMap of HlaUpdatable names and instances.- Throws:
IllegalActionException
- If failed to retrieve the HLA actor attribute value name.
-
initializeAttributesSubscribedToVariables
public void initializeAttributesSubscribedToVariables(java.util.HashMap<java.lang.String,java.lang.Object[]> hlaAttributesSubscribedTo) throws IllegalActionException
Initialize variables specific to HLA attribute value subscription.- Parameters:
hlaAttributesSubscribedTo
- the HashMap of HlaSubcribers names and instances.- Throws:
IllegalActionException
- If failed to retrieve HLA actor attribute value name.
-
initializeReportVariables
public void initializeReportVariables(double hlaLookAHead, double hlaTimeStep, double hlaTimeUnitValue, double startTime, Time stopTime, java.lang.String federateName, java.lang.String fedFilePath, java.lang.Boolean isCreator, java.lang.Boolean timeStepped, java.lang.Boolean eventBased)
Initialize all variables used in reports.
-
updateFolRAVsTimes
public void updateFolRAVsTimes(Time ravTimeStamp)
This method updates the _folRAVsTimes (StringBuffer) with the RAV's timestamp value.- Parameters:
ravTimeStamp
- The RAV timestamp.
-
updateRAVsInformation
public void updateRAVsInformation(HlaReflectable hs, HlaTimedEvent te, Time ptTime, java.util.HashMap<java.lang.String,java.lang.Object[]> hlaAttributesToSubscribeTo, java.lang.Object value) throws IllegalActionException
This method records in StringBuffer arrays all information about RAVs during the simulation execution.- Parameters:
hs
- HlaReflectable actor which has received the RAV.te
- HLA timed event associated to the RAV in Ptolemy's DE domain.hlaAttributesToSubscribeTo
- List of HlaSubscribers.value
- The HLA update attribute value received.- Throws:
IllegalActionException
- If the HlaReflectable attribute name is not retrieved. NOTE: this method is responsible of the setup of all variable for the RAVs reporting part.
-
updateUAVsInformation
public void updateUAVsInformation(HlaUpdatable hp, Token in, Time hlaTime, Time ptTime, int microstep, certi.rti.impl.CertiLogicalTime uavTimeStamp) throws IllegalActionException
This method records in StringBuffer arrays all information about UAVs during the simulation execution.- Parameters:
hp
- HlaUpdatable actor responsible of the UAV.in
- The emitted token.hlaTime
- HLA logical time as Ptolemy's time.ptTime
- PTII time as Ptolemy's time.microstep
- The current DE director's microstep.uavTimeStamp
- The timestamp of the UAV.- Throws:
IllegalActionException
- If the HlaUpdatable attribute name is not retrieved.
-
setTimeOfTheLastAdvanceRequest
public void setTimeOfTheLastAdvanceRequest(long value)
Set the time of the last advance request call.
-
getTimeOfTheLastAdvanceRequest
public double getTimeOfTheLastAdvanceRequest()
Get the time of the last advance request call.
-
storeTimes
public void storeTimes(java.lang.String reason, Time hlaCurrentTime, Time ptolemyCurrentTime)
This method records the PTII time and the HLA time as Ptolemy's time.- Parameters:
reason
- Reason to store the time values.hlaCurrentTime
- HLA logical time as Ptolemy's time.directorTime
- PTII time as Ptolemy's time.
-
writeDelays
public void writeDelays()
Write a report containing(in a .csv file_csvFile
), among other informations, the number of ticks, the delay between a NER or a TAR and its respective TAG, the number of UAVs and RAVs.
-
writeNumberOfHLACalls
public void writeNumberOfHLACalls()
Write the number of HLA calls of each federate, along with information about the time step and the runtime, in a file. The name and location of this file are specified in the initialization of the variable file.
-
writeRAVsInformation
public void writeRAVsInformation()
Write all recorded RAV information to file.
-
writeTimes
public void writeTimes()
Write all time information to file ('...-times.csv').
-
writeUAVsInformation
public void writeUAVsInformation()
Write all recorded UAV information to file.
-
-