unLHCLoggingDB 8.5.7
unLHCLoggingDBParser.ctl File Reference

Library containing import file related functions of the unLHCLoggingDB component. More...

Functions

public bool unLHCLoggingDBParser_getImportData (const string sConfigFile, dyn_string &dsVariableName, dyn_string &dsHierarchy, dyn_string &dsDescription, dyn_string &dsElementId, dyn_string &dsUnit, dyn_string &dsRDBSource, dyn_string &dsDataCategoryId, bool &bDataCategoryManualInput, dyn_anytype &daConflicts)
 
public bool unLHCLoggingDBParser_getConfigFileData (const string sConfigFile, dyn_string &dsVariableName, dyn_string &dsDpe, dyn_string &dsHierarchy, dyn_string &dsDescription, dyn_string &dsDataCategory)
 
public dyn_string unLHCLoggingDBParser_cleanHierarchies (const dyn_string &dsHierarchy)
 
private bool unLHCLoggingDBParser_parseConfigFile (const string sFileName, dyn_string &dsVariableName, dyn_string &dsDpe, dyn_string &dsAlias, dyn_string &dsHierarchy, dyn_string &dsDescription, dyn_string &dsDataCategory, dyn_anytype &daConflicts)
 
private bool unLHCLoggingDBParser_parseXmlConfigFile (const string sFileName, dyn_string &dsVariableName, dyn_string &dsDpe, dyn_string &dsAlias, dyn_string &dsHierarchy, dyn_string &dsDescription, dyn_string &dsDataCategory, dyn_anytype &daConflicts)
 
private bool unLHCLoggingDBParser_getNodeAttribute (const unsigned doc, const unsigned node, const string attr, string &value)
 
private bool unLHCLoggingDBParser_checkDpConsistency (dyn_string &dsDpe, dyn_string &dsAlias, dyn_anytype &daConflicts)
 
private bool unLHCLoggingDBParser_isDpName (string sDp)
 
public bool unLHCLoggingDBParser_getElementData (const dyn_string &dsFullDpeName, const dyn_string &dsDpe, const dyn_string &dsAlias, dyn_string &dsElementId, dyn_string &dsUnit, dyn_string &dsRDBSource, dyn_anytype &daConflicts)
 
private bool unLHCLoggingDBParser_getDataCategoryId (const dyn_string &dsDpe, const dyn_string &dsAlias, const dyn_string &dsDataCategory, dyn_string &dsDataCategoryId, bool &DataCategoryManualInput, dyn_anytype &daConflicts)
 
public void unLHCLoggingDBParser_updateMissingDataCategoryIds (dyn_string &dsDataCategoryId, const string sDefaultDataCategoryId)
 
private bool unLHCLoggingDBParser_replaceChars (dyn_string &dsDescription, dyn_anytype &daConflicts)
 
public void unLHCLoggingDBParser_replaceCharsInString (string &sTextToReplace, mapping &mReplacements)
 
private void unLHCLoggingDBParser_reduceStringToWhiteList (string &sInput, mapping &mRemovedChars)
 
private bool unLHCLoggingDBParser_doWhiteListCheck (const dyn_string &dsDpe, const dyn_string &dsAlias, const dyn_string &dsVariableName, const dyn_string &dsDescription, const dyn_string &dsHierarchy, dyn_anytype &daConflicts)
 
public bool unLHCLoggingDBParser_checkStringUsingWhiteList (string sInput, string &sErrorMsg)
 
private bool unLHCLoggingDBParser_checkVarNames (const dyn_string &dsVariableName, dyn_anytype &daConflicts)
 
private bool unLHCLoggingDBParser_checkHierarchies (const dyn_string &dsHierarchy, dyn_anytype &daConflicts)
 
private bool unLHCLoggingDBParser_checkIfVariablesAlreadyRegistered (const dyn_string &dsDpe, const dyn_string &dsAlias, const dyn_string &dsElementId, const dyn_string &dsVariableName, const dyn_string &dsDescription, const dyn_string &dsUnit, dyn_anytype &daConflicts)
 
