the tdl experimental domain in ptolemy€¦ · timing definition language (tdl) in a nutshell ......

43
Stefan Resmerita Patricia Derler Wolfgang Pree C. Doppler Lab Embedded Software Systems cs.uni-salzburg.at The TDL Experimental Domain in Ptolemy

Upload: others

Post on 16-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

Stefan Resmerita

Patricia Derler

Wolfgang Pree

C. Doppler Lab Embedded Software Systemscs.uni-salzburg.at

The TDL Experimental Domain

in Ptolemy

Page 2: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)2

Contents

Timing Definition Language (TDL) in a nutshell

Implementation of the TDL Ptolemy domain

Conclusions and further work

Page 3: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)3

TDL in a nutshell

Page 4: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)4

What is TDL?

A high-level textual notation for defining the timing behavior of a real-time application.

Conceptually based on Giotto, in particular its Logical Execution Time (LET) abstraction.

TDL = Giotto + syntax + cleanups+ component architecture + control engineering enhancements.

QuickTime™ and aTIFF (LZW) decompressor

are needed to see this picture.

Page 5: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)5

develop once

3 dSpace

mabx

TT

Ethernet

deploy on any

platform

C

2 Renesas. . .

FlexRay-based communication

Giotto/TDL vision:

. . .

Page 6: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)6

TDL syntax by example

start mode main [period=5ms] {

task

[freq=1] inc(); // LET=5ms/1=5ms

actuator

[freq=1] a1 := inc.o;

mode

[freq=1] if exitMain(s1) then freeze;

}

mode freeze [period=1000ms] {}

}

s1 inc [5ms] a1

Sender (mode main)

time

5 ms

Logical Execution Time (LET)

module Sender {

sensor boolean s1 uses getS1;

actuator int a1 uses setA1;

public task inc {

output int o := 10;

uses incImpl(o);

}

Page 7: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)7

Module import

module Receiver {

import Sender;

task clientTask {

input int i1;

}

mode main [period=10ms] {

task [freq=1] clientTask(Sender.inc.o); // LET = 10ms / 1 = 10ms

}

}

s1 a1

Sender

clientTask [10ms] a1

Receiver

inc [5ms]

Page 8: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)8

TDL: Additional Features

Fast tasks

Different LET and period of invocation for a task

Flexible placement of the LET within the period

Specified by slot selection

Example:

time

Task1

LET = 2,Per. = 8

Offset = 0

Task2

LET = 3, Period = 8

Offset = 4

41 2 3 5 6 7 80

Slo

t 0

Page 9: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)9

TDL Modeling and Simulation

TDL:VisualCreator

Simulink:

Page 10: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)10

Why Ptolemy?

Experiment with heterogeneous models involving TDL

components

Rapid testing of new TDL developments

Existence of computational models closely related to

TDL

Reuse of functionality

Reuse of graphical user interface

Page 11: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)11

The Experimental TDL

Domain in Ptolemy

Page 12: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)12

General

• Based on modal models of the finite state machine domain

• Reuse of existing concepts– Modes with different behaviors

– Only one active mode

– Transitions between modes

– Graphical representation

• Main changes – Order of execution

– Deterministic choice of transitions

– Mode switches only at certain points during execution

– Output ports are not updated after every firing

– Guarded task executions and port updates

Page 13: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)13

TDL Module

TDL Module Actor

• Contains modes

TDL Mode Controller

• Mirrors ports in refinements

TDL Module Director

• Generates and executes schedule

TDLModule

-_init()

ModalModel

FSMActor

TDLActor

- newRelation()

TDLController

- newPort()

ModalDirector

TDLModuleDirector

-prefire()-fire()-newReceiver()-transferInputPorts()-transferOutputPorts()-buildSchedule()

Modal-Controller

Page 14: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)14

TDL Module

TDL Module Actor

• Contains modes

TDL Mode Controller

• Mirrors ports in refinements

TDL Module Director

• Generates and executes schedule

TDLModule

-_init()

ModalModel

FSMActor

TDLActor

- newRelation()

TDLController

- newPort()

ModalDirector

TDLModuleDirector

-prefire()-fire()-newReceiver()-transferInputPorts()-transferOutputPorts()-buildSchedule()

Modal-Controller

Page 15: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)15

TDL Module

TDL Module Actor

• Contains modes

TDL Mode Controller

• Mirrors ports in refinements

TDL Module Director

• Generates and executes schedule

TDLModule

-_init()

ModalModel

FSMActor

TDLActor

- newRelation()

TDLController

- newPort()

ModalDirector

TDLModuleDirector

-prefire()-fire()-newReceiver()-transferInputPorts()-transferOutputPorts()-buildSchedule()

Modal-Controller

Page 16: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)16

TDL Schedule

Mode Schedule Generation

The TDL module director creates a static schedule in 2 steps:1. LET Schedule: general Schedule for LET based tasks2. TDL-specific Schedule: actuators, fast tasks, mode switches

LETModeScheduler

-getModeSchedule()

TDLModeScheduler

-getModeSchedule()

LETTask

-let-invocationPeriod

Page 17: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)17

LET Schedule Example

0 1 2 3 4 5 6 7 8

8 is the least common multiple

of all invocation periods

Time Scheduled actions Example

0=8 Update tasks output ports T2_out

Update tasks input ports T1 _in T2_in T3_in

Execute tasks T1 T2 T3

T1 : let = 2

invocation period = 4

T2: let = 4

invocation period = 4

T3: let = 3

invocation period = 8

Time Scheduled actions Example

1 Update tasks output ports

Update tasks input ports

