Salesforce

Simcenter Testlab Automation

« Go Back

Information

 
TitleSimcenter Testlab Automation
URL NameSimcenter-Testlab-Automation
Summary
Details

Direct YouTube link: https://youtu.be/w1F-Gh7gUJc


What is Simcenter Testlab Automation?

Using the automation capability of Simcenter Testlab, users can create entirely custom programs or applications.  Simcenter Testlab can be called from other applications (Visual Basic for Excel, programming languages), or can host applications. For example, applications can access data in a Simcenter Testlab project (*.lms), acquire data via Simcenter Testlab, and process data.

To use the automation capability, the Simcenter Testlab software must be installed and licensed.  The automation libraries occupy an additional 27 tokens if using Simcenter Testlab token licensing.

Automation is a technology that allows software packages to expose their features to development tools and other applications.  It allows the user to:
  • Create applications and programming tools that expose objects and their functionality.  The application which exposes is called the “server.”
  • Create and manipulate objects exposed in one application from another application.  An application which uses exported functionality is called a “client.”
In other words, the Simcenter Testlab applications can expose some of their functionality by means of automation.  Therefore, it has been enhanced with the necessary server capabilities.

This article serves as an introduction to Simcenter Testlab Automation:
1. Key Concepts
2. Object Models
3. Interfaces
4. Type Libraries
5. Example Simcenter Testlab Automation Program


1. Key Concepts

In order to support automation, a server application needs to describe which objects it will export, and what kind of actions can be performed on those objects. This language independent description provides information to the automation services of how client applications can interface with the server. The automation layer provides language and Windows platform independence.

Although automation is specially aimed at supporting interpreted languages, like Visual Basic and Matlab, it just as well can be used from compiled languages like Visual C++, J++, Java, C#. An additional strong point in the binding between client and server application is that they both can run as separate processes. Such a configuration will improve stability. When the client application should crash, the server application will continue running without further disadvantage. 

2. Object Models

An object model, associated with an application, is a description of the set of objects, their properties and methods, and the relations between these objects.  Applications, which support automation, supply a kind of roadmap, which you can use to navigate from one object to another. Once you reached the desired object, you can query for some characteristics or perform some actions, defined on it.

3. Interfaces

An interface is a group of semantically related functions that provide access to an automation object. Each interface defines a contract that allows objects to interact according to the given Component Object Model (COM).  Once you have such an object, you are safe to perform any operation defined in the interface.  There are three types of members that an interface can provide:
  • Methods:  A method makes the object perform a specific action. This can be opening a project or document, bringing a specific sheet to the front, saving data, ... etc.
  • Properties:  An interface property returns discrete state information that is associated with an object. It merely reflects the objects' condition. The number of sheets in a workbook, the width of a window, the number of columns in a grid, the title of a paragraph, the visibility or sensitivity of a sheet, the X and Y values of a data block are only a few examples of properties.
  • Events:  'Events' are notifications from the server application to the clients. These notifications are asynchronous. This means that a client's call-back routine can be triggered without it having to do a busy-wait for this event. So instead of performing an action which will keep pending until an event occurs on the server side, you just need to specify a routine which will be called, should the situation occur Some interfaces supply events, which will report the client when a project is opened, when a cell is changed, when a measurement is launched, ... etc.
4. Type Libraries

Information regarding different interfaces, their methods, properties and events, associated parameters, parameter types and short descriptions are stored in a separate file, called a type library. The type library file is a binary file, usually has a .TLB filename extension and can be used by other applications to get information about the automation server. Next to any written documentation, this is probably the most important source of information regarding the object model, which is exposed by a server application. There are some viewing tools that allow inspecting a type library's contents.
  • Object browser:  When using the Visual Basic Development environment, selecting 'View>Object Browser (F2)' will launch the Object browser to view the Type Lib contents. Figure 1 shows an instance of such a browser. Before you can view a specific type library, it needs to be added to the 'Project>Reference' list in the VB IDE. 
User-added image
Figure 1: Viewing the Object Browser in Visual Studio
  • OLE viewer:  This is an 'Object Linking and Embedding' viewing tool. Its 'File>View TypeLib...' entry will allow you to select a .tlb file and opens it in an 'ITypeLib viewer' window. This OLE viewer comes with the Visual C++ development environment. This viewer shows the interface type information in a way, which is closer to the raw description, provided by the server application.
  • Freeware tools:  There are some stand-alone type-library-viewing tools available on the Internet.
5.  Example Simcenter Testlab Automation Program

Below is an example Simcenter Testlab Automation program that displays a data block in a window within the Navigator worksheet.

First, find the LMSTestLabAutomation reference to add the project:
•    In Visual Studio, go to Project > Add Reference… and select the “COM” tab.
•    In the Microsoft Excel code editor, go to Tools > References.

Select the “LMS Test.Lab® Automation 19A Type Library” reference.  This allows the code to identify and interact with all of the objects preceded by “LMSTestLabAutomation” in the following code.

'Connect with the running application using an Application object
Dim TL As New LMSTestLabAutomation.Application

'Get the active project using the Database property of the IBook object, which itself is 'the ActiveBook property of the Application object.
Dim my_db As LMSTestLabAutomation.IDatabase
my_db = TL.ActiveBook.Database

'Get a data block using the GetItem method of the IDatabase object.  In this example we 'use a fixed path to the block.  If this path is invalid, an error message is given.
Dim my_block As LMSTestLabAutomation.IBlock2
my_block = my_db.GetItem("Section1/Run 1/Fixed sampling/Runup/Sections/Orders/Order 2.00 Point1")

'Get the picture manager from a DataWatch object
Dim datawatch_PictManag As LMSTestLabAutomation.DataWatch
Dim my_PictManager As LMSTestLabAutomation.IPictureManager
datawatch_PictManag = TL.ActiveBook.FindDataWatch("Navigator_DataViewing_PictureManager")
my_PictManager = datawatch_PictManag.Data

'Add a picture to the picture manager
Dim my_picture As LMSTestLabAutomation.IPicture
my_picture = my_PictManager.AddPicture("1x2")

'Get the first display of this picture (the index is zero-based)
Dim my_display As LMSTestLabAutomation.IDisplay
my_display = my_picture.Display(0)

'Add the block to the display
my_display.AddData(0, my_block)

Note:  when using the GetItem method of an IDatabase object, the item has to exist at the exact path passed to the method parameter; the above tutorial is looking for a block located as shown in Figure 2 in the folder pane of the Navigator tab in Simcenter Testlab: 
 
User-added image
Figure 2: Expected database structure for Automation example

Hope this article helped introduce Simcenter Testlab Automation concepts and capabilities!

Questions?  Check out the resources below (including article attachments) or contact Siemens Support Center.

Simcenter Testlab Automation resources:
 

Powered by