Enumeration IdCardGetterInterfaceSignal

The IdCardGetterInterfaceSignal lists all the signals that may be sent by the IdCardGetterInterface.

These signals are emitted by the IdCardGetterInterface when some data is available.

/** 
* Sample to illustrate the use of an IdCardGetterInterface with the parsing of
* PartInstanceInfoInterface to display some information about a part instance.
*/
import {
VisibilityContextInterface, IdCardGetterInterface, IdCardGetterInterfaceSignal,
InfiniteEvent, PartInstanceInfoInterface, PartInstanceInfoStatusFlag, DataSessionInterface,
} from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// created previously
let lVisibilityContext : VisibilityContextInterface;
// the `part instance id` to get
let lPartInstanceId : number;
// what to do when we have retrieved id card information ?
let onIdCardReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// create an idCardGetter
const lIdCardGetterInterface : IdCardGetterInterface = lDataSession.createIdCardGetter();
// what to do when result is ready ?
lIdCardGetterInterface.addEventListener(IdCardGetterInterfaceSignal.IdCardReady, onIdCardReady);

// onIdCardReady will be called when data is available
onIdCardReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
if (lIdCardGetterInterface.getLastError().length !== 0) {
// do nothing in case of error
// perhaps some GUI code ?
}
const lPartInstanceInfos : Array<PartInstanceInfoInterface> | undefined = lIdCardGetterInterface.getPartInstanceInfos();
if (!lPartInstanceInfos || lPartInstanceInfos.length !== 1)
{
// no data (isCancelled ?)
return;
}
// we required only one `part instance`, as such, only one result should be retrieved
// iterate over the instantiation chain, but take the first chain since one `part instance` retrieved
const lCurrentChain : PartInstanceInfoInterface = lPartInstanceInfos[0];

// number of items
const lNbAncestors : number = lCurrentChain.getAncestors().length;
const lOffsetToPartInstance : number = lNbAncestors - 1;
// we get the `part` metadata of the given `part instance` (and not their parents - grand parents) => lNbAncestors-1
const lPartMetadata : Object = lCurrentChain.getIdCardHierarchy().partmd[lOffsetToPartInstance];
// some fancy output
console.log(JSON.stringify(lPartMetadata));

// get the flags in order to get information about the `part instance`
const lFlags : number = lCurrentChain.getAncestorsStatusFlags()[lOffsetToPartInstance];
if ((lFlags & PartInstanceInfoStatusFlag.PI_Displayable) !== 0)
{
console.log('this part instance is displayable')
}
}

// trigger the retrieval
lIdCardGetterInterface.retrieveIdCard(lPartInstanceId, lVisibilityContext);

Please refer to [IdCardGetterInterface](../interfaces/IdCardGetterInterface.html) for more information about idcard requests.
Events

See

IdCardGetterInterface

Enumeration Members

Enumeration Members

IdCardCancelled: "cancelled"

Signal sent by the IdCardGetterInterface when the IdCardGetterInterface is requested to be cancelled.

Such an event is fired if the IdCardGetterInterface was running and cancel is called. The IdCardReady signal will be triggered shortly after.

No attachment for events of this type.

IdCardReady: "ready"

Signal sent by the IdCardGetterInterface when the IdCardGetterInterface is ready, i.e. getPartInstanceInfos can be called.

Warning, the IdCardReady signal is sent when cancel is called and the IdCardGetterInterface is updating. In such a case, not data will be available in the IdCardGetterInterface.

The attachment is a string telling the request id of the call to retrieveIdCard (getLastRequestId).