public bool unLHCLoggingDBParser_createConfigFile (string sFilePathName, bool bIsXmlFile, const dyn_string &dsDpe, const dyn_string &dsAlias, const dyn_string &dsName, const dyn_string &dsHierarchy, const dyn_string &dsDescription, const dyn_string &dsDataCategory)
 
private bool unLHCLoggingDBParser_createXmlConfigFile (string sFilePathName, const dyn_string &dsDpe, const dyn_string &dsAlias, const dyn_string &dsName, const dyn_string &dsHierarchy, const dyn_string &dsDescription, const dyn_string &dsDataCategory)
 
public dyn_string unLHCLoggingDBParser_getSetOfPossibleDPEs (bool bShowInternalDPs=true, bool bShowDevices=true, bool bShowAlarms=true, bool bShowOthers=false, dyn_string dsPatterns=makeDynString())
 
private dyn_string unLHCLoggingDBParser_getArchivedDPEs (bool bShowInternalDPs=true)
 
private dyn_string unLHCLoggingDBParser_filterForDevicesAndAlarms (const dyn_string &dsDPE, bool bShowDevices, bool bShowAlarms, bool bShowOthers)
 
private dyn_string unLHCLoggingDBParser_getDevices ()
 
private dyn_string unLHCLoggingDBParser_filterForUserPatterns (const dyn_string &dsPatterns, const dyn_string &dsDpe)
 
public dyn_string unLHCLoggingDBParser_retrieveConfigData (const string sDPE, const string sUserFunction)
 
public dyn_string unLHCLoggingDBParser_generateImportFiles (const dyn_string &dsConfigurations, bool createTempFile=true)
 
public dyn_string unLHCLoggingDBParser_getImportFileNames (const dyn_string &dsConfigurations)
 
private mapping unLHCLoggingDBParser_prepareConfigData (const dyn_string &dsDPE, const string sUserFunction, bool forceDpeUsage)
 

Variables

const string c_NXCALS_meta_schema_p = UNLDB_NXCALS_METADATA_SCHEMA
 NXCALS meta schema.
 
const string c_unLHCLoggingDBParser_LibVersion = "1.2.0"
 Version of this library. (Only increment this, if we edit this file)
 
private const dyn_char c_dcAllowedChars
 Allowed characters for white list check.
 
private const dyn_anytype c_daCharReplaceList
 Characters that will be automatically replaced.
 

Detailed Description

Library containing import file related functions of the unLHCLoggingDB component.

Date
04/09/2014
Author
Josef Hofer

Usage: Public

PVSS manager usage: CTRL, UI

Constraints:

  • PVSS version: 3.16
  • operating system: Linux.

Function Documentation

◆ unLHCLoggingDBParser_getImportData()

public bool unLHCLoggingDBParser_getImportData ( const string  sConfigFile,
dyn_string &  dsVariableName,
dyn_string &  dsHierarchy,
dyn_string &  dsDescription,
dyn_string &  dsElementId,
dyn_string &  dsUnit,
dyn_string &  dsRDBSource,
dyn_string &  dsDataCategoryId,
bool &  bDataCategoryManualInput,
dyn_anytype &  daConflicts 
)

Retrieve data from config file and database, which is needed to register signals in the file for logging

Parameters
sConfigFileinput, Pathname of the config file
&dsVariableNameoutput, list of VARIABLE_NAMES from config file
&dsHierarchyoutput, list of HIERARCHIES from config file
&dsDescriptionoutput, list of DESCRIPTIONS from config file
&dsElementIdoutput, list of ELEMENT_IDS from ELEMENTS table
&dsUnitoutput, list of UNITSS from ELEMENTS table
&dsRDBSourceoutput, list of GROUP_NAMES from ELEMENTS table
&dsDataCategoryoutput, list of data categories
&bDataCategoryManualInputoutput, Manual input of data category is required
&daConflictsoutput, list of conflicts
Returns
bSuccess output, true=success,false=error

