Package org.openwebnet4j.message
Class BaseOpenMessage
- java.lang.Object
-
- org.openwebnet4j.message.OpenMessage
-
- org.openwebnet4j.message.BaseOpenMessage
-
- Direct Known Subclasses:
Automation
,EnergyManagement
,EnergyManagementDiagnostic
,GatewayMgmt
,Lighting
,Thermoregulation
,ThermoregulationDiagnostic
public abstract class BaseOpenMessage extends OpenMessage
BaseOpenMessage class is the abstract base class for other OpenWebNet message types.- Author:
- M. Valla - Initial contribution
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
FORMAT_DIMENSION_REQUEST
protected static String
FORMAT_DIMENSION_WRITING_1P_1V
protected static String
FORMAT_DIMENSION_WRITING_1V
protected static String
FORMAT_DIMENSION_WRITING_2V
protected static String
FORMAT_REQUEST
protected static String
FORMAT_STATUS
protected static int
MAX_FRAME_LENGTH
protected Where
where
protected String
whereStr
protected Who
who
-
Fields inherited from class org.openwebnet4j.message.OpenMessage
FRAME_ACK, FRAME_ACK_NACK_BUSY_START, FRAME_BUSY_NACK, FRAME_END, FRAME_NACK, FRAME_START, FRAME_START_DIM, frameValue
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseOpenMessage(String frame)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static String
addValues(String msgStr, String... vals)
Helper method to add to the given msg frame a list of values separated by*
at the end of the frame:*frame##
-->*frame*val1*val2*..*valN##
abstract OpenDeviceType
detectDeviceType()
Tries to return aOpenDeviceType
based on frame valueprotected abstract Dim
dimFromValue(int i)
int[]
getCommandParams()
Returns message command parameters (*WHO*WHAT#Param1#Param2...#ParamN*...), or empty array if no parameters are presentDim
getDim()
Returns message DIM (dimension,*#WHO*#DIM*...##
) or null id not DIM is presentint[]
getDimParams()
Returns an array with DIM parameters PAR1..PARN (*#WHO*DIM#PAR1..#PARN*...##), or empty array if no parameters are presentString[]
getDimValues()
Returns and array with DIM values, or empty array if no values are presentWhat
getWhat()
Returns message WHAT or null if message has no valid WHAT partWhere
getWhere()
Returns message WHERE or null if message has no valid WHERE partWho
getWho()
Returns message WHOboolean
isCommand()
Is this OpenMessage a command? (*WHO..
).boolean
isCommandTranslation()
Check if message is a command translation (*WHO*1000#WHAT*...##)boolean
isDimWriting()
Check if message is a dimension writing message*#WHO*#DIM*...##
static OpenMessage
parse(String frame)
Parses the frame and returns a new OpenMessage object.protected abstract void
parseWhere()
Parse WHERE and assigns it towhere
attributeString
toStringVerbose()
Get a verbose representation of this message.protected abstract What
whatFromValue(int i)
-
Methods inherited from class org.openwebnet4j.message.OpenMessage
equals, getFrameValue, isACK, isBUSY_NACK, isNACK, toString
-
-
-
-
Field Detail
-
MAX_FRAME_LENGTH
protected static final int MAX_FRAME_LENGTH
- See Also:
- Constant Field Values
-
FORMAT_DIMENSION_REQUEST
protected static final String FORMAT_DIMENSION_REQUEST
- See Also:
- Constant Field Values
-
FORMAT_DIMENSION_WRITING_1V
protected static final String FORMAT_DIMENSION_WRITING_1V
- See Also:
- Constant Field Values
-
FORMAT_DIMENSION_WRITING_2V
protected static final String FORMAT_DIMENSION_WRITING_2V
- See Also:
- Constant Field Values
-
FORMAT_DIMENSION_WRITING_1P_1V
protected static final String FORMAT_DIMENSION_WRITING_1P_1V
- See Also:
- Constant Field Values
-
FORMAT_REQUEST
protected static final String FORMAT_REQUEST
- See Also:
- Constant Field Values
-
FORMAT_STATUS
protected static final String FORMAT_STATUS
- See Also:
- Constant Field Values
-
whereStr
protected String whereStr
-
who
protected Who who
-
where
protected Where where
-
-
Constructor Detail
-
BaseOpenMessage
protected BaseOpenMessage(String frame)
-
-
Method Detail
-
isCommand
public boolean isCommand()
Description copied from class:OpenMessage
Is this OpenMessage a command? (*WHO..
).- Specified by:
isCommand
in classOpenMessage
- Returns:
- true if it's a command frame
-
parse
public static OpenMessage parse(String frame) throws MalformedFrameException, UnsupportedFrameException
Parses the frame and returns a new OpenMessage object. This parser uses a "lazy approach": other parts (WHERE, WHAT, DIM, parameters, etc.) are not parsed until requested.- Parameters:
frame
- the frame String to parse- Returns:
- a new
OpenMessage
object representing the OpenWebNet frame - Throws:
MalformedFrameException
- in case the provided frame String is not a valid OpenWebNet frameUnsupportedFrameException
- in case the provided frame String is not a supported OpenWebNet frame
-
getWho
public Who getWho()
Returns message WHO- Returns:
- message WHO
-
getWhat
public What getWhat()
Returns message WHAT or null if message has no valid WHAT part- Returns:
- message WHAT
-
getWhere
public Where getWhere()
Returns message WHERE or null if message has no valid WHERE part- Returns:
- message WHERE
-
getDim
public Dim getDim()
Returns message DIM (dimension,*#WHO*#DIM*...##
) or null id not DIM is present- Returns:
- message DIM, or null if no DIM is present
-
isDimWriting
public boolean isDimWriting()
Check if message is a dimension writing message*#WHO*#DIM*...##
- Returns:
- true if it's a dimension writing message
-
parseWhere
protected abstract void parseWhere() throws FrameException
Parse WHERE and assigns it towhere
attribute- Throws:
FrameException
- in case of error in frame
-
dimFromValue
protected abstract Dim dimFromValue(int i)
-
whatFromValue
protected abstract What whatFromValue(int i)
-
detectDeviceType
public abstract OpenDeviceType detectDeviceType() throws FrameException
Tries to return aOpenDeviceType
based on frame value- Returns:
- recognized device type or null if not device can be recognized
- Throws:
FrameException
- in case of error in frame
-
isCommandTranslation
public boolean isCommandTranslation() throws FrameException
Check if message is a command translation (*WHO*1000#WHAT*...##)- Returns:
- true if the WHAT part is prefixed with command translation: 1000#
- Throws:
FrameException
- in case of error in frame
-
getCommandParams
public int[] getCommandParams() throws FrameException
Returns message command parameters (*WHO*WHAT#Param1#Param2...#ParamN*...), or empty array if no parameters are present- Returns:
- int[] of command parameters, or empty array if no parameters are present
- Throws:
FrameException
- in case of error in frame
-
getDimParams
public int[] getDimParams() throws FrameException
Returns an array with DIM parameters PAR1..PARN (*#WHO*DIM#PAR1..#PARN*...##), or empty array if no parameters are present- Returns:
- a int[] of DIM parameters, or empty array if no parameters are present
- Throws:
FrameException
- in case of error in frame
-
getDimValues
public String[] getDimValues() throws FrameException
Returns and array with DIM values, or empty array if no values are present- Returns:
- a String[] of DIM values, or empty array if no values are present
- Throws:
FrameException
- in case of error in frame
-
addValues
protected static String addValues(String msgStr, String... vals)
Helper method to add to the given msg frame a list of values separated by*
at the end of the frame:*frame##
-->*frame*val1*val2*..*valN##
- Parameters:
msgStr
- the input frame Stringvals
- Strings containing values to be added to the frame- Returns:
- a String with the new message frame with values added at the end
-
toStringVerbose
public String toStringVerbose()
Description copied from class:OpenMessage
Get a verbose representation of this message.- Specified by:
toStringVerbose
in classOpenMessage
- Returns:
- verbose string representation
-
-