Composer での ThingWorx モデルの定義 > モデル化 > Thing > アラート > アラートからのしきい値情報の取得
アラートからのしきい値情報の取得
制限値、最大値、最小値などは GetAlertDefinition サービスから返される alertAttributes インフォテーブル内に格納されています。
インフォテーブル内の特定の値にアクセスするには、ラッパーサービスが必要です。
INTEGER プロパティの「上」タイプのアラートから制限値を取得するサービス:
入力
出力
propertyName : STRING
result: INTEGER
* 
result のタイプは返される属性のタイプと一致している必要があります。この例では、result は INTEGER です。
alertName : STRING
スクリプトの例
// 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!");
関連リンク