◆ unLHCLoggingDBParser_getConfigFileData()

public bool unLHCLoggingDBParser_getConfigFileData ( const string  sConfigFile,
dyn_string &  dsVariableName,
dyn_string &  dsDpe,
dyn_string &  dsHierarchy,
dyn_string &  dsDescription,
dyn_string &  dsDataCategory 
)

Get data from config file and resolve dp names.

This function is needed to do the full consictency check

Parameters
sConfigFileinput, Pathname of the config file
&dsVariableNameoutput, variable names from config file
&dsDpeoutput, resolved dpe names from config file
&dsHierarchyoutput, hierarchies from config file
&dsDescriptionoutput, descriptions from config file
&dsDataCategoryoutput, data category names from config file
Returns
bSuccess output, true=success,false=error

◆ unLHCLoggingDBParser_cleanHierarchies()

public dyn_string unLHCLoggingDBParser_cleanHierarchies ( const dyn_string &  dsHierarchy)

Cleanup function to make sure each hierarchy are of the correct format Function is made public for unit tests

Returns
always returns true

◆ unLHCLoggingDBParser_parseConfigFile()

private bool unLHCLoggingDBParser_parseConfigFile ( const string  sFileName,
dyn_string &  dsVariableName,
dyn_string &  dsDpe,
dyn_string &  dsAlias,
dyn_string &  dsHierarchy,
dyn_string &  dsDescription,
dyn_string &  dsDataCategory,
dyn_anytype &  daConflicts 
)

Parse config file and store data into dyn_strings

Parameters
sFileNameinput, Pathname of the config file
&dsVariableNameoutput, list of variable names
&dsDpeoutput, list of dpe names
&dsAliasoutput, list of dpe aliases
&dsHierarchyoutput, list of hierarchies
&dsDescriptionoutput, list of desciptions
&dsDataCategoryoutput, list of data categories
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_parseXmlConfigFile()

private bool unLHCLoggingDBParser_parseXmlConfigFile ( const string  sFileName,
dyn_string &  dsVariableName,
dyn_string &  dsDpe,
dyn_string &  dsAlias,
dyn_string &  dsHierarchy,
dyn_string &  dsDescription,
dyn_string &  dsDataCategory,
dyn_anytype &  daConflicts 
)

Parse Xml file and store data into dyn_strings

For example config files see: unLHCLoggingDB/PVSS/data/

Parameters
sFileNameinput, Pathname of the XML file
&dsVariableNameoutput, list of variable names
&dsDpeoutput, list of dpe names
&dsAliasoutput, list of dpe aliases
&dsHierarchyoutput, list of hierarchies
&dsDescriptionoutput, list of desciptions
&dsDataCategoryoutput, list of data categories
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_getNodeAttribute()

private bool unLHCLoggingDBParser_getNodeAttribute ( const unsigned  doc,
const unsigned  node,
const string  attr,
string &  value 
)

Get value of xml node attribute and check if attribute is missing or has no value

Parameters
docinput, xml document id
nodeinput, node number
attrinput, attribute name
&valueoutput, attribute value
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_checkDpConsistency()

private bool unLHCLoggingDBParser_checkDpConsistency ( dyn_string &  dsDpe,
dyn_string &  dsAlias,
dyn_anytype &  daConflicts 
)

Check consistency between datapoint and alias and resolve it to full datapoint element name stored in dsDpe

3 possible cases:

  • dsDpe[i] is a full DPE name
  • dsAlias[i] is a DPE alias --> it will be resolved to full DPE name
  • dsAlias[i] is a DP alias and dsDpe[i] is a element name --> it will be resolved to full DPE name
Parameters
&dsDpeinput/output, list of dpe names
&dsAliasinput/output, list of dpe aliases
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_isDpName()

