Assembler - STARIONGROUP/COMET-SDK-Community-Edition GitHub Wiki
The Assembler class is responsible for translating the DTO instances that are queried from the CDP4-COMET Web Services into POCO instances and to update the Cache.
The Assembler works in close collaboration with the Session class. An API developer should only access the Assembler in order to retrieve a Thing from the Cache. The ISession interface and Session class provide a layer of abstraction that should shield away the Assembler from an API consumer.
The following methods and properties of the Assembler class are exposed to an API developer. In principle these methods and properties, with the exception of the Cache, should not be directly used. The mehtods are documented here information purposes only.
The Synchronize method is used to update the POCOs that are stored in the Cache with updates retrieved from a data-source. An IEnumerable<CDP4Common.DTO.Thing>
is passed as an argument. If a DTO is not yet reprsented by a corresponding POCO, the POCO is created and added to the Cache. If a DTO is already represented by a POCO in the Cache, that POCO is updated with the information transfered by the DTO. Synchronize returns a Task
and can be awaited.
The CDPMessageBus is used to notify any listeners of updates to POCO objects by means of ObjectChangedEvent
The Clear method is used to clear the Cache. For each EngineeringModel and Iteration that is contained in the Cache an ObjectChangedEvent with EventKind set to EventKind.Removed
is sent to notify listeners that these objects have been removed from the Cache.
When an EngineeringModel is opened, the required chain of Reference Data Libraries is loaded as well. The CloseRdl method is used to remove the contents of the ReferenceDataLibrary from the Cache. The ReferenceDataLibrary itself is only updated, not removed from the Cache.
The CloseIterationSetup method is used to remove the contents of the IterationSetup from the Cache. The IterationSetup itself is only updated, not removed from the Cache.
The SiteDirectory object is a singleton in a specific data-source. The RetrieveSiteDirectory method is a convenience method used to get that singleton SiteDirectory object from the Cache.
The CDP4-COMET cache is implemented using the ConcurrentDictionary. The ConcurrentDictionary
represents a thread-safe collection of key/value pairs that can be accessed by multiple threads concurrently.
ConcurrentDictionary<CacheKey, Lazy<Thing>> cache
The Assembler class manages one Cache, the Cache that corresponds to the data-source URI that the Assembler was constrcuted with. This Cache object can be access through the Cache property of the Assembler class.
The PocoThingFactory class is used by the Assembler to resolve the references of POCO ojects to other POCO objects.