IBM
Contents Index Previous Next



Using the SDL Suite Services


Introduction

This section exemplifies the usage of some SDL Suite services. The examples take advantage of the Service Encapsulator described in the previous section.

In these examples, we only use textual values of the parameters <tool> and <service>. Available textual values is found in the spMList variable in sdt.h.

In the examples below, the Service Encapsulator is executed from a csh shell (on UNIX), or from the "DOS" prompt (in Windows). If another shell is used, the examples below might need to be modified in order to supply the parameters correctly. Take care how to supply the quoted strings.

Note:

Due to limitations in DOS, this Service Encapsulator example is not as extensive in Windows as the UNIX version.

Load External Signal Definitions into the Information Server

For this service to be available, the Information Server must be started. This could be done by either starting the Type Viewer from the Organizer, by requesting Signal Dictionary support in the SDL Editor or by using the Start service. For a complete service description, See Start Tool.

Requesting the Service

It is assumed that a file a.pr is to be loaded. Note that the file to be loaded must be specified with a full directory path.

On UNIX: serverpc info loaddefinition /usr/ab/a.pr

In Windows: serverpc info loaddefinition 
c:\sdt\ex\a.pr

If the Information Server is started, the following reply message is returned:

Reply status is OK

If the Information Server is not started, we get the following reply message.

Error sending to postmaster:  server not connected 
to postmaster

The external files loaded into the SDL Infoserver should have the following appearance e.g.:

signal sig1
signal sig2
signal sig3

Obtain Source (SDL/GR Reference)

Returns a complete SDT reference of each of the selected symbols in the specified editor.

serverpc sdle obtainsource

If the editor was already started and there was a selection the reply message might look like:

Reply status is OK
 1 
"#SDTREF(SDL,c:\IBM\Rational\SDL_TTCN_Suite6.3\sdt\e
xamples\demongam\demon.spr(1),125(30, 70))"

Note that the reference returns a complete file path of the diagram file in which the selection was made.

If the editor did not contain any selection, the reply becomes:

Reply status is OK
0

For a complete description of the service, see Obtain GR Reference.

Show Source

Selects the object given by the parameters in an editor. The editor is started if necessary as a side effect. A system must however be opened in the Organizer containing the specified reference.

To test this service we could now deselect all selections in the SDL Editor and use the reference extracted by obtainsource to select this symbol again. Note how the SDT reference is quoted to pass it from the shell into the tool.

On UNIX: serverpc organizer showsource \
  """#SDTREF(SDL,/usr/sdt-inst/examples/simulator- \
  integration/sunos4/demon.spr(1),125(30,70))"""

In Windows: serverpc organizer showsource 
\"#SDTREF(SDL,c:\IBM\Rational\SDL_TTCN_Suite6.3\sdt\
examples\demongam\demon.spr(1),125(30, 70))\"

If the reference is found the following message is replied:

Reply status is OK

For a complete description of the service, see Show Source.

For a complete description of how to specify a SDT reference, see Syntax.

Dynamic Menus

The following example shows how a dynamic menu is created and how a number of menu items are inserted in the dynamic menu. The script dyn-menu in the example directory performs the example below.

For a complete description of the services, see Add Menu, Delete Menu, Clear Menu and Add Item to Menu - Graphical Editors.

Add a new menu to the SDL Editor:

serverpc sdle menuadd \"dyn-menu\"

Reply:

Reply status is OK

Add a menu item which executes the OS command ls (on UNIX) or DIR (in Windows) after a confirmation from the user:

On UNIX: serverpc sdle menuadditem  \
\"dyn-menu\" \"ls\" 0 \
\"Perform OS command ls\"  0 0 0 \
\"OK to perform ls!\" 1 1 \"ls\"

In Windows: serverpc sdle menuadditem \"dyn-menu\" 
\"DIR\" 0 \"Perform OS command DIR\" 0 0 0 \"OK to 
perform OS command DIR!\" 1 1 \"CMD /C DIR /W\"

Reply:

Reply status is OK

Then a menu item is added displaying the SDT reference of the selected symbol on standard output (on UNIX), or in the Organizer Log window (in Windows):

On UNIX: serverpc sdle menuadditem  \
\"dyn-menu\" \"SDT-ref\" 1 \
\"export SDT ref\"  0 0 1 \
\"\" 1 1 \"echo \'%g\'\"

In Windows: serverpc sdle menuadditen \"dyn-menu\" 
\"SDT-ref\" 1 \"export SDT-ref\" 0 0 1 \"\" 1 1 
\"CMD /C echo %%g\"

Reply:

Reply status is OK

Note that only dimmed if more than one item is selected. Normally a selected symbol includes a selection of in-going and out-going flowlines. These flowlines must be de-selected in order to get the SDT reference of the symbol.

Finally display the file containing the selected symbol on standard output (on UNIX), or in the Organizer Log window (in Windows):

On UNIX: serverpc sdle menuadditem  \
\"dyn-menu\" \"filename\" 0 \
\"export filename\"  0 0 1 \
\"\" 1 1 \"ls -ls %a\"

In Windows: serverpc sdle menuadditem \"dyn-menu\" 
\"filename\" 0 \"export filename\" 0 0 1 \"\" 1 1 
\"CMD /C DIR %%a\"

Reply:

Reply status is OK

Extended Object Data Attributes (UNIX only)

The SDL Suite allows external attributes to be added to SDL Suite objects. These extensions are persistent. That is, they are stored in the normal SDL diagram files and could be used at subsequent sessions. This UNIX only example gives a brief introduction to such extended attributes.

An description of extended attributes are found in Extended Data Attribute. Extended attributes are handled as binary data by the SDL Suite. As such, their services are preferably accessed via C program interface, in which binary data is easily handled.

However, in this example extended attribute services are accessed via the Service Encapsulator, which works for simple examples.

The example assumes one selection in an SDL Editor. This reference is saved in a shell variable

set ref=`serverpc sdle obtainsource`

If we have exactly one selection, we set the extended attribute. Parameter 9 will give us the SDT reference.

serverpc sdle createattribute 0 0 $ref[9] 0 \ 
  \"myComment\" \"\"  6"\0"MyData

Note that the length of data (MyData) must be manually calculated and that the data part must be preceded by a "\0".

We get the reply:

Reply status is OK

Now we extract the extended attribute on the selection.

serverpc sdle readattribute 0 0 $ref[9]

Which replies:

Reply status is OK
0 "myComment" "" 6MyData

Note that data immediately follows its' length without any spaces. In the reply message, there is a ASCII 0 character after the length, preceding the data part.

Then we update the attribute by;

serverpc sdle updateattribute 0 0 $ref[9] 0 
\"newComment\" \"\" 7"\0"NewData

Reply:

Reply status is OK

Finally we read the extended attribute and should receive the updated value.

serverpc sdle readattribute 0 0 $ref[9]

Which replies:

Reply status is OK
0 "NewComment" "" 7NewData

The script extended-attributes performs the above described actions.


http://www.ibm.com/rational
Contents Index Previous Next