private bool unLHCLoggingDBParser_isDpName ( string  sDp)

Checks if a string is a DP name

Dot was found at last position -> it is a DP name

Parameters
&sDpinput, DP string
Returns
output, true: it's a DP name, false: it's no DP name

◆ unLHCLoggingDBParser_getElementData()

public bool unLHCLoggingDBParser_getElementData ( const dyn_string &  dsFullDpeName,
const dyn_string &  dsDpe,
const dyn_string &  dsAlias,
dyn_string &  dsElementId,
dyn_string &  dsUnit,
dyn_string &  dsRDBSource,
dyn_anytype &  daConflicts 
)

Get additional data (ELEMENT_ID, UNIT, RDBSource) from ELEMENTS table

Parameters
&dsFullDpeNameinput, list of resolved Dpes
&dsDpeinput, list of Dpes
&dsAliasinput, list of Aliases
&dsElementIdoutput, list of ELEMENT_IDS from ELEMENTS table
&dsUnitoutput, list of UNITSS from ELEMENTS table
&dsRDBSourceoutput, list of RDBSources from ELEMENTS table
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_getDataCategoryId()

private bool unLHCLoggingDBParser_getDataCategoryId ( const dyn_string &  dsDpe,
const dyn_string &  dsAlias,
const dyn_string &  dsDataCategory,
dyn_string &  dsDataCategoryId,
bool &  DataCategoryManualInput,
dyn_anytype &  daConflicts 
)

Resolve data category names to data category ids

Parameters
&dsDataCategoriesinput, list of data category name / subname
&dsDataCategoryIdsoutput, list of data category ids
&DataCategoryManualInputoutput, Manual input of data category required
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_updateMissingDataCategoryIds()

public void unLHCLoggingDBParser_updateMissingDataCategoryIds ( dyn_string &  dsDataCategoryId,
const string  sDefaultDataCategoryId 
)

update Missing Data Category Ids with default value

Parameters
&dsDataCategoryIdinput/output, list of data category ids
&sDefaultDataCategoryIdoutput, default value

◆ unLHCLoggingDBParser_replaceChars()

private bool unLHCLoggingDBParser_replaceChars ( dyn_string &  dsDescription,
dyn_anytype &  daConflicts 
)

Find and replace illegal characters (only in attribute 'descripton')

This function is only needed to don't break compatibility to old logging because there are thousands of files that contain french accents etc. and we still want to be able to import them.

By showing the warning we encourage people to create clean files that don't contain invalid characters.

Parameters
&dsDescriptioninput/output, list of descriptions to replace
&daConflictsinput/output, list of conflicts
Returns
output, success

◆ unLHCLoggingDBParser_replaceCharsInString()

public void unLHCLoggingDBParser_replaceCharsInString ( string &  sTextToReplace,
mapping &  mReplacements 
)

Replace illegal characters (only in attribute 'descripton')

Parameters
&sTextToReplaceinput/output, description to replace
&mReplacementsinput/output, replacements that have been done

◆ unLHCLoggingDBParser_reduceStringToWhiteList()

private void unLHCLoggingDBParser_reduceStringToWhiteList ( string &  sInput,
mapping &  mRemovedChars 
)

Remove all chars from string, which are not in the white list

Parameters
sInputinput/output string to limit
mRemovedCharsoutput, set of removed chars

◆ unLHCLoggingDBParser_doWhiteListCheck()

private bool unLHCLoggingDBParser_doWhiteListCheck ( const dyn_string &  dsDpe,
const dyn_string &  dsAlias,
const dyn_string &  dsVariableName,
const dyn_string &  dsDescription,
const dyn_string &  dsHierarchy,
dyn_anytype &  daConflicts 
)

Check parsed output for illegal characters (only check variable_name, description and hierarchy)

