@p2olab/pimad-core
Version:
PiMAd (Process-industry-Modular-Automation-description) High level access to automation of modular plants.
224 lines (223 loc) • 9.57 kB
TypeScript
import { Backbone, SemanticVersion } from '../../Backbone';
import PiMAdResponseVendor = Backbone.PiMAdResponseVendor;
import PiMAdResponse = Backbone.PiMAdResponse;
declare abstract class AImporter implements Importer {
protected initialized: boolean;
protected metaModelVersion: SemanticVersion;
protected nextImporter: Importer | undefined;
protected responseVendor: PiMAdResponseVendor;
constructor();
/** @inheritDoc */
abstract convertFrom(instructions: object, callback: (response: PiMAdResponse) => void): void;
getMetaModelVersion(): SemanticVersion;
initialize(nextImporter: Importer): boolean;
}
/**
* Last link of every importer chain. Cleans up and build a meaningful answer why the import has failed.
*/
export declare class LastChainLinkImporter extends AImporter {
/**
* All prioritized importers could not perform the import. Error message with debug information is created and
* returned to the calling one.
*
* @param instructions - A set of instructions, configuring the importer.
* @param callback - Passing the result back via a callback function.
*/
convertFrom(instructions: object, callback: (response: PiMAdResponse) => void): void;
/**
* Initializing the LastChainLink.
* @param nextImporter - The next Importer element in the chain, but this is already the last element! Therefore the
* object will not be stored. You could also pass an 'undefined' here.
*/
initialize(nextImporter: Importer | undefined): boolean;
}
/**
* Importer for MTPFreeze 2020.01.
*/
export declare class MTPFreeze202001Importer extends AImporter {
private servicePart;
private hmiPart;
private mtpPart;
private textPart;
private amlGateFactory;
private dataAssemblyVendor;
private mtpGateFactory;
private peaFactory;
private procedureFactory;
private serviceFactory;
private xmlGateFactory;
private zipGateFactory;
/** @inheritDoc */
convertFrom(instructions: InstructionsConvertFrom, callback: (response: PiMAdResponse) => void): void;
/**
* This method evaluates the instructions to the importer. Valid instructions are forwarded to {@link accessDataSource} to gain
* access to the source and the data stored in it.
*
* Answers the first question of the activity {@link Importer.convertFrom} for this importer.
*
* @param instructions - Pass the address of the source via the source attribute of the object.
* @param callback - Returns a successful {@link SuccessResponse} with PEAModel or an {@link ErrorResponse} with
* a message why this step has finally failed.
*/
private followInstructions;
/**
* This method reads the data from the source and converts it into a JSON-object, which is then passed to the
* {@link checkInformationModel} to check the meta model.
*
* Answers the second question of the activity {@link Importer.convertFrom} for this importer.
*
* @param instructions - Pass the address of the source via the source attribute of the object.
* @param callback - Returns a successful {@link SuccessResponse} with PEAModel or an {@link ErrorResponse} with
* a message why this step has finally failed.
* @private
*/
private accessDataSource;
/**
* Uff... actually there is no real possibility to check IM of MTP. Missing SemVer. Therefore passing to the
* next stage.
*
* Answers the third question of the activity {@link Importer.convertFrom} for this importer.
*
* @param data - The content of a CAEXFile as a JSON-object.
* @param pimadIdentifier - ???
* @param callback - TODO after rework!
* @private
*/
private checkInformationModel;
/**
* Get a specific ModuleTypePackageSet-Set.
* @param refBaseSystemUnitPath - The meta model path.
* @param array - An array with ModuleTypePackage-Sets
* @param callback - ???
* @private
*/
private getSet;
/**
* This method translates the interface description of the ModuleTypePackage within the CAEX file into a PEAModel of the
* PiMAd-core-IM. After the different MTP parts are extracted by {@link ImporterPart}s, DataAssemblies, Services
* and Procedures are merged. The reference system of the MTP is used for this. The import of the MTP is then
* completed.
*
* Detailed inline code documentation exists for this method. Nevertheless, it is important to read the MTP
* standard.
*
* <uml>
* skinparam shadowing false
* partition "convert" {
* start
* :prepare pea-data-storage;
* :loop through the InstanceHierarchy\nand extract data for different\nModuleTypePackage parts;
* if(extracted data\nis valid?) then (no)
* :callback an ErrorResponse;
* stop
* else (yes)
* while (are there\nmore services?) is (yes)
* :take next service;
* :get and store the\nreferenced DataAssembly;
* if (is referenced DataAssembly undefined?) then (yes)
* :skipping this service;
* else (no)
* :prepare service-data-storage;
* while (are there\nmore procedures?) is (yes)
* :take next procedure;
* :get and store the\nreferenced DataAssembly;
* if (is referenced DataAssembly undefined?) then (yes)
* :skipping this procedure;
* else (no)
* :initialize procedure;
* if (initialization successful?) then (yes)
* :push procedure to\nservice-data-storage;
* endif
* endif
* endwhile (no)
* :initialize service;
* if (initialization successful?) then (yes)
* :push service to\npea-data-storage;
* endif
* endif
* endwhile (no)
* :initialize a PEAModel object;
* if (initialization successful?) then (yes)
* :callback the PEAModel\nvia SuccessResponse;
* else (no)
* :callback error\nvia ErrorResponse;
* endif
* endif
* stop
* }
* </uml>
*
* @param data - The data as CAEXFile.
* @param pimadIdentifier - ???
* @param callback - ???
* @private
*/
private convert;
/**
* remove HealthStateView(Procedures) and ServiceControls from dataAssemblies, because subscribeToAllVariables()
* in backend will take this list for the variables
* @param dataAssemblies
* @private
*/
private cleanUpDataAssemblies;
constructor();
}
export interface Importer {
/**
* This method converts a set of data into a PEAModel of the PiMAd core IM. It first checks whether the instructions
* given are understood. Then, whether the data source can be tapped. Then whether the information model of the data
* source is understood. If all responses are positive, the actual conversion into a PEAModel takes place. If parts of
* the responses are negative, the next element in the chain of importers (Chain-of-Responsibility pattern) is
* called.
*
* <uml>
* skinparam shadowing false
* partition convertFrom {
* start
* :parse instructions;
* if(Can I follow\nthe instructions?) then (yes)
* if(Can I access\nthe data source?) then (yes)
* if(Do I understand the\ninformation model?) then (yes)
* :Convert it;
* :Fire callback;
* stop
* else (no)
* endif
* else (no)
* endif
* else (no)
* endif
* :Pass to the next\nchain element;
* stop
* }
* </uml>
*
* @param instructions - Pass the address of the source via the source attribute of the object.
* @param callback - Returns a successful {@link SuccessResponse} with PEAModel or an {@link ErrorResponse} with
* a message why the converting has finally failed.
*/
convertFrom(instructions: object, callback: (response: PiMAdResponse) => void): void;
/**
* Initialize this importer object.
* @param nextImporter - The next importer in the Chain-of-Responsibility.
*/
initialize(nextImporter: Importer): boolean;
getMetaModelVersion(): SemanticVersion;
}
declare abstract class AImporterFactory implements ImporterFactory {
abstract create(): Importer;
}
export declare class MTPFreeze202001ImporterFactory extends AImporterFactory {
create(): Importer;
}
export declare class LastChainElementImporterFactory extends AImporterFactory {
create(): Importer;
}
export interface ImporterFactory {
create(): Importer;
}
declare type InstructionsConvertFrom = {
source: string;
identifier: string;
};
export {};