Package com.dsi.ant.message.fromhost
Class ChannelPeriodMessage
java.lang.Object
com.dsi.ant.message.AntMessage
com.dsi.ant.message.fromhost.AntMessageFromHost
com.dsi.ant.message.fromhost.ChannelPeriodMessage
Configures the channel period the channel will operate on. Messages will be
sent and received every channel period.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
ANT channel period = channel period time (s) *CHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECOND
.static final int
The message content offset to the channel periodstatic final int
The number of bytes used for the channel periodFields inherited from class com.dsi.ant.message.AntMessage
BITMASK_CHANNEL_NUMBER, FILLER_BYTE, OFFSET_CHANNEL_NUMBER, RAW_OFFSET_MESSAGE_CONTENT_START, RAW_OFFSET_MESSAGE_ID, RAW_OFFSET_MESSAGE_SIZE, SIZE_CHANNEL_NUMBER, SIZE_FILLER_BYTE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ChannelPeriodMessage
(byte[] messageContent) ChannelPeriodMessage
(int channelPeriod) Constructs the message from the given channel period. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the channel period this message configures.static int
getChannelPeriod
(double messagesPerSecond) Converts a transmitted data rate in Hz to the channel period value used by ANT.byte[]
getMessageContent
(int channelNumber, int networkNumber) The content of the message with specified channel number and network number set if required.double
Gets the transmitted data rate this message configures.static double
getMessagesPerSecond
(int channelPeriod) Converts the channel period value used by ANT to the transmitted data rate in Hz.The unique type of this message based on its message id, contents, and intended channel type.toString()
Methods inherited from class com.dsi.ant.message.fromhost.AntMessageFromHost
createAntMessage, createAntMessage, getMessageContent, getMessageContent, getMessageId, getRawMessage, toStringHeader
Methods inherited from class com.dsi.ant.message.AntMessage
equals, getMessageContentString, getMessageIdString, hashCode, maskChannelNumber
-
Field Details
-
OFFSET_CHANNEL_PERIOD
public static final int OFFSET_CHANNEL_PERIODThe message content offset to the channel period- Since:
- 4.0
- See Also:
-
SIZE_CHANNEL_PERIOD
public static final int SIZE_CHANNEL_PERIODThe number of bytes used for the channel period- Since:
- 4.0
- See Also:
-
CHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECOND
public static final double CHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECONDANT channel period = channel period time (s) *CHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECOND
.E.g.: To send or receive a message at 4Hz, set the channel period to
CHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECOND
/4 = 8192.
getChannelPeriod(double)
andgetMessagesPerSecond(int)
are helper methods to get these values.- Since:
- 4.5
- See Also:
-
-
Constructor Details
-
ChannelPeriodMessage
public ChannelPeriodMessage(int channelPeriod) Constructs the message from the given channel period.- Parameters:
channelPeriod
- The channel period in 1/32768ths of a second units.- Since:
- 4.0
-
ChannelPeriodMessage
protected ChannelPeriodMessage(byte[] messageContent)
-
-
Method Details
-
getChannelPeriod
public static int getChannelPeriod(double messagesPerSecond) Converts a transmitted data rate in Hz to the channel period value used by ANT.- Parameters:
messagesPerSecond
- The desired data rate, in Hz. This MUST be an integer divisor ofCHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECOND
.- Returns:
- The channel period in 1/32768ths of a second units.
- Since:
- 4.5
-
getChannelPeriod
public int getChannelPeriod()Gets the channel period this message configures.- Returns:
- The channel period in 1/32768ths of a second units.
- Since:
- 4.0
-
getMessagesPerSecond
public static double getMessagesPerSecond(int channelPeriod) Converts the channel period value used by ANT to the transmitted data rate in Hz.- Parameters:
channelPeriod
- The desired messaging period, inCHANNEL_PERIOD_UNITS_FRACTION_OF_A_SECOND
's.- Returns:
- The matching data rate, in Hz.
- Since:
- 4.5
-
getMessagesPerSecond
public double getMessagesPerSecond()Gets the transmitted data rate this message configures.- Returns:
- The data rate, in Hz.
- Since:
- 4.5
-
getMessageContent
public byte[] getMessageContent(int channelNumber, int networkNumber) Description copied from class:AntMessageFromHost
The content of the message with specified channel number and network number set if required.- Specified by:
getMessageContent
in classAntMessageFromHost
- Parameters:
channelNumber
- Written to the channel number byte if requirednetworkNumber
- Written to the network number byte if required- Returns:
- Message content raw byte array.
- Since:
- 4.0
-
getMessageType
Description copied from class:AntMessageFromHost
The unique type of this message based on its message id, contents, and intended channel type.It is recommended to use this rather than the raw message ID.
- Specified by:
getMessageType
in classAntMessageFromHost
- Returns:
- The type of message returned by the host.
- Since:
- 4.0
-
toString
- Overrides:
toString
in classAntMessageFromHost
-