SFHub ad-hoc Functions
SFHub ad-hoc Functions are a set of built-in functions performing special SFHub tasks.
The following sectionstopics provide details about the ad-hoc functions.
InterlockedOperator
The InterlockedOperator function is only supported in Studio. allows
you to change a variable value in a safe mode. The InterlockedOperator
supports only numeric or Dictionary variables containing numeric values.
InterlockedOperator has to be used every time an Analytic variable has to be modified with information contained in Elements; the reason for this is that Studio elaborates all elements in parallel , and therefore the variable must be accessed in safe mode.
InterlockedOperator works with number, string as well as with Dictioary, using dictionary is a powerful function as it intrinsically manages aggregation, see next examplesn
Prototype
----------- ----------------------------------------------
*Arguments*
----------------------- ----------------------- ------------------------
Variable Object By value
----------------------- ----------------------- ------------------------
Argument contains the variable to be changed.
:::
----------------------- ----------------------- ------------------------
Value Number or String By value
----------------------- ----------------------- ------------------------
Argument contains the value used to update the variable.
:::
----------------------- ----------------------- ------------------------
Operator String By value
----------------------- ----------------------- ------------------------
Argument contains the operator to be applied. Supported operators are:
\+
\-
/
\*
Min
Max
:::warning
**Important**: If value is of type string, only the '+' operator can be used to concatenate strings.
:::
*Returns*
Boolean
True if the operator terminates successfully. Notice that the function
is NOT case sensitive.
:::
*Exception*
Undefined
Undefined is returned if one of the two arguments is not a valid string.
:::
Examples
InterlockedOperator($myVar ; 1; '+')
This will add [1] to the [\$myVar ]variable. :::
InterlockedOperator( $$myDictionary["material"] ; "MeasuredMass" ; '+')
This will add the stored value in the [MeasuredMass ]attribute to the [\$\$myDictionary] dictionary for the material recorded in the [Material ]attribute.
Using this function, it's easy to aggregate values grouped by dynamic keys. :::
TableAnalyticMerge
The TableAnalyticMerge function is only supported in Studio. The function returns a Data Table variable that is filled with results produced by another analytic. To better understand how it works, imagine you have an analytic that runs every time a case is published storing some relevant information about the case (as an example the DX indexes) in a variable, and then imagine you want to read all DX indexes of the last month; with TableAnalyticMerge you can do that
The function allows to specify the analytic (the one who produced the results), the search period (start and end time), the specific Sigmafine Analysis (or all), the specific model (or all) and the name of the variable that we want to read.
Prototype
Model ; PluginId; Start ; End
; Variable ; AdditionalKeys )
-------------- -----------------------------
*Arguments*
----------------------- ----------------------- ------------------------
Analytic String By value
----------------------- ----------------------- ------------------------
Argument contains the name of the analytic who produced the results to
be collected.
:::
----------------------- ----------------------- ------------------------
Model String By value
----------------------- ----------------------- ------------------------
Optional argument that contains the unique identifier of the model. If a
model is passed, then only the results produced for the specific model
will be collected.
:::
----------------------- ----------------------- ------------------------
PluginId String By value
----------------------- ----------------------- ------------------------
Optional argument that contains the unique identifier of the Analysis.
If an analysis is passed, then only the results produced for the
specific analysis will be collected.
:::
----------------------- ----------------------- ------------------------
Start Number By value
----------------------- ----------------------- ------------------------
Argument contains the search start time. Only those results obtained
from a case started at or after the Start parameter will be collected.
:::
----------------------- ----------------------- ------------------------
End Number By value
----------------------- ----------------------- ------------------------
Argument contains the search end time. Only those results obtained from
a case started at or before the End parameter will be collected.
:::
----------------------- ----------------------- ------------------------
Variable String By value
----------------------- ----------------------- ------------------------
Argument contains the name of the variable containing the information to
be collected.
:::
----------------------- ----------------------- ------------------------
AdditionalKeys String By value
----------------------- ----------------------- ------------------------
Optional arguments that contain the additional information to be added
to the data table. None or a combination of the following keys can be
specified:
**CaseId** -- The CaseId column is added to the table and each record
will be filled with the case unique identifier.
**PluginId** -- The PluginId column is added to the table and each
record will be filled with the Analysis unique identifier.
**PluginName** -- The PluginName column is added to the table and each
record will be filled with the name of the Analysis to which the read
data refers.
**CaseStart** -- The CaseStart column is added to the table and each
record will be filled with the start time of the case to which the read
data refers.
**CaseEnd** -- The CaseEnd column is added to the table and each record
will be filled with the end time of the case to which the read data
refers.
**ModelId** -- The ModelId column is added to the table and each record
will be filled with the unique identifier of the model to which the read
data refers.
:::
:::
*Returns*
Data Table
An empty data table, without columns and rows, is returned if there are
no values to be merged.
:::
*Exception*
Undefined
- Undefined is returned if the analytic (passed by name) is not found.
- Undefined is returned if improper additional keys are defined.
- Undefined is returned if the variable name is empty or Undefined.
:::
Example:
`$$DxSeries = TableAnalyticMerge('Dx Tx On case'; {modelid}; GetAnalysisRuleId( $$SelectedA ) ; DateToEpoch($$Start) ; DateToEpoch($$End); '$$DX' ; 'PluginName'; 'CaseId' )`
The variable [\$\$DxSeries] will be assigned
with a table containing as many rows as many analytic results will be
found according to the passed parameters.
+--------------------+-------------------------------------------------+
| Placeholder | Description |
+====================+=================================================+
| 'Dx Tx On case' | The name of the analytic to be searched, that |
| | is, the name of the analytic who produced the |
| | results you want to read. |
+--------------------+-------------------------------------------------+
| {ModelId} | Read only the results produced for the same |
| | model that is currently used by the analytic |
| | running the function. |
+--------------------+-------------------------------------------------+
| GetAnalysisRuleId( | Read only the results produced for the |
| \$\$SelectedA ) | Sigmafine Analysis whose name is contained in |
| | the analytic variable \$\$SelectedA. |
+--------------------+-------------------------------------------------+
| Date | The search start time. |
| ToEpoch(\$\$Start) | |
| | The analytic variable \$\$Start contains the |
| | Date and time and it's transformed to Epoch. |
+--------------------+-------------------------------------------------+
| Dat | The search end time. |
| eToEpoch(\$\$End); | |
| | The analytic variable \$\$End contains the date |
| | and time and it's transformed to Epoch. |
+--------------------+-------------------------------------------------+
| \'\$\$DX\' | The name of the variable, of type Table, to be |
| | read from the collected analytic results. |
+--------------------+-------------------------------------------------+
| \'PluginName\'; | The additional information to be added to each |
| \'CaseId\' | row of the returned table. |
| | |
| | In the example each row will contain the name |
| | of the Sigmafine Analysis and the case unique |
| | Id. |
+--------------------+-------------------------------------------------+
:::