Presentation is loading. Please wait.

Presentation is loading. Please wait.

Access Point Event Simulator (APES) for Legacy Software Systems (LESS) Stefan Resmerita Joint work with Patricia Derler and Edward Lee February 17, 2009.

Similar presentations


Presentation on theme: "Access Point Event Simulator (APES) for Legacy Software Systems (LESS) Stefan Resmerita Joint work with Patricia Derler and Edward Lee February 17, 2009."— Presentation transcript:

1 Access Point Event Simulator (APES) for Legacy Software Systems (LESS) Stefan Resmerita Joint work with Patricia Derler and Edward Lee February 17, 2009

2 APES-LESS: February 17, 20092 Contents 1.Goals and motivation 2.Approach 3.Ptolemy II components 4.Further work 5.Demos Contents

3 APES-LESS: February 17, 20093 Main Goals Short-term: –Simulate (on a host computer) execution of embedded software written in C for OSEK-compliant OS and given platform model –Achieve fast Software-in-the-Loop testing Medium to long term: –Enable modeling of legacy applications –Apply MBD principles to legacy software Goals and Motivation

4 APES-LESS: February 17, 20094 Software in the Loop Testing Plant Model Actuator models Sensor Models Simulation of original application code Simulation of modified application code + – User Input Error Goals and Motivation

5 APES-LESS: February 17, 20095 Classical Problem DynamicsController.c void dC_step() { … write(angle); … } … 002345612 00234570 00234596 002346023 00234610 00234630 … Memory MotorController.c void mC_step() { … read(angle); … } write(angle)read(angle) dC mC time Simulation dC mC time Execution on the ECU write(angle) read(angle) preemption S-function Goals and Motivation

6 APES-LESS: February 17, 20096 Simulation Engine Based on Ptolemy II Fast prototyping –Discrete event simulation –Java threads Component-based design Visual modeling Portability Enables execution of legacy code under different models of computation Approach

7 APES-LESS: February 17, 20097 Request Response Model Structure Functionality actors OSEK actors Actor execution Actor interaction Java-C bridge Ptolemy II components

8 APES-LESS: February 17, 20098 Event-Based Approach Access Point Event (APE) An access point is a line of source code with an I/O access or a system call In a run of the software, an access point event occurs whenever the code of an access point starts executing Access Point Event (APE) An access point is a line of source code with an I/O access or a system call In a run of the software, an access point event occurs whenever the code of an access point starts executing void dC_step() { … angle = t1*s1; … } void mC_step() { … tmp_a = angle; … } void dC_step() { … SendMessage(m_a, angle); … } void mC_step() { … ReceiveMessage(m_a,angle); … } void appDispatcher(){ while (appRunning){ WaitEvent(appDispatcherEvent); ClearEvent(appDispatcherEvent); if(simStep%5 == 0){ ActivateTask(dC_Task); } SetEvent(mC_Task, mC_Event); simStep++; } TerminateTask(); } Approach

9 APES-LESS: February 17, 20099 Execution Control at Access Points Insert a callback to the simulation engine at every access point –Determine the execution time since the previous APE –Send the timestamped APE to the task scheduler –Pause the execution of the task The task scheduler generates an Access Granted Event (AGE) The execution of the task is resumed upon receiving the AGE Approach activate(T 1 ) activate(T 2 ) AGE T 2 AGE T 1 APE T 1 (  1 ) APE T 2 (  2 ) terminate(T 2 ) APE T (  1 ’) T1T1 T2T2 t 1 t 2 t 2 +  2 t 1 +  1 +  2

10 APES-LESS: February 17, 200910 Example MotorController.c void mC_step() { … aPCallback(12); tmp_angle = angle; … aPCallback(42); WaitEvent(evMask); … } Thread cCodeThread; void fire() { notify(); } void aPCallback(time) { requestExecTime(time); sleep(); } CTask.java 2. start 6. resume 3. callback (stop) b. change task state, reschedule 1. Trigger 4. APE a. system call  CCodeLibrary 5. AGE Approach

11 APES-LESS: February 17, 200911 Functionality Actor: CTask Executes a C function mapped to an OSEK task in a dedicated thread Implements two callback methods: –accessPointCallback(executionTime, minimumDelay); before every access point where no monitoring is needed –accessPointCallback(executionTime, minimumDelay, varName, value); Inserted in the C code after the line where varName is updated Parameters: –The name of a C function mapped to an OSEK task –The priority of the task Ports: –Multicast output port, used to send APEs –Multicast input port, used to receive AGEs –Regular I/O ports for global variables Ptolemy II components

