Définition du modèle ThingWorx dans Composer > Modélisation > Objets > Alertes > Récupération des informations de seuils des alertes
Récupération des informations de seuils des alertes
Les valeurs limit, maximum ou encore minimum sont stockées dans la table d'informations alertAttributes renvoyée par le service GetAlertDefinition.
Pour accéder aux valeurs spécifiques de la table d'informations, un service wrapper est obligatoire.
Exemple
Un service qui renvoie la valeur limite pour un type d'alerte Above sur une propriété INTEGER :
Entrées
Sorties
propertyName : STRING
result : INTEGER
* 
Le type de résultat doit correspondre au type de l'attribut renvoyé. Dans cet exemple, il doit s'agit d'un entier.
alertName : STRING
Exemple 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!");
Rubriques connexes