public interface ISpecFileTemplate
Note: The examples provided use the Jython syntax.
Modifier and Type | Method and Description |
---|---|
String |
createSectionText(List<research.ch.cern.unicos.utilities.IDeviceInstance> theTypeInstances,
int optionDuplicate,
int counterStart,
int counterStep,
String textIfLink,
String textIfNoLink)
This method is used to generate text for a program/section.
|
String |
createSectionText(List<research.ch.cern.unicos.utilities.IDeviceInstance> theTypeInstances,
int counterStart,
int counterStep,
String textRepeated)
This method is used to generate text for a program/section.
|
int |
Dcount(String field,
String type,
String condition)
Count the number of elements found by the
Dlookup(String, String, String) method.Iterates through all the instances of the device type specified. |
List<String> |
DependentLoop(String deviceTypeName,
String master,
int start,
int step,
String textRepeated)
Create a String vector with the 'textRepeated' for each device instance matching the specified conditions.
|
List<String> |
DependentLoop(String deviceTypeName,
String master,
int start,
int step,
String textRepeated,
String condition)
Create a String vector with the 'textRepeated' for each device instance matching the specified conditions.
|
String |
DependentLoopString(String deviceTypeName,
String master,
int start,
int step,
String textRepeated)
Similar to
DependentLoop(String, String, int, int, String) . |
String |
DependentLoopString(String deviceTypeName,
String master,
int start,
int step,
String textRepeated,
String condition)
Similar to
DependentLoop(String, String, int, int, String, String) This method returns only one String where the different lines are separated by end-of-line char ("\n"). |
List<String> |
Dlookup(String field,
String type,
String condition)
Dependent look up method.
|
String |
DlookupString(String field,
String type,
String condition)
Dependent look up String method.
|
research.ch.cern.unicos.utilities.IDeviceInstance |
findInstanceByName(String instanceName)
Find a device instance by name.
|
research.ch.cern.unicos.utilities.IDeviceInstance |
findInstanceByName(String deviceTypeNames,
String instanceName)
Find a device instance by name.
|
research.ch.cern.unicos.utilities.IDeviceInstance |
findInstanceByNameIgnoreCase(String instanceName)
Find a device instance by name, case insensitive.
|
research.ch.cern.unicos.utilities.IDeviceInstance |
findInstanceByNameOrExpertName(String instanceName,
String deviceTypeNames)
Find a device instance by name or expert name.
|
List<research.ch.cern.unicos.utilities.IDeviceInstance> |
findMatchingInstances(String deviceTypeNames,
String condition)
This method is used to get all the instances of the specified device type(s) where the specified condition is
true.
|
List<research.ch.cern.unicos.utilities.IDeviceInstance> |
findMatchingInstances(String deviceTypeNames,
String masterObject,
String condition)
This method is used to get all the instances of an specified device type with an specified master object, where
the specified condition is true.
|
List<research.ch.cern.unicos.utilities.IDeviceInstance> |
findMatchingInstances(String deviceTypeNames,
String masterObject,
String condition,
List<Integer> positions)
This method is used to get all the instances of an specified device type with an specified master object, where
the specified condition is true.
|
String |
GenericDepLoop(String instanceName,
String targetDevice,
String linkedField,
int optionDuplicate,
int first,
int fStep,
String fTextWithLink,
String fTextNoLink)
This function detects link between an object name in another object table (targetDevice) in a particular field
(LinkedField).
If a link is detected then it will replace in the string FTextWithLink the fields between # with the correspondent value in the target device and returns the string to the function. If several links are found, there are three different options: optionDuplicate=0 then it will concatenate the several strings; optionDuplicate=1 then it will keep the first replaced string; optionDuplicate=2 then it will keep the last replaced string; If no link is detected then, it will return the string FTextNoLink. |
List<research.ch.cern.unicos.utilities.IDeviceType> |
getAllDeviceTypes()
Get all the device types available in the specs file.
|
String |
getAllDeviceTypesString()
Get a String containing all the device type names separated by the character ','.
|
research.ch.cern.unicos.utilities.IDeviceType |
getDeviceType(String theDeviceTypeName)
Get a device type from the specs file.
|
ISpecDocumentation |
getProjectDocumentation()
Get the project documentation data from the specs file.
|
String |
getResourcesName()
Get the name of the resources package used to build the specs file.
|
String |
getResourcesVersion()
Get the version of the resources package used to build the specs file.
|
String |
getSpecsPath()
Return the path to the specs file.
|
String createSectionText(List<research.ch.cern.unicos.utilities.IDeviceInstance> theTypeInstances, int optionDuplicate, int counterStart, int counterStep, String textIfLink, String textIfNoLink)
theTypeInstances
- Vector with all the necessary instances to produce the output text.optionDuplicate
- Integer value to specify if the generated text must be duplicated for each device
instance. The possible values are:
counterStart
- Integer used as the value for the first instance.counterStep
- Integer used as step to increment the 'counterStart' of the previous object.textIfLink
- Text to be inserted for each instance in the vector. It's possible to perform string
replacements using the specs path of the required data (see the example below).textIfNoLink
- If the instances vector provided doesn't have any instance, the String contained in this
parameter will be returned.
# Get the DigitalInput device type
diDeviceType = theRawInstances.getDeviceType("DigitalInput")
# Get a vector with all the DigitalInput instances
diInstances = diDeviceType.getAllDeviceTypeInstances()
# optionDuplicate = 0
generatedText0 = theRawInstances.createSectionText(diInstances, 0, 1, 1, "#counter# - Device name: #DeviceIdentification:Name#", "No instances provided!")
# optionDuplicate = 1
generatedText1 = theRawInstances.createSectionText(diInstances, 1, 1, 1, "#counter# - Device name: #DeviceIdentification:Name#", "No instances provided!")
# optionDuplicate = 2
generatedText2 = theRawInstances.createSectionText(diInstances, 2, 1, 1, "#counter# - Device name: #DeviceIdentification:Name#", "No instances provided!")
Output:
If the specs file contains, for example, three instances of the DigitalInput device type the content of
the generatedText variables will be the following:
generatedText0 variable (with optionDuplicate = 0)
1 - Device name: DigitalInput_1
2 - Device name: DigitalInput_2
3 - Device name: DigitalInput_3
generatedText1 variable (with optionDuplicate = 1)
1 - Device name: DigitalInput_1
generatedText2 variable (with optionDuplicate = 2)
3 - Device name: DigitalInput_3
Note: If there are no DigitalInput instances defined in the spec file, the content of the three
generatedText variables will be the String: "No instances provided!"
String createSectionText(List<research.ch.cern.unicos.utilities.IDeviceInstance> theTypeInstances, int counterStart, int counterStep, String textRepeated)
theTypeInstances
- Vector with all the necessary instances to produce the output text.counterStart
- Integer used as the value for the first instance.counterStep
- Integer used as step to increment the 'counterStart' of the previous object.textRepeated
- Text to be inserted for each instance in the vector. It's possible to perform string
replacements using the specs path of the required data (see the example below).
# Get the DigitalInput device type
diDeviceType = theRawInstances.getDeviceType("DigitalInput")
# Get a vector with all the DigitalInput instances
diInstances = diDeviceType.getAllDeviceTypeInstances()
generatedText = theRawInstances.createSectionText(diInstances, 1, 1, "#counter# - Device name: #DeviceIdentification:Name#")
Output:
The example above will store in the generatedText variable a string containing, for each instance of the
DigitalInput device type, the instance number and its name as specified in the specs file, e.g.:
1 - Device name: DigitalInput_1
2 - Device name: DigitalInput_2
...
int Dcount(String field, String type, String condition)
Dlookup(String, String, String)
method.field
- The field required for the returned String.type
- The device type name.condition
- The condition to match.Dlookup(String, String, String)
List<String> DependentLoop(String deviceTypeName, String master, int start, int step, String textRepeated)
deviceTypeName
- The device type name.master
- Value of the #LogicDeviceDefinitions:Master# field of the device in the spec file.start
- First value of the counter for the loop.step
- Amount counter is increased each time through the loop.textRepeated
- String expression to be repeated if the field Master in the Object equals the value Master.
# For each AnalogAlarm instance which master object is 'DEMON_1_EH01AD', create a text displaying
# the counter value and the instance name.
text = theRawInstances.DependentLoop("AnalogAlarm", "DEMON_1_EH01AD", 1, 1, "#counter# - #DeviceIdentification:Name#")
# Show the created text
for str in text:
thePlugin.writeDebugInUABLog("$str$")
Output:
An example of the debug messages displayed in the user report window is:
1 - AnalogAlarm_1
2 - AnalogAlarm_2
...
List<String> DependentLoop(String deviceTypeName, String master, int start, int step, String textRepeated, String condition)
deviceTypeName
- The device type name.master
- Value of the #LogicDeviceDefinitions:Master# field of the device in the spec file.start
- First value of the counter for the loop.step
- Amount counter is increased each time through the loop.textRepeated
- String expression to be repeated if the field Master in the Object equals the value Master.condition
- String expression evaluated for each step. If True, 'textRepeated' is append to the output
vector.
# For each AnalogAlarm instance of type 'TS' which master object is 'DEMON_1_EH01AD', create a text displaying
# the counter value and the instance name.
text = theRawInstances.DependentLoop("AnalogAlarm", "DEMON_1_EH01AD", 1, 1, "#counter# - #DeviceIdentification:Name#", "'#FEDeviceAlarm:Type#'='TS'")
# Show the created text
for str in text:
thePlugin.writeDebugInUABLog("$str$")
Output:
An example of the debug messages displayed in the user report window is:
1 - AnalogAlarm_1
2 - AnalogAlarm_2
...
String DependentLoopString(String deviceTypeName, String master, int start, int step, String textRepeated)
DependentLoop(String, String, int, int, String)
. deviceTypeName
- The device type name.master
- Value of the #LogicDeviceDefinitions:Master# field of the device in the spec file.start
- First value of the loop.step
- Amount counter is increased each time through the loop.textRepeated
- String expression to be repeated if the field Master in the Object equals the value Master.DependentLoop(String, String, int, int, String)
String DependentLoopString(String deviceTypeName, String master, int start, int step, String textRepeated, String condition)
DependentLoop(String, String, int, int, String, String)
deviceTypeName
- The device type name.master
- Value of the #LogicDeviceDefinitions:Master# field of the device in the spec file.start
- First value of the loop.step
- Amount counter is increased each time through the loop.textRepeated
- String expression to be repeated if the field Master in the Object equals the value Master.condition
- String expression evaluated for each step. If True, TextRepeated is append to the output vector.
The binary operators available for the conditions are: "!=", "=", "contains", "startsWith",
"endsWith", "matches"DependentLoop(String, String, int, int, String, String)
List<String> Dlookup(String field, String type, String condition)
field
- The field required for the returned String.type
- The device type name.condition
- The condition to match.
result = theRawInstances.Dlookup("DeviceIdentification:Name", "AnalogAlarm", "'#FEDeviceAlarm:Type#'='AL'")
# Display the name of all the analog alarms matching the criteria in the UAB log (as debug message)
for alarmName in result:
thePlugin.writeDebugInUABLog("Analog Alarm: $alarmName$")
String DlookupString(String field, String type, String condition)
field
- The field required for the returned String.type
- The device type name.condition
- The condition to match.
result = theRawInstances.DlookupString("DeviceIdentification:Name", "AnalogAlarm", "'#FEDeviceAlarm:Type#'='AL'")
# Display the name of all the first analog alarm matching the criteria in the UAB log (as debug message)
thePlugin.writeDebugInUABLog("Analog Alarm: $result$")
Dlookup(String, String, String)
research.ch.cern.unicos.utilities.IDeviceInstance findInstanceByName(String deviceTypeNames, String instanceName)
deviceTypeNames
- Device type name(s) where the method will look for the instances (e.g.:
"DigitalInput,DigitalOutput"). The string "*" can be used to look in all the device types.instanceName
- The name of the instance to look for.research.ch.cern.unicos.utilities.IDeviceInstance findInstanceByName(String instanceName)
instanceName
- The name of the instance to look for.research.ch.cern.unicos.utilities.IDeviceInstance findInstanceByNameOrExpertName(String instanceName, String deviceTypeNames)
instanceName
- The name of the instance to look for.deviceTypeNames
- name of the device type or comma separated list of device types to look for given instanceresearch.ch.cern.unicos.utilities.IDeviceInstance findInstanceByNameIgnoreCase(String instanceName)
instanceName
- The name of the instance to look for.List<research.ch.cern.unicos.utilities.IDeviceInstance> findMatchingInstances(String deviceTypeNames, String condition)
deviceTypeNames
- Device type name(s) where the method will look for the instances (e.g.:
"DigitalInput,DigitalOutput"). The string "*" can be used to look in all the device types.condition
- The condition to be fulfilled by the instances (e.g.: "'#LogicDeviceDefinitions:Type#'='FS'")
alarms = theRawInstances.findMatchingInstances("AnalogAlarm", "'#FEDeviceAlarm:Type#'='AL'")
# Display the name of all the devices found in the UAB log (as debug message)
for alarm in alarms:
thePlugin.writeDebugInUABLog("Analog Alarm: " + alarm.getAttributeData("DeviceIdentification:Name"))
List<research.ch.cern.unicos.utilities.IDeviceInstance> findMatchingInstances(String deviceTypeNames, String masterObject, String condition)
deviceTypeNames
- Device type name(s) where the method will look for the instances (e.g.:
"DigitalInput,DigitalOutput"). The string "*" can be used to look in all the device types.masterObject
- Name of the required master object for the instances.condition
- The condition to be fulfilled by the instances (e.g.: "'#LogicDeviceDefinitions:Type#'='FS'")
alarms = theRawInstances.findMatchingInstances("AnalogAlarm", "DEMON_1_EH01AD", "'#FEDeviceAlarm:Type#'='AL'")
# Display the name of all the devices found in the UAB log (as debug message)
for alarm in alarms:
thePlugin.writeDebugInUABLog("Analog Alarm: " + alarm.getAttributeData("DeviceIdentification:Name"))
List<research.ch.cern.unicos.utilities.IDeviceInstance> findMatchingInstances(String deviceTypeNames, String masterObject, String condition, List<Integer> positions)
deviceTypeNames
- Device type name(s) where the method will look for the instances (e.g.:
"DigitalInput,DigitalOutput"). The string "*" can be used to look in all the device types.masterObject
- Name of the required master object for the instances.condition
- The condition to be fulfilled by the instances (e.g.: "'#LogicDeviceDefinitions:Type#'='FS'")positions
- For each device found, the list will contain the position where the 'masterObject' is found,
e.g. if the specs field 'LogicDeviceDefinitions:Master' contains the values 'PCO, PCO1, PCO2', and the
parameter 'masterObject' contains the value 'PCO', then the list will contain the position index '0'
for that instance.
# Create a list to get the master object positions
positions = ArrayList()
# Get the required instances
alarms = theRawInstances.findMatchingInstances("AnalogAlarm", "DEMON_1_CV01Ana", "'#FEDeviceAlarm:Type#'='Multiple'", positions)
# Display the name of all the devices found and the master's position in the UAB log (as debug message)
i = 0
for alarm in alarms:
thePlugin.writeDebugInUABLog("Analog Alarm: " + alarm.getAttributeData("DeviceIdentification:Name"))
thePlugin.writeDebugInUABLog("Master position: " + str(positions.get(i)))
i = i+1
String GenericDepLoop(String instanceName, String targetDevice, String linkedField, int optionDuplicate, int first, int fStep, String fTextWithLink, String fTextNoLink)
instanceName
- Name of the device instance to look for.targetDevice
- Name of the device type where to look for the link.linkedField
- Field where to look for the specified link.optionDuplicate
- Integer value to specify if the generated text must be duplicated for each device
instance. The possible values are:
first
- Integer used as the value for the first instance.fStep
- Integer used as step to increment the 'first' value of the previous instance.fTextWithLink
- Text to return if there are one or more links found.fTextNoLink
- Text to return it there are no links found.
# optionDuplicate = 0
generatedText0 = theRawInstances.GenericDepLoop("AnalogParameter_1", "AnalogAlarm", "FEDeviceManualRequests:LL Alarm", 0, 1, 1, "#counter# - #DeviceIdentification:Name#", "No links found!")
# optionDuplicate = 1
generatedText1 = theRawInstances.GenericDepLoop("AnalogParameter_1", "AnalogAlarm", "FEDeviceManualRequests:LL Alarm", 1, 1, 1, "#counter# - #DeviceIdentification:Name#", "No links found!")
# optionDuplicate = 2
generatedText2 = theRawInstances.GenericDepLoop("AnalogParameter_1", "AnalogAlarm", "FEDeviceManualRequests:LL Alarm", 2, 1, 1, "#counter# - #DeviceIdentification:Name#", "No links found!")
Output:
If the specs file contains, for example, three instances of the AnalogAlarm device type matching the
specified conditions, the content of the generatedText variables will be the following:
generatedText0 variable (with optionDuplicate = 0)
1 - AnalogAlarm_1
2 - AnalogAlarm_2
3 - AnalogAlarm_3
generatedText1 variable (with optionDuplicate = 1)
1 - AnalogAlarm_1
generatedText2 variable (with optionDuplicate = 2)
3 - AnalogAlarm_3
Note: If there are no AnalogAlarm instances matching the specified conditions the content of the
three generatedText variables will be the String: "No links found!"
List<research.ch.cern.unicos.utilities.IDeviceType> getAllDeviceTypes()
deviceTypes = theRawInstances.getAllDeviceTypes()
# Display the description of all the device types in the UAB log (as debug message)
for deviceType in deviceTypes:
thePlugin.writeDebugInUABLog("Device Type: " + deviceType.getDeviceTypeName() + " Description: " + deviceType.getDescription())
IDeviceType
String getAllDeviceTypesString()
deviceTypes = theRawInstances.getAllDeviceTypesString()
# Show the device types string in the UAB log (as debug message)
thePlugin.writeDebugInUABLog("Device Types: $deviceTypes$")
research.ch.cern.unicos.utilities.IDeviceType getDeviceType(String theDeviceTypeName)
theDeviceTypeName
- The device type name (e.g. "DigitalInput")
deviceType = theRawInstances.getDeviceType("DigitalInput")
# Display the description of the device type in the UAB log (as debug message)
thePlugin.writeDebugInUABLog("Device Type: " + deviceType.getDeviceTypeName() + " Description: " + deviceType.getDescription())
IDeviceType
ISpecDocumentation getProjectDocumentation()
ISpecDocumentation}
String getResourcesName()
String getResourcesVersion()
String getSpecsPath()
Copyright © 2010–2016 CERN. All rights reserved.