Classes | Typedefs | Enumerations | Enumerator | Functions | Variables
I-model IPC connection

The i-model connection library provides APIs to connect Engine from host application. More...

Classes

struct  ConnectionStatus
 This structure holds the connection status. More...
 
class  IModelEngine
 Engine class. More...
 
class  ConnectionManager
 IModel ConnectionManager. More...
 

Typedefs

typedef void(* ImodelCallback )(wchar_t *)
 User Message callback. More...
 
typedef std::vector
< ImodelCallback > 
CallbackList
 Message callback list. More...
 
typedef IModelEngine * IModelEngineP
 IModelEngine pointer. More...
 

Enumerations

enum  Status { Success = 0, Error }
 Imodel connection status. More...
 
enum  Reason {
  NewEngine = 0, GraphicalEngine, NonGraphicalEngine, ErrorDifferentRunningEngine,
  ErrorNoResponseNewEngine, ErrorNoResponseRunningEngine, ErrorStartingNewEngine, ErrorConnectionExist,
  ErrorMismatchRequestedGraphicsMode, ErrorEngineNotFound
}
 Imodel connection Success/Error reasons. More...
 

Functions

void GetName (Bentley::WString &name)
 Get name of the engine. More...
 
void GetDisplayName (Bentley::WString &displayName)
 Get display name of the engine. More...
 
void GetDisplayVersion (Bentley::WString &displayVersion)
 Get display version of the engine. More...
 
void GetVersion (Bentley::WString &version)
 Get version of the engine. More...
 
void GetProgramPath (Bentley::WString &programPath)
 Get folder path of the engine. More...
 
void GetProgramFullPath (Bentley::WString &programFullPath)
 Get full path of the engine. More...
 
void GetWorkspacePath (Bentley::WString &workspacePath)
 Get workspace path of the engine. More...
 
int LoadApp (Bentley::WString &appPath)
 Load user app in the engine. More...
 
int StartApp (Bentley::WString const &KeyinString)
 Start user Key-in. More...
 
int SetCallback (ImodelCallback callback)
 Set message callback. More...
 
static ConnectionManager * GetManagerObj ()
 Get connection manager object. More...
 
static void DeleteManagerObj ()
 Delete connection manager object. More...
 
int DiscoverEngines ()
 Discover available engines in the machine. More...
 
IModelEngine * GetEngine (int index)
 Get IModelEngine object pointer at the index. More...
 
ConnectionStatus Connect (IModelEngine *engine, Bentley::WString const &seedFile, bool connectGraphicalEngine=false)
 Connect to engine. More...
 
int Disconnect (IModelEngine *engine)
 Disconnect the engine If connected to non graphical engine, it will stop the engine, however, it does not stop any Graphical engine. More...
 
StatusInt SendImodelMessage (WStringR messageString)
 Send message to IModel host application. More...
 

Variables

Status status
 
Reason reason
 status of connection More...
 

Detailed Description

The i-model connection library provides APIs to connect Engine from host application.

Overview of common uses for i-model IPC connection library with the following capabilities:

Typedef Documentation

typedef std::vector< ImodelCallback > CallbackList

Message callback list.

typedef void(* ImodelCallback)(wchar_t *)

User Message callback.

typedef IModelEngine* IModelEngineP

IModelEngine pointer.

Enumeration Type Documentation

enum Reason

Imodel connection Success/Error reasons.

Enumerator
NewEngine 

New instance of Engine.

GraphicalEngine 

Graphical Engine is running.

NonGraphicalEngine 

Non-Graphical Engine is running.

ErrorDifferentRunningEngine 

Error. Running engine is different from requested engine connect.

ErrorNoResponseNewEngine 

Error. New engine instance is not responding.

ErrorNoResponseRunningEngine 

Error. Running engine is not responsive.

ErrorStartingNewEngine 

Error starting new engine.

ErrorConnectionExist 

Error. Connection already exist. For new connection user need to disconnect earlier connection.

ErrorMismatchRequestedGraphicsMode 

Error. Requested UI mode is different from running engine.

ErrorEngineNotFound 

Error. Engine requested not found. Either Engine is not yet initialized or the Engine is not running with the same privilge as of 3rd party appllication.

enum Status

Imodel connection status.

Enumerator
Success 

Successfully connected to the Engine.

Error 

Error, See the reason structure for detail error.

Function Documentation

ConnectionStatus Connect ( IModelEngine engine,
Bentley::WString const &  seedFile,
bool  connectGraphicalEngine = false 
)

Connect to engine.

Connect to a non graphical engine connects to a already running non graphics engine. If no non graphics engine found it starts a new instance of engine and connect to that engine Connect to a graphical engine connects to a already running Graphical engine. If no graphical engine found it does not start any engine. Multiple application connecting to a engine may cause the engine to behave unexpectedly and should be avoided. Disconnect the engine as soon as the publishing is done so that no other application can connecting to a same engine.

