Skip to content

LIN

feral3gp.feral.lin(config, director=Simulation.director_de)

Source code in feral3gp/feral/network/lin.py
53
54
55
56
57
58
59
60
61
def lin(config: LINConfig, director=Simulation.director_de) -> JLINNetwork:
    number_of_nodes = len(config.nodes)
    java_lin_network = JDefaultLINNetwork(config.name, director, number_of_nodes)
    __configure_lin_network(config=config, java_lin_network=java_lin_network)

    __configure_nodes(config=config, network=java_lin_network, configure_func=__configure_lin_node)
    __configure_console(java_component=java_lin_network, config=config.console)

    return java_lin_network

feral3gp.feral.add_schedule(name, network)

Adds a schedule for the LIN bus master.

Parameters:

Name Type Description Default
name str

The name of the schedule

required
network LINNetwork

The LIN network

required

Returns:

Type Description
LINSchedule

The created :class:LINSchedule

Source code in feral3gp/feral/network/lin.py
115
116
117
118
119
120
121
122
def add_schedule(name: str, network: JLINNetwork) -> LINSchedule:
    """
    Adds a schedule for the LIN bus master.
    :param name: The name of the schedule
    :param network: The LIN network
    :returns: The created :class:`LINSchedule`
    """
    return LINSchedule(network.addSchedule(JString(name)))

feral3gp.feral.LINSchedule dataclass

Source code in feral3gp/feral/network/lin.py
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
@dataclass
class LINSchedule:
    __lin_schedule: JLINSchedule

    def add_unconditional_frame(self, sender_idx: int, delay: int, lin_id: int) -> LINSchedule:
        """
        Appends a new unconditional frame to this schedule. Given delay will be rounded up to next multiple of the time
        base.

        **Note** -- *If an unconditional frame is sent by the master, the message inside the master will not be consumed and
        will get sent again next time.*
        :param sender_idx: Producer of this frame, 0 for master, 1..16 for nth slave
        :param delay: The frame duration in multiples of the time base
        :param lin_id: LIN ID associated with the unconditional frame
        :returns: The schedule itself to chain addXXXFrame commands
        """
        # The list has to be converted to a Java array. This can be done using the matmul-operator.
        self.__lin_schedule = self.__lin_schedule.addUnconditionalFrame(JInt(sender_idx), JInt(delay), JInt(lin_id))
        return self

    def add_sporadic_frame(self, delay: int, lin_ids: typing.List[int]) -> LINSchedule:
        """
        Appends a new sporadic frame to this schedule. (sender is always the master)
        Given delay will be rounded up to next multiple of the time base.

        **Note** -- *If a sporadic frame is sent by the master, the message inside the master be consumed.
        It cannot be sent again.*
        :param delay: The frame duration in multiples of the time base
        :param lin_ids: List of LIN IDs associated with the sporadic frame. First has the highest priority.
        :returns: The :class:`LINSchedule` itself to chain addXXXFrame commands
        """
        self.__lin_schedule = self.__lin_schedule.addSporadicFrame(JInt(delay), JInt[:] @ lin_ids)
        return self

    def add_event_triggered_frame(self, collision_table_name: str, delay: int, lin_id: int,
                                  associated_lin_ids: typing.List[int]) -> LINSchedule:
        """
        Appends a new event triggered frame to this schedule. Given delay will be rounded up to next multiple of the
        time base.
        :param collision_table_name: Name of the schedule table that will get executed once on collision
        :param delay: The frame duration in multiples of the time base
        :param lin_id: LIN ID associated with the event triggered frame
        :param associated_lin_ids: LIN IDs of unconditional frames that are associated with this event triggered frame
        :returns: The :class:`LINSchedule` itself to chain addXXXFrame commands
        """
        # The list has to be converted to a Java array. This can be done by casting.
        self.__lin_schedule = self.__lin_schedule.addEventTriggeredFrame(collision_table_name, JInt(delay),
                                                                         JInt(lin_id), JInt[:] @ associated_lin_ids)
        return self

add_event_triggered_frame(collision_table_name, delay, lin_id, associated_lin_ids)

Appends a new event triggered frame to this schedule. Given delay will be rounded up to next multiple of the time base.

Parameters:

Name Type Description Default
collision_table_name str

Name of the schedule table that will get executed once on collision

required
delay int

The frame duration in multiples of the time base

required
lin_id int

LIN ID associated with the event triggered frame

required
associated_lin_ids List[int]

LIN IDs of unconditional frames that are associated with this event triggered frame

required

Returns:

Type Description
LINSchedule

The :class:LINSchedule itself to chain addXXXFrame commands

Source code in feral3gp/feral/network/lin.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
def add_event_triggered_frame(self, collision_table_name: str, delay: int, lin_id: int,
                              associated_lin_ids: typing.List[int]) -> LINSchedule:
    """
    Appends a new event triggered frame to this schedule. Given delay will be rounded up to next multiple of the
    time base.
    :param collision_table_name: Name of the schedule table that will get executed once on collision
    :param delay: The frame duration in multiples of the time base
    :param lin_id: LIN ID associated with the event triggered frame
    :param associated_lin_ids: LIN IDs of unconditional frames that are associated with this event triggered frame
    :returns: The :class:`LINSchedule` itself to chain addXXXFrame commands
    """
    # The list has to be converted to a Java array. This can be done by casting.
    self.__lin_schedule = self.__lin_schedule.addEventTriggeredFrame(collision_table_name, JInt(delay),
                                                                     JInt(lin_id), JInt[:] @ associated_lin_ids)
    return self

