UNPKG

@p2olab/pimad-core

Version:

PiMAd (Process-industry-Modular-Automation-description) High level access to automation of modular plants.

216 lines (215 loc) 8.53 kB
import { DataItemModel, ModuleAutomation, Parameter } from '../../ModuleAutomation'; import { AML } from '@p2olab/pimad-types'; import { Backbone } from '../../Backbone'; import Attribute = AML.Attribute; import PiMAdResponseVendor = Backbone.PiMAdResponseVendor; import PiMAdResponse = Backbone.PiMAdResponse; import DataAssembly = ModuleAutomation.DataAssembly; declare abstract class AImporterPart implements ImporterPart { protected responseVendor: PiMAdResponseVendor; extract(data: object, callback: (response: PiMAdResponse) => void): void; /** * Extract a specific attribute from an Attribute Array. F.ex. the RefID-Attribute. * @param attributeName - The name of the attribute. * @param attributes - The attributes array. * @param callback - A callback function with an instance of the Response-Interface. */ protected getAttribute(attributeName: string, attributes: Attribute[], callback: (response: PiMAdResponse) => void): void; constructor(); } export declare class HMIPart extends AImporterPart { } /** * Handles the 'MTPPart' of a ModuleTypePackage file. This means CommunicationSet, HMISet, ServiceSet, ... */ export declare class MTPPart extends AImporterPart { private communicationInterfaceDataVendor; private dataAssemblyVendor; private baseDataItemFactory; /** * This method extracts data from the MTPPart of the ModuleTypePackage and converts it into different objects of the PiMAd-core-IM. * * Attention! Currently (31.07.2020) only data from the CommunicationSet is processed! * * <uml> * skinparam shadowing false * partition "extract" { * start * :extract communicationSet; * if (extracted data is valid?) is (true) * :callback the data\nwith SuccessResponse; * else (false) * :callback an\nErrorResponse; * endif * stop * } * </uml> * * @param data - The bare ModuleTypePackage-object of the MTP. Containing a CommunicationSet, HMISet, ServiceSet and TextSet. * @param callback - A callback function with an instance of the Response-Interface. The type of the response-content-object-attribute data is {@link ExtractDataFromCommunicationSetResponseType} */ extract(data: { CommunicationSet: object[]; HMISet: object; ServiceSet: object; TextSet: object; }, callback: (response: PiMAdResponse) => void): void; private getRefBaseSystemUnitPathElement; /** * This method extracts data from the ModuleTypePackage-CommunicationSet, evaluates it and then transfers it to the * PiMAd-core internal data model. The following diagram visualizes the general method flow: * * <uml> * skinparam shadowing false * partition "extractDataFromCommunicationSet" { * start * :extract InstanceList & \nSourceList; * if(extracted data seems valid) then (yes) * :parsing SourceList; * :parsing InstanceList; * :CommunicationInterfaceData: communicationInterfaceData, \nDataAssemblies: dataAssemblies ] * stop * else (no) * endif * :CommunicationInterfaceData: [], \nDataAssemblies: [] ] * stop * } * </uml> * * The following activity diagram shows the detailed steps for parsing the SourceList: * * <uml> * skinparam shadowing false * partition "extractDataFromCommunicationSet:parsing-SourceList" { * start * while (more InternalElements?) is (true) * if (element == OPCUAServer?) then (yes) * :extract opcua-\nserver interface; * :extract external interfaces; * else (no) * stop * endif * endwhile (no) * stop * } * </uml> * * The following activity diagram shows the detailed steps for parsing the InstanceList: * * <uml> * skinparam shadowing false * partition "buildCommunicationSet:parsing-InstanceList" { * start * while (more InternalElements\nin InstanceList?) is (true) * :setup local\ndata storage; * while (more Attributes\nin InternalElement?) is (true) * if(attributeDataType == xs:IDREF) * :merging attribute data\nwith external interface data; * :initialize DataItemModel with\nmerged data and push\nit to the local storage; * elseif (attributeDataType == xs:ID) * :save the RefID as\nDataAssembly-Identifier; * endif * endwhile (no) * :initialize DataAssembly with\nparsed data and push it\to the local storage; * endwhile (no) * stop * } * </uml> * * @param communicationSet - The bare CommunicationSet-object of the MTP. */ private extractDataFromCommunicationSet; constructor(); } /** * Handles the 'ServicePart' of the ModuleTypePackage file. */ export declare class ServicePart extends AImporterPart { private baseProcedureFactory; /** * This method extracts data from the service part of the ModuleTypePackage and converts it into an intermediate * format very similar to the {@link Service} interface of the PiMAd core IM. * * <uml> * skinparam shadowing false * partition "extract" { * start * while (more services?) is (yes) * :take the next service; * :extract and store\nfirst level data of\nthe service; * while (more InternalElements?) is (yes) * :take the next element; * if (element == ServiceProcedure) is (true) * :extract the data\nof the service procedure; * :push procedure to service; * else (no) * :Skipping this element; * endif * endwhile (no) * :push service to storage; * endwhile (no) * :callback the extracted\nservices with a\nSuccessResponse; * stop * } * </uml> * * @param data - All service data as object. * @param callback - A callback function with an instance of the Response-Interface. */ extract(data: ServicePartExtractInputDataType, callback: (response: PiMAdResponse) => void): void; /** * Transforming AML-Attributes into AML-Attributes. Ignoring specific one. f. ex. RefID. Needs a Refactor -\> PiMAd * needs an attribute interface too! * @param attributes - The attributes array. * @param callback - A callback function with an instance of the Response-Interface. */ private extractAttributes; constructor(); } export declare class TextPart extends AImporterPart { } /** * Importers consist of individual parts that each extract specific sections of the information model. */ export interface ImporterPart { /** * Extracts data based on a specific information model and converts it into the internal data model of PiMAd. * @param data - The data source. * @param callback - Return the results via callback-function. */ extract(data: object, callback: (response: PiMAdResponse) => void): void; } /** * Type of the object that is created by the method {@link extractDataFromCommunicationSet} */ export declare type ExtractDataFromCommunicationSetResponseType = { DataAssemblies: DataAssembly[]; ServerCommunicationInterfaceData: DataItemModel[]; }; /** * Types the content object in the {@link SuccessResponse} from {@link ServicePart.extract} */ export declare type InternalServiceType = InternalProcedureType & { Procedures: InternalProcedureType[]; }; /** * Types the Procedures in {@link InternalServiceType} */ export declare type InternalProcedureType = { Attributes: Attribute[]; DataAssembly: Attribute; Identifier: string; MetaModelRef: string; Name: string; Parameters: Parameter[]; }; /** * Types the object that the method {@link ServicePart.extract} expects as input. */ export declare type ServicePartExtractInputDataType = { Name: string; ID: string; Version: string; InternalElement: object[]; }; export {};