12 APES-LESS: February 17, 200912 Multithreaded DE Simulation: Problem Ptolemy II components t1t1 t2t2 t3t3 model time real time Process ev 1 Trigger task 1 Wake up thread of C task 1 (CT1) Process ev 2 Process ev 3 CT1 callback(  t 1 ) Generate APE 1 with timestamp t 1 +  1 ev 1 ev 2 t 1 +  1 APE 1 ev 3 CT2 CT1 11

13 APES-LESS: February 17, 200913 Multithreaded DE Simulation: Solution Ptolemy II components t1t1 t2t2 t3t3 model time real time Process ev 1 Trigger task 1 Wake up thread of C task 1 (CT1) Ask to be re-fired at t 1 +  1 Process ev 2 Process APE 1 CT1 callback(  1,  2 ) Resume DE thread Suspend C thread ev 1 ev 2 t 1 +  1 APE 1 ev 3 CT2 CT1  1,  1 t 1 +  1 ev´ 1 Process ev´ 1 Suspend execution of DE thread Generate APE 1 Finish ev´ 1 processing

14 APES-LESS: February 17, 200914 OSEK Actor: TaskScheduler Maintains task status information Implements task system services –ActivateTask, TerminateTask Receives task status notifications from other OSEK actors Sends AGEs to functionality actors Fixed priority preemptive scheduling Receives APEs from CTask actors ready running waiting suspended trigger AGE preemption event/resource received wait for event resource blocked termiate task Ptolemy II components

15 APES-LESS: February 17, 200915 OSEK Actor: EventManager Implements event OSEK services –SendEvent –GetEvent –ClearEvent Notifies the TaskScheduler to change task status –If a task needs to wait for an event –If a waiting task receives an event Ptolemy II components

16 APES-LESS: February 17, 200916 Source (sensor) Actor: FormattedLineReader Reads data from an input file –At each iteration, data from one line is send to the output ports Assumes input text in tabular format –A column is a sampled signal –A line contains the values of all signals at a sample time Maps port names and types to named columns Buffered reading –All the file is processed at initialization, when all tokens are created and stored in memory Ptolemy II components

17 APES-LESS: February 17, 200917 Infrastructure Element: MultiCastIOPort Provides line-free connectivity between actors Output port: –Destination actors are specified at runtime in each send action –Static filter for eligible destinations given as a parameter Input: –Static filter for source actors specified as a parameter Can help in modeling service oriented applications Ptolemy II components

18 APES-LESS: February 17, 200918 Monitoring Task execution: Visualization of task states in time Global variables Ptolemy II components

19 APES-LESS: February 17, 200919 Java-C bridge Java classes –OSEKEntryPoint: Receives all system calls from C tasks and routes them to the appropriate OSEK actors –AccessPointCallbackDispatcher: Routes the callbacks from C to the appropriate functionality actors C wrapping code –APES layer –OS layer –Application layer Ptolemy II components

20 APES-LESS: February 17, 200920 Next Steps: The Simulator Methods –Refine source line granularity –Adapt and use existing methods for estimation of execution time Automatization tools –Code instrumentation –Generation of the APES model Visualization tools Performance evaluation Further work

21 APES-LESS: February 17, 200921 Application Performance Evaluation Simulation of closed-loop control applications –Bridging different simulation environments –Tool support Testing with code coverage Stability analysis/validation with regard to execution times Further work

22 APES-LESS: February 17, 200922 Modeling of Legacy Applications Task Model Functional Model Timing Model Modal Model Further work

23 APES-LESS: February 17, 200923 Demos: Active Rear Steering Control Simulink model: Demos

24 APES-LESS: February 17, 200924 Demo 1: Building a Basic APES model C code is generated from the Simulink model for each of the three subsystems Both controllers and the plant model are compiled in the same native library Input is read in the C part from a file CTask actors are used only for execution control No connections necessary at the Ptolemy level Demos

25 APES-LESS: February 17, 200925 The ARS Model for Demo 1

26 APES-LESS: February 17, 200926 Demo 2: APES model with plant actor in C The two controllers are compiled in the same native library Speed input is provided by a Ptolemy DE actor, and front angle input from a file at the Ptolemy level The plant is wrapped in an EmbeddedCActor Connections are needed between controllers and their environment Demos

27 APES-LESS: February 17, 200927 The ARS Model for Demo 2 Demos

28 Thank you for your attention!


Download ppt "Access Point Event Simulator (APES) for Legacy Software Systems (LESS) Stefan Resmerita Joint work with Patricia Derler and Edward Lee February 17, 2009."

Similar presentations


Ads by Google