Skip to content
David Gonzalez edited this page Apr 10, 2016 · 57 revisions

#Quick guide

Getting Trace Data: Get a TraceHelper

To obtain the current data of the trace service, you should subscribe to the "traceChanged" event and its payload.data will contain the most recent TraceHelper. More details in the Trace Helper Sequence Diagram ###0. Your class must have an event aggregator In order to subscribe to Aurelia event system, you should an Event Aggregator defined in your class. You could inject it or receive it from another class.

###1. Import and instantiate the Trace Model In this class, we consolidated all structures use in our API. You will need this library to obatain the

import {TraceModel} from '../traceService/trace-model';
export class YourClass{
   constructor(){
       this.traceModel = new TraceModel();
   }
}

Similar to the event aggregator, you could inject it or receive it from another class.

###2. Subscribing to the trace changes and Obtaining the Trace Helper

let traceChangedEvent = this.traceModel.traceEvents.changed.event;
        this.eventAggregator.subscribe( traceChangedEvent, payload =>{
            let traceHelper = payload.data;
            // do something
        });

###4. List of helper methods

Raw output Format

From the previous snippet, the result contained in payload is as follows:

        {
         status: 'onTraceServiceEnd',
         description: 'Trace built successfully.' ,
         data : [expression_01,..., expression_n]
        }

Normally, you will expect an output like the one above. However, long code or problems such as infinite loops/recursion and runtime errors could happen, so we can keep your inform of what is going on. These are the events the service handles:

TraceService FSM

Variables and their values

Let's look this example:

    let c= false;
    let  n=c; 

The trace (payload.data) will contain the following information:

    

Listening to trace changes [Execution-Visualization Team]

Assuming that results are published after the document changed, subscribing to the onTraceChanged event will keep your trace up to date:

        subscribe() {
        let ea = this.eventAggregator;
        
        ea.subscribe('onTraceChanged', payload =>  {
                   this.trace = payload;
              }
        );
        }

So you can visualize the elements with the aid of a TraceHelper:

       visualizelineValues( lineNumber){
         let traceHelper = new TraceHelper(); 
         let values = traceHelper.getLineValues(this.trace, lineNumber);
         // draw values somehow
       }

Handy methods

To simplify the output of the trace, use the following methods:

getVariables()

This is the case shows values only for variables in the trace. Trace Service Output

#Service Workflow This is the whole picture of how Trace Service works: Aurelia usage sequence UML

the client sends the source code text as input (we will discuss other parameters later). Then, the service will add log calls to that code and run it. Once it ends it will return the results. In the snippet, when the source code changes, the method publishes the event "traceChanged" with the trace output as payload.

We have the following events for the service:

service FSM

######ExecutionTrace feature team trace javascript classes and functions


traceHelper.js class

===== Public Method(s) =====================================

2. getLineValues(Integer lineNumber, Map valueTable): Array
  • Usage: get all the values of the "lineNumber" stored in an array
  • Parameter Information: none.
  • Function Dependencies: getValues(Map esprimaRange, Map valueTable): Array
  • Class Dependencies: none.
3. getValues(Map esprimaRange, Map valueTable): Array
  • Usage: get all the values within the "esprimaRange" stored in an array
  • Parameter Information: none.
  • Function Dependencies: none.
  • Class Dependencies: none.
4. getValuesWithType(Map esprimaRange, Map valueTable): Map
  • Usage: get all the values with the type within the "esprimaRange" stored in a map
  • Parameter Information: none.
  • Function Dependencies: none.
  • Class Dependencies: none.