Composer 中的 ThingWorx 模型定義 > 建模 > 物件 > 警示 > 從警示擷取臨界值資訊
從警示擷取臨界值資訊
限制值、最大值、最小值等值均儲存在 GetAlertDefinition 服務傳回的 alertAttributes 資料負載內。
欲存取資料負載內的特定值,必須使用包裝函式服務。
範例
INTEGER 內容的 Above 警示類型擷取限制值的服務:
輸入
輸出
propertyName : STRING
result: INTEGER
* 
結果類型必須與傳回的屬性類型相符。以此範例而言,結果是 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!");
相關連結