Object based program API¶
The object based program API is designed to read, to modify, to create trace.check relevant files. With it you can create your own scripts in a Python development environment of your choice. The design follows an object oriented approach. To execute your script, a started trace.check is needed.
To use it from an external Python environment, extend your PYTHONPATH to include
<path to program>\Templates\ApiClient to import ApiClient with
from ApiClient import ApiClient. The ApiClient is Python 2 and Python 3 compatible.
To use the object based API from within trace.check use api.ObjectApi
Note that the API is for managing artifacts, not for starting simulations. Therefore, refer to the REST or COM API.
Examples for coding with the Object API can be found here: Code Examples Object API
JavaClient¶
It is also possible to use the API in Java the same way as in Python. Please use the
ApiClient-X.Y-SNAPSHOT.jar from the same directory for that. (where X and Y are the
major and minor version of your trace.check installation) Please note, default arguments are
not supported. Instead of the Python value None, the Java value null must be
used / will be returned.
The following snippet is the same example translated in Java.
On a command line one can use javac -cp ApiClient-X.Y-SNAPSHOT.jar ApiClientExample.java
to compile and java -cp .;ApiClient-X.Y-SNAPSHOT.jar ApiClientExample to run the example.
import de.tracetronic.tts.apiClient.stubs.Package;
import de.tracetronic.tts.apiClient.stubs.ApiClient;
import de.tracetronic.tts.apiClient.stubs.TraceAnalysis;
import de.tracetronic.tts.apiClient.stubs.TraceStep;
import de.tracetronic.tts.apiClient.stubs.TraceStepContainer;
import de.tracetronic.tts.apiClient.stubs.Plot;
import de.tracetronic.tts.apiClient.stubs.PlotSignal;
public final class ApiClientExample {
public void modifyPackage() {
ApiClient.setXmlRpcPortNumber(8001);
ApiClient api = new ApiClient();
String packageFile = "C:\\Daten\\ExampleWorkspace\\Packages\\EngineStarts.pkg";
Package examplePackage = api.PackageApi.OpenPackage(packageFile);
TraceAnalysis traceAnalysis = examplePackage.GetTraceAnalyses()[0];
for (TraceStep epi : traceAnalysis.GetTraceSteps(false)) {
if (epi.IsContainer()) {
TraceStepContainer episode = (TraceStepContainer) epi;
for (TraceStep trcStp : episode.GetTraceSteps(false)) {
if (trcStp.IsContainer()) {
TraceStepContainer traceStep = (TraceStepContainer) trcStp;
for (TraceStep plt : traceStep.GetTraceSteps(false)) {
if (plt instanceof Plot) {
Plot plot = (Plot) plt;
for (PlotSignal plotSignal : plot.GetPlotSignals()) {
plotSignal.SetMarkerStyle("x");
}
}
}
}
}
}
}
examplePackage.Save(packageFile);
}
public static void main(String[] args) {
ApiClientExample client = new ApiClientExample();
client.modifyPackage();
}
}
DotNet-Client¶
It is also possible to use the API in C# and Visual Basic .Net the same way as in Python. Please
add a reference to the ApiClient.dll for that. It can be found in the same directory as
the Python and Java client. Instead of the Python value None, the C# value null or the
Visual Basic value Nothing must be used / will be returned.
The following snippet is the example translated to C#.
using TTObjectApiClient.stubs;
namespace ApiTest
{
class ApiClientExample
{
public static void ModifyPackage()
{
ApiClient.SetXmlRpcPortNumber(8001);
ApiClient api = new ApiClient();
string packageFile = "C:\Daten\ExampleWorkspace\Packages\EngineStarts.pkg";
Package examplePackage = api.PackageApi.OpenPackage(packageFile);
TraceAnalysis traceAnalysis = examplePackage.GetTraceAnalyses()[0];
foreach (TraceStep epi in traceAnalysis.GetTraceSteps(false))
{
if (epi.IsContainer() == true)
{
TraceStepContainer episode = (TraceStepContainer)epi;
foreach (TraceStep trcStp in episode.GetTraceSteps(false))
{
if (trcStp.IsContainer() == true)
{
TraceStepContainer traceStep = (TraceStepContainer)trcStp;
foreach (TraceStep plt in traceStep.GetTraceSteps(false))
{
if (plt is Plot plot)
{
foreach (PlotSignal plotSignal in plot.GetPlotSignals())
{
plotSignal.SetMarkerStyle("x");
}
}
}
}
}
}
}
examplePackage.Save(packageFile);
}
static void Main(string[] args)
{
ModifyPackage();
}
}
}
The following snippet is the example translated to Visual Basic .Net.
Imports TTObjectApiClient.stubs
Module Module1
Sub ModifyPackage()
ApiClient.SetXmlRpcPortNumber(8001)
Dim api As ApiClient = New ApiClient()
Dim packageFile As String = "C:\Daten\ExampleWorkspace\Packages\EngineStarts.pkg"
Dim examplePackage As Package = api.PackageApi.OpenPackage(packageFile)
Dim traceAnalysis As TraceAnalysis = examplePackage.GetTraceAnalyses()(0)
For Each epi As TraceStep In traceAnalysis.GetTraceSteps(False)
If epi.IsContainer().GetValueOrDefault(False) Then
Dim episode As TraceStepContainer = CType(epi, TraceStepContainer)
For Each trcStp As TraceStep In episode.GetTraceSteps(False)
If trcStp.IsContainer().GetValueOrDefault(False) Then
Dim TraceStep As TraceStepContainer = CType(trcStp, TraceStepContainer)
For Each plt As TraceStep In TraceStep.GetTraceSteps(False)
If TypeOf plt Is Plot Then
Dim plot As Plot = CType(plt, Plot)
For Each plotSignal As PlotSignal In plot.GetPlotSignals()
plotSignal.SetMarkerStyle("x");
Next
End If
Next
End If
Next
End If
Next
examplePackage.Save(packageFile)
End Sub
Sub Main()
ModifyPackage()
End Sub
End Module
API entry points¶
Part of the Object based program API.
- class ApiClient¶
Entry point for object based api.
- AnalysisJobApi¶
Returns the AnalysisJobApi namespace
- Returns:
AnalysisJobApi namespace
- Return type:
- ArtifactApi¶
Returns the ArtifactApi namespace.
- Returns:
ArtifactApi namespace
- Return type:
- AttributeSpecApi¶
Returns the AttributeSpecApi namespace.
- Returns:
AttributeSpecApi namespace
- Return type:
- ConfigurationApi¶
Returns the ConfigurationApi namespace.
- Returns:
ConfigurationApi namespace
- Return type:
- GlobalMappingApi¶
Returns the GlobalMappingApi namespace.
- Returns:
GlobalMappingApi namespace
- Return type:
- MultimediaApi¶
Returns the MultimediaApi namespace.
- Returns:
MultimediaApi namespace
- Return type:
- PackageApi¶
Returns the PackageApi namespace.
- Returns:
PackageApi namespace
- Return type:
- ParameterApi¶
Returns the ParameterApi namespace.
- Returns:
ParameterApi namespace
- Return type:
- ProjectApi¶
Returns the ProjectApi namespace.
- Returns:
ProjectApi namespace
- Return type:
- RelationApi¶
Returns the RelationApi namespace.
- Returns:
RelationApi namespace
- Return type:
- SignalDescriptionApi¶
Returns the SignalDescriptionApi namespace.
- Returns:
SignalDescriptionApi namespace
- Return type:
- TraceFileApi¶
Returns the TraceFileApi namespace.
- Returns:
TraceFileApi namespace
- Return type:
- TraceStepTemplateApi¶
Returns the TraceStepTemplateApi namespace.
- Returns:
TraceStepTemplateApi namespace
- Return type:
- WorkspaceApi¶
Returns the WorkspaceApi namespace.
- Returns:
WorkspaceApi namespace
- Return type:
- GetApplicationVersion()¶
Returns the version of ecu.test in format ‘year.release.servicepack’.
- Returns:
ecu.test version
- Return type:
str
- GetClientVersion()¶
Returns the version of the object based api client.
- Returns:
client version
- Return type:
str