Definición del modelo de ThingWorx en Composer > Modelado > Cosas > Alertas > Recuperación de información del umbral de alertas
Recuperación de información del umbral de alertas
Los valores de límite, máximo, mínimo, etc. se almacenan dentro de la infotable alertAttributes que el servicio GetAlertDefinition devuelve.
Para acceder a los valores específicos que se incluyen en la infotable, se requiere un servicio de empaquetador.
Ejemplo
Servicio que recupera el valor límite de un tipo de alerta Por encima de de una propiedad INTEGER:
Entradas
Salidas
propertyName : STRING
result: INTEGER
* 
El tipo de resultado debe coincidir con el tipo del atributo devuelto. Para este ejemplo, el resultado es INTEGER.
alertName : STRING
Ejemplo de script
// These parameters have been parameterized into "alertName" and
// "propertyName" parameters at the service level. If these values
// will not change, they can be hard coded instead.
var params = {
alertName: alertName /* STRING */,
property: propertyName /* STRING */
};
// Retrieve the Alert Definition
var alertDef = me.GetAlertDefinition(params)
// Safety check on result from GetAlertDefinition()
if (alertDef != null && alertDef.rows.length > 0) {
// There should only be one row returned by GetAlertDefinition()
var alertProps = alertDef.rows[0];
// Safety check on alertAttributes infotable.
if (alertProps.alertAttributes != null && alertProps.alertAttributes.rows.length > 0) {
// Return the "limit" property from the alertAttributes table.
var result = alertProps.alertAttributes.rows[0].limit;
} else {
// The alertAttributes infotable was undefined or empty. This logs an error, but
// does not change the value returned. (Service returns no value.)
logger.error("AlertAttributes was null/empty!");
}
} else {
// The Alert Definition was empty.
// This is most commonly caused by invalid alertName/propertyName.
logger.error("Result from GetAlertDefinition was null/empty!");
Vínculos relacionados