@winccoa-tools-pack/npm-winccoa-core 0.1.0-04b5cbe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/components/WinCCOAComponent.js +327 -0
- package/dist/cjs/types/components/WinCCOAComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/AlertManagerComponent.js +14 -0
- package/dist/cjs/types/components/implementations/AlertManagerComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/AndroidComponent.js +17 -0
- package/dist/cjs/types/components/implementations/AndroidComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/ApiComponent.js +14 -0
- package/dist/cjs/types/components/implementations/ApiComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/AsciiManagerComponent.js +14 -0
- package/dist/cjs/types/components/implementations/AsciiManagerComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/ConfComponent.js +17 -0
- package/dist/cjs/types/components/implementations/ConfComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/CtrlComponent.js +34 -0
- package/dist/cjs/types/components/implementations/CtrlComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/DNP3Component.js +17 -0
- package/dist/cjs/types/components/implementations/DNP3Component.js.map +1 -0
- package/dist/cjs/types/components/implementations/DataComponent.js +17 -0
- package/dist/cjs/types/components/implementations/DataComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/DbManagerComponent.js +14 -0
- package/dist/cjs/types/components/implementations/DbManagerComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/DistComponent.js +14 -0
- package/dist/cjs/types/components/implementations/DistComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/DriverComponent.js +14 -0
- package/dist/cjs/types/components/implementations/DriverComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/EventComponent.js +17 -0
- package/dist/cjs/types/components/implementations/EventComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/HttpComponent.js +14 -0
- package/dist/cjs/types/components/implementations/HttpComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/IEC60870Component.js +17 -0
- package/dist/cjs/types/components/implementations/IEC60870Component.js.map +1 -0
- package/dist/cjs/types/components/implementations/IEC61850Component.js +17 -0
- package/dist/cjs/types/components/implementations/IEC61850Component.js.map +1 -0
- package/dist/cjs/types/components/implementations/IosComponent.js +17 -0
- package/dist/cjs/types/components/implementations/IosComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/JavaComponent.js +17 -0
- package/dist/cjs/types/components/implementations/JavaComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/JavaScriptComponent.js +17 -0
- package/dist/cjs/types/components/implementations/JavaScriptComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/ModbusComponent.js +17 -0
- package/dist/cjs/types/components/implementations/ModbusComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/OpcComponent.js +17 -0
- package/dist/cjs/types/components/implementations/OpcComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/OpcDaComponent.js +17 -0
- package/dist/cjs/types/components/implementations/OpcDaComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/OpcUaComponent.js +17 -0
- package/dist/cjs/types/components/implementations/OpcUaComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/PmonComponent.js +728 -0
- package/dist/cjs/types/components/implementations/PmonComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/RdbComponent.js +14 -0
- package/dist/cjs/types/components/implementations/RdbComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/ReduComponent.js +14 -0
- package/dist/cjs/types/components/implementations/ReduComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/ReportManagerComponent.js +14 -0
- package/dist/cjs/types/components/implementations/ReportManagerComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/S7Component.js +17 -0
- package/dist/cjs/types/components/implementations/S7Component.js.map +1 -0
- package/dist/cjs/types/components/implementations/S7TopSapComponent.js +17 -0
- package/dist/cjs/types/components/implementations/S7TopSapComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/SimComponent.js +17 -0
- package/dist/cjs/types/components/implementations/SimComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/SplitComponent.js +14 -0
- package/dist/cjs/types/components/implementations/SplitComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/UIComponent.js +36 -0
- package/dist/cjs/types/components/implementations/UIComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/ValueArchManagerComponent.js +14 -0
- package/dist/cjs/types/components/implementations/ValueArchManagerComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/VideoDriverComponent.js +14 -0
- package/dist/cjs/types/components/implementations/VideoDriverComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/VisionComponent.js +17 -0
- package/dist/cjs/types/components/implementations/VisionComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/WebUIComponent.js +17 -0
- package/dist/cjs/types/components/implementations/WebUIComponent.js.map +1 -0
- package/dist/cjs/types/components/implementations/index.js +74 -0
- package/dist/cjs/types/components/implementations/index.js.map +1 -0
- package/dist/cjs/types/index.js +23 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/localization/OaLanguage.js +136 -0
- package/dist/cjs/types/localization/OaLanguage.js.map +1 -0
- package/dist/cjs/types/logs/WinCCOAErrorHandler.js +94 -0
- package/dist/cjs/types/logs/WinCCOAErrorHandler.js.map +1 -0
- package/dist/cjs/types/logs/WinCCOALogEntry.js +3 -0
- package/dist/cjs/types/logs/WinCCOALogEntry.js.map +1 -0
- package/dist/cjs/types/logs/WinCCOALogParser.js +213 -0
- package/dist/cjs/types/logs/WinCCOALogParser.js.map +1 -0
- package/dist/cjs/types/project/CurrentProjectInfo.js +12 -0
- package/dist/cjs/types/project/CurrentProjectInfo.js.map +1 -0
- package/dist/cjs/types/project/ProjEnv.js +109 -0
- package/dist/cjs/types/project/ProjEnv.js.map +1 -0
- package/dist/cjs/types/project/ProjEnvErrorHandler.js +12 -0
- package/dist/cjs/types/project/ProjEnvErrorHandler.js.map +1 -0
- package/dist/cjs/types/project/ProjEnvPmonStatus.js +22 -0
- package/dist/cjs/types/project/ProjEnvPmonStatus.js.map +1 -0
- package/dist/cjs/types/project/ProjEnvProject.js +1015 -0
- package/dist/cjs/types/project/ProjEnvProject.js.map +1 -0
- package/dist/cjs/types/project/ProjEnvProjectConfig.js +327 -0
- package/dist/cjs/types/project/ProjEnvProjectConfig.js.map +1 -0
- package/dist/cjs/types/project/ProjEnvProjectRegistry.js +327 -0
- package/dist/cjs/types/project/ProjEnvProjectRegistry.js.map +1 -0
- package/dist/cjs/types/status/WinCCOAManager.js +3 -0
- package/dist/cjs/types/status/WinCCOAManager.js.map +1 -0
- package/dist/cjs/types/version/DetailedVersionInfo.js +6 -0
- package/dist/cjs/types/version/DetailedVersionInfo.js.map +1 -0
- package/dist/cjs/utils/index.js +25 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/winccoa-components.js +7 -0
- package/dist/cjs/utils/winccoa-components.js.map +1 -0
- package/dist/cjs/utils/winccoa-localization.js +12 -0
- package/dist/cjs/utils/winccoa-localization.js.map +1 -0
- package/dist/cjs/utils/winccoa-logging.js +3 -0
- package/dist/cjs/utils/winccoa-logging.js.map +1 -0
- package/dist/cjs/utils/winccoa-paths.js +222 -0
- package/dist/cjs/utils/winccoa-paths.js.map +1 -0
- package/dist/cjs/utils/winccoa-project-environment.js +73 -0
- package/dist/cjs/utils/winccoa-project-environment.js.map +1 -0
- package/dist/cjs/utils/winccoa-version-info.js +23 -0
- package/dist/cjs/utils/winccoa-version-info.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/components/WinCCOAComponent.js +290 -0
- package/dist/esm/types/components/WinCCOAComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/AlertManagerComponent.js +10 -0
- package/dist/esm/types/components/implementations/AlertManagerComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/AndroidComponent.js +13 -0
- package/dist/esm/types/components/implementations/AndroidComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/ApiComponent.js +10 -0
- package/dist/esm/types/components/implementations/ApiComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/AsciiManagerComponent.js +10 -0
- package/dist/esm/types/components/implementations/AsciiManagerComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/ConfComponent.js +13 -0
- package/dist/esm/types/components/implementations/ConfComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/CtrlComponent.js +30 -0
- package/dist/esm/types/components/implementations/CtrlComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/DNP3Component.js +13 -0
- package/dist/esm/types/components/implementations/DNP3Component.js.map +1 -0
- package/dist/esm/types/components/implementations/DataComponent.js +13 -0
- package/dist/esm/types/components/implementations/DataComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/DbManagerComponent.js +10 -0
- package/dist/esm/types/components/implementations/DbManagerComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/DistComponent.js +10 -0
- package/dist/esm/types/components/implementations/DistComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/DriverComponent.js +10 -0
- package/dist/esm/types/components/implementations/DriverComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/EventComponent.js +13 -0
- package/dist/esm/types/components/implementations/EventComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/HttpComponent.js +10 -0
- package/dist/esm/types/components/implementations/HttpComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/IEC60870Component.js +13 -0
- package/dist/esm/types/components/implementations/IEC60870Component.js.map +1 -0
- package/dist/esm/types/components/implementations/IEC61850Component.js +13 -0
- package/dist/esm/types/components/implementations/IEC61850Component.js.map +1 -0
- package/dist/esm/types/components/implementations/IosComponent.js +13 -0
- package/dist/esm/types/components/implementations/IosComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/JavaComponent.js +13 -0
- package/dist/esm/types/components/implementations/JavaComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/JavaScriptComponent.js +13 -0
- package/dist/esm/types/components/implementations/JavaScriptComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/ModbusComponent.js +13 -0
- package/dist/esm/types/components/implementations/ModbusComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/OpcComponent.js +13 -0
- package/dist/esm/types/components/implementations/OpcComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/OpcDaComponent.js +13 -0
- package/dist/esm/types/components/implementations/OpcDaComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/OpcUaComponent.js +13 -0
- package/dist/esm/types/components/implementations/OpcUaComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/PmonComponent.js +723 -0
- package/dist/esm/types/components/implementations/PmonComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/RdbComponent.js +10 -0
- package/dist/esm/types/components/implementations/RdbComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/ReduComponent.js +10 -0
- package/dist/esm/types/components/implementations/ReduComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/ReportManagerComponent.js +10 -0
- package/dist/esm/types/components/implementations/ReportManagerComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/S7Component.js +13 -0
- package/dist/esm/types/components/implementations/S7Component.js.map +1 -0
- package/dist/esm/types/components/implementations/S7TopSapComponent.js +13 -0
- package/dist/esm/types/components/implementations/S7TopSapComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/SimComponent.js +13 -0
- package/dist/esm/types/components/implementations/SimComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/SplitComponent.js +10 -0
- package/dist/esm/types/components/implementations/SplitComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/UIComponent.js +32 -0
- package/dist/esm/types/components/implementations/UIComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/ValueArchManagerComponent.js +10 -0
- package/dist/esm/types/components/implementations/ValueArchManagerComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/VideoDriverComponent.js +10 -0
- package/dist/esm/types/components/implementations/VideoDriverComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/VisionComponent.js +13 -0
- package/dist/esm/types/components/implementations/VisionComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/WebUIComponent.js +13 -0
- package/dist/esm/types/components/implementations/WebUIComponent.js.map +1 -0
- package/dist/esm/types/components/implementations/index.js +36 -0
- package/dist/esm/types/components/implementations/index.js.map +1 -0
- package/dist/esm/types/index.js +7 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/localization/OaLanguage.js +132 -0
- package/dist/esm/types/localization/OaLanguage.js.map +1 -0
- package/dist/esm/types/logs/WinCCOAErrorHandler.js +90 -0
- package/dist/esm/types/logs/WinCCOAErrorHandler.js.map +1 -0
- package/dist/esm/types/logs/WinCCOALogEntry.js +2 -0
- package/dist/esm/types/logs/WinCCOALogEntry.js.map +1 -0
- package/dist/esm/types/logs/WinCCOALogParser.js +176 -0
- package/dist/esm/types/logs/WinCCOALogParser.js.map +1 -0
- package/dist/esm/types/project/CurrentProjectInfo.js +11 -0
- package/dist/esm/types/project/CurrentProjectInfo.js.map +1 -0
- package/dist/esm/types/project/ProjEnv.js +103 -0
- package/dist/esm/types/project/ProjEnv.js.map +1 -0
- package/dist/esm/types/project/ProjEnvErrorHandler.js +8 -0
- package/dist/esm/types/project/ProjEnvErrorHandler.js.map +1 -0
- package/dist/esm/types/project/ProjEnvPmonStatus.js +18 -0
- package/dist/esm/types/project/ProjEnvPmonStatus.js.map +1 -0
- package/dist/esm/types/project/ProjEnvProject.js +1008 -0
- package/dist/esm/types/project/ProjEnvProject.js.map +1 -0
- package/dist/esm/types/project/ProjEnvProjectConfig.js +287 -0
- package/dist/esm/types/project/ProjEnvProjectConfig.js.map +1 -0
- package/dist/esm/types/project/ProjEnvProjectRegistry.js +283 -0
- package/dist/esm/types/project/ProjEnvProjectRegistry.js.map +1 -0
- package/dist/esm/types/status/WinCCOAManager.js +2 -0
- package/dist/esm/types/status/WinCCOAManager.js.map +1 -0
- package/dist/esm/types/version/DetailedVersionInfo.js +5 -0
- package/dist/esm/types/version/DetailedVersionInfo.js.map +1 -0
- package/dist/esm/utils/index.js +9 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/winccoa-components.js +4 -0
- package/dist/esm/utils/winccoa-components.js.map +1 -0
- package/dist/esm/utils/winccoa-localization.js +9 -0
- package/dist/esm/utils/winccoa-localization.js.map +1 -0
- package/dist/esm/utils/winccoa-logging.js +3 -0
- package/dist/esm/utils/winccoa-logging.js.map +1 -0
- package/dist/esm/utils/winccoa-paths.js +184 -0
- package/dist/esm/utils/winccoa-paths.js.map +1 -0
- package/dist/esm/utils/winccoa-project-environment.js +66 -0
- package/dist/esm/utils/winccoa-project-environment.js.map +1 -0
- package/dist/esm/utils/winccoa-version-info.js +20 -0
- package/dist/esm/utils/winccoa-version-info.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/types/components/WinCCOAComponent.d.ts +138 -0
- package/dist/types/components/WinCCOAComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/AlertManagerComponent.d.ts +6 -0
- package/dist/types/components/implementations/AlertManagerComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/AndroidComponent.d.ts +9 -0
- package/dist/types/components/implementations/AndroidComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/ApiComponent.d.ts +6 -0
- package/dist/types/components/implementations/ApiComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/AsciiManagerComponent.d.ts +6 -0
- package/dist/types/components/implementations/AsciiManagerComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/ConfComponent.d.ts +9 -0
- package/dist/types/components/implementations/ConfComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/CtrlComponent.d.ts +10 -0
- package/dist/types/components/implementations/CtrlComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/DNP3Component.d.ts +9 -0
- package/dist/types/components/implementations/DNP3Component.d.ts.map +1 -0
- package/dist/types/components/implementations/DataComponent.d.ts +9 -0
- package/dist/types/components/implementations/DataComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/DbManagerComponent.d.ts +6 -0
- package/dist/types/components/implementations/DbManagerComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/DistComponent.d.ts +6 -0
- package/dist/types/components/implementations/DistComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/DriverComponent.d.ts +6 -0
- package/dist/types/components/implementations/DriverComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/EventComponent.d.ts +9 -0
- package/dist/types/components/implementations/EventComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/HttpComponent.d.ts +6 -0
- package/dist/types/components/implementations/HttpComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/IEC60870Component.d.ts +9 -0
- package/dist/types/components/implementations/IEC60870Component.d.ts.map +1 -0
- package/dist/types/components/implementations/IEC61850Component.d.ts +9 -0
- package/dist/types/components/implementations/IEC61850Component.d.ts.map +1 -0
- package/dist/types/components/implementations/IosComponent.d.ts +9 -0
- package/dist/types/components/implementations/IosComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/JavaComponent.d.ts +9 -0
- package/dist/types/components/implementations/JavaComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/JavaScriptComponent.d.ts +9 -0
- package/dist/types/components/implementations/JavaScriptComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/ModbusComponent.d.ts +9 -0
- package/dist/types/components/implementations/ModbusComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/OpcComponent.d.ts +9 -0
- package/dist/types/components/implementations/OpcComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/OpcDaComponent.d.ts +9 -0
- package/dist/types/components/implementations/OpcDaComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/OpcUaComponent.d.ts +9 -0
- package/dist/types/components/implementations/OpcUaComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/PmonComponent.d.ts +168 -0
- package/dist/types/components/implementations/PmonComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/RdbComponent.d.ts +6 -0
- package/dist/types/components/implementations/RdbComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/ReduComponent.d.ts +6 -0
- package/dist/types/components/implementations/ReduComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/ReportManagerComponent.d.ts +6 -0
- package/dist/types/components/implementations/ReportManagerComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/S7Component.d.ts +9 -0
- package/dist/types/components/implementations/S7Component.d.ts.map +1 -0
- package/dist/types/components/implementations/S7TopSapComponent.d.ts +9 -0
- package/dist/types/components/implementations/S7TopSapComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/SimComponent.d.ts +9 -0
- package/dist/types/components/implementations/SimComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/SplitComponent.d.ts +6 -0
- package/dist/types/components/implementations/SplitComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/UIComponent.d.ts +13 -0
- package/dist/types/components/implementations/UIComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/ValueArchManagerComponent.d.ts +6 -0
- package/dist/types/components/implementations/ValueArchManagerComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/VideoDriverComponent.d.ts +6 -0
- package/dist/types/components/implementations/VideoDriverComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/VisionComponent.d.ts +9 -0
- package/dist/types/components/implementations/VisionComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/WebUIComponent.d.ts +9 -0
- package/dist/types/components/implementations/WebUIComponent.d.ts.map +1 -0
- package/dist/types/components/implementations/index.d.ts +36 -0
- package/dist/types/components/implementations/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/localization/OaLanguage.d.ts +101 -0
- package/dist/types/localization/OaLanguage.d.ts.map +1 -0
- package/dist/types/logs/WinCCOAErrorHandler.d.ts +35 -0
- package/dist/types/logs/WinCCOAErrorHandler.d.ts.map +1 -0
- package/dist/types/logs/WinCCOALogEntry.d.ts +12 -0
- package/dist/types/logs/WinCCOALogEntry.d.ts.map +1 -0
- package/dist/types/logs/WinCCOALogParser.d.ts +53 -0
- package/dist/types/logs/WinCCOALogParser.d.ts.map +1 -0
- package/dist/types/project/CurrentProjectInfo.d.ts +24 -0
- package/dist/types/project/CurrentProjectInfo.d.ts.map +1 -0
- package/dist/types/project/ProjEnv.d.ts +73 -0
- package/dist/types/project/ProjEnv.d.ts.map +1 -0
- package/dist/types/project/ProjEnvErrorHandler.d.ts +6 -0
- package/dist/types/project/ProjEnvErrorHandler.d.ts.map +1 -0
- package/dist/types/project/ProjEnvPmonStatus.d.ts +23 -0
- package/dist/types/project/ProjEnvPmonStatus.d.ts.map +1 -0
- package/dist/types/project/ProjEnvProject.d.ts +475 -0
- package/dist/types/project/ProjEnvProject.d.ts.map +1 -0
- package/dist/types/project/ProjEnvProjectConfig.d.ts +54 -0
- package/dist/types/project/ProjEnvProjectConfig.d.ts.map +1 -0
- package/dist/types/project/ProjEnvProjectRegistry.d.ts +61 -0
- package/dist/types/project/ProjEnvProjectRegistry.d.ts.map +1 -0
- package/dist/types/status/WinCCOAManager.d.ts +15 -0
- package/dist/types/status/WinCCOAManager.d.ts.map +1 -0
- package/dist/types/version/DetailedVersionInfo.d.ts +16 -0
- package/dist/types/version/DetailedVersionInfo.d.ts.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/winccoa-components.d.ts +3 -0
- package/dist/utils/winccoa-components.d.ts.map +1 -0
- package/dist/utils/winccoa-localization.d.ts +7 -0
- package/dist/utils/winccoa-localization.d.ts.map +1 -0
- package/dist/utils/winccoa-logging.d.ts +1 -0
- package/dist/utils/winccoa-logging.d.ts.map +1 -0
- package/dist/utils/winccoa-paths.d.ts +49 -0
- package/dist/utils/winccoa-paths.d.ts.map +1 -0
- package/dist/utils/winccoa-project-environment.d.ts +34 -0
- package/dist/utils/winccoa-project-environment.d.ts.map +1 -0
- package/dist/utils/winccoa-version-info.d.ts +14 -0
- package/dist/utils/winccoa-version-info.d.ts.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,1008 @@
|
|
|
1
|
+
//--------------------------------------------------------------------------------
|
|
2
|
+
import { PmonComponent } from '../components/implementations';
|
|
3
|
+
import { findProjectRegistryById } from '../project/ProjEnvProjectRegistry';
|
|
4
|
+
import { OaLanguage, OaLanguageFromString } from '../localization/OaLanguage';
|
|
5
|
+
import { tr } from '../../utils/winccoa-localization';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
// import { getComponentName } from "../../utils/winccoa-components"
|
|
8
|
+
import { ProjEnvPmonStatus } from './ProjEnvPmonStatus';
|
|
9
|
+
import { ProjEnvProjectConfig } from './ProjEnvProjectConfig';
|
|
10
|
+
import { ProjEnvProjectRunnable, ProjEnvProjectFileSysStruct, ProjEnvProjectState, } from './ProjEnv';
|
|
11
|
+
import { WinCCOAErrorHandler } from '../logs/WinCCOAErrorHandler';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import { PmonComponentCredential } from '../..';
|
|
14
|
+
/**
|
|
15
|
+
* @brief WinCC OA Project class for managing project lifecycle and configuration
|
|
16
|
+
* @details Handles project creation, registration, startup, shutdown and management
|
|
17
|
+
* of project components and settings.
|
|
18
|
+
*/
|
|
19
|
+
export class ProjEnvProject {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.runnable = ProjEnvProjectRunnable.Unknown;
|
|
22
|
+
this.currentProject = false;
|
|
23
|
+
//--------------------------------------------------------------------------------
|
|
24
|
+
//@protected members
|
|
25
|
+
//--------------------------------------------------------------------------------
|
|
26
|
+
//------------------------------------------------------------------------------
|
|
27
|
+
// general project options
|
|
28
|
+
this._id = '';
|
|
29
|
+
this._name = '';
|
|
30
|
+
// Pmon object to control pmon self.
|
|
31
|
+
this._pmon = new PmonComponent();
|
|
32
|
+
this._errorHandler = new WinCCOAErrorHandler();
|
|
33
|
+
//--------------------------------------------------------------------------------
|
|
34
|
+
//@private members
|
|
35
|
+
//--------------------------------------------------------------------------------
|
|
36
|
+
// Languages
|
|
37
|
+
this._languages = [];
|
|
38
|
+
// sub-projects
|
|
39
|
+
this._subProjects = [];
|
|
40
|
+
// project config file handler
|
|
41
|
+
this._projectConfigFile = new ProjEnvProjectConfig();
|
|
42
|
+
}
|
|
43
|
+
//------------------------------------------------------------------------------
|
|
44
|
+
initFromRegister(registry) {
|
|
45
|
+
// console.log(
|
|
46
|
+
// '__initFromRegister__, Initializing project from registry: ', registry
|
|
47
|
+
// );
|
|
48
|
+
this.setInstallDir(registry.installationDir);
|
|
49
|
+
if (registry.id) {
|
|
50
|
+
if (this.getId() && this.getId() !== registry.id) {
|
|
51
|
+
this._errorHandler.warning(`Project ID mismatch during initFromRegister: expected '${this.getId()}', got '${registry.id}'. We will use '${registry.id}'.`);
|
|
52
|
+
}
|
|
53
|
+
this._id = registry.id;
|
|
54
|
+
}
|
|
55
|
+
this.setName(registry.name ?? registry.id);
|
|
56
|
+
if (registry.notRunnable !== undefined)
|
|
57
|
+
this.setRunnable(!registry.notRunnable);
|
|
58
|
+
this.currentProject = registry.currentProject ?? false;
|
|
59
|
+
this._subProjects = [];
|
|
60
|
+
this._languages = [];
|
|
61
|
+
if (this.isRunnable()) {
|
|
62
|
+
if (registry.installationVersion !== undefined) {
|
|
63
|
+
// console.log(
|
|
64
|
+
// `[${new Date().toISOString()}]`,
|
|
65
|
+
// this.getId() +
|
|
66
|
+
// ` Setting project version from registry: ${registry.installationVersion}`,
|
|
67
|
+
// );
|
|
68
|
+
this.setVersion(registry.installationVersion);
|
|
69
|
+
}
|
|
70
|
+
// try to get other project properties from config file
|
|
71
|
+
const configPath = this.getConfigPath();
|
|
72
|
+
if (configPath === '') {
|
|
73
|
+
this._errorHandler.warning('The project config file does not exist for project ' + this.getId());
|
|
74
|
+
}
|
|
75
|
+
else if (!fs.existsSync(configPath)) {
|
|
76
|
+
this._errorHandler.warning(`The project config file does not exist for project ${this.getId()}: ${configPath}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this._projectConfigFile.setConfigPath(configPath);
|
|
80
|
+
const projectVersion = this.getProjectVersion();
|
|
81
|
+
if (projectVersion && this.getVersion() && projectVersion !== this.getVersion()) {
|
|
82
|
+
this._errorHandler.warning(`Project version mismatch between registry and config file for project ${this.getId()}: registry=${this.getVersion()}, config=${projectVersion}`);
|
|
83
|
+
}
|
|
84
|
+
// read sub-projects from config file
|
|
85
|
+
// the last one proj_path entry is the project itself
|
|
86
|
+
const subProjectsEntries = this._projectConfigFile.getEntryValueList('proj_path') || [];
|
|
87
|
+
// check for sub-project entries on windows paths may take a while
|
|
88
|
+
// the last one is always the project itself, therefoee we skip it
|
|
89
|
+
// when we have no subpojects
|
|
90
|
+
if (subProjectsEntries.length > 0) {
|
|
91
|
+
subProjectsEntries.forEach((entry, _idx) => {
|
|
92
|
+
// console.log('Checking sub-project entry:', entry, 'at position', _idx);
|
|
93
|
+
if (!entry || entry.trim().length === 0)
|
|
94
|
+
return;
|
|
95
|
+
const origEntry = entry;
|
|
96
|
+
entry = entry.replace(/\\/g, '/').replace(/\/\//g, '/').toLowerCase();
|
|
97
|
+
if (!entry.endsWith('/')) {
|
|
98
|
+
entry += '/';
|
|
99
|
+
}
|
|
100
|
+
const myDir = this.getDir()
|
|
101
|
+
.replace(/\\/g, '/')
|
|
102
|
+
.replace(/\/\//g, '/')
|
|
103
|
+
.toLowerCase();
|
|
104
|
+
// console.log(
|
|
105
|
+
// `[${new Date().toISOString()}]`,
|
|
106
|
+
// `Found sub-project entry in config: ${entry}, my dir is ${this.getDir()}`,
|
|
107
|
+
// );
|
|
108
|
+
if (entry.toLowerCase() === myDir) {
|
|
109
|
+
// console.log(
|
|
110
|
+
// `[${new Date().toISOString()}]`,
|
|
111
|
+
// `Skipping sub-project entry that matches self project dir`,
|
|
112
|
+
// );
|
|
113
|
+
return; // skip self
|
|
114
|
+
}
|
|
115
|
+
const subProj = new ProjEnvProject();
|
|
116
|
+
subProj.setDir(origEntry);
|
|
117
|
+
this._subProjects.push(subProj);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
// read languages from config file
|
|
121
|
+
const langEntries = this._projectConfigFile.getEntryValueList('langs') || [];
|
|
122
|
+
langEntries.forEach((entry, _idx) => {
|
|
123
|
+
const oaLang = OaLanguageFromString(entry);
|
|
124
|
+
if (oaLang === OaLanguage.undefined || oaLang === OaLanguage.auto) {
|
|
125
|
+
console.warn(`[${new Date().toISOString()}]`, `Invalid language entry in project config: ${entry}`);
|
|
126
|
+
}
|
|
127
|
+
// console.log('Checking language entry:', entry, 'at position', _idx, oaLang);
|
|
128
|
+
this._languages.push(oaLang);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//------------------------------------------------------------------------------
|
|
134
|
+
isCurrentProject() {
|
|
135
|
+
return this.currentProject;
|
|
136
|
+
}
|
|
137
|
+
//------------------------------------------------------------------------------
|
|
138
|
+
/**
|
|
139
|
+
* @brief Sets the project identifier
|
|
140
|
+
* @param id Project ID (directory name containing project files)
|
|
141
|
+
* @return Error code:
|
|
142
|
+
* 0 = Success
|
|
143
|
+
* -1 = Invalid project ID
|
|
144
|
+
* -2 = Invalid WinCC OA version
|
|
145
|
+
* -3 = Invalid project path
|
|
146
|
+
*/
|
|
147
|
+
setId(id) {
|
|
148
|
+
if (id === undefined || id.trim().length === 0) {
|
|
149
|
+
this._errorHandler.severe(tr('The project ID must not be empty!'));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (id === this.getId()) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this._id = id;
|
|
156
|
+
if (this.runnable == ProjEnvProjectRunnable.Unknown) {
|
|
157
|
+
const registry = findProjectRegistryById(id);
|
|
158
|
+
if (registry) {
|
|
159
|
+
this.initFromRegister(registry);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//------------------------------------------------------------------------------
|
|
164
|
+
format(template, ...args) {
|
|
165
|
+
// Replace $1, $2 ... in template with provided args
|
|
166
|
+
return template.replace(/\$(\d+)/g, (_m, idx) => {
|
|
167
|
+
const i = parseInt(idx, 10) - 1;
|
|
168
|
+
return args[i] !== undefined ? String(args[i]) : '';
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @brief Function returns project ID.
|
|
173
|
+
* @return Project ID.
|
|
174
|
+
* @exception Empty string.
|
|
175
|
+
*/
|
|
176
|
+
getId() {
|
|
177
|
+
return this._id;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets the WinCC OA version from project config file
|
|
181
|
+
*/
|
|
182
|
+
getProjectVersion() {
|
|
183
|
+
return this._projectConfigFile.getEntryValue('proj_version');
|
|
184
|
+
}
|
|
185
|
+
//------------------------------------------------------------------------------
|
|
186
|
+
/**
|
|
187
|
+
* @brief Function set the project name.
|
|
188
|
+
* @param name Project name.
|
|
189
|
+
* @return Error code.
|
|
190
|
+
* value | description
|
|
191
|
+
* ------|------------
|
|
192
|
+
* 0 | Success.
|
|
193
|
+
* -1 | Name is not valid.
|
|
194
|
+
*/
|
|
195
|
+
setName(name) {
|
|
196
|
+
if (!name) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this._name = name;
|
|
200
|
+
}
|
|
201
|
+
//------------------------------------------------------------------------------
|
|
202
|
+
/**
|
|
203
|
+
* @brief Function returns project name.
|
|
204
|
+
* @return Project-name.
|
|
205
|
+
* @exception Empty langString.
|
|
206
|
+
*/
|
|
207
|
+
getName() {
|
|
208
|
+
return this._name;
|
|
209
|
+
}
|
|
210
|
+
getDisplayName() {
|
|
211
|
+
return this._name ? this._name : this._id;
|
|
212
|
+
}
|
|
213
|
+
//------------------------------------------------------------------------------
|
|
214
|
+
/**
|
|
215
|
+
* @brief Function set project version.
|
|
216
|
+
* @param version Project version in format ```<major>.<minor>```
|
|
217
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
218
|
+
*/
|
|
219
|
+
setVersion(version) {
|
|
220
|
+
if (!version) {
|
|
221
|
+
throw new Error('Project version must not be empty: ' + this.getId());
|
|
222
|
+
}
|
|
223
|
+
this.version = version;
|
|
224
|
+
this._pmon.setVersion(this.version ?? '');
|
|
225
|
+
}
|
|
226
|
+
//------------------------------------------------------------------------------
|
|
227
|
+
/**
|
|
228
|
+
* @brief Function returns project version.
|
|
229
|
+
* @return Project version.
|
|
230
|
+
* @exception Empty string.
|
|
231
|
+
*/
|
|
232
|
+
getVersion() {
|
|
233
|
+
return this.version;
|
|
234
|
+
}
|
|
235
|
+
//------------------------------------------------------------------------------
|
|
236
|
+
/**
|
|
237
|
+
* @brief Function set project dir.
|
|
238
|
+
*/
|
|
239
|
+
setInstallDir(dirPath) {
|
|
240
|
+
if (!dirPath)
|
|
241
|
+
return;
|
|
242
|
+
// Store path with trailing separator
|
|
243
|
+
this.installPath = dirPath;
|
|
244
|
+
// unse unix style separators
|
|
245
|
+
this.installPath = this.installPath.replace(/\\/g, '/').replace(/\/\//g, '/');
|
|
246
|
+
if (!this.installPath.endsWith('/')) {
|
|
247
|
+
this.installPath += '/';
|
|
248
|
+
}
|
|
249
|
+
if (!fs.existsSync(this.installPath)) {
|
|
250
|
+
console.warn(`[${new Date().toISOString()}] Warning: Project install directory does not exist: ${this.installPath}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//------------------------------------------------------------------------------
|
|
254
|
+
/**
|
|
255
|
+
* @brief Function returns dir, where are project created.
|
|
256
|
+
* @return Project installation dir.
|
|
257
|
+
*/
|
|
258
|
+
getInstallDir() {
|
|
259
|
+
return this.installPath;
|
|
260
|
+
}
|
|
261
|
+
//------------------------------------------------------------------------------
|
|
262
|
+
/**
|
|
263
|
+
* @brief Function returns project dir inclusive project self.
|
|
264
|
+
* @return Project dir path.
|
|
265
|
+
*/
|
|
266
|
+
getDir(relativeDirPath = '') {
|
|
267
|
+
if (!this.getId()) {
|
|
268
|
+
throw new Error('Project ID is not set');
|
|
269
|
+
return '';
|
|
270
|
+
}
|
|
271
|
+
const base = this.getInstallDir();
|
|
272
|
+
if (!base) {
|
|
273
|
+
throw new Error('Project install directory is not set: ' + this.getId());
|
|
274
|
+
return '';
|
|
275
|
+
}
|
|
276
|
+
let retPath = base + this.getId() + '/' + relativeDirPath;
|
|
277
|
+
// Add separator between base and ID, handle both forward and backslash
|
|
278
|
+
if (!retPath.endsWith('/')) {
|
|
279
|
+
retPath += '/';
|
|
280
|
+
}
|
|
281
|
+
return retPath;
|
|
282
|
+
}
|
|
283
|
+
//------------------------------------------------------------------------------
|
|
284
|
+
/**
|
|
285
|
+
* @brief Function returns project config path.
|
|
286
|
+
* @param configFileName Name of the config file. Default: "config"
|
|
287
|
+
* @return Project config path.
|
|
288
|
+
*/
|
|
289
|
+
getConfigPath(configFileName = 'config') {
|
|
290
|
+
const p = this.getDir(ProjEnvProjectFileSysStruct.CONFIG_REL_PATH);
|
|
291
|
+
if (!p || !fs.existsSync(p + configFileName))
|
|
292
|
+
return '';
|
|
293
|
+
return p + configFileName;
|
|
294
|
+
}
|
|
295
|
+
//------------------------------------------------------------------------------
|
|
296
|
+
/** Function set project languages.
|
|
297
|
+
* @param languages Project languages.
|
|
298
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
299
|
+
*/
|
|
300
|
+
setLanguages(languages) {
|
|
301
|
+
this._languages = languages;
|
|
302
|
+
}
|
|
303
|
+
//------------------------------------------------------------------------------
|
|
304
|
+
/**
|
|
305
|
+
* @brief Gets configured project languages
|
|
306
|
+
* @return Dynamic array of configured language codes
|
|
307
|
+
*/
|
|
308
|
+
getLanguages() {
|
|
309
|
+
return this._languages;
|
|
310
|
+
}
|
|
311
|
+
//------------------------------------------------------------------------------
|
|
312
|
+
/**
|
|
313
|
+
* @brief Sets whether the project is runnable
|
|
314
|
+
* @details Not runnable project are typically sub-projects
|
|
315
|
+
* @param runnable True if project should be runnable, false otherwise.
|
|
316
|
+
*/
|
|
317
|
+
setRunnable(runnable) {
|
|
318
|
+
this.runnable = runnable
|
|
319
|
+
? ProjEnvProjectRunnable.Runnable
|
|
320
|
+
: ProjEnvProjectRunnable.NotRunnable;
|
|
321
|
+
}
|
|
322
|
+
//------------------------------------------------------------------------------
|
|
323
|
+
/**
|
|
324
|
+
* @brief Checks if project is configured as runnable
|
|
325
|
+
* @return True if project is runnable, false otherwise
|
|
326
|
+
*/
|
|
327
|
+
isRunnable() {
|
|
328
|
+
return this.runnable === ProjEnvProjectRunnable.Runnable;
|
|
329
|
+
}
|
|
330
|
+
//------------------------------------------------------------------------------
|
|
331
|
+
/** @brief Function checks if project (this object) is valid.
|
|
332
|
+
* @return Returns TRUE when object is valid, otherwise FALSE.
|
|
333
|
+
*/
|
|
334
|
+
isValid() {
|
|
335
|
+
return this.getInvalidReason() === '';
|
|
336
|
+
}
|
|
337
|
+
//------------------------------------------------------------------------------
|
|
338
|
+
/** Function returns the reason, why is this project invalid.
|
|
339
|
+
* @return empty string in case the project is valid, the reason otherwise.
|
|
340
|
+
*/
|
|
341
|
+
getInvalidReason() {
|
|
342
|
+
if (!this.getId())
|
|
343
|
+
return this.format('The project ID is empty.\n$1', this.toString('\t'));
|
|
344
|
+
if (!this.getInstallDir())
|
|
345
|
+
return this.format('The project install directory is empty.\n$1', this.toString('\t'));
|
|
346
|
+
if (!this.getName())
|
|
347
|
+
return this.format('The project name is empty.\n$1', this.toString('\t'));
|
|
348
|
+
if (this.isRunnable()) {
|
|
349
|
+
if (!this.getVersion())
|
|
350
|
+
return this.format('The project version is empty.\n$1', this.toString('\t'));
|
|
351
|
+
if (this.isRegistered()) {
|
|
352
|
+
if (this.getLanguages().length === 0)
|
|
353
|
+
return this.format('The project languages are empty.\n$1', this.toString('\t'));
|
|
354
|
+
let langIndex = 1;
|
|
355
|
+
for (const lang of this.getLanguages()) {
|
|
356
|
+
if (lang === OaLanguage.undefined) {
|
|
357
|
+
return this.format('The project has an undefined language configured at position $1.\n$2', langIndex, this.toString('\t'));
|
|
358
|
+
}
|
|
359
|
+
langIndex++;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return '';
|
|
364
|
+
}
|
|
365
|
+
//---------------------------------------------------------------------------
|
|
366
|
+
/** Set the project directory
|
|
367
|
+
*/
|
|
368
|
+
setDir(pathStr) {
|
|
369
|
+
this.setInstallDir(path.dirname(pathStr));
|
|
370
|
+
const projId = path.basename(pathStr);
|
|
371
|
+
this.setId(projId);
|
|
372
|
+
this.setName(projId);
|
|
373
|
+
}
|
|
374
|
+
//------------------------------------------------------------------------------
|
|
375
|
+
/** @brief Function checks if the project is registered.
|
|
376
|
+
* @details Function does not check if the project physically exists.
|
|
377
|
+
* @return Returns TRUE when project is registered, otherwise FALSE.
|
|
378
|
+
*/
|
|
379
|
+
isRegistered() {
|
|
380
|
+
if (!this.getId())
|
|
381
|
+
this._errorHandler.exception(this.getInvalidReason());
|
|
382
|
+
return findProjectRegistryById(this.getId()) !== undefined;
|
|
383
|
+
}
|
|
384
|
+
//------------------------------------------------------------------------------
|
|
385
|
+
/**
|
|
386
|
+
* Registers the project with the WinCC OA system.
|
|
387
|
+
* The project must have a valid configuration file.
|
|
388
|
+
*
|
|
389
|
+
* **Retry Logic:**
|
|
390
|
+
* If the first registration attempt fails, automatically retries once.
|
|
391
|
+
* This handles transient failures from file system delays or temporary locks.
|
|
392
|
+
*
|
|
393
|
+
* @synchronized Function is not thread safe.
|
|
394
|
+
* @returns 0 when project is registered successfully, -1 if config not found, -2 on failure
|
|
395
|
+
*/
|
|
396
|
+
async registerProj() {
|
|
397
|
+
// set the name in case the user forgot it
|
|
398
|
+
if (!this.getName())
|
|
399
|
+
this.setName(this.getId());
|
|
400
|
+
if (!this.isValid())
|
|
401
|
+
this._errorHandler.exception(this.getInvalidReason());
|
|
402
|
+
const configFile = this.isRunnable() ? this.getConfigPath('config') : this.getDir();
|
|
403
|
+
if (!configFile) {
|
|
404
|
+
this._errorHandler.severe(`Cannot register project ${this.getId()}: Config file ${this.getDir() + ProjEnvProjectFileSysStruct.CONFIG_REL_PATH + 'config'} not found.`);
|
|
405
|
+
return -1;
|
|
406
|
+
}
|
|
407
|
+
let result;
|
|
408
|
+
try {
|
|
409
|
+
result = await this.tryToRegister(configFile);
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
this._errorHandler.warning(`First attempt to register project ${this.getId()} failed: ${error.toString()}`);
|
|
413
|
+
// retry once if registration fails
|
|
414
|
+
result = await this.tryToRegister(configFile);
|
|
415
|
+
}
|
|
416
|
+
if (result === 0) {
|
|
417
|
+
const registry = findProjectRegistryById(this.getId());
|
|
418
|
+
if (registry) {
|
|
419
|
+
this.initFromRegister(registry);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
this._errorHandler.warning(`Project ${this.getId()} registered successfully but could not find registry entry afterwards.`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return result ?? -2;
|
|
426
|
+
}
|
|
427
|
+
//------------------------------------------------------------------------------
|
|
428
|
+
/**
|
|
429
|
+
* Internal helper to register a project with the WinCC OA system.
|
|
430
|
+
*
|
|
431
|
+
* **Registration Process:**
|
|
432
|
+
* 1. Calls pmon's registerProject command
|
|
433
|
+
* 2. Polls registration status using isRegistered() with 100ms intervals
|
|
434
|
+
* 3. Waits up to 5 seconds (50 attempts) for registration to complete
|
|
435
|
+
* 4. Reloads project registry cache automatically via file watching
|
|
436
|
+
*
|
|
437
|
+
* **Async Behavior:**
|
|
438
|
+
* Uses async/await to properly wait between status checks, preventing
|
|
439
|
+
* busy-waiting and allowing the file system watcher to detect changes.
|
|
440
|
+
*
|
|
441
|
+
* @param configFile - Absolute path to the project's config file
|
|
442
|
+
* @returns 0 on success, -2 on timeout or failure
|
|
443
|
+
*/
|
|
444
|
+
async tryToRegister(configFile) {
|
|
445
|
+
const result = this.isRunnable()
|
|
446
|
+
? await this._pmon.registerProject(configFile, this.getVersion() ?? '')
|
|
447
|
+
: await this._pmon.registerSubProject(configFile);
|
|
448
|
+
console.log(`[${new Date().toISOString()}]`, 'Register project result:', result);
|
|
449
|
+
let counter = 0;
|
|
450
|
+
while (!this.isRegistered()) {
|
|
451
|
+
++counter;
|
|
452
|
+
if (counter > 50) {
|
|
453
|
+
console.warn(`[${new Date().toISOString()}] Registration of project '${this.getId()}' is taking longer than expected.`);
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
console.log(`[${new Date().toISOString()}] Waiting for project '${this.getId()}' to be registered...`);
|
|
457
|
+
await sleep(100);
|
|
458
|
+
}
|
|
459
|
+
return result ?? -2;
|
|
460
|
+
}
|
|
461
|
+
//------------------------------------------------------------------------------
|
|
462
|
+
/**
|
|
463
|
+
* Unregisters the project from the WinCC OA system.
|
|
464
|
+
* The project files remain unchanged; only the system registration is removed.
|
|
465
|
+
*
|
|
466
|
+
* **Retry Logic:**
|
|
467
|
+
* If the first unregistration attempt fails, automatically retries once.
|
|
468
|
+
* This handles transient failures from file system delays or temporary locks.
|
|
469
|
+
*
|
|
470
|
+
* @synchronized Function is not thread safe.
|
|
471
|
+
* @returns 0 when project is unregistered successfully, -2 on failure
|
|
472
|
+
*/
|
|
473
|
+
async unregisterProj() {
|
|
474
|
+
if (!this.getId())
|
|
475
|
+
this._errorHandler.exception(this.getInvalidReason());
|
|
476
|
+
let result;
|
|
477
|
+
try {
|
|
478
|
+
result = await this.tryToUnregister(this.getId());
|
|
479
|
+
}
|
|
480
|
+
catch (error) {
|
|
481
|
+
console.warn(`First attempt to register project ${this.getId()} failed:`, error);
|
|
482
|
+
// retry once if registration fails
|
|
483
|
+
result = await this.tryToUnregister(this.getId());
|
|
484
|
+
}
|
|
485
|
+
return result ?? -2;
|
|
486
|
+
}
|
|
487
|
+
//------------------------------------------------------------------------------
|
|
488
|
+
/**
|
|
489
|
+
* Internal helper to unregister a project from the WinCC OA system.
|
|
490
|
+
*
|
|
491
|
+
* **Unregistration Process:**
|
|
492
|
+
* 1. Calls pmon's unregisterProject command
|
|
493
|
+
* 2. Polls registration status using isRegistered() with 100ms intervals
|
|
494
|
+
* 3. Waits up to 0.5 seconds (5 attempts) for unregistration to complete
|
|
495
|
+
* 4. Reloads project registry cache automatically via file watching
|
|
496
|
+
*
|
|
497
|
+
* **Async Behavior:**
|
|
498
|
+
* Uses async/await to properly wait between status checks, preventing
|
|
499
|
+
* busy-waiting and allowing the file system watcher to detect changes.
|
|
500
|
+
*
|
|
501
|
+
* @param projId - The project ID to unregister
|
|
502
|
+
* @returns 0 on success, -2 on timeout or failure
|
|
503
|
+
*/
|
|
504
|
+
async tryToUnregister(projId) {
|
|
505
|
+
const result = await this._pmon.unregisterProject(projId);
|
|
506
|
+
console.log(`[${new Date().toISOString()}]`, 'Register project result:', result);
|
|
507
|
+
let counter = 0;
|
|
508
|
+
while (this.isRegistered()) {
|
|
509
|
+
++counter;
|
|
510
|
+
if (counter > 5) {
|
|
511
|
+
console.warn(`[${new Date().toISOString()}] UN-Registration of project ${this.getId()} is taking longer than expected.`);
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
await sleep(100);
|
|
515
|
+
}
|
|
516
|
+
return result ?? -2;
|
|
517
|
+
}
|
|
518
|
+
//------------------------------------------------------------------------------
|
|
519
|
+
/** @brief Function checks if the project physically exists.
|
|
520
|
+
* @details Does not check if is registered.
|
|
521
|
+
* @return Returns TRUE when project is exists, otherwise FALSE.
|
|
522
|
+
*/
|
|
523
|
+
exists() {
|
|
524
|
+
const p = this.getDir();
|
|
525
|
+
return p != '' && fs.existsSync(p);
|
|
526
|
+
}
|
|
527
|
+
//------------------------------------------------------------------------------
|
|
528
|
+
/** @brief Function convert this object to string variable.
|
|
529
|
+
* @details This is helper for debugging in std log.
|
|
530
|
+
* @param prefix Prefix for each new line.
|
|
531
|
+
* @return Object formatted in string variable.
|
|
532
|
+
*/
|
|
533
|
+
toString(prefix = '') {
|
|
534
|
+
let ret = '';
|
|
535
|
+
ret = prefix + this.format('Project ID: $1\n', this.getId());
|
|
536
|
+
ret += prefix + this.format('Name: $1\n', this.getName());
|
|
537
|
+
const instDir = this.getInstallDir();
|
|
538
|
+
if (instDir !== undefined)
|
|
539
|
+
ret += prefix + this.format('Install directory: $1\n', instDir);
|
|
540
|
+
ret += prefix + this.format('Version: $1', this.getVersion() ?? '');
|
|
541
|
+
return ret;
|
|
542
|
+
}
|
|
543
|
+
//------------------------------------------------------------------------------
|
|
544
|
+
/** @brief Function removes (physical) and un-register the project.
|
|
545
|
+
*
|
|
546
|
+
* @synchronized Function is not thread safe.
|
|
547
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
548
|
+
* @warning Work only with locale host.
|
|
549
|
+
*/
|
|
550
|
+
async deleteProj() {
|
|
551
|
+
const dirPath = this.getDir();
|
|
552
|
+
this.unregisterProj();
|
|
553
|
+
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
554
|
+
return fs.existsSync(dirPath) ? -1 : 0;
|
|
555
|
+
}
|
|
556
|
+
//------------------------------------------------------------------------------
|
|
557
|
+
/**
|
|
558
|
+
* @brief Starts the project and waits for completion
|
|
559
|
+
* @param timeOut Seconds to wait for project startup (0 = don't wait)
|
|
560
|
+
* @return Error code:
|
|
561
|
+
* 0 = Success
|
|
562
|
+
* -1 = Start failed
|
|
563
|
+
* -2 = Before-start hook failed
|
|
564
|
+
* -3 = After-start hook failed
|
|
565
|
+
* -4 = Wait timeout
|
|
566
|
+
* -5 = After-started hook failed
|
|
567
|
+
*/
|
|
568
|
+
async start() {
|
|
569
|
+
this._pmon.startPmonOnly(this.getName());
|
|
570
|
+
const result = await this._pmon.startProject(this.getId());
|
|
571
|
+
return result ?? -1;
|
|
572
|
+
}
|
|
573
|
+
//------------------------------------------------------------------------------
|
|
574
|
+
/** @brief Function stops the Project.
|
|
575
|
+
* @param timeOut for stopping the project.
|
|
576
|
+
* @details But the pmon are still on living after them. Stop only all project managers.
|
|
577
|
+
* With default parameter the function does not wait till project stopped.
|
|
578
|
+
When the function is called with parameter >= 0 it waits the amount in seconds till the Project has the State Down
|
|
579
|
+
*
|
|
580
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
581
|
+
*/
|
|
582
|
+
async stop() {
|
|
583
|
+
const result = await this._pmon.stopProject(this.getId());
|
|
584
|
+
return result ?? -1;
|
|
585
|
+
}
|
|
586
|
+
//------------------------------------------------------------------------------
|
|
587
|
+
/** @brief Function restarts the project.
|
|
588
|
+
* @param timeOut for starting the project.
|
|
589
|
+
* @details Start the project via pmon interface.
|
|
590
|
+
* Function start also pmon self, when is not running.
|
|
591
|
+
* The function does wait till project is restarted.
|
|
592
|
+
* When the function is called with *timeOut* > 0 it waits the amount in seconds till the Project has the State Monitoring again.
|
|
593
|
+
*
|
|
594
|
+
* @return Error code.
|
|
595
|
+
* value | description
|
|
596
|
+
* ------|------------
|
|
597
|
+
* 0 | Success.
|
|
598
|
+
* -1 | Pmon does not accept start command. Ex. NW-problem.
|
|
599
|
+
* -2 | Could not restart project within timeOut.
|
|
600
|
+
* -3 | Project could not be stopped within timeOut
|
|
601
|
+
*/
|
|
602
|
+
async restart() {
|
|
603
|
+
const result = this._pmon.restartProject(this.getId());
|
|
604
|
+
return result ?? -1;
|
|
605
|
+
}
|
|
606
|
+
//------------------------------------------------------------------------------
|
|
607
|
+
/** @brief Function kills manager at the given idx.
|
|
608
|
+
* @details Index begin with 1. Pmon has idx 0 in progs file.
|
|
609
|
+
*
|
|
610
|
+
* @param manIdx Manager index in the pmon table.
|
|
611
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
612
|
+
*/
|
|
613
|
+
async killManager(manIdx) {
|
|
614
|
+
const result = await this._pmon.killManager(this.getId(), manIdx);
|
|
615
|
+
return result ?? -1;
|
|
616
|
+
}
|
|
617
|
+
//------------------------------------------------------------------------------
|
|
618
|
+
/** @brief Function start pmon for this project.
|
|
619
|
+
* @details Pmon can be started locally only.
|
|
620
|
+
* @return Error code.
|
|
621
|
+
* value | description
|
|
622
|
+
* ------|------------
|
|
623
|
+
* 0 | Success.
|
|
624
|
+
* -1 | Cannot start pmon. See log file for more information.
|
|
625
|
+
* -2 | Cannot connect to pmon.
|
|
626
|
+
*/
|
|
627
|
+
async startPmon() {
|
|
628
|
+
const result = await this._pmon.startPmonOnly(this.getId());
|
|
629
|
+
return result ?? -1;
|
|
630
|
+
}
|
|
631
|
+
//------------------------------------------------------------------------------
|
|
632
|
+
/**
|
|
633
|
+
* @brief Function stop the Pmon.
|
|
634
|
+
*
|
|
635
|
+
* @details The function stops also the project with it.
|
|
636
|
+
* @param timeout Time in s.ms to wait for pmon stop
|
|
637
|
+
* @return Returns 0 when successful, otherwise -1.
|
|
638
|
+
*/
|
|
639
|
+
async stopPmon(timeout) {
|
|
640
|
+
if (timeout !== undefined) {
|
|
641
|
+
timeout = timeout * 1000;
|
|
642
|
+
}
|
|
643
|
+
const result = await this._pmon.stopProjectAndPmon(this.getId(), timeout);
|
|
644
|
+
return result ?? -1;
|
|
645
|
+
}
|
|
646
|
+
//------------------------------------------------------------------------------
|
|
647
|
+
/** @brief Function checks if pmon is running.
|
|
648
|
+
* @details Checks only pmon, does not check if the pmon is running for this project.
|
|
649
|
+
* It can be used to general check, if the pmon with given host, port is
|
|
650
|
+
* running. Be sure that you have nw-connection to the remote pmon-host.
|
|
651
|
+
* @return Returns TRUE when pmon is running on the host, otherwise FALSE.
|
|
652
|
+
*/
|
|
653
|
+
async isPmonRunning() {
|
|
654
|
+
const result = await this._pmon.getStatus(this.getId());
|
|
655
|
+
return result === ProjEnvPmonStatus.Running;
|
|
656
|
+
}
|
|
657
|
+
//------------------------------------------------------------------------------
|
|
658
|
+
/** @brief Function checks if is the pmon running.
|
|
659
|
+
* @return Returns TRUE when pmon with 'this' project is running on the host, otherwise FALSE.
|
|
660
|
+
*/
|
|
661
|
+
isRunning() {
|
|
662
|
+
return this.getStatus() === ProjEnvProjectState.Monitoring;
|
|
663
|
+
}
|
|
664
|
+
//------------------------------------------------------------------------------
|
|
665
|
+
/** Returns current project status.
|
|
666
|
+
@details The function returns the project status. The status is stored in the pmon table.
|
|
667
|
+
@return Project status.
|
|
668
|
+
@see ProjEnvProjectState.
|
|
669
|
+
*/
|
|
670
|
+
getStatus() {
|
|
671
|
+
return this.getProjectStatus()?.project?.status;
|
|
672
|
+
}
|
|
673
|
+
//------------------------------------------------------------------------------
|
|
674
|
+
/** Function checks if the project is in emergency mode.
|
|
675
|
+
*
|
|
676
|
+
* @returns true if emergency mode is active, false otherwise
|
|
677
|
+
*/
|
|
678
|
+
isEmergencyMode() {
|
|
679
|
+
return this.getProjectStatus()?.project?.emergency;
|
|
680
|
+
}
|
|
681
|
+
//------------------------------------------------------------------------------
|
|
682
|
+
/** Function checks if the project use demo license.
|
|
683
|
+
*
|
|
684
|
+
* @returns true if demo mode-license is active, false otherwise
|
|
685
|
+
*/
|
|
686
|
+
isDemoMode() {
|
|
687
|
+
return this.getProjectStatus()?.project?.demo;
|
|
688
|
+
}
|
|
689
|
+
//------------------------------------------------------------------------------
|
|
690
|
+
/** @brief Function activates a debug flag
|
|
691
|
+
* @details Sends the "activate debug flag(s)" command during running time
|
|
692
|
+
* @param manIdx Manager index in the pmon table.
|
|
693
|
+
* @param dbgFlags debug parameter e.g.: -dbg 2 or -report ALL
|
|
694
|
+
* @return Returns 0 when flag was set, otherwise returns -1 or -2.
|
|
695
|
+
*/
|
|
696
|
+
async sendDbgFlag(manIdx, dbgFlags) {
|
|
697
|
+
const result = await this._pmon.sendDebugFlag(dbgFlags, this.getId(), manIdx);
|
|
698
|
+
return result ?? -1;
|
|
699
|
+
}
|
|
700
|
+
//------------------------------------------------------------------------------
|
|
701
|
+
/** @brief Function starts manager at the given idx.
|
|
702
|
+
* @details Index begin with 1. Pmon has idx 0 in progs file.
|
|
703
|
+
*
|
|
704
|
+
* @param manIdx Manager index in the pmon table.
|
|
705
|
+
* @param timeOut Time to wait for expected manager state.
|
|
706
|
+
* @param state Expected manager state.
|
|
707
|
+
* @return Error code. Returns 0 when . Otherwise -1.
|
|
708
|
+
*/
|
|
709
|
+
async startManager(manIdx) {
|
|
710
|
+
const result = await this._pmon.startManager(this.getId(), manIdx);
|
|
711
|
+
return result ?? -1;
|
|
712
|
+
}
|
|
713
|
+
//------------------------------------------------------------------------------
|
|
714
|
+
/** @brief Function stopped manager at the given idx.
|
|
715
|
+
* @details Index begin with 1. Pmon has idx 0 in progs file.
|
|
716
|
+
*
|
|
717
|
+
* @param manIdx Manager index in the pmon table.
|
|
718
|
+
* @param timeOut Time to wait for expected manager state.
|
|
719
|
+
* @param state Expected manager state.
|
|
720
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
721
|
+
*/
|
|
722
|
+
async stopManager(manIdx) {
|
|
723
|
+
const result = await this._pmon.stopManager(this.getId(), manIdx);
|
|
724
|
+
return result ?? -1;
|
|
725
|
+
}
|
|
726
|
+
//------------------------------------------------------------------------------
|
|
727
|
+
/** @brief Function deletes manager at the given idx.
|
|
728
|
+
* @param manIdx Manager index in the pmon table.
|
|
729
|
+
* Index begin with 1. Pmon has idx 0 in progs file.
|
|
730
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
731
|
+
*/
|
|
732
|
+
async deleteManager(manIdx) {
|
|
733
|
+
const result = await this._pmon.removeManager(this.getId(), manIdx);
|
|
734
|
+
return result ?? -1;
|
|
735
|
+
}
|
|
736
|
+
//------------------------------------------------------------------------------
|
|
737
|
+
/** @brief Function inserts manager at the given idx.
|
|
738
|
+
* @details Index begin with 1. Pmon has index 0 in progs file.
|
|
739
|
+
* @param opts Manager options.
|
|
740
|
+
* @param manIdx Manager index in the pmon table.
|
|
741
|
+
* Index begin with 1. Pmon has idx 0 in progs file.
|
|
742
|
+
* @return Error code. Returns -1 when failed, -2 when pmon is not reachable, otherwise returns the index of the inserted manager.
|
|
743
|
+
*/
|
|
744
|
+
async insertManager(opts, manIdx = undefined) {
|
|
745
|
+
const result = await this._pmon.insertManagerAt(opts, this.getId(), manIdx);
|
|
746
|
+
return result ?? -1;
|
|
747
|
+
}
|
|
748
|
+
//------------------------------------------------------------------------------
|
|
749
|
+
/** @brief Function changes manager options at the given index.
|
|
750
|
+
* @details Index begin with 1. Pmon has index 0 in progs file.
|
|
751
|
+
* @param manIdx Manager index in the pmon table.
|
|
752
|
+
* Index begin with 1. Pmon has index 0 in progs file.
|
|
753
|
+
* @param opts Manager options.
|
|
754
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
755
|
+
*/
|
|
756
|
+
async changeManagerOptions(manIdx, opts) {
|
|
757
|
+
const result = await this._pmon.setManagerOptionsAt(opts, this.getId(), manIdx);
|
|
758
|
+
return result ?? -1;
|
|
759
|
+
}
|
|
760
|
+
//------------------------------------------------------------------------------
|
|
761
|
+
/** @brief Function changes manager start mode at the given index.
|
|
762
|
+
* @details Index begin with 1. Pmon has index 0 in progs file.
|
|
763
|
+
* @param manIdx Manager index in the pmon table.
|
|
764
|
+
* Index begin with 1. Pmon has index 0 in progs file.
|
|
765
|
+
* @param startMode Start mode of the manager.
|
|
766
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
767
|
+
*/
|
|
768
|
+
async changeManagerStartMode(manIdx, startMode) {
|
|
769
|
+
const current = this.getManagerOptions(manIdx);
|
|
770
|
+
if (!current)
|
|
771
|
+
return -1;
|
|
772
|
+
current.startMode = startMode;
|
|
773
|
+
return this.changeManagerOptions(manIdx, current);
|
|
774
|
+
}
|
|
775
|
+
//------------------------------------------------------------------------------
|
|
776
|
+
/** @brief Function changes manager start options at the given index.
|
|
777
|
+
* @details Index begin with 1. Pmon has index 0 in progs file.
|
|
778
|
+
* @param manIdx Manager index in the pmon table.
|
|
779
|
+
* Index begin with 1. Pmon has index 0 in progs file.
|
|
780
|
+
* @param startOptions Start options of the manager.
|
|
781
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
782
|
+
*/
|
|
783
|
+
async changeManagerStartOptions(manIdx, startOptions) {
|
|
784
|
+
const current = this.getManagerOptions(manIdx);
|
|
785
|
+
if (!current)
|
|
786
|
+
return -1;
|
|
787
|
+
current.startOptions = startOptions;
|
|
788
|
+
return this.changeManagerOptions(manIdx, current);
|
|
789
|
+
}
|
|
790
|
+
//------------------------------------------------------------------------------
|
|
791
|
+
/** @brief Function returns manager options at the given index.
|
|
792
|
+
* @details Index begin with 1. Pmon has index 0 in progs file.
|
|
793
|
+
* @param idx Manager index in the pmon table.
|
|
794
|
+
* @return Manager options. Returns NULL when failed.
|
|
795
|
+
*/
|
|
796
|
+
getManagerOptions(idx) {
|
|
797
|
+
if (idx < 0)
|
|
798
|
+
return null;
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
//------------------------------------------------------------------------------
|
|
802
|
+
/** @brief Function returns list of all manager options.
|
|
803
|
+
* @details The function returns the list of all manager options.
|
|
804
|
+
* The list is stored in the pmon table.
|
|
805
|
+
* @return List of ProjEnvManagerOptions. In case of error is empty dyn_anytype.
|
|
806
|
+
*/
|
|
807
|
+
getListOfManagerOptions() {
|
|
808
|
+
return [];
|
|
809
|
+
}
|
|
810
|
+
//------------------------------------------------------------------------------
|
|
811
|
+
/** @brief Function returns project status.
|
|
812
|
+
* @details The function returns the project status.
|
|
813
|
+
* The status is stored in the pmon table.
|
|
814
|
+
* @return Project status ProjEnvPmonProjectStatus. In case of error returns undefined.
|
|
815
|
+
*/
|
|
816
|
+
getProjectStatus() {
|
|
817
|
+
return undefined;
|
|
818
|
+
}
|
|
819
|
+
//------------------------------------------------------------------------------
|
|
820
|
+
/**
|
|
821
|
+
* @brief Function returns manager info as mapping.
|
|
822
|
+
* @param idx Manager index in the pmon table.
|
|
823
|
+
* Index begin with 1. Pmon has idx 0 in progs file.
|
|
824
|
+
* @return Manager information ProjEnvManagerInfo. In case of error returns empty ProjEnvManagerInfo.
|
|
825
|
+
*/
|
|
826
|
+
getManagerInfo(idx) {
|
|
827
|
+
return this.getProjectStatus()?.managers?.[idx];
|
|
828
|
+
}
|
|
829
|
+
//------------------------------------------------------------------------------
|
|
830
|
+
/**
|
|
831
|
+
* @brief Function returns manager state ProjEnvManagerState.
|
|
832
|
+
* @param idx Manager index in the pmon table.
|
|
833
|
+
* Index begin with 1. Pmon has idx 0 in progs file.
|
|
834
|
+
* @return Manager state. See also ProjEnvManagerState.
|
|
835
|
+
*/
|
|
836
|
+
getManagerStatus(idx) {
|
|
837
|
+
return this.getProjectStatus()?.managers?.[idx]?.state;
|
|
838
|
+
}
|
|
839
|
+
//------------------------------------------------------------------------------
|
|
840
|
+
/** @brief Function insert value to project config file.
|
|
841
|
+
* @param value Value to insert into the config file
|
|
842
|
+
* @param key Config key under which to insert the value
|
|
843
|
+
* @param section Config section name (defaults to "general")
|
|
844
|
+
* @param configFile Name of config file (defaults to "config")
|
|
845
|
+
* @return Error code:
|
|
846
|
+
* 0 = Success
|
|
847
|
+
* -1 = Failed to insert value
|
|
848
|
+
*/
|
|
849
|
+
insertCfgValue(value, key, section = 'general', configFile = 'config') {
|
|
850
|
+
const cfg = new ProjEnvProjectConfig(this.getConfigPath(configFile));
|
|
851
|
+
if (cfg.insertValue(value, key, section))
|
|
852
|
+
return -1;
|
|
853
|
+
return 0;
|
|
854
|
+
}
|
|
855
|
+
//------------------------------------------------------------------------------
|
|
856
|
+
/** @brief Function set value to project config file.
|
|
857
|
+
* @param value Value to set in the config file
|
|
858
|
+
* @param key Config key to set
|
|
859
|
+
* @param section Config section name (defaults to "general")
|
|
860
|
+
* @param configFile Name of config file (defaults to "config")
|
|
861
|
+
* @return Error code:
|
|
862
|
+
* 0 = Success
|
|
863
|
+
* -1 = Failed to set value
|
|
864
|
+
*/
|
|
865
|
+
setCfgValue(value, key, section = 'general', configFile = 'config') {
|
|
866
|
+
const cfg = new ProjEnvProjectConfig(this.getConfigPath(configFile));
|
|
867
|
+
if (cfg.setValue(value, key, section))
|
|
868
|
+
return -1;
|
|
869
|
+
return 0;
|
|
870
|
+
}
|
|
871
|
+
//------------------------------------------------------------------------------
|
|
872
|
+
/** @brief Function deletes value in project config file.
|
|
873
|
+
* @param value Value to delete from config
|
|
874
|
+
* @param key Config key to delete
|
|
875
|
+
* @param section Config section name (defaults to "general")
|
|
876
|
+
* @param configFile Name of config file (defaults to "config")
|
|
877
|
+
* @return Error code:
|
|
878
|
+
* 0 = Success
|
|
879
|
+
* -1 = Failed to delete value
|
|
880
|
+
*/
|
|
881
|
+
deleteCfgValue(value, key, section = 'general', configFile = 'config') {
|
|
882
|
+
const cfg = new ProjEnvProjectConfig(this.getConfigPath(configFile));
|
|
883
|
+
if (cfg.deleteValue(value, key, section))
|
|
884
|
+
return -1;
|
|
885
|
+
return 0;
|
|
886
|
+
}
|
|
887
|
+
//------------------------------------------------------------------------------
|
|
888
|
+
/** @brief Function deletes entry in config file, used when only the key is known - but not the value. Deletes only one entry, from top to bottom
|
|
889
|
+
* @param key Config key.
|
|
890
|
+
* @param section Config section.
|
|
891
|
+
* @param configFile Config file.
|
|
892
|
+
* @return Error code. Returns 0 when successful. Otherwise -1.
|
|
893
|
+
*/
|
|
894
|
+
deleteCfgEntry(key, section = 'general', configFile = 'config') {
|
|
895
|
+
const cfg = new ProjEnvProjectConfig(this.getConfigPath(configFile));
|
|
896
|
+
if (cfg.deleteEntry(key, section))
|
|
897
|
+
return -1;
|
|
898
|
+
return 0;
|
|
899
|
+
}
|
|
900
|
+
//------------------------------------------------------------------------------
|
|
901
|
+
/** Returns ID formatted for logs.
|
|
902
|
+
* It includes few more information, like host name, which makes the log analysis
|
|
903
|
+
* for parallel (multiple nodes) executions more easy.
|
|
904
|
+
*/
|
|
905
|
+
getIdInLogFormat() {
|
|
906
|
+
const logId = this.getId();
|
|
907
|
+
return logId;
|
|
908
|
+
}
|
|
909
|
+
//---------------------------------------------------------------------------
|
|
910
|
+
/** Returns default project location (directory).
|
|
911
|
+
* @details The default project location is the last used project directory.
|
|
912
|
+
* If the last used project directory is not set, the default location is:
|
|
913
|
+
* - Windows: C:\WinCC_OA_Proj\
|
|
914
|
+
* - Linux: /opt/WinCC_OA_Proj/
|
|
915
|
+
* @return Default project location (directory).
|
|
916
|
+
*/
|
|
917
|
+
getDefaultInstallDir() {
|
|
918
|
+
// TODO use getLastUsedProjectDir() from ProjEnvProjectRegistry here
|
|
919
|
+
const defaultDirectory = ''; // placeholder for paGetLastUsedProjDir()
|
|
920
|
+
if (defaultDirectory)
|
|
921
|
+
return defaultDirectory;
|
|
922
|
+
// platform-specific defaults could be returned here
|
|
923
|
+
return '';
|
|
924
|
+
}
|
|
925
|
+
//---------------------------------------------------------------------------
|
|
926
|
+
/** @brief Function checks if the given file path belongs to this project.
|
|
927
|
+
* @param filePath Full path to the file to check.
|
|
928
|
+
* @return Returns TRUE if the file belongs to this project, otherwise FALSE.
|
|
929
|
+
*/
|
|
930
|
+
isProjectFile(filePath) {
|
|
931
|
+
const projDir = this.getDir();
|
|
932
|
+
if (!projDir)
|
|
933
|
+
return false;
|
|
934
|
+
const normalizedProjDir = path.normalize(projDir).toLowerCase();
|
|
935
|
+
const normalizedFilePath = path.normalize(filePath).toLowerCase();
|
|
936
|
+
return normalizedFilePath.startsWith(normalizedProjDir);
|
|
937
|
+
}
|
|
938
|
+
//------------------------------------------------------------------------------
|
|
939
|
+
/** @brief Function returns sub-projects of this project.
|
|
940
|
+
* @details In case the project does not contains sub-projects, the function returns an empty array.
|
|
941
|
+
* @return Array of sub-projects.
|
|
942
|
+
*/
|
|
943
|
+
getSubProjects() {
|
|
944
|
+
return this._subProjects;
|
|
945
|
+
}
|
|
946
|
+
//------------------------------------------------------------------------------
|
|
947
|
+
/** @brief Function checks if the project is protected.
|
|
948
|
+
* @details A project is considered protected if it has a password set in the progs file.
|
|
949
|
+
* @returns true if the project is protected, false otherwise.
|
|
950
|
+
*/
|
|
951
|
+
isProtected() {
|
|
952
|
+
if (!this.isRunnable()) {
|
|
953
|
+
return false; // sub-projects are not protected
|
|
954
|
+
}
|
|
955
|
+
if (this._pmon.getCredentials() != null)
|
|
956
|
+
return true; // user name or pw has been set
|
|
957
|
+
const progsPath = this.getConfigPath('progs');
|
|
958
|
+
if (!progsPath || fs.existsSync(progsPath)) {
|
|
959
|
+
return false; // progs file does not exist
|
|
960
|
+
}
|
|
961
|
+
const content = fs.readFileSync(progsPath, 'utf-8');
|
|
962
|
+
if (content.indexOf('auth "" ""') !== -1)
|
|
963
|
+
return false; // user name or pw has not been set in progs file
|
|
964
|
+
else
|
|
965
|
+
return true; // user name or pw has been set in progs file
|
|
966
|
+
}
|
|
967
|
+
//------------------------------------------------------------------------------
|
|
968
|
+
/** @brief Function logs into the project using the provided credentials.
|
|
969
|
+
* @details This function logs into the project using the provided username and password.
|
|
970
|
+
* It verifies the credentials against the project's pmon component.
|
|
971
|
+
* @param username The username to use for login.
|
|
972
|
+
* @param password The password to use for login.
|
|
973
|
+
*/
|
|
974
|
+
async loginPmon(username, password) {
|
|
975
|
+
if (!this.isRunnable()) {
|
|
976
|
+
this._errorHandler.exception(`Project ${this.getId()} is not runnable and cannot be logged into.`);
|
|
977
|
+
}
|
|
978
|
+
const cred = new PmonComponentCredential(username, password);
|
|
979
|
+
const rc = this._pmon.verifyCredentials(this.getId(), cred);
|
|
980
|
+
if ((await rc) === false) {
|
|
981
|
+
this._errorHandler.exception(`Failed to login to project ${this.getId()}: Invalid credentials`);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
//------------------------------------------------------------------------------
|
|
985
|
+
/** @brief Function sets the credentials for the project.
|
|
986
|
+
* @details This function sets the credentials for the project in the pmon component.
|
|
987
|
+
* @param username The username to set.
|
|
988
|
+
* @param password The password to set.
|
|
989
|
+
* @return Error code:
|
|
990
|
+
* 0 = Success
|
|
991
|
+
* -1 = Failed to set credentials
|
|
992
|
+
*/
|
|
993
|
+
async setPmonCredentials(username, password) {
|
|
994
|
+
if (!this.isRunnable()) {
|
|
995
|
+
this._errorHandler.exception(`Project ${this.getId()} is not runnable and cannot used credentials.`);
|
|
996
|
+
}
|
|
997
|
+
const cred = new PmonComponentCredential(username, password);
|
|
998
|
+
const code = this._pmon.saveCredentials(this.getId(), cred);
|
|
999
|
+
if ((await code) !== 0) {
|
|
1000
|
+
this._errorHandler.exception(`Failed to set credentials for project ${this.getId()}`);
|
|
1001
|
+
}
|
|
1002
|
+
return 0;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
const sleep = async (ms) => {
|
|
1006
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1007
|
+
};
|
|
1008
|
+
//# sourceMappingURL=ProjEnvProject.js.map
|