add_sporadic_frame(delay, lin_ids)

Appends a new sporadic frame to this schedule. (sender is always the master) Given delay will be rounded up to next multiple of the time base.

Note -- If a sporadic frame is sent by the master, the message inside the master be consumed. It cannot be sent again.

Parameters:

Name Type Description Default
delay int

The frame duration in multiples of the time base

required
lin_ids List[int]

List of LIN IDs associated with the sporadic frame. First has the highest priority.

required

Returns:

Type Description
LINSchedule

The :class:LINSchedule itself to chain addXXXFrame commands

Source code in feral3gp/feral/network/lin.py
84
85
86
87
88
89
90
91
92
93
94
95
96
def add_sporadic_frame(self, delay: int, lin_ids: typing.List[int]) -> LINSchedule:
    """
    Appends a new sporadic frame to this schedule. (sender is always the master)
    Given delay will be rounded up to next multiple of the time base.

    **Note** -- *If a sporadic frame is sent by the master, the message inside the master be consumed.
    It cannot be sent again.*
    :param delay: The frame duration in multiples of the time base
    :param lin_ids: List of LIN IDs associated with the sporadic frame. First has the highest priority.
    :returns: The :class:`LINSchedule` itself to chain addXXXFrame commands
    """
    self.__lin_schedule = self.__lin_schedule.addSporadicFrame(JInt(delay), JInt[:] @ lin_ids)
    return self

add_unconditional_frame(sender_idx, delay, lin_id)

Appends a new unconditional frame to this schedule. Given delay will be rounded up to next multiple of the time base.

Note -- If an unconditional frame is sent by the master, the message inside the master will not be consumed and will get sent again next time.

Parameters:

Name Type Description Default
sender_idx int

Producer of this frame, 0 for master, 1..16 for nth slave

required
delay int

The frame duration in multiples of the time base

required
lin_id int

LIN ID associated with the unconditional frame

required

Returns:

Type Description
LINSchedule

The schedule itself to chain addXXXFrame commands

Source code in feral3gp/feral/network/lin.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def add_unconditional_frame(self, sender_idx: int, delay: int, lin_id: int) -> LINSchedule:
    """
    Appends a new unconditional frame to this schedule. Given delay will be rounded up to next multiple of the time
    base.

    **Note** -- *If an unconditional frame is sent by the master, the message inside the master will not be consumed and
    will get sent again next time.*
    :param sender_idx: Producer of this frame, 0 for master, 1..16 for nth slave
    :param delay: The frame duration in multiples of the time base
    :param lin_id: LIN ID associated with the unconditional frame
    :returns: The schedule itself to chain addXXXFrame commands
    """
    # The list has to be converted to a Java array. This can be done using the matmul-operator.
    self.__lin_schedule = self.__lin_schedule.addUnconditionalFrame(JInt(sender_idx), JInt(delay), JInt(lin_id))
    return self

feral3gp.feral.LINConfig dataclass

Bases: NetworkConfig

The configuration of the LIN network

Source code in feral3gp/feral/network/lin_config.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@dataclass
class LINConfig(NetworkConfig):
    """
    The configuration of the LIN network
    """

    name: str = "unnamed LIN network"
    """The name of the network"""

    bit_rate: int = 19200
    """The bitrate of the bis in Bits/s"""

    sync_break_length_in_bits: int = 13
    """The size of the Sync Break in bits (excluding the delimiter length)"""

    sync_break_delimiter_length_in_bits: int = 1
    """The size of the Sync Break Delimiter in bits"""

    inter_byte_space: int = 0
    """The length if the Inter-Byte-Space in ns"""

    response_space: int = 0
    """The length of the Response Space in ns"""

    jitter_range: typing.Tuple[int, int] = (0, 0)
    """
    The range of the jitter for master to start sending in nanoseconds. 
    Must both be positive. 
    First element lower bound, second one upper bound. 
    """

    time_base: int = feral.millis(5)
    """The time base for the LIN master in ns. Must be positive."""

    schedule_start_delay: int = 0
    """The time that passes before LIN master starts the schedule"""

    starting_schedule_name: str = None
    """The name of the starting schedule (or None if not defined yet)."""

bit_rate: int = 19200 class-attribute instance-attribute

The bitrate of the bis in Bits/s

inter_byte_space: int = 0 class-attribute instance-attribute

The length if the Inter-Byte-Space in ns

jitter_range: typing.Tuple[int, int] = (0, 0) class-attribute instance-attribute

The range of the jitter for master to start sending in nanoseconds. Must both be positive. First element lower bound, second one upper bound.

name: str = 'unnamed LIN network' class-attribute instance-attribute

The name of the network

response_space: int = 0 class-attribute instance-attribute

The length of the Response Space in ns

schedule_start_delay: int = 0 class-attribute instance-attribute

The time that passes before LIN master starts the schedule

starting_schedule_name: str = None class-attribute instance-attribute

The name of the starting schedule (or None if not defined yet).

sync_break_delimiter_length_in_bits: int = 1 class-attribute instance-attribute

The size of the Sync Break Delimiter in bits

sync_break_length_in_bits: int = 13 class-attribute instance-attribute

The size of the Sync Break in bits (excluding the delimiter length)

time_base: int = feral.millis(5) class-attribute instance-attribute

The time base for the LIN master in ns. Must be positive.