

AWS IoT FleetWise 不再向新客戶開放。現有的 AWS IoT FleetWise 客戶可以繼續使用 服務。[上的連線行動性指南 AWS](https://aws.amazon.com/solutions/guidance/connected-mobility-on-aws/)提供如何為連線行動解決方案開發和部署模組化服務的指引，這些解決方案可用於實現與 AWS IoT FleetWise 同等的功能。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 診斷故障碼使用案例
<a name="dtc-use-cases"></a>

**重要**  
對特定 AWS IoT FleetWise 功能的存取目前受到鎖定。如需詳細資訊，請參閱[AWS AWS IoT FleetWise 中的區域和功能可用性](fleetwise-regions.md)。

下列使用案例假設 `DTC_QUERY`函數已在[示範指令碼](https://github.com/aws/aws-iot-fleetwise-edge/blob/main/docs/dev-guide/edge-agent-uds-dtc-dev-guide.md)中定義。

## 定期擷取
<a name="dtc-periodic-fetch"></a>

以設定的間隔擷取 DTC 集合。

下列範例是具有針對所有 ECUs `Vehicle.DTC_INFO` 狀態遮罩的所有 DTCs 定期擷取訊號的行銷活動。為 收集的資料有一項條件`Vehicle.DTC_INFO`。

```
{
  "compression": "SNAPPY",
  "spoolingMode": "TO_DISK",
  "signalsToFetch": [
    {
      "fullyQualifiedName": "Vehicle.ECU1.DTC_INFO",
      "signalFetchConfig": {
        "timeBased": {
        // The FleetWise Edge Agent will query the UDS module for all DTCs every five seconds.
          "executionFrequencyMs": 5000
        }
      },
      "actions": [
      // Every five seconds, this action is called and its output is stored in the
      // signal history buffer of Vehicle.DTC_INFO
        "custom_function(\"DTC_QUERY\", -1, 2, -1)"
      ]
    }
  ],
  "signalsToCollect": [
    {
      "name": "Vehicle.ECU1.DTC_INFO"
    }
  ],
  "collectionScheme": {
    "conditionBasedCollectionScheme": {
      "conditionLanguageVersion": 1,
      // Whenever a new DTC is filled into the signal, the data is ingested.
      "expression": "!isNull($variable.`Vehicle.ECU1.DTC_INFO`)",
      "minimumTriggerIntervalMs": 1000,
      // Make sure that data is ingested only when there are new DTCs.
      "triggerMode": "RISING_EDGE"
    }
  },
  "dataDestinationConfigs": [
    {
      "s3Config": 
        {
          "bucketArn": "bucket-arn",
          "dataFormat": "PARQUET",
          "prefix": "campaign-name",
          "storageCompressionFormat": "GZIP"
        }
    }
  ]
}
```

## 條件驅動型擷取
<a name="dtc-condition-fetch"></a>

符合條件時擷取 DTC 集合。例如，當 CAN 訊號為 時`Vehicle.Ignition == 1`，請擷取並上傳 DTC 資料。

下列範例行銷活動具有 的條件驅動訊號擷取`Vehicle.ECU1.DTC_INFO`，以檢查 DTC ("AAA123") 是否在 ECU-1 的 recordNumber 1 中等待。此行銷活動具有以時間為基礎的資料收集和上傳。

```
{
  "compression": "SNAPPY",
  "spoolingMode": "TO_DISK",
  "signalsToFetch": [
    {
      "fullyQualifiedName": "Vehicle.ECU1.DTC_INFO",
      "signalFetchConfig": {
        "conditionBased": {
        // The action will only run when the ignition is on.
          "conditionExpression": "$variable.`Vehicle.Ignition` == 1",
          "triggerMode": "ALWAYS"
        }
      },
      // The UDS module is only requested for the specific ECU address and the specific DTC Number/Status.
      "actions": ["custom_function(\"DTC_QUERY\", 1, 2, 8, \"0xAAA123\")"]
    }
  ],
  "signalsToCollect": [
    {
      "name": "Vehicle.ECU1.DTC_INFO"
    },
    {
      "name": "Vehicle.Ignition"
    }
  ],
  "collectionScheme": {
    "timeBasedCollectionScheme": {
      "periodMs": 10000
    }
  },
  "dataDestinationConfigs": [
    {
      "s3Config": 
        {
          "bucketArn": "bucket-arn",
          "dataFormat": "PARQUET",
          "prefix": "campaign-name",
          "storageCompressionFormat": "GZIP"
        }
    }
  ]
}
```

## 隨需擷取
<a name="fetch-dtc-for-fleet"></a>

擷取機群的特定 DTC。

對於隨需使用案例，您可以使用與定期擷取中定義的相同行銷活動。使用 AWS IoT FleetWise 主控台或執行下列 CLI 命令，在行銷活動部署後立即暫停行銷活動，即可實現隨需效果。
+ 將 {{command-name}} 取代為命令名稱。

```
aws iotfleetwise update-campaign \
    --name {{campaign-name}} \
    --action APPROVE
```

然後，在 DTC 資料送達後暫停行銷活動。

```
aws iotfleetwise update-campaign \
    --name {{campaign-name}} \
    --action SUSPEND
```

您可以再次繼續行銷活動以進行 DTC 資料擷取。

```
aws iotfleetwise update-campaign \
    --name {{campaign-name}} \
    --action RESUME
```