public class SensorDataFeederItem extends java.lang.Object implements java.lang.Comparable<SensorDataFeederItem>, java.lang.Cloneable
String
or file and to convert it into a
JSON-message object. Objects of this class will be sorted by their event time.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATA_SEPARATOR_CHAR
The default separator char of data within an '*.sgs' coded file.
|
static java.lang.String |
LINE_SEPARATOR_CHAR
The default separator char of lines within an '*.sgs' coded file.
|
private int |
time
The time in minutes relative to the simulation start where this event happens.
|
private java.lang.String |
type
The simulated sensor type name.
|
private java.lang.String |
value
The simulated sensors measured value.
|
Constructor and Description |
---|
SensorDataFeederItem(java.lang.String typeIn,
java.lang.String valueIn,
int timeIn)
Initializes a new
SensorDataFeederItem object. |
Modifier and Type | Method and Description |
---|---|
SensorDataFeederItem |
clone()
Clones this object and returns a new object value but not object identically to this object.
|
int |
compareTo(SensorDataFeederItem other)
The method compares the current object with another
SensorDataFeederItem object. |
static java.util.Map<java.lang.Integer,SensorDataFeederItem> |
fromFile(java.lang.String filePath)
Creates all
SensorDataFeederItem defined within a story file by parsing its content using
LINE_SEPARATOR_CHAR and fromString(String) for each line. |
static SensorDataFeederItem |
fromString(java.lang.String storyLine)
Create a new
SensorDataFeederItem from a given string by parsing it using DATA_SEPARATOR_CHAR
and NumericalConstants.DECIMAL_BASE . |
private java.lang.String |
getRealTime()
Returns the simulation time to which this event happens as formatted
String "hh:mm". |
static java.lang.String |
getStringTime(int timeInMinutes)
Converts an amount of minutes to a simulation time
String formatted as "hh:mm". |
int |
getTime()
Returns the event time in simulation minutes.
|
java.lang.String |
getType()
Returns the events sensor type name as
String . |
java.lang.String |
getValue()
Returns the events simulated value as
String . |
JsonSensorDataFeederItem |
toJsonObject()
Converts the object to a JSON message representation to use in common with ActiveMQ publishing.
|
java.lang.String |
toString() |
public static final java.lang.String DATA_SEPARATOR_CHAR
public static final java.lang.String LINE_SEPARATOR_CHAR
private java.lang.String type
private java.lang.String value
private int time
public SensorDataFeederItem(java.lang.String typeIn, java.lang.String valueIn, int timeIn)
SensorDataFeederItem
object.typeIn
- The simulated sensors type name as String
.valueIn
- The simulated sensors measured value as String
.timeIn
- The time when the event happens as int
.public static SensorDataFeederItem fromString(java.lang.String storyLine)
SensorDataFeederItem
from a given string by parsing it using DATA_SEPARATOR_CHAR
and NumericalConstants.DECIMAL_BASE
.storyLine
- The String
line which contains the data for the simulated sensor event in "*.sgs"
format.SensorDataFeederItem
based on the supplied string.public static java.util.Map<java.lang.Integer,SensorDataFeederItem> fromFile(java.lang.String filePath)
SensorDataFeederItem
defined within a story file by parsing its content using
LINE_SEPARATOR_CHAR
and fromString(String)
for each line.filePath
- The path to the file where the story is defined as String
.Map
of simulation time in minutes (Integer
) to
SensorDataFeederItem
.public final java.lang.String getType()
String
.String
.public final java.lang.String getValue()
String
.String
.public final int getTime()
public final JsonSensorDataFeederItem toJsonObject()
JsonSensorDataFeederItem
representing the sensor event for the ActiveMQ.private java.lang.String getRealTime()
String
"hh:mm".String
.public final java.lang.String toString()
toString
in class java.lang.Object
String
representation of this object.Object.toString()
public static final java.lang.String getStringTime(int timeInMinutes)
String
formatted as "hh:mm".timeInMinutes
- The daytime in minutes as int
.String
formatted as "hh:mm".public final int compareTo(SensorDataFeederItem other)
SensorDataFeederItem
object. Both objects will be
compared by their event time using Integer.compareTo(Integer)
.compareTo
in interface java.lang.Comparable<SensorDataFeederItem>
other
- The other SensorDataFeederItem
object with which this object shall be compared.0
means that these events are starting at the same time. A value less than
0
indicates that this event starts before the other. A value greater than
0
that this event starts after the other object.Integer.compareTo(Integer)
public final SensorDataFeederItem clone()
clone
in class java.lang.Object
SensorDataFeederItem
.