Execute tasks

Time Scheduled actions Example

2 Update tasks output ports T1_out

Update tasks input ports

Execute tasks

Time Scheduled actions Example

3 Update tasks output ports T3_out

Update tasks input ports

Execute tasks

Time Scheduled actions Example

4 Update tasks output ports T2_out

Update tasks input ports T1_in T2_in

Execute tasks T1 T2

Time Scheduled actions Example

5 Update tasks output ports

Update tasks input ports

Execute tasks

Time Scheduled actions Example

6 Update tasks output ports T1_out

Update tasks input ports

Execute tasks

Time Scheduled actions Example

7 Update tasks output ports

Update tasks input ports

Execute tasks

Time Scheduled actions Example

Update tasks output ports

Update tasks input ports

Execute tasks

Page 18: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)18

TDL Schedule

general LET based scheduleTDL specific parts of the schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Test mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 19: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)19

TDL Mode

TDL Mode

• Group TDL tasks

TDL Transition

• Switch between TDL modes

TDL Receiver

• All receivers inside the TDL module

• Based on Giotto Receiver

TDLMode

-period

State

TDLTransition

- frequency

Transition

AbstractReceiver

TDLReceiver

- token

-hasRoom()-put()-update()

Page 20: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)20

TDL Mode

TDL Mode

• Group TDL tasks

TDL Transition

• Switch between TDL modes

TDL Receiver

• All receivers inside the TDL module

• Based on Giotto Receiver

TDLMode

-period

State

TDLTransition

- frequency

Transition

AbstractReceiver

TDLReceiver

- token

-hasRoom()-put()-update()

Page 21: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)21

TDL Mode

TDL Mode

• Group TDL tasks

TDL Transition

• Switch between TDL modes

TDL Receiver

• All receivers inside the TDL module

• Based on Giotto Receiver

TDLMode

-period

State

TDLTransition

- frequency

Transition

AbstractReceiver

TDLReceiver

- token

-hasRoom()-put()-update()

Page 22: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)22

TDL Mode

TDL Refinement

• A TDL mode has exactly one TDL refinement

TDL Task Actor

• A TDL refinement contains only TDL tasks

• TDL tasks can only be SDF actors

TDLRefinement

- newPort()

Refinement

TDLRefinementPort

-frequency-initialValue-fast

RefinementPort

TDLTask

-frequency-fast

-newPort()

TypedCompositeActor

TDLTaskOutputPort

- initialValue

TypedIOPort

Page 23: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)23

TDL Mode

TDL Refinement

• A TDL mode has exactly one TDL refinement

TDL Task Actor

• A TDL refinement contains only TDL tasks

• TDL tasks can only be SDF actors

TDLRefinement

- newPort()

Refinement

TDLRefinementPort

-frequency-initialValue-fast

RefinementPort

TDLTask

-frequency-fast

-newPort()

TypedCompositeActor

TDLTaskOutputPort

- initialValue

TypedIOPort

Page 24: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)24

TDL Director

TDL Director

• Must be top-level director for models containing TDL module actors

• Mostly the same as the DE director with special handling of TDL module actors

TDLDirector

- fire()

DEDirector

Page 25: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)25

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

general LET based scheduleTDL specific parts of the schedule

Page 26: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)26

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 27: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)27

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 28: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)28

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 29: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)29

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 30: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)30

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 31: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)31

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 32: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)32

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 33: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)33

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 34: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)34

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 35: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)35

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 36: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)36

TDL Schedule

Time Scheduled actions

0 Update LET tasks output ports

Update actuators

Calculate mode switches

Fast tasks: - Update input ports- Execute fast tasks- Update output ports- Update connected actuators

Update LET tasks input ports

Execute LET tasks

0 + t Update LET tasks output ports

Page 37: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)37

User Interface Changes

Vergil

• Graphical representation of TDL modules

• Enable adding TDL refinements to TDL modes

Configuration Files

• Adding TDL actors to Libraries

• Icon for TDL module

TDLModuleTableFactory

- createTableau()

TableauFactory

HierarchicalMode-ControllerFactory

- create()

HierarchicalModeController

AddRefinementAction

StateControllerNodeControllerFactory

Page 38: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)38

Difficulties Extending Ptolemy

• Many configuration files in different places

• Extending Ptolemy by subclassing– Private and protected variables/methods in Ptolemy make deriving

difficult

– Lots of code duplication in case of deriving• 1749 LOC for the TDLDirector to override the fire of the DEDirector

– Hierarchy• E.g. a TDLTransition is derived from a Transition, however they should be

at the same level

Page 39: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)39

TDL in Ptolemy – Open Issues

• Having the same instance of an actor (task) in different refinements is hard to achieve

TDL Module

TDL Task 1 TDL Task 1

Page 40: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)40

LET behavior

tSender inc inc

Receiver clientTask

inc inc

10 ms

5 ms

communication of inc’s

output to clientTask

clientTask

Page 41: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)41

Execution on distributed systems

tSender inc inc

Receiver clientTask

inc inc

10 ms

5 ms

clientTask

N1

N2

t

Page 42: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)42

Deployment of TDL Code

Page 43: The TDL Experimental Domain in Ptolemy€¦ · Timing Definition Language (TDL) in a nutshell ... –Lots of code duplication in case of deriving • 1749 LOC for the TDLDirectorto

© 2004, name(s)43

Summary

Experimental TDL domainLET Task

TDL Module

TDL Domain Controller

Further work

Functionality • TDL extensions

• Code generation

Usability• Hide library elements that should not be used

• Provide all necessary parameters

Research• Interaction with other domains