15.6.2 DTSL option example walk-through

The following is a simplified example from the Keil MCBSTM32E platform Jython script:

1.     class DSTREAMDebugAndTrace(DTSLv1):
2.         '''A top level configuration class which supports debug and trace'''
3.
4.         @staticmethod
5.         def getOptionList():
6.             '''The method which specifies the configuration options which
7.                the user can edit via the launcher panel |Edit...| button
8.             '''
9.             return [
10.                DTSLv1.tabSet(
11.                    name='options',
12.                    displayName='Options',
13.                    childOptions=[
14.                        DSTREAMDebugAndTrace.getTraceBufferOptionsPage(),
15.                        DSTREAMDebugAndTrace.getETMOptionsPage(),
16.                        DSTREAMDebugAndTrace.getITMOptionsPage()
17.                    ]
18.                )
19.            ]

Line 4 marks the method as a static method of the containing class. This allows it to be called before an instance of the class exists. It also implies that any methods that are called are also static methods, because there is no self (this) associated with an instance of the class. Line 5 defines the static method with the name getOptionList. If this static method is present, then the configuration has options, otherwise it does not. Line 10 creates a TabSet object with name 'options', display name 'Options', and an array of child options, which in this example are each created by calling another static method.

Note:

You might find it helpful to provide child options using several static methods. This prevents the nesting level of brackets from becoming too deep and difficult to understand, and makes it easier for you to avoid using the wrong type of bracket in the wrong place.

The following code extract shows the getTraceBufferOptionsPage method:

1.     @staticmethod
2.     def getTraceBufferOptionsPage():
3.         return DTSLv1.tabPage(
4.             name='traceBuffer',
5.             displayName='Trace Buffer',
6.             childOptions=[
7.                 DTSLv1.enumOption(
8.                     name='traceCaptureDevice',
9.                     displayName='Trace capture method',
10.                    defaultValue='none',
11.                    values=[
12.                        ('none', 'No trace capture device'),
13.                        ('DSTREAM', 'DSTREAM 4GB Trace Buffer')
14.                    ]
15.                ),
16.                DTSLv1.booleanOption(
17.                    name='clearTraceOnConnect',
18.                    displayName='Clear Trace Buffer on connect',
19.                    defaultValue=True
20.                ),
21.                DTSLv1.booleanOption(
22.                    name='startTraceOnConnect',
23.                    displayName='Start Trace Buffer on connect',
24.                    defaultValue=True
25.                ),
26.                DTSLv1.enumOption(
27.                    name='traceWrapMode',
28.                    displayName='Trace full action',
29.                    defaultValue='wrap',
30.                    values=[
31.                        ('wrap', 'Trace wraps on full and continues to store data'),
32.                        ('stop', 'Trace halts on full')
33.                    ]
34.                )
35.            ]
36.    )

Note:

The code uses nesting and indentation to help keep track of closing bracket types.

Line 3 creates a tab page named 'traceBuffer', which has an array of child options. These child options are displayed on the tab page within a GUI. Working through the child options might help you understand how they are displayed to the user. Line 7 creates an enum option. This is an option whose value is one of a set of pre-defined values, and which is typically presented to the user as a drop down list box. The list box shows the pre-defined values, and the user selects one of them. The values are given as pairs of strings. The first string is the internal value, and the second string is the text displayed to the user. Lines 16 to 21 create boolean options. These are options which are true or false, or on or off, and are usually shown to the user as a check box GUI element.

The following figure shows how DS-5 renders the tab set and tab page:

Figure 15-11 DSTREAM Trace Options
DSTREAM Trace Options


For more examples, see the full source code for the Keil example in the DTSLExampleConfigdb project.

Non-ConfidentialPDF file icon PDF versionARM DUI0446Z
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.