Interface ConfContextInterface

The ConfContextInterface interface is used to get the available part instances inside the "Configurations" of a DMU. It may be used to filter out a group of part instances depending on their presence in these "Configurations", or to display or hide them.

The ConfContextInterface interfaces are created through the createConfContext method, and there may be any number of different configurations inside the ConfContextInterface.

The list of available configurations is accessible through the getConfigurationList method.

/** 
* Sample to illustrate the change of configuration in the ConfContextInterface.
*/
import { ConfContextInterface, DataSessionInterface, ConfigurationInterface } from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// create a ConfContextInterface
const lConfContext : ConfContextInterface = lDataSession.createConfContext();
// retrieve the list of available configurations
const lActiveConfs : Array<ConfigurationInterface> = lDataSession.getConfigurationList();
// we will take the first ConfigurationInterface for this context
const lConfs : Array<string> = new Array<string>(1);
lConfs[0] = lActiveConfs[0].getConfigurationId();
console.log('Using the configuration ' + lActiveConfs[0].getName() + ' : ' + lActiveConfs[0].getDescription())
// set the active confs
lConfContext.setActiveConfs(lConfs);
// and ask to compute all changes requested since the last call to the DataSessionInterface
lDataSession.update();

The user may include any number of [ConfigurationInterface](ConfigurationInterface.html) inside the ConfContextInterface (by their id), the resulting set will be the union of all the requested [ConfigurationInterface](ConfigurationInterface.html) : any `part instance` included in at least one [ConfigurationInterface](ConfigurationInterface.html) will be available through the resulting ConfContextInterface.

The ConfContextInterface has two major uses :

For example, the following code hides all the part instances except the ones in the ConfContextInterface :

/** 
* Sample to illustrate the retrieval of the `geometric instance ids` in the ConfContextInterface, applying
* a "visibility" to the InfiniteEngineInterface.
*/
import {
ConfContextInterface, InfiniteEngineInterface, VisualStates, ConfContextInterfaceSignal,
tListenerCallback, InfiniteEvent,
} from 'generated/documentation/appinfiniteapi';

// the ConfContextInterface should have been created previously
let lConfContext : ConfContextInterface;
// the InfiniteEngineInterface should have been created previously
let lInfiniteEngine : InfiniteEngineInterface;
// the callback called when the ConfContextInterface is ready
let lConfContextReady : tListenerCallback;

// getting notified when the ConfContextInterface is ready
lConfContext.addEventListener(ConfContextInterfaceSignal.ConfContextReady, lConfContextReady);

lConfContextReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// get the geometries of this ConfContextInterface
const lGeometries: Uint32Array | undefined = lConfContext.getGeometricInstanceIds();
// make sure we are not updating the content (isRunning() is true)
if (lGeometries)
{
// hide all geometries and set them as invisible and not ghosted
lInfiniteEngine.updateGeometricStateForAll(VisualStates.S_Hidden | VisualStates.S_Ghost, (VisualStates.S_Hidden | ~VisualStates.S_Ghost));
// set all the geometries of the ConfContextInterface as visible.
lInfiniteEngine.updateGeometricState(lGeometries, VisualStates.S_Hidden, ~VisualStates.S_Hidden);
}
}

The list of signals the ConfContextInterface may trigger is available in the [ConfContextInterfaceSignal](../enums/ConfContextInterfaceSignal.html) enumeration.

The active configurations are set through the setActiveConfs method. Each time the setActiveConfs method is called, the ConfContextChanged signal is sent. The setActiveConfs does not trigger a computation on the infinite servers, the user has to call the update method to trigger a computation (after the ConfContextInterface has been changed). The result is not available right away, but the event ConfContextReady is triggered when the result of the ConfContextInterface is available.

Warning : Creating a ConfContextInterface by createConfContext will fire a ConfContextReady with all the part instances of the DMU, this is equivalent to calling :

/** 
* Sample to illustrate the change of configuration in the ConfContextInterface.
*/
import { ConfContextInterface, DataSessionInterface, ConfigurationInterface } from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// create a ConfContextInterface
const lConfContext : ConfContextInterface = lDataSession.createConfContext();
// retrieve the list of available configurations
const lActiveConfs : Array<ConfigurationInterface> = lDataSession.getConfigurationList();
// we will take the first ConfigurationInterface for this context
const lConfs : Array<string> = new Array<string>(1);
lConfs[0] = lActiveConfs[0].getConfigurationId();
console.log('Using the configuration ' + lActiveConfs[0].getName() + ' : ' + lActiveConfs[0].getDescription())
// set the active confs
lConfContext.setActiveConfs(lConfs);
// and ask to compute all changes requested since the last call to the DataSessionInterface
lDataSession.update();

Or with async calls :
/** 
* Sample to illustrate the asynchronous change of configuration in the ConfContextInterface.
*/
import { ConfContextInterface, DataSessionInterface, ConfigurationInterface, AsyncResultReason, AsyncUInt32ArrayResult } from 'generated/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// create a ConfContextInterface
const lConfContext : ConfContextInterface = lDataSession.createConfContext();
// retrieve the list of available configurations
const lActiveConfs : Array<ConfigurationInterface> = lDataSession.getConfigurationList();
// we will take the first ConfigurationInterface for this context
const lConfs : Array<string> = new Array<string>(1);
lConfs[0] = lActiveConfs[0].getConfigurationId();
console.log('Using the configuration ' + lActiveConfs[0].getName() + ' : ' + lActiveConfs[0].getDescription())

