Series tutorial

Using and configuring Series

Configuring Series:

The following script presents the different types of series and how to create them.

# bitrate series configuration
	
# create default bitrate series
series = series_builder.bitrate()

# create bitrate series with custom sampling time (default : 1)
series = series_builder.bitrate(0.5)

# create bitrate series with custom sampling time, control bitrate, 
# and data bitrate (default: 1, 500000, 2000000 respectively)

# control bitrate and data bitrate are considered only for can-fd
# messages with bitrate switch (brs) ON
series = series_builder.bitrate(0.5, 500000, 50000000)
		
# packet rate series configuration
 
# create default packet rate series
series = series_builder.packetrate()

# create packet rate series with custom sampling time (default: 1)
series = series_builder.packetrate(0.5)

# deltatime series has no configuration

# create default deltatime series
series = series_builder.deltatime()

Creating Series and printing its elements:

The following script is an example of using a bitrate series with 1 second timestamp (default)

# example on using series

# imports
from time import sleep

# create bitrate series (packetrate() and deltatime() also supported)
series = series_builder.bitrate()

# add received messages to series
def on_message_received(msg):
    series.add(msg)
    
# create a sample message (sender_channel and receiver_channel are supposedly preconfigured)
sample_message = message_builder.create_ethernet_message(sender_channel.name, receiver_channel.name)

sample_message.on_message_received += on_message_received
sample_message.start_capture()

# sending sample_message 1000 times
for x in range(1000):
    sleep(0.010)
    sample_message.send()

sample_message.stop_capture()
sample_message.on_message_received -= on_message_received

# printing series' elements (timestamp, value)
print("=====================================")
for s in series.values:
    print(s.X)
    print(s.Y)
print("=====================================")