Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


 
Return the type of the instance identified by the instanceId given in the argument <instance>. The instance type is returned as an entityID that uniquely identifies the entity definition instance in the remote EDMdatabase that defines the actual entity, i.e. the actual instance type.
Related functions: edmiRemoteGetInstance , edmiRemoteGetInstancesType
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteGetInstanceType(SdaiServerContext serverContextId,
                                     SdaiInstance      instance, 
                                     SdaiEntity        *entityId, 
                                     SdaiString        *instTypeName,
                                     SdaiInvocationId  *edmiInvocationId);
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

instance

The numeric instanceId that uniquely identifies the instance in the _EDMdatabase{_}.

entityId

A variable that will receive the entityId that uniquely identifies the instance type in the remote _EDMdatabase_

instTypeName

A variable that will receive the name that has been assigned to the instance type identified by the returned entityId.

edmiInvocationId

Currently not used.

Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
EdmiError rstat;
SdaiServerContext myContext;
SdaiRepository repositoryId;
SdaiModel modelId;
SdaiEntity entityId;
SdaiString entityName;
SdaiInstance instId;
SdaiAttr attrId;
SdaiPrimitiveType attrType;
SdaiString stringId = "721212";
SdaiInteger integerId = 721212;
SdaiVoid value;
 
/* In this example, the instance Id, instId
is an input parameter. The type of instance 
is not specified, but it is assumed to have 
an ID attribute of either string or integer 
type. */ 
 
/* Create Server Context */
rstat = edmiDefineServerContext("MyContext",
"Johnny", "Supervisor", "cf37ftr", 
"TCP", "9090", "MyServerHost", 
NULL, NULL, NULL, NULL, NULL, &myContext); 
 
/* Find the repositoryId and
the modelId of the instance */ 
rstat = edmiRemoteGetInstanceModel(myContext,
instId, &repositoryId, &modelId, NULL); 
 
/* Get instance type */
rstat = edmiRemoteGetInstanceType(myContext,
instId, &entityId, &entityName, NULL); 
 
/* Get the Id of the ID attribute */
rstat = edmiRemoteGetAttrDefinition(myContext, entityId,
"ID", &attrId, NULL); 
if (rstat == sdaiEATTRUNDEF) {
printf("\nEntity %s does not have an ID attribute", entityName); 
goto err; 
}
 
/* Find the primitive type of the attribute */
rstat = edmiRemoteGetAttrPrimitiveType(myContext,
attrId, &attrType, NULL); 
 
/* Apply the proper ID format */
switch(attrType) {
 
case sdaiINTEGER: value = &integerId; 
break; 
case sdaiSTRING: value = &stringId; 
break; 
default: printf("\nInvalid ID attribute type"); 
goto err; 
}
 
/* Insert the Id */
rstat = edmiRemotePutAttrsBN(myContext, instId, 1, NULL,
"ID", attrType, value); 
. . .

  • No labels