If an OTX procedure will be executed, the OTX-Runtime API creates a new runtime context. Each runtime context normally has its own process called OTX-Runner. Especially in safety-critical systems it might not be possible to create new processes. In this case the runtime context will be run inside a thread of the application and not inside a new runner process. This is called RAW transport layer.
Code snippet of the OTX-Runtime API Sample Program.
1 #include <RuntimeManagerFactory.h>
5 #include <IRuntimeContext.h>
8 #include <Project/IProject.h>
9 using OpenTestSystem::Otx::Runtime::Api::Otx::IProject;
11 #include <Otx/IProcedure.h>
14 #include <OtxDiagFactory.h>
16 using OpenTestSystem::Otx::DiagManager::Common::ICommandProcessor;
20 #include <OpenTestSystem.Otx.Runtime2.Api/License/LicenseManager.h>
21 #include <OpenTestSystem.OtxDiagManager.OtxDiagApi/License/LicenseManager.h>
23 typedef ICommandProcessor* (__cdecl* typeCreateCommandProcessor)(IDiagRuntimeSystem* diagRuntimeSystem);
24 typedef IDiagRuntimeSystem* (__cdecl* typeCreateDiagRuntimeSystem)(
const char * projectName,
const char * vehicleInfo);
29 int main(
int argc,
char **argv)
34 const char * odxProject =
"";
35 const char * odxVehicle =
"";
36 const char * commandProcessorFilePath =
"OpenTestSystem.Otx.DiagManager.CommandProcessor.dll";
37 const char * drsFilePath =
"OpenTestSystem.Otx.DiagManager.DiagRuntimeSystem.dll";
40 OpenTestSystem::Otx::DiagManager::OtxDiagApi::License::LicenseManager::SetLicenseKey(
"XXXXX-XXXXX-XXXXX-XXXXX-XXXXX");
45 HMODULE DRS_Module = ::LoadLibrary(drsFilePath);
46 if (DRS_Module == NULL)
48 std::cout << drsFilePath <<
" not found!" << std::endl;
53 typeCreateDiagRuntimeSystem createDRSFunction =
reinterpret_cast<typeCreateDiagRuntimeSystem
>(::GetProcAddress(DRS_Module,
"CreateDiagRuntimeSystem"));
54 if (createDRSFunction == NULL)
56 std::cout <<
"function CreateDiagRuntimeSystem not found!" << std::endl;
61 HMODULE CP_Module = ::LoadLibrary(commandProcessorFilePath);
62 if (CP_Module == NULL)
64 std::cout << commandProcessorFilePath <<
" not found!" << std::endl;
69 typeCreateCommandProcessor createCPFunction =
reinterpret_cast<typeCreateCommandProcessor
>(::GetProcAddress(CP_Module,
"CreateCommandProcessor"));
70 if (createCPFunction == NULL)
72 std::cout <<
"function CreateCommandProcessor not found!" << std::endl;
77 IDiagRuntimeSystem * diagRuntimeSystem = createDRSFunction(odxProject, odxVehicle);
80 ICommandProcessor * commandProcessor = createCPFunction(diagRuntimeSystem);
82 OtxDiagFactory otxDiagFactory;
83 std::shared_ptr<IOtxDiag> rawOtxDiag = otxDiagFactory.CreateRawOtxDiag(commandProcessor);
96 std::shared_ptr<IRuntimeManager> runtimeManager = RuntimeManagerFactory::CreateRawRuntimeManager(rawOtxDiag);
99 std::shared_ptr<IProject> project = runtimeManager->LoadPtx(
"DiagComSample.ptx");
100 std::shared_ptr<IProcedure> procedure = project->GetMainProcedure();
103 std::shared_ptr<IRuntimeContext> runtimeContext = runtimeManager->Execute(procedure);
Interface which a DiagRuntimeSystem must be implemented
Definition: IDiagRuntimeSystem.h:21
DiagManager, which contains methods to get access to the supported OTX extension classes
Definition: IOtxDiag.h:32
Factory class for creating the DiagOtxApi
Definition: OtxDiagFactory.h:37
Contains information of a Runner instance.
Definition: IRuntimeContext.h:30
Main class to load and execute an OTX project
Definition: IRuntimeManager.h:72
static void SetLicenseKey(const std::string &licenseKey)
Sets a valid license key to release the API.
Represents an OTX Procedure.
Definition: IProcedure.h:15
Factory class for creating runtime managers, see IRuntimeManager
Definition: RuntimeManagerFactory.h:17