Parameters
[in]engineDesired engine to connect. Only one connection is possible at a time. So, to connect another engine, user need to disconnect already connected engine.
[in]seedFileSeedfile path. To use already opened DGN file, pass blank string. If the file path is not valid, it will not load the seed file.
[in]connectGraphicalEnginetrue to connect UI engine, false to connect Non-ui engine in background
Returns
status of the connection Connection may fail due to various reason. Main reason could be uninitialized engine. In that case, user have to wait for the engine to load all its module. If failed to connect on first attempt, try to connect after couple of minute.
See also
ConnectionStatus
static void DeleteManagerObj ( )
static

Delete connection manager object.

int Disconnect ( IModelEngine engine)

Disconnect the engine If connected to non graphical engine, it will stop the engine, however, it does not stop any Graphical engine.

Parameters
[in]engineDesired engine to disconnect.
Returns
status of the operation, 0 for Success. -1 for Error.
int DiscoverEngines ( )

Discover available engines in the machine.

On subsequent call, it will not renew the engine list.

Returns
count of available engines
void GetDisplayName ( Bentley::WString displayName)

Get display name of the engine.

Full name of the product i.e. 'MicroStation V8i (SELECTseries 3)'

Parameters
[out]displayNameDisplayName of the engine
void GetDisplayVersion ( Bentley::WString displayVersion)

Get display version of the engine.

i.e. 08.11.09.260

Parameters
[out]displayVersionDisplayVersion of the engine
IModelEngine* GetEngine ( int  index)

Get IModelEngine object pointer at the index.

Parameters
[in]indexEngine at index place will be retrieved
Returns
IModelEngineP. If not found any engine at index, return NULL
static ConnectionManager* GetManagerObj ( )
static

Get connection manager object.

Returns
ConnectionManager object pointer
void GetName ( Bentley::WString name)

Get name of the engine.

A short name of the product i.e. 'MicroStation'

Parameters
[out]nameName of the engine
void GetProgramFullPath ( Bentley::WString programFullPath)

Get full path of the engine.

Parameters
[out]programFullPathProgramPath along with the exe path of the engine
void GetProgramPath ( Bentley::WString programPath)

Get folder path of the engine.

Parameters
[out]programPathProgram folder path of the engine
void GetVersion ( Bentley::WString version)

Get version of the engine.

Similer to Display Version in the form of 081109260

Parameters
[out]versionVersion of the engine
void GetWorkspacePath ( Bentley::WString workspacePath)

Get workspace path of the engine.

Parameters
[out]workspacePathWorkspacePath of the engine
int LoadApp ( Bentley::WString appPath)

Load user app in the engine.

Parameters
[in]appPathUser application path including the dll name. The path of App should be inside the Engine's installed folder. Suppose the Engine is installed at "c:\\Program Files (x86)\\Bentley 08.11.09.260\\MicroStation\\", then the App path should be "c:\\Program Files (x86)\\Bentley 08.11.09.260\\MicroStation\\mdlapps\\userApp.dll", where "userApp.dll" is the app that user want to load using LoadApp method. If the user App path is outside the engine's install path then Engine might fail to load the App.
Returns
status of the operation, SUCCESS ( 0 ) or ERROR ( -1 ) if app path is not found
StatusInt Bentley::IPC::SendImodelMessage ( WStringR  messageString)

Send message to IModel host application.

Parameters
[in]messageStringMessage. Max 256 char long
Returns
status of the operation. Error if Server is not found. To start server user need to call ConnectionManager::Connect method from 3rd party application.
int SetCallback ( ImodelCallback  callback)

Set message callback.

Parameters
[in]callbackcallback method
Returns
status of the operation, SUCCESS ( 0 ) or ERROR ( -1 ).
int StartApp ( Bentley::WString const &  KeyinString)

Start user Key-in.

Parameters
KeyinStringUser key-in
Returns
status of the operation, SUCCESS ( 0 ) or ERROR ( -1 ).. If the KeyinString is blank then it return ERROR Please use the following snippet to call the user Key-ins
ConnectionManager *cm = ConnectionManager::GetManagerObj();
int count = cm->DiscoverEngines ();
if ( 0 == count )
return;
IModelEngineP engine = cm->GetEngine (0); // provide the index of the desired engine
engine->LoadApp ( L"c:\\Program Files (x86)\\Bentley 08.11.09.260\\MicroStation\\mdlapps\\userApp.dll",); // provide the app full path
engine->StartApp ( L"ReadImodel" ); // starts 'ReadImodel' key-in that user implemented inside the userApp.dll.

Variable Documentation

Reason reason

status of connection

Status status

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.