Getting Started: Ocean Software Development Framework For Techlog
Getting Started: Ocean Software Development Framework For Techlog
Contents 1
Schlumberger Private - Customer Use
Create an installer for your plug-in ................................................................................... 46
Deploy folders and files with the plug-in dll ................................................................ 48
User folder versus company folder deployment ........................................................... 51
Upgrade existing Ocean plug-in to 2016.1 .............................................................................. 52
2 Getting Started
Schlumberger Private - Customer Use
Welcome to Ocean for Techlog
Ocean for Techlog is an application development framework, part of the Ocean suite of
Schlumberger software platform SDKs, focused on wellbore data processing and
visualization. It allows the application developers to extend the functionality and
workflows of the Techlog platform.
The Ocean framework provides a productive development environment that allows the
developers to focus on science.
Ocean plug-ins are loaded on-demand by the Techlog end-user as libraries (dll) using
the Techlog module manager.
A plug-in integrates in Techlog the menus and workflows like native modules. They
may appear as:
activities started for instance through a menu item, which decide by themselves
when they are finished. They are displayed as tasks in Techlog, such that you
can monitor and possibly stop them manually.
activities as worksteps which run within a Techlog workflow.
All the code snippets in this document have been built with Ocean for Techlog
2016.1.
Getting Started 3
Schlumberger Private - Customer Use
Ocean for Techlog Architecture
Ocean for Techlog provides lifecycle management, a runtime environment, and a public
API for plugins to interoperate with Techlog functionalities. Figure 1 shows how Ocean
for Techlog provides the glue between Techlog and the plugins.
Module
Ocean Ocean
Services RPC connection Plug-ins
API
Module
The Ocean for Techlog architecture is based on native C++ and the Qt framework, with
plug-ins running outside of the main Techlog process. Each plug-in running in its own
process provides stability and compatibility as it:
allows plug-ins to run in debug mode with the release version of Techlog
avoids conflicts between third-party libraries used by the different plug-ins
allows debugging, fixing, recompile and rerun of a plug-in without having to
restart Techlog
allows binary compatibility over multiple versions of Techlog and Qt
allows isolation of Techlog in case of a crash of one plug-in
The Ocean for Techlog public API (Slb.Ocean.Techlog.dll) is the host for Ocean
applications and is the environment in which the Ocean module needs to run. The
public API provides:
the domain objects and their data source
the graphical environment in which the applications will display their data
a common look and feel for all application user interface components
4 Getting Started
Schlumberger Private - Customer Use
Ocean for Techlog UI Infrastructure
The Ocean for Techlog API does not limit itself to accessing the Data domain of
Techlog. It also provides a rich environment for integrating the Ocean module with the
graphic environment familiar to Techlog users.
The User Interface API provides functionality to customize many elements of the
Techlog window system.
Ocean provides the capability to extend Techlog’s user interface functionality for the
GUI to be tailored to the needs of new applications. The example provided in Figure 2
shows some examples of what is customizable with the Ocean API:
Menu bar extensions:
o Adding new tabs, groups and menus to the tbar (Techlog ribbon) or
extending native Techlog menus
Windows:
o Adding custom windows (Qt widgets) in Techlog workspace
Plots:
o Adding custom plots
o Customize native and custom plots adding graphic items
o Add user interactions through graphic items
o Extend menu bar, tool bar and context menu of native and custom plots
with custom tools
Workflow manager
o Add custom user interface to an Ocean workstep
o Extend worktep properties (Techlog properties editor) with custom
properties tab
Getting Started 5
Schlumberger Private - Customer Use
Ocean for Techlog plug-in identity and activities
The PluginIdentity is an interface that the developer has to implement to declare
some information about the plug-in, its list of activities, and the menu items used to
trigger those activities.
This is the main entry point class of the plug-in and this class, compiled into the library,
provides identity and support information on the plug-in.
Once the plug-in library is deployed into the Extensions folder of Techlog (could be in
the Techlog, Company or User folder), the end-user can enable or disable it in the
Techlog module manager accessible through the Project > Licensing > Module
Manager menu.
The module manager in Techlog manages the integration of the plugin activities into
Techlog: it loads and queries the plugin, creates actions that can launch the plugin
activities, and links them to menu items in Techlog.
In Techlog, a module is a set of functionalities associated to a license feature. A plugin
can contribute its Activities into some Techlog Modules. For instance, a Plugin can
contribute an environmental correction workstep (associated to the environmental
correction license), and can also add some geology-related processing to the WBI
(wellbore imaging) module, that is to say available only if the user has also a WBI
license. This means that the integration into the Techlog menus is dynamic, based on
the Techlog modules enabled by the user, and therefore subject to license checks.
6 Getting Started
Schlumberger Private - Customer Use
Figure 4 Plugins contribute activities to modules (native or custom). Modules can
be licensed.
All the activities of a given plugin run in a single process, and multiple instances of a
given activity can run in that same process. This way, activities within a given plugin
can communicate between each other (for instance, multiple worksteps forming a
workflow).
Qt LGPL notice
Ocean framework is distributed with Qt LGPL 5.4.2 libraries. Per requirement of LGPL
components used, you must provide with your plug-in a notice that LGPL code is being
used. This can be done by deploying with your plug-in dll (plug-in folder) README.txt
and LGPL.txt files shipped with the Ocean framework.
Getting Started 7
Schlumberger Private - Customer Use
Figure 5 LGPL notice files
See the “Deploy folders and files with the plug-in dll” section for more information on
how to deploy additional files in the plug-in folder.
Open and modify the README.txt files before deploying it with your plug-in changing
the “Ocean for Techlog Software” with the name of the plug-in at the beginning of the
file.
8 Getting Started
Schlumberger Private - Customer Use
Install and setup the Ocean for Techlog development environment
Getting Started 9
Schlumberger Private - Customer Use
Figure 7 Techlog and VS 2012, 2013 or 2015 installed
If you have already a Techlog user folder defined on your system (TLUSERDIR
environment variable), sample plug-ins are deployed to this folder. Otherwise the
installer deploys sample plug-ins to user profile’s AppData in order to avoid any UAC
(User Account Control) issues.
Note: If you have already a QTDIR environment variable defined on your system
and pointing on Qt version installed on your machine, the value of this
environment variable is replaced by the path to Qt folder deployed with
Ocean for Techlog package.
See the “Ocean for Techlog environment variables” section for more information on
how to setup Ocean environment variables.
The installer shows Visual Studio components installed with Ocean.
3. Select all components and click Install in the dialog window. (See Figure 8.)
10 Getting Started
Schlumberger Private - Customer Use
Figure 8 Visual Studio components
4. Reboot is required to get all Ocean for Techlog Visual Studio extensions
properly installed. (See Figure 9.)
Getting Started 11
Schlumberger Private - Customer Use
Ocean for Techlog package content
Ocean for Techlog Framework is deployed by the installer. The Ocean for Techlog
package will have the following folders tree installed on your disk when installed:
Plug-ins are built on Qt. The Ocean for Techlog Framework installer comes with the
LGPL 5.4.2 version of Qt and QtCore and QtGui libraries (the 2 most basic Qt libraries).
The Ocean for Techlog API exposes the following objects:
Base classes: QObject (plug-in classes are QObject and in particular they
expose their event handlers as Qt’s slots methods), QWidget (a simple way of
providing a custom GUI is by implementing a QWidget)
Basic types: QString, QVariant, QImage, QColor, etc.
Containers: QList, QMap, QHash, etc.
Enums: Qt::PenStyle, etc.
Google tests 1.6.0 mvsc2013 x64 librairies are provided with Ocean framework in order
to create Ocean test plug-in. See the “Create unit tests for your plug-in” section for
more information on how to create Google tests for an Ocean plug-in.
All libraries needed to develop plug-ins with the Ocean for Techlog framework are
shipped with the installer and are installed under the 3rdparty folder.
The examples folder includes the following plug-ins:
HelloWorld: a simple plug-in useful to test your Ocean for Techlog
development environment.
DotNetExample: showing how to integrate a .NET library in Techlog using Qt
and Ocean framework.
12 Getting Started
Schlumberger Private - Customer Use
MyPlugin: some code examples of each API exposed in Ocean for Techlog
o Read and write data access
o Creating workstep, add it and run it in a Techlog workflow
o Plot examples as Logview, cross-plots, custom plots
o Custom UI examples
GenericFileStorage: some plug-in domain objects (custom domain objects)
code samples
The Extensions folder contains the compiled plug-in examples listed previously and
can be used as deployment folder during the development phase of your plug-ins. For
that you need to create or modify the TLUSERDIR environment variable to point the
User folder to the parent of the Extensions folder of the package. This is described in
the next section.
The same known Extensions location can be added within Techlog’s multi-level folder
organization: Techlog, Company and User. This allows the plugin to be deployed
along with the Techlog installation, or on the Company’s shared drive to reach many
users, or just by an individual.
content of the Company folder is usually handled by a dedicated team within the
company
Techlog extensions folder hosts plug-ins deployed with the Techlog baseline as
native Techlog modules
QTDIR used to build plug-in with Qt libraries. If you use the Qt libraries shipped
with the package in the third-party folder, the path can be set as follows
%TechlogSDKHome%\3rdParty\Qt
To see in the Techlog module manager the demo plug-ins installed with the Ocean
package, an additional parameter is needed which is the user folder where are
deployed the plug-ins.
If there is no user folder sets on your machine, the installer sets the
%AppData%\Schlumberger\Ocean for Techlog 2016.1\techlog folder as
user folder and deploy sample plug-ins in this folder. Sample plug-ins code is also
deployed in the %AppData%\Schlumberger\Ocean for Techlog
2016.1\examples
You can change it anytime through Techlog Options window (Project > Options).
Getting Started 13
Schlumberger Private - Customer Use
Figure 11 Techlog user folder
Close and re-open any explorer window to propagate the new environment var-
iable settings.
14 Getting Started
Schlumberger Private - Customer Use
Figure 12 Release plug-ins deployed with Ocean Framework
The module manager scans the Extensions folder of the Ocean for Techlog package
and the three example plug-ins built in release mode and shipped with the Ocean
framework displayed as in Figure 11.
2. Go to %TechlogSDKHome%\examples\HelloWorld folder and run
qmakepluginhelloworld.bat to create the visual studio project file.
3. Open HelloWorld.vcxproj with Visual and build the project in debug x64 mode.
Getting Started 15
Schlumberger Private - Customer Use
Figure 13 HelloWorld build in debug x64
The project must build successfully and a new debug x64 library of the HelloWorld
project is generated in Extensions user folder.
Note: In the following screenshot you can see that the expected plug-in structure
folder is VendorName/PluginName/TechlogVersion/PluginVersion/.
If this structure folder is not respected the plug-in is not loaded in Techlog.
4. In Techlog open the module manager, right-click on Ocean plug-ins node and click
on Refresh plug-ins item in the context menu. The new HelloWorld debug
x64 plug-in appears in ocean plug-ins group as in Figure 15.
16 Getting Started
Schlumberger Private - Customer Use
Figure 15 HelloWorld64D plug-in
If you get the error messages below for some plug-ins built in debug mode when
you refresh the list of plug-ins in the module manager it means that Techlog plug-in
debug host process executable and its dependencies have not been deployed properly
in bin64/pluginhost folder of Techlog installation folder. Please re-install Ocean
package.
Error: Plugin 'myplugin64D.dll': can't find corresponding plugin host file.
Error: Can't launch plugin host for plugin 'myplugin64D.dll': host process not
running.
5. Enable the plug-in and click on the Hello World action menu in the new HelloWorld
plug-in added in Techlog. Hello Plugin World message displays in the Techlog
output console.
Getting Started 17
Schlumberger Private - Customer Use
Figure 16 HelloWorld64D activity running
Please review the user folder path in Techlog (or TLUSERDIR), TechlogSDKHome,
and QTDIR environment variables if one of these steps does not work properly.
One of the reasons listed below can be the root of your issue:
If QTDIR is not set correctly, qmake will not create the solution.
If the plug-in dll isn’t generated in TLUSERDIR, the built plugin will not be
loaded.
If the plug-in folder structure Vendor-
Name/PluginName/TechlogVersion/PluginVersion/ isn’t respected the
plug-in will not be loaded.
If a Debug version plug-gin is not loaded, the Debug version of the pluginhost is
not present in bin64/pluginhost folder of Techlog installation folder.
18 Getting Started
Schlumberger Private - Customer Use
Writing your first plug-in
The Ocean for Techlog framework provides a development and runtime environment
for wellbore centric data manipulation, interpretation, and visualization applications.
You have the ability to create workflows that interoperate with or extend the com-
mercial Techlog Interactive Suite and the capability to extend the scope of Techlog to
address new petrotechnical domains. This chapter describes the procedure of creating
a simple plug-in.
Note: Since Ocean 2016.1, you can have two different versions installed on
the user machine, a 2015.1 and a 2016.1.
Getting Started 19
Schlumberger Private - Customer Use
Ocean Plug-in template
Project name
20 Getting Started
Schlumberger Private - Customer Use
Figure 18 Plug-in wizard
The wizard creates the project with the main plug-in class.
10. Add a new plug-in activity by right-clicking on the project in the Solution Ex-
plorer and selecting Add > New Item in the contextual menu.
11. In the Item types area, under Visual C++ item type, select Ocean >
Techlog 2016.1.
12. Select the Ocean Activity template.
13. Provide the name “ReadDataActivity” for the activity.
14. Click Add in the dialog (See Figure 19.)
Activity name
Note: From this window you have the ability to create an Ocean Workstep
Activity. This will add to the project an activity class that instantiates a
Workstep in the Techlog Application Workflow Interface with its signals and
slots. See the “Workfow and worksteps” section in Ocean Basics developer
guide for more information on how to implement an Ocean workstep.
15. Change the “Tab title”, “Group title”, “Action menu text” and “Action menu
tooltip” fields as appropriate (See Figure 20.).
Note that those fields are used to create the plug-in menu in Techlog toolbar
that triggers the Ocean activity.
16. Click Finish.
Getting Started 21
Schlumberger Private - Customer Use
Figure 20 New activity wizard
If Intellisense is disabled in Visual Studio 2013, Ocean template items are not
accessible and an error message is raised. In Tools > Options menu of Visual Studio
2013, Disable database has to be turned off.
The Ocean for Techlog Wizard creates a solution named “MyFirstPlugin” with a project
named “MyFirstPlugin” in the Visual Studio Solution Explorer. The project will contain
header and source file for the Plugin class that was created, and the Activity class (See
Figure 22).
22 Getting Started
Schlumberger Private - Customer Use
Plugin header
Activity header
Plugin source
Activity source
Plugin
#pragma once
#include "tsdkpluginidentity.h"
These three methods must be implemented in the source file that first includes the
plugin and activity header files and Slb::Ocean::Techlog namespace at the be-
ginning of MyFirstPlugin.cpp file.
#include "tsdkplugininformation.h"
#include "tsdkpluginactivities.h"
#include "tsdkpluginmenu.h"
#include "tsdkpluginmenutab.h"
#include "tsdkpluginmenuaction.h"
#include "tsdkpluginmenugroup.h"
#include "MyFirstPlugin.h"
24 Getting Started
Schlumberger Private - Customer Use
pluginInformation.setCreator(PLUGIN_VENDOR_NAME);
pluginInformation.setSupportEmail("jsmith@slb.com");
pluginInformation.setCrashDumpEmail("jsmith@slb.com");
}
static QString
ReadDataActivityId(QLatin1String("f1007f1e-1ce3-477e-a47f-d91f4e7e1b7b
"));
Getting Started 25
Schlumberger Private - Customer Use
The wizard implements the getMenu method in MyFirstPlugin.cpp, this method is
used to add custom menus to Techlog.
The sequence to customize the TBar (Ribbon) can be summarized as follows using the
PluginMenu API exposed with Ocean:
To link ReadDataActivity with the PluginMenuAction that triggers this activity the
wizard instantiates the PluginMenuAction object passing to the constructor of the
class the unique identifier (GUID) of the activity declared at the beginning of
MyFirstPlugin.cpp.
group.addAction(actionReadData);
tab.addGroup(group);
menu.addTab(tab);
}
26 Getting Started
Schlumberger Private - Customer Use
Activity
This new action menu triggers the ReadDataActivity. This class inherits from the
AbstractActivity interface class which is the base class for any Ocean for Techlog
plug-in activity.
The dispose method can be overridden in case if you need to cleanup resources
before the activity is unloaded.
private:
void run();
};
Once the skeleton of the plug-in has been created, you need to implement the plug-in
logic that will be triggered when the user clicks on the action menu declared in the
getMenu method of the plug-in identity class (main plug-in class).
You add the custom algorithm code overriding the run method of the Abstrac-
tActivity interface.
#include "ReadDataActivity.h"
void ReadDataActivity::run()
{
// TODO: Implement the action menu logic here.
}
Code the run method. The work for the activity is completed as follows:
Get for each dataset from the corresponding properties exposed in the Dataset class:
Its name
Its size exposed with rowCount public method and returns the number of
rows of the dataset (and therefore of all its variables)
Print the well name, dataset name and size from the main Techlog project using
Session::current().currentWorkspace() API. The Workspace class ex-
poses the logEvent method to print message into Techlog output console with some
different output levels listed in LogLevel enumeration class:
Debug
Information
Warning
Error
For each dataset parse through all its variables using the variables public function
exposes in the Dataset class.
Get for each variable from the corresponding properties exposed in the Variable
class:
Its name
Its unit
Its family
And print its property values in the Techlog output console using the logEvent
method of the current Workspace with a LogLevel set to Information.
Call stop method inherited from AbtractActivity interface class at the end of your
activity run method to stop the plug-in activity. Otherwise, the plug-in will stay in the
background until the user manually stops the plug-in task in the workspace manager of
Techlog (Figure 25) or stops Techlog.
28 Getting Started
Schlumberger Private - Customer Use
Figure 25 Techlog workspace manager
#include "ReadDataActivity.h"
#include "tsdklock.h"
#include "tsdkloglevel.h"
#include "tsdkvariableenums.h"
void ReadDataActivity::run()
{
// TODO: Implement the action menu logic here.
// Lock all
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Getting Started 29
Schlumberger Private - Customer Use
// iterate on all the variables of the current dataset in the loop
foreach(Variable var, dataset.variables())
{
// Get the name, unit and family of the current variable in the loop
QString varName = var.name();
QString varUnit = var.unit();
QString varFamily = var.family();
// Display variable infos in Techlog output console
workspace.logEvent(LogLevelInformation,
QString("Variable name = %1,Variable unit = %2,Variable family = %3")
.arg(varName).arg(varUnit).arg(varFamily));
}
}
}
// release objects locked
lock.release();
Open the Techlog module manager and enable MyFirstPlugin. My first plug-in tab
is added to the Techlog native tabs. This tab contains only one group My first group
and this group only one action menu Read Data (Figure 26).
30 Getting Started
Schlumberger Private - Customer Use
Figure 26 Enable MyFirstPlugin in the module manager
Import Techlog fundamentals dataset deployed with the Ocean framework (%Tech-
logSDKHome%\demo-project) and click on the Read Data action menu. The Read
Data activity shows all the wells, datasets and variables in the Techlog message log
(Figure 27).
Note: Opening a Techlog project with an Ocean framework license will taint the
project.
You have now written, built, and run your first Ocean for Techlog plug-in.
Getting Started 31
Schlumberger Private - Customer Use
Debug the plug-in
To debug the plug-in you have to build it in debug mode. Go to the Visual Studio
solution and change the build mode from release x64 to debug x64. Still in Visual
Studio open the ReadDataActivity.cpp file and into the run method of the activity
add a breakpoint on the first line.
Re-build the solution, close and reopen Techlog.
Press the Ctrl+Alt key of your keyboard and click on the Read Data action menu. The
Visual Studio Just-In-Time debugger pops up and asks you to select from the list
a Visual Studio solution debugger to attach to the plug-in host which is for a plug-in
built in 64 bit the techlogpluginhost64D.exe. Select MyFirstPlugin in the list and
click Yes as shown in Figure 29.
32 Getting Started
Schlumberger Private - Customer Use
Figure 29 Debug the plug-in
The debugger stops on the first line of the run activity method where the breakpoint
has been added.
Getting Started 33
Schlumberger Private - Customer Use
Techlog Viewer plug-in development (Schlumberger Internal only)
The Techlog Viewer is a software to facilitate display and interaction with data.
Note: Techlog Viewer is mono-well by design, developing a plug-in that will use
several wells will result in having an assert displayed in the Techlog Viewer
output window.
Signed plug-ins
Having a signature on the plug-in is not necessary for internal development only.
However a .sign file will be mandatory if any external deployment is planned.
To generate the signature file, please contact the Techlog Platform Product Champion
- ERivoliier@slb.com -
34 Getting Started
Schlumberger Private - Customer Use
Creating a Test plug-in with Visual Studio
Add a new test plug-in project to the solution that contains an Ocean plug-in project by
clicking right on the solution in the Solution Explorer. Then select in the contextual
menu Add > New Project. In the Project types area, under Visual C++ project
type, select Ocean > Techlog 2016.1. Then select the Ocean Test Plug-in tem-
plate.
Note: A test project cannot be created into an empty Visual Studio solution. Test
project wizard is looking at a main plug-in project in the solution.
Provide the name “TestMyFirstPlugin” for the project. Click OK to start the Wizard (see
Figure 31).
Project name
Getting Started 35
Schlumberger Private - Customer Use
Figure 32 Test Plug-in wizard
Note: The path to the “3rdparty” folder of the Ocean package that contains
Google test libraries (debug and release folders) and header files (include
folder) is added to the project by the wizard.
The Ocean Test Plug-in Wizard adds a project named “TestMyFirstPlugin” in the Visual
Studio Solution Explorer. The project contains header and source file for the Test Plugin
class that was created, and Test Activity and runner classes (see Figure 33.)
36 Getting Started
Schlumberger Private - Customer Use
Test Plugin header
The Test Activity runs all the Google tests implemented in the Test plug-in through the
Test runner utility class.
Google test API provides a number of options out there you could/should consider
depending on your requirements. You can refer to the official Google test online
documentation http://code.google.com/p/googletest/.
In TestMyFirstPluginTests.cpp file, there are two types of Google tests created by
the wizard.
The first one uses the TEST macro to define the test.
TEST has two parameters: the test case name and the test name. After using the
macro, you should define your test logic between a pair of braces. You can use a bunch
of macros to indicate the success or failure of a test.
In the following example, the test creates a well in Techlog project, sets its color
property to blue and checks if the color is correctly set.
TEST(GTestName1, OkTest)
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Project project = Session::current().mainProject();
Getting Started 37
Schlumberger Private - Customer Use
Well well = Well::create("MyWell", project);
Droid wellDroid = well.droid();
well.setColor(Qt::blue);
lock.release();
if (well.isNull())
{
ASSERT_FALSE(well.isNull());
lock.release();
return;
}
EXPECT_EQ(well.color(), Qt::blue);
lock.release();
lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
well.erase();
lock.release();
}
The second one uses the TEST_F macro that defines a Google test fixture.
A test fixture is a place to hold objects and functions shared by all tests in a test case.
Using a test fixture avoids duplicating the test code necessary to initialize and cleanup
those common objects for each test. It is also useful for defining sub-routines that your
tests need to invoke a lot.
In the following example “MyWell” is initialized in SetUp method called before the test
is run. Check in the test fixture if the color of “MyWell” is blue. “MyWell” is erased in
TearDown method called after the test is run.
void TestMyFirstPluginTest::SetUp()
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Project project = Session::current().mainProject();
Well well = Well::create("MyWell", project);
well.setColor(Qt::blue);
lock.release();
}
void TestMyFirstPluginTest::TearDown()
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Project project = Session::current().mainProject();
Well well = project.wells().get("MyWell");
well.erase();
38 Getting Started
Schlumberger Private - Customer Use
lock.release();
}
TEST_F(TestMyFirstPluginTest, WellColor)
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Project project = Session::current().mainProject();
Well well = project.wells().get("MyWell");
if (well.isNull())
{
ASSERT_FALSE(well.isNull());
lock.release();
return;
}
EXPECT_EQ(well.color(), Qt::blue);
lock.release();
}
Ocean test plug-in project is created in a Visual Studio solution that already hosts an
Ocean plug-in project to allow the developer to make some calls to Ocean plug-in
methods in Google tests.
if we have in ReadDataActivity of MyFirstPlugin a public method that allows us to
remove from a Techlog Variable all the missing values and that we want to test this
plug-in functionality calling it from a Google test of my Test plug-in.
Variable ReadDataActivity::removeMissingValues(Variable variable)
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Dataset dataset = variable.dataset();
Well well = dataset.well();
QVector<float> resultVarValues;
QVector<float> resultRefValues;
Dataset resultDataset =
Dataset::create(QString("%1_result").arg(dataset.name()),
ref.name(), ref.format(), resultVarValues.count(), well);
Variable resultVar =
Variable::create(variable.name(), resultDataset,
variable.format(), VariableTypeContinuous, 1);
resultVar.setFamily(variable.family());
resultVar.setUnit(variable.unit());
resultVar.setFloatValues(resultVarValues);
lock.release();
return resultVar;
}
The first thing that the plug-in developer needs to do is to export the
ReadDataActivity class when MyFirstPlugin is built and import ReadDataActivity
class when TestMyFirstPlugin is built. This can be done by adding to MyFirstPlugin
project settings a conditional compilation tag in C/C++ > Preprocessor >
Preprocessor Definitions (see figure 34).
40 Getting Started
Schlumberger Private - Customer Use
Then in ReadDataActivity header file, the code below must be added:
#ifdef T_BUILDING_ACTIVITY
# define DllExport __declspec( dllexport )
#else
# define DllExport __declspec( dllimport)
#endif
private:
void run();
public:
Slb::Ocean::Techlog::Variable
removeMissingValues(Slb::Ocean::Techlog::Variable variable);
};
The removeMissingValues function is imported by the Test plug-in and can now be
called in a Google test as follows.
TEST_F(TestMyFirstPluginTest, RemoveMissingValues)
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
Variable variable =
project.wells().get("Well1").datasets().get("DATAFULL").
variables().get("GR");
lock.release();
Getting Started 41
Schlumberger Private - Customer Use
}
}
ASSERT_TRUE(true);
lock.release();
}
In TearDown function the result dataset is erased after the test.
void TestMyFirstPluginTest::TearDown()
{
Lock lock1 = LOCK_CREATE_AND_ACQUIRE_ALL(lock1);
Dataset dataset =
Session::current().mainProject().wells().get("Well1").datasets().
find("DATAFULL_result");
if (!dataset.isNull())
dataset.erase();
lock1.release();
}
Note: The test fixture TestWorkstep created by the Ocean Test plug-in wizard
shows how to test AWI workstep method, waiting for the end of the
processing in order to assert the results.
Once the solution is built MyFirstPlugin and TestMyFirstPlugin can be listed by the
Techlog module manager.
Open the module manager, refresh the list of plug-ins and enable TestMyFirstPlugin.
42 Getting Started
Schlumberger Private - Customer Use
Figure 35 Enable test plug-in
GTest tab is added to the Techlog menus that contain a gTest action item from which
the test are run in the Techlog context. When the tests have finished to run, the user
can open the result tests log file directly from the Techlog output console (see figure
36).
Getting Started 43
Schlumberger Private - Customer Use
You can also run the tests directly from Visual Studio through the Test Adapter.
1. In Visual Studio click on TEST menu and select Windows > Test Explorer. Text
Explorer window opens in Visual Studio and when Test Plug-in is built all the tests
are displayed in this window:
44 Getting Started
Schlumberger Private - Customer Use
Figure 38 Enable TestRunnerPlugin
Getting Started 45
Schlumberger Private - Customer Use
Note: Tests have to be run with “Default Processor Architecture” option set to x64
in TEST > Test Settings > Default Processor Architecture menu. If
x64 processor is not selected error message below is raised when tests are
run.
Can't run the tests in Techlog. Please make sure that you use x64 version of VS
Test Explorer. An exception occurred while invoking executor
'executor://techloggtestexecutor/': An attempt was made to load a program with
an incorrect format.
Note: If several versions of the Ocean framework are installed make sure that the
right Test Adapter version is selected in Ocean > Techlog Test
Adapter menu in order to allow the Test Explorer to discover tests
properly.
Add a new plug-in installer project to the solution that contains the Ocean plug-in
project that you want to package by clicking right on the solution in the Solution Ex-
plorer. Then select in the contextual menu Add > New Project. In the Project types
area, under Visual C++ project type, select Ocean > Techlog 2016.1. Then select
the Ocean Plug-in Installer template.
Note: An installer project cannot be created into an empty Visual Studio solution.
Installer project wizard is looking at a main plug-in project in the solution.
46 Getting Started
Schlumberger Private - Customer Use
Provide the name “MyFirstPluginInstaller” for the project. Click the OK button to start
the Wizard. (See Figure 41.)
Project name
Getting Started 47
Schlumberger Private - Customer Use
Figure 42 Plug-in installer wizard
WIX installer project for MyFirstPlugin is added to the Visual Studio solution. Build the
project, a MSI installer is generated in output of the build and can be used to deploy the
plug-in in Techlog for the plug-in users.
You may have to deploy additional files following a particular folders structure with your
plug-in dll. WIX installer created through the Ocean plug-in installer template allows
you to add those files editing the Product.wxs file.
Let’s consider a plug-in activity that creates a Logview from a layout template stored at
the plug-in level.
48 Getting Started
Schlumberger Private - Customer Use
void SetupLogviewActivity::run()
{
Lock lock = LOCK_CREATE_AND_ACQUIRE_ALL(lock);
LogviewTemplate logviewTemplate =
LogviewTemplate::get(StorageLevelPlugin, "Well9_short");
Logview logview =
Logview::create(workspace, logviewTemplate, wells);
lock.release();
stop();
}
The layout template Well9_short.xml has to be deployed with the plug-in dll in a folder
named LayoutTemplates.
In the lower section of the Ocean plug-in installer wizard dialog allows you to do this.
You can browse a folder on the disk and add it or you can add a virtual one that will be
created at the plug-in installation time.
1. Add LayoutTemplates folder to plug-in folder
Getting Started 49
Schlumberger Private - Customer Use
You can also delete folders and files with the Remove button. When you are
happy with folder structure and files that will be deployed with the plug-in you can click
Finish in the dialog. Then the Ocean plug-in installer is added to the Visual Studio
solution with folders and files added to Product.wxs file.
After the fact some additional folders and files can be added modifying manually the
Product.wxs file as follow:
1. The file must be added to the <Feature></Feature> block tags in the
Product.wxs file.
<Fea-
tu-
re Id="ProductFeature" ConfigurableDirectory="EXTENSIONS" Descriptio
n="$(var.description)" Title="$(var.mainpluginname)" Level="1">
<ComponentRef Id="Component" Primary="yes" />
<ComponentRef Id="IniFile" Primary="yes"/>
<ComponentRef Id="MyLayoutTemplate" Primary="yes"/>
</Feature>
2. Then declare inside the <Directory></Directory> block tags of the plug-in dll a
<Directory></Directory> block tags with name attribute value equals to the name
of the folder that you want to deploy with the plug-in dll (LayoutTemplates). The
file, in our case Well9_short.xml, is added inside the new <Directory></Directory>
block tags with component id previously declared.
<Directory Id="PluginVersion" Name="$(var.mainpluginversion)">
<Compo-
nent Id="Component" Guid="80dd22d7-5e83-4967-88f3-9fec434a6b83">
<Condition>TECHLOGPATH</Condition>
<File Id="fil1649aa340c434607ae9771ceeebeb051" Source="..\MyFirs
tPlugin/x64/$(var.Configuration)/MyFirstPlugin.dll" />
</Component>
<Directory Id="LayoutTemplates" Name="LayoutTemplates">
<Compo-
nent Id="MyLayoutTemplate" Guid="80dd22d7-5e83-4967-88f3-9fec434a6b8
4">
<Condition>TECHLOGPATH</Condition>
<File Id="fil1649aa340c434607ae9771ceeebeb052"
Source="..\MyFirstPlugin/x64/$(var.Configuration)/Well9_short.xml" /
>
</Component>
</Directory>
</Directory>
50 Getting Started
Schlumberger Private - Customer Use
3. The WIX installer searches for the file in the output directory of Visual Studio
plug-in project.
Well9_short.xml file must be:
copied to the Visual Studio plug-in project directory
added to the Visual Studio project (Add > Existing item in contextual menu
of the project)
copied from the project directory to the output directory adding the following
command line in Post-Build Event of project properties:
copy "Well9_short.xml" "$(OutDir)Well9_short.xml" /Y
Getting Started 51
Schlumberger Private - Customer Use
Upgrade existing Ocean plug-in to 2016.1
It isn’t a prerequisite to uninstall Ocean framework 2015.1 before to install 2016.1
version. You can have several Ocean framework versions installed on your machine.
If you open an Ocean plug-in project created with Ocean template and wizard 2015.1,
you can upgrade this project to 2016.1 clicking right on the project in the Solution
Explorer. Then select in the contextual menu Upgrade Ocean for Techlog project.
52 Getting Started
Schlumberger Private - Customer Use
Then an information message warns the user about changes that have been applied to
the Ocean for Techlog plug-in project.
Getting Started 53
Schlumberger Private - Customer Use
values. But if you change those values through the Ocean for Techlog properties
editor, the new values are only set at the project level and environment variable
values remain unchanged. Through the “Techlog version” you can also control the
Techlog version folder name of the plug-in structure folder. You can also change at
the project setting level the path to the Techlog user folder (TLUSERDIR) where
plug-in structure folders and the plug-in dll are generated at the post-build time.
54 Getting Started
Schlumberger Private - Customer Use