const getResult = async (): Promise<AsyncUInt32ArrayResult> => {
// set the active confs
lConfContext.setActiveConfs(lConfs);
const lContent : AsyncUInt32ArrayResult = await lConfContext.asyncGetGeometricInstanceIds();
console.assert(lContent.reason === AsyncResultReason.ARR_Success);
console.assert(lContent.value !== undefined);
return lContent;
}

getResult();

Warning : there may be cases when the [getGeometricInstanceIds](ConfContextInterface.html#getGeometricInstanceIds) is not available such as when the ConfContextInterface is updating, i.e. when [isRunning](ConfContextInterface.html#isRunning) returns true, or when the ConfContextInterface has been cancelled, i.e. when [isCancelled](ConfContextInterface.html#isCancelled) returns true.

A ConfContextInterface may be interrupted (cancelled) when the ConfContextInterface is running and cancelUpdate is called. In such cases, the ConfContextCancelled signal is fired, and shortly after, ConfContextReady signal is fired, but getGeometricInstanceIds will return undefined. Just call update and the computation of the ConfContextInterface will resume.

If you call multiple times setActiveConfs before receiving the ConfContextReady, only one ConfContextReady will be sent with the content of the last call to setActiveConfs.


Metadata

See

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Gets the list of all the geometric Instance ids of the part instances represented by the union of these ConfigurationInterface.

    The list of geometric Instance ids is returned once the ConfContextInterface has finished computing. If it's been cancelled, or disposed, the returned promise contains this information.

    If pRunUpdate is true (by default), a update is automatically called.

    DO NOT modify this array in place, this results in undefined behavior.

    Returns

    A promise. The promise is resolved with the reason (success, cancelled, disposed, bad input), or rejected in case of an unexpected error. In case of success, the promise is resolved with the list of geometric instances ids represented by this ConfContextInterface.

    Parameters

    • Optional pRunUpdate: boolean

      If set to true, a update is called (defaults to true).

    Returns Promise<AsyncUInt32ArrayResult>

  • Gets the list of active ConfigurationInterface ids, as set previously by setActiveConfs.

    Modifying this array in place results in undefined behavior.

    DO NOT modify this array.

    Returns

    const
    The list of active [ConfigurationInterface](ConfigurationInterface.html) ids in this ConfContextInterface.

    See

    getConfigurationId

    Returns readonly string[]

  • Gets the identifier of the ConfContextInterface.

    Returns

    The identifier of the ConfContextInterface.

    Returns string

  • Gets the list of all the geometric Instance ids of the part instances represented by the union of these ConfigurationInterface.

    The list of geometric Instance ids is returned if the ConfContextInterface has finished computing. Use addEventListener on the event ConfContextReady to know when the ConfContextInterface is ready.

    DO NOT modify this array in place, this results in undefined behavior.

    Returns

    const
    The list of geometric instances ids represented by this ConfContextInterface, or undefined if the ConfContextInterface is computing or if the ConfContextInterface is in error or cancelled.

    See

    Returns undefined | Uint32Array

  • Gets the last error returned by the update of the ConfContextInterface.

    Returns

    The last error message (if any, or an empty string if no error occurred).

    Returns string

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Tells if the ConfContextInterface has been cancelled.

    This is generally the case after calling cancelUpdate when the ConfContextInterface is updating (ie .isRunning() is true).

    Returns

    true If the ConfContextInterface is cancelled.

    See

    cancelUpdate

    Returns boolean

  • Tells if the ConfContextInterface is updating (running).

    This is generally the case after calling setActiveConfs, or right after the ConfContextInterface creation with createConfContext.

    Returns

    true if the ConfContextInterface is updating.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](ConfContextInterface.html#addEventListener) that you want to remove.

    Returns boolean

  • Sets the ids of the active configurations that are included in this ConfContextInterface.

    An event ConfContextChanged signal is sent.

    The consecutive call to update will trigger the calculation of the part instances inside this union of getConfigurationId.

    If pActiveConfigurationIds is an empty array (the default case), the given ConfContextInterface is "unconfigured", i.e. it contains all the part instances of the DMU.

    Only unique and valid configuration ids from pActiveConfigurationIds will be activated. If pActiveConfigurationIds contains duplicates or invalid configuration ids they will be skipped which might results as activating an empty array (the default case).

    Returns

    true if the ConfContextInterface is changed and update must be called.

    See

    getConfigurationId

    Parameters

    • pActiveConfigurationIds: string[]
      in
      The list of [ConfigurationInterface](ConfigurationInterface.html) ids to set.

    Returns boolean

  • Sets the identifier of the ConfContextInterface. Make sure the id is unique. A unique ConfContextInterface identifier is created if the identifier is not overridden.

    Parameters

    • pConfCtxId: string
      in
      The new identifier of the ConfContextInterface.

    Returns void