Skip to content
mihai-stfc edited this page Jan 5, 2021 · 32 revisions
  1. Overview
  2. PV Import Service
  3. Service Manager

Overview

The purpose of the service is to enable efficient monitoring of Helium consumption by populating the HLM Database with new object measurements using the PV data provided by the Helium Recovery PLC. This repository contains both the HLM PV Import Service and its Service Manager.


PV Import Service

The service uses caproto for Channel Access ("EPICS") to read and store the data of specified PVs, whose values are then added to the HLM Database as Measurements for objects. For example, an object ""

The service primarily consists of three objects:

  1. User Config (PV configuration) - reads & validates the Record/Meas. PVs user config., stores & prepares records & PV names list
  2. PV Monitors (Channel Access) - sets up the PV monitors, handles PV data, updates, stale PV checks etc.
  3. PV Import (Main Loop) - adds measurements to the HLM DB, initializes tasks & handles update intervals and more
Service Diagram

On service start, the settings EPICS CA Address List will be set, and an UserConfig object will be created. After validating the provided configuration, it will fetch the entries (object IDs, measurement PVs, logging periods) and store them as attributes. The PV measurements list from the UserConfig is then used to create the PV Monitors object. The monitors object will prepare caproto's threading client Context. Monitors will be set-up for each PV name, and a dictionary containing the latest PV values will be regularly updated by the callback functions that were added to each subscription, alongside the time of each update (for checking stale PVs).

Lastly, a PV Import object will be created with references to the UserConfig and PV Monitors object. This is the main loop, which will be responsible for preparing the addition of new measurement: initialize tasks, handle update intervals, run stale PV checks, handle missing PV data, etc. If the PVs of a measurement meet the criteria, PV Import will call DBUtils to add it.

The supporting modules are:

  • DB Functions - functions for working with the HLM DB (e.g. add measurement, add relation, check for object Software Level Device).
  • Utilities - Various utility functions (e.g. get full PV name, get PV name without prefix/domain).
  • Logger - Custom logging for DB insertions, errors, stale PV warnings and more.
  • Settings - Service settings, paths, table/key names and other constants, all in one place.

Note: The PV Import service does not require the service manager - it can be set-up manually by directly editing the files and WinReg, adding the objects and run via terminal commands. The service's only dependencies are its settings.ini, pv_config.json and the He DB user & pass as service parameters in the Windows Registry.


Service Manager

Although the PV Import service can be managed manually (see above), the HLM Service Manager offers a GUI that makes it easier to set-up, configure, validate and run the service. It can also be used to create new objects to add configurations to, and handle any SLD requirements.

Features include:

  • Viewing the service details and current status
  • Running, stopping and restarting the service
  • Viewing the live service log output
  • Adding, editing & deleting PV configuration entries
  • Creating new objects and handle Software Level Device requirements
  • Displaying details of existing objects when managing the PV configuration
  • Running PV connection checks
  • Easily set up the HLM Database connection
  • Configuring the general settings of the PV Import service, such as EPICS Channel Access address list, PV settings etc.

Note: The manager should be run with administrator rights to ensure all features are available.

Main Window

The main window is divided into three sections, from top to bottom:

  1. Service Status, control & details
  2. Object/PV Configuration table
  3. Service Log output

The service status panel is updated with the current status and details of the service every few seconds. The user can start, stop or restart the service. The database connection status for the manager is also displayed, and the connection can be refreshed.

The PV configuration table displays the contents of pv_config.json as a table. The buttons on the left of the table allows one to add or edit a configuration for an object, or delete existing entries. Utility buttons allow the user to expand/shrink the table, apply filters to the table and refresh the contents (they should be automatically refreshed, unless the file is changed manually while the manager is running). The Add/Edit buttons will open the Configuration Entry dialog.

The service log panel displays the real time contents of the HLM PV Import, together with some utility widgets.

hlm_manager_main_window




Configuration Entry

Through the Object PV Configuration Entry dialog, the user can add, edit or delete a PV configuration entry, as well as create new objects to the database. If the newly created object is a vessel, cryostat or gas counter, a Software Level Device will be created as well as the relation between the two.

In the object name field, an existing object can be selected, or the name of a new object can be entered. If the object exists, the type, comment and object details panel (name, id, class, function, SLD name & ID) will be autocompleted from the database. If the name of a new object is entered, the type & comment (optional) fields will be enabled for editing.

The value of the measurements update interval spinbox represents the minutes between each new measurement that will be added to the object; the default time between updates is 60 minutes.

In Measurements and PVs, the names of up to 5 PVs can be entered. Depending on the class of the selected object, each measurement can have different meanings in the HLM database, which will be displayed next to each field.

The Check Measurement PVs will start a connection test for all entered PV names, displaying the results for each PV. An automatic check will start upon clicking "Save"; this can be enabled or disabled in manager general settings.

If the selected object already has a PV configuration in pv_config.json, a message will inform the user of that, and a "Load" button will appear, which upon clicking will fill the fields with the PV names from the config entry. An option to enable/disable existing config auto-load is available in manager general settings.

If any field is invalid, an error message will inform the user and highlight the respective field(s).

hlm_manager_config_entry




Settings

Service Directory Path

When first starting the manager, a dialog will ask for the service directory path. Once provided, the manager will look for the service settings and PV config, and if not found, create them from the templates. The directory path can be changed at any time from Settings -> Service Directory.

DB Connection

The database connection can be configured through Settings -> DB Connection. The host, database name, user & password can be changed. The host and database will be saved in the service settings.ini, while the host & password will be saved as parameters of the service in the Windows Registry. In order for the manager to connect to the database, the set service directory must be correct and contain settings.ini.

Channel Access

The EPICS CA address list and other PV settings can be configured through Settings -> Channel Access. The address list and PV settings are saved in the service settings.ini.

General Settings

The manager can be configured through Settings -> General Settings. Settings include PV auto-check on config Save, auto-load existing config entries, default update interval value, etc.

Manager Data

The manager data directory can be opened through View -> Manager Data Dir. It contains the logs and settings of the manager. They can differ depending on the user, as the directory is stored in AppData.

Clone this wiki locally