Parameters
&dsDpeinput, list of Dpes
&dsAliasinput, list of Aliases
&dsVariableNameoutput, list of variable names
&dsDescriptionoutput, list of descriptions
&dsHierarchyoutput, list of hierarchies
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_checkStringUsingWhiteList()

public bool unLHCLoggingDBParser_checkStringUsingWhiteList ( string  sInput,
string &  sErrorMsg 
)

Detect illegal chars in string

Parameters
sInputinput, input string
sErrorMsgoutput, error description
Returns
output, true: stirng is ok, false: string is not ok, illegal chars found

◆ unLHCLoggingDBParser_checkVarNames()

private bool unLHCLoggingDBParser_checkVarNames ( const dyn_string &  dsVariableName,
dyn_anytype &  daConflicts 
)

Check names for max length and duplications

Parameters
&dsVariableNameinput, list of variable names
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_checkHierarchies()

private bool unLHCLoggingDBParser_checkHierarchies ( const dyn_string &  dsHierarchy,
dyn_anytype &  daConflicts 
)

Check, if parsed output contains hierarchy=ERROR or IGNORE

Parameters
&dsHierarchyinput, list of hierarchies
&daConflictsoutput, list of conflicts
Returns
output, true=success,false=error

◆ unLHCLoggingDBParser_checkIfVariablesAlreadyRegistered()

private bool unLHCLoggingDBParser_checkIfVariablesAlreadyRegistered ( const dyn_string &  dsDpe,
const dyn_string &  dsAlias,
const dyn_string &  dsElementId,
const dyn_string &  dsVariableName,
const dyn_string &  dsDescription,
const dyn_string &  dsUnit,
dyn_anytype &  daConflicts 
)

Check if list of variables is already registered for logging (in META_VARIABLES table)

Parameters
&dsDpeinput, list of Dpes
&dsAliasinput, list of Aliases
&dsElementIdinput, list of ELEMENT_IDS from ELEMENTS table
&dsVariableNameinput, list of VARIABLE_NAMES from config file
&dsDescriptioninput, list of descriptions
&dsUnitinput, list of units
&daConflictsoutput, list of conflicts
Returns
output, true: no renamed signals found, false: at least 1 renamed signal found

◆ unLHCLoggingDBParser_createConfigFile()

public bool unLHCLoggingDBParser_createConfigFile ( string  sFilePathName,
bool  bIsXmlFile,
const dyn_string &  dsDpe,
const dyn_string &  dsAlias,
const dyn_string &  dsName,
const dyn_string &  dsHierarchy,
const dyn_string &  dsDescription,
const dyn_string &  dsDataCategory 
)

Create new config file for logging configuration

Parameters
sFilePathNameinput, full pathname of the file
bIsXmlFileinput, true=xml-file, false=txt-file
&dsDpeinput, list of dpe names
&dsAliasinput, list of dpe aliases
&dsNameinput, list of variable names
&dsHierarchyinput, list of hierarchies
&dsDescriptioninput, list of desciptions
&dsDataCategoryinput, list of data categories name/subname
Returns
output, true=success, false=error

◆ unLHCLoggingDBParser_createXmlConfigFile()

private bool unLHCLoggingDBParser_createXmlConfigFile ( string  sFilePathName,
const dyn_string &  dsDpe,
const dyn_string &  dsAlias,
const dyn_string &  dsName,
const dyn_string &  dsHierarchy,
const dyn_string &  dsDescription,
const dyn_string &  dsDataCategory 
)

Create new xml config file for logging configuration

Parameters
sFilePathNameinput, full pathname of the file
&dsDpeinput, list of dpe names
&dsAliasinput, list of dpe aliases
&dsNameinput, list of variable names
&dsHierarchyinput, list of hierarchies
&dsDescriptioninput, list of desciptions
&dsDataCategoryinput, list of data categories name/subname
Returns
output, true=success, false=error

◆ unLHCLoggingDBParser_getSetOfPossibleDPEs()

public dyn_string unLHCLoggingDBParser_getSetOfPossibleDPEs ( bool  bShowInternalDPs = true,
bool  bShowDevices = true,
bool  bShowAlarms = true,
bool  bShowOthers = false,
dyn_string  dsPatterns = makeDynString() 
)

Get set of datapoints that could be registered for logging

Parameters
bShowInternalDPsinput, take internal DPs into account
&bShowDevicesinput, take Devices into account
&bShowAlarmsinput, take SystemAlarms into account
&bShowOthersinput, take Others (no Devices and SystemAlarms) into account
&dsPatternsinput, take user defined filter patterns into account
Returns
List of DPEs

◆ unLHCLoggingDBParser_getArchivedDPEs()

private dyn_string unLHCLoggingDBParser_getArchivedDPEs ( bool  bShowInternalDPs = true)

Get set of datapoints that are using RDB Archive

Parameters
bShowInternalDPsinput, true: take internal DPs into account, false: supress internal DPs
Returns
List of DPEs

◆ unLHCLoggingDBParser_filterForDevicesAndAlarms()

private dyn_string unLHCLoggingDBParser_filterForDevicesAndAlarms ( const dyn_string &  dsDPE,
bool  bShowDevices,
bool  bShowAlarms,
bool  bShowOthers 
)

Filter list of DPEs for Devices, Alarms and Others

Parameters
&bShowDevicesinput, forward Devices into output list
&bShowAlarmsinput, forward SystemAlarms into output list
&bShowOthersinput, forward Others (no Devices and SystemAlarms) into output list
Returns
dsResult, List of DPEs

◆ unLHCLoggingDBParser_getDevices()

private dyn_string unLHCLoggingDBParser_getDevices ( )

Get list of devices, that are known by the project

Returns
dsDevices, List of devices

◆ unLHCLoggingDBParser_filterForUserPatterns()

private dyn_string unLHCLoggingDBParser_filterForUserPatterns ( const dyn_string &  dsPatterns,
const dyn_string &  dsDpe 
)

Filter list of DPEs with a list of patterns and forward DPE to output, if they match with at least one pattern

Parameters
&dsPatternsinput, List of patterns
&dsDpeinput, List of DPEs
Returns
dsResult, List of DPEs that match patterns

◆ unLHCLoggingDBParser_retrieveConfigData()

public dyn_string unLHCLoggingDBParser_retrieveConfigData ( const string  sDPE,
const string  sUserFunction 
)

Retrieve logging config data for a list of DPEs using a user defined function

Parameters
&dsDpeinput, List of DPEs
&sUserFunctioninput, User defined config file generator function
Returns
dsResult, Logging config data as a dyn_string

dsResult[1] = name dsResult[2] = description dsResult[3] = hierarchy dsResult[4] = alias dsResult[5] = dpe extension

◆ unLHCLoggingDBParser_generateImportFiles()

public dyn_string unLHCLoggingDBParser_generateImportFiles ( const dyn_string &  dsConfigurations,
bool  createTempFile = true 
)

Generates import files using the builtin mechanism

Parameters
&dsConfigurationsinput, List of configurations
&createTempFileinput, true create files with .tmp extension
Returns
list of import files created

◆ unLHCLoggingDBParser_getImportFileNames()

public dyn_string unLHCLoggingDBParser_getImportFileNames ( const dyn_string &  dsConfigurations)

Retrieve import file names from configurations

Parameters
dsConfigurationsinput, List of configurations
Returns
list of import file names

◆ unLHCLoggingDBParser_prepareConfigData()

private mapping unLHCLoggingDBParser_prepareConfigData ( const dyn_string &  dsDPE,
const string  sUserFunction,
bool  forceDpeUsage 
)

Retrieve config data for a specific set of data point elements.

Parameters
dsDPEinput, List of data point elements
sUserFunctioninput, Function used for data retrieval
forceDpeUsageinput, Flag whether to use Alias+DPE or DPE only
Returns
mapping of arrays