SyncSamplingFormulas
namespace SyncSamplingFormulas

Contains formulas for determining Sync Sampling configuration

Constants
Sync Sampling Constants
MAX_SLOTS

1024  - The maximum number of slots for normal capacity mode

MAX_SLOTS_HIGH_CAPACITY

1024 * 16 - The maximum number of slots for high capacity mode

MIN_TDMA

1  - The minimum TDMA address allowed to be assigned to a Node

Functions
bytesPerSecond
double bytesPerSecond(
const SampleRate &sampleRate,
uint16 numChs,
uint8 bytesPerSample
)

Calculates the number of bytes per second

Parameters
sampleRate
const SampleRate&

The SampleRate

numChs
uint16

The number of active channels

bytesPerSample
uint8

The number of bytes per sample

Returns

The number of bytes per second

maxBytesPerPacket
uint32 maxBytesPerPacket(
const SampleRate &sampleRate,
bool lossless,
bool highBandwidth,
uint8 syncFormulaVersion
)

Calculates the maximum number of bytes per packet

Parameters
sampleRate
const SampleRate&

The SampleRate

lossless
bool

Whether the network is using lossless or not

highBandwidth
bool

Whether we are attempting to optimize bandwidth or not

syncFormulaVersion
uint8

The version of the Sync Sampling formula to use

groupSize
uint32 groupSize(
double bytesPerSecond,
uint32 maxBytesPerPacket,
bool highCapacity
)

Calculates the group size

Parameters
bytesPerSecond
double

The number of bytes per second

maxBytesPerPacket
uint32

The maximum number of bytes per packet

highCapacity
bool

Whether the network is using high capacity mode or not

Returns

The group size for the network

txPerGroup
uint32 txPerGroup(
double bytesPerSecond,
uint32 maxBytesPerPacket,
uint32 groupSize
)

Calculates the transmissions per group

Parameters
bytesPerSecond
double

The number of bytes per second

maxBytesPerPacket
uint32

The maximum number of bytes per packet

groupSize
uint32

The group size for the network

Returns

The transmissions per group

txPerSecond
float txPerSecond(
uint32 txPerGroup,
uint32 groupSize
)

Calculates the number of transmissions per second

Parameters
txPerGroup
uint32

The number of transmissions per group

groupSize
uint32

The group size for the network

Returns

The number of transmissions per second

slotSpacing
uint16 slotSpacing()

Gets the slot spacing for the network

Returns

The slot spacing for the network

maxTdmaAddress
uint32 maxTdmaAddress(
uint32 txPerGroup,
uint32 groupSize
)

Gets the maximum TDMA address that is allowed

Returns

The maximum TDMA address that is allowed

percentBandwidth
float percentBandwidth(
float txPerSecond
)

Calculates the percent of bandwidth for a single node

Parametesr
txPerSecond

The number of transmissions per second

Returns

The percent of bandwidth

sampleDuration
double sampleDuration(
uint32 numSweeps,
const SampleRate &sampleRate
)

Calculates the sample duration for a given sample rate and number of sweeps

Parameters
numSweeps
uint32

The number of sweeps sampleRate The SampleRate

bytesPerSweep
uint32 bytesPerSweep(
uint8 bytesPerSample,
uint16 numChs
)

Gets the total number of bytes per data sweep

Parameters
bytesPerSample
uint8

The number of bytes per sample

numChs
uint16

The number of active channels

Returns

The total number of bytes per data sweep

checkSamplingDelay
bool checkSamplingDelay(
WirelessTypes::SyncSamplingMode samplingMode,
const SampleRate &sampleRate,
WirelessModels::NodeModel nodeModel
)

Whether or not the sampling delay should be checked when finding slots in the Sync Sampling network

Parameters
samplingMode

The WirelessTypes::SyncSamplingMode of the node

sampleRate
const SampleRate&

The SampleRate of the node

nodeModel

The WirelessModels::NodeModel of the node

Returns

true if the sampling delay should be checked, false if it should not be checked

slotsBetweenTx
uint16 slotsBetweenTx(
uint32 txPerGroup,
uint32 groupSize
)

Calculates the number of slots that need to be between each transmission

Parameters
txPerGroup
uint32

The number of transmissions per group

groupSize
uint32

The group size for the network

Returns

The number of slots that need to be between each transmission

canHaveSlot1
bool canHaveSlot1(
WirelessModels::NodeModel nodeModel,
uint8 syncVersion
)

Checks whether the node can be assigned slot 1 in the Sync Sampling network

Parameters
nodeModel

The WirelessModels::NodeModel of the node

syncVersion
uint8

The version of the Sync Sampling formulas supported by the node

Returns

true if the node can be assigned slot 1, false if it cannot be assigned slot 1

totalBytesPerBurst
uint32 totalBytesPerBurst(
uint32 bytesPerSweep,
uint32 numSweeps
)

Gets the total number of bytes per burst

Parameters
bytesPerSweep
uint32

The total number of bytes per data sweep

numSweeps
uint32

The number of sweeps

Returns

The total number of bytes per burst

maxDataBytesPerPacket
uint32 maxDataBytesPerPacket(
uint32 bytesPerSweep,
bool lossless
)

Gets the maximum number of bytes per packet

Parameters
bytesPerSweep
uint32

The total number of bytes per data sweep

lossless
bool

Whether the network is using lossless or not

Returns

The maximum number of bytes per packet

totalNeededBurstTx
uint32 totalNeededBurstTx(
uint32 totalBytesPerBurst,
uint32 maxBurstBytesPerPacket
)

Calculates the total needed transmissions for bursts

Parameters
totalBytesPerBurst
uint32

The total number of bytes per burst

maxBurstBytesPerPacket
uint32

The maximum number of bytes per packet

Returns

The total needed transmissions for Bursts

minTimeBetweenBursts
uint32 minTimeBetweenBursts(
uint32 totalNeededTx,
double sampleDuration,
bool lossless
)

Calculates the minimum amount of time allowed between bursts

Parameters
totalNeededTx
uint32

The total needed transmissions for bursts

sampleDuration
double

The sample duration

lossless
bool

Whether the network is using lossless or not

Returns

The minimum amount of time allowed between bursts

minTimeBetweenBursts
TimeSpan minTimeBetweenBursts(
WirelessTypes::DataFormat dataFormat,
uint8 numActiveChs,
const mscl::SampleRate &sampleRate,
uint32 sweepsPerBurst
)

Gets the minimum time that can be assigned for a Burst Sync Sampling session.

Parameters
dataFormat

The WirelessTypes::DataFormat of the sampling session.

numChannels

The number of active channels for the sampling session.

sampleRate
const mscl::SampleRate&

The SampleRate that for the sampling session.

sweepsPerBurst
uint32

The number of sweeps per burst for the sampling session.

Returns

A TimeSpan representing the minimum time that can be assigned for a Burst Sync Sampling session.

burstTxPerSecond
uint32 burstTxPerSecond(
uint32 totalNeededTx,
uint32 timeBetweenBursts,
double sampleDuration,
bool lossless
)

Calculates the burst transmissions per second

Parameters
totalNeededTx
uint32

The total needed transmissions for bursts

timeBetweenBursts
uint32

The time between each burst

sampleDuration
double

The sample duration

lossless
bool

Whether the network is using lossless or not

Returns

The burst transmissions per second