d2aura
v26.0.41
Published
D2 AURA - Advanced User Interface Resource Architecture
Readme
d2aura
D2 AURA — Advanced User Interface Resource Architecture.
A TypeScript + React component and API library for building web front-ends on top of the
Ipesoft D2000 SCADA system. It wraps the low-level D2000 web API (d2jsapi) into D2000-aware
application scaffolding (connection lifecycle, authentication, RPC with the D2000 error contract,
CRUD over D2000 Event objects) and a set of Ant Design based components — data grids, editors,
charts, advanced filters, file pickers, web-push management and the full EDA Manager
(energy data bank vectors, groups, scenarios and the EDA-L editor).
Installation
yarn add d2aurareact and react-dom (18.x) must be provided by the application. The D2000 stack packages
d2jsapi, d2core, d2coreui, antd and @ant-design/pro-layout are regular dependencies of
d2aura and are installed with it.
Usage
Imports are bare subpath specifiers — the package has no barrel entry point, import exactly the module you need:
import "d2coreui/style/index.less"
import "flexlayout-react/style/light.scss"
import "d2coreui/style/flexLayout/flexLayout.scss"
import "d2coreui/style/splitPane/splitPane.css"
import AbstractApp, {AbstractAppProps, AbstractAppState} from "d2aura/coreui/abstractApp";
import AbstractApi from "d2aura/api/abstractApi";Application shell
Subclass AbstractApp. It creates the D2WebApiClient, wires the error / service-message /
password-change handlers, connects, and calls back when the connection is up — that is where the
application builds its API objects. It also provides the About and Change-Password modals and the
loading spinner.
export default class App extends AbstractApp<AbstractAppProps, AbstractAppState> {
// build API objects on connect, render ProLayout + routes
}API layer
api/abstractApi— base for all API classes.callRpc()is the central RPC wrapper: it appends the D2000 convention trailing parametersisOk(BOOL) +errorMessage(TEXT), decodes them and automatically shows an error dialog unlessskipCheckError*is set. It also caches structure definitions and converts unival records. Call RPCs through this rather than throughd2jsapidirectly.api/abstractEntityApi— CRUD over a D2000 Event object: pass(entityClassName, eventName, structureDefinitionName, entityFields)and get create / list / subscribe helpers that marshal rows to and from D2000 unival structures.- Specialised APIs:
api/archiveApi,api/advancedFilterApi,api/edaApi,api/eda/edaManagerApi,api/webPush/webPushApi.
Conventions
- D2000 booleans are not JS booleans — convert with
D2BooleanUtils(api/util/d2Boolean). - Time uses
UnixTime(d2core/types/unixTime), notDate. - i18n: strings are wrapped with
i18n(...)fromd2core/i18n/i18n; the translation JSON ships incore/i18n/(d2aura.sk.json,d2aura.en.json, …) and is loaded dynamically by the app.
Build configuration of the application
The package is plain ES modules and builds with webpack 5 and vite alike. Its web workers (the EDA-L
analysis and monaco's editor.worker) are standard new Worker(new URL(..., import.meta.url)) entry points both
bundlers pick up on their own — no worker plugin and no Node polyfill is needed. An application that configures
monaco's workers itself (MonacoEnvironment) keeps its own setup.
webpack — emitting chunks into a subdirectory (chunkFilename: "scripts/[name].js") requires
output.publicPath: "auto"; with a relative "./" a worker looks for its chunks relative to itself. An existing
ThreadsPlugin / MonacoWebpackPlugin may stay, it is just no longer necessary.
vite — the dev server serves the workers of d2aura and d2coreui from node_modules as they are, so their
CommonJS dependencies (threads, pdfmake, lodash) have to be pre-bundled: add the worker files to optimizeDeps.entries
(node_modules/d2coreui/components/grid/export/worker/*.js, and for the EDA Manager
node_modules/d2aura/coreui/components/edaManagerComponent/dialogs/edaLanguage/{worker/edaWorker,monacoEditorWorker}.js).
A production build needs nothing. See app_template/vite.config.ts of the d2aura repository.
Dynamic imports of the translation JSON return a module namespace — pass its .default to i18n.translator.add.
EDA Manager — D2000 server-side prerequisites
d2configuration/edaManager/ contains the D2000 object XML exports (DB.*, DBC_*, E.*, EM.EVH,
I.*, SD.*, SV.*) for the EDA Manager's server-side objects. All six steps below are required —
the EDA Manager does not work with the import alone.
E.EDA_Connect_EM exists only to bring the EDA connection unit into EM.EVH, so that the EDA API is usable
from the EDA Manager's events.
1. The server must have EDA installed
The exports reference the standard D2000 EDA API — the EDA_* external functions (EDA_CreateVectorRec,
EDA_ReadValuesFromVektorRec, EDA_SetFunctionRec, …) and the SD.EDA_* parameter structures. These are not
shipped here; they must already exist on the target server, otherwise the import fails with object reference
can not be found. The EDA connection unit is not among them — its name is application-specific, see step 3.
2. Import the objects
Import the whole d2configuration/edaManager/ directory in D2000 CNF in one go — dependencies are
resolved against the objects in the same import, so no particular order is needed.
3. Point E.EDA_Connect_EM at the EDA connection unit
This is the one export you must edit, and it is easy to forget. E.EDA_Connect_EM ships with its UNIT
line commented out and the unit name left as a #…# placeholder — the unit that logs in to the EDA server is
application-specific, and no name can be guaranteed to exist on the target server, so the export carries no
reference to it. The #EDIT marker is the spot:
; @SUPPRESS unusedVariable
#EDIT
; UNIT (#E.EDA_Connect_Unit#) _UNITReplace the placeholder with the unit on your server that performs the EDA initialisation (login to the EDA
server), uncomment the UNIT line and remove the #EDIT line:
; @SUPPRESS unusedVariable
UNIT (E.My_EDA_Connect_Unit) _UNITKeep the @SUPPRESS unusedVariable line above it: the unit is included for its initialisation, _UNIT is
never referenced.
Left commented out, everything imports and starts cleanly, but no EDA call from the EDA Manager's events ever reaches the EDA server.
4. Configure and start EM.EVH
All E.* objects have EM.EVH as their parent and come up with it. The shipped export is deliberately
unconfigured — START is False, path and working directory are empty; the command line is
/F60 /FI0 /TP /DW /WEM. Configure it in CNF and start it.
5. Configure DBC_EM_EDA
DBC_EM_EDA is a DB_CONNECT under SELF.DBM and must be pointed at the EDA database — the same schema
the EDA server uses.
6. Implement I.EM_INTERFACE and fill SV.EM_INTERFACE
I.EM_INTERFACE is the seam between the EDA Manager and the hosting application. Everything the EDA Manager
cannot decide for itself — ID allocation and code generation for new vectors, groups and scenarios — goes
through it, so that the shipped objects carry no reference to any application object.
Implement it in an EVENT object of your own:
IMPLEMENTATION I.EM_INTERFACE
IMPLEMENTATION RPC PROCEDURE I.EM_INTERFACE^GetVectorID(INT _nextId, BOOL _isOk)
; allocate the next free EDA vector ID
EXCEPTION_HANDLER
_isOk := @FALSE
END GetVectorID
BEGIN
PRAGMA "ENABLE_INOUT_BY_REF"
ENDThe procedures return their results through INOUT parameters, so the implementing script needs
PRAGMA "ENABLE_INOUT_BY_REF".
All seven procedures must be implemented — GetVectorID, GetGroupID, GetScenarioID,
GetVectorScenarioID, GetVectorCode, GetGroupCode, GetScenarioCode. The full skeleton is in the object's own description
(I.EM_INTERFACE.xml).
Then set the two columns of SV.EM_INTERFACE (shipped with no start values):
| Column | Value |
|---|---|
| Event | your implementing EVENT object |
| Process | the .EVH process that event runs on |
Without them the EDA Manager cannot create vectors, groups or scenarios.
Do not edit the exports
EM.EVH, DBC_EM_EDA, SV.EM_INTERFACE and the UNIT line of E.EDA_Connect_EM are the only
configuration points. Everything else (E.*, SD.*, DB.*, I.EM_INTERFACE)
is a static export that must be imported as-is: editing the E.* scripts forks the EDA Manager and the next
d2aura upgrade will overwrite it. Application-specific behaviour belongs in your I.EM_INTERFACE
implementation.
Package contents
The published package is the compiled output (lib/esm): JavaScript + .d.ts declarations plus the
.less/.scss/.css styles, coreui/images/ and d2configuration/. The TypeScript sources are
not published.
Versioning
Flat 26.0.x scheme — the major version tracks the D2000 platform / d2jsapi 26 line. See
CHANGELOG.md.
