

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 명령 사용 시나리오
<a name="remote-command-use-cases"></a>

**중요**  
특정 AWS IoT FleetWise 기능에 대한 액세스는 현재 게이트됩니다. 자세한 내용은 [AWS AWS IoT FleetWise의 리전 및 기능 가용성](fleetwise-regions.md) 단원을 참조하십시오.

명령 기능을 사용할 때 다음 시나리오에서 명령을 생성하고 실행할 수 있습니다.
+ 생성 중에 파라미터를 생략하고 명령 ID만 지정할 수 있습니다. 이 경우 대상 디바이스에서 명령을 실행할 때 사용할 파라미터를 지정해야 합니다.
+ 명령을 생성할 때 하나 이상의 파라미터를 지정하고 기본값을 구성할 수 있습니다. 기본값을 제공하면 부정확한 명령을 보내지 않도록 보호할 수 있습니다.
+ 명령을 생성할 때 하나 이상의 파라미터를 지정하고 해당 파라미터의 값을 구성할 수 있습니다. 둘 이상의 파라미터를 제공할 수 있지만 둘 중 하나만 실행되며이 파라미터의 `Name` 필드는 `$actuatorPath` 접두사를 사용해야 합니다.

이 섹션에서는 `CreateCommand` 및 `StartCommandExecution` API와 파라미터 사용에 대한 몇 가지 사용 시나리오를 제공합니다. 또한 상태 템플릿과 함께 명령을 사용하는 몇 가지 예를 보여줍니다.

**Topics**
+ [파라미터 없이 명령 생성](#remote-command-use-case1)
+ [파라미터의 기본값을 사용하여 명령 생성](#remote-command-use-case2)
+ [파라미터 값을 사용하여 명령 생성](#remote-command-use-case3)
+ [상태 템플릿과 함께 명령 사용](#remote-command-use-cases-templates)

## 파라미터 없이 명령 생성
<a name="remote-command-use-case1"></a>

다음 사용 사례는 `CreateCommand` API 또는 `create-command` CLI를 사용하여 파라미터 없이 명령을 생성하는 방법을 보여줍니다. 명령을 생성할 때 명령 ID와 역할 ARN만 제공하면 됩니다.

이 사용 사례는 차량에 동일한 명령을 여러 번 보내려는 경우와 같은 반복 사용 사례에서 특히 유용합니다. 이 경우 명령은 특정 액추에이터에 연결되지 않으며 모든 액추에이터에서 명령을 실행할 수 있는 유연성을 제공합니다. `StartCommandExecution` API 또는 `start-command-execution` CLI를 사용하여 명령을 실행할 때 액추에이터와 물리적 신호 값을 포함하는 대신 런타임에 파라미터를 지정해야 합니다.

### `mandatory-parameters` 입력 없이 명령 생성
<a name="remote-command-use-case1-create"></a>

이 사용 사례는 필수 파라미터 입력 없이 명령을 생성하는 방법을 보여줍니다.

```
aws iot create-command \
    --command-id "UserJourney1" \
    --role-arn "arn:aws:iam:accountId:role/FwCommandExecutionRole" \
    --description "UserJourney1 - No mandatory parameters" \
    --namespace "AWS-IoT-FleetWise"
```

### `mandatory-parameters` 입력 없이 생성된 명령 실행
<a name="remote-command-use-case1-start"></a>

이 첫 번째 예제에서 위에서 생성된 명령을 사용하면 제한 없이 모든 액추에이터에서 명령을 실행할 수 있습니다. 값을 10`actuator1`으로 설정하려면 다음을 실행합니다.

```
aws iot-jobs-data start-command-execution \
    --command-arn arn:aws:iot:region:111122223333:command/UserJourney1 \
    --target-arn arn:aws:iot:region:111122223333:thing/target-vehicle \
    --parameters '{
        "$actuatorPath.Vehicle.actuator1": {"S": "10"}
    }'
```

마찬가지로를 값으로 설정하는 명령을 실행할 수 `actuator3` 있습니다`true`.

```
aws iot-jobs-data start-command-execution \
    --command-arn arn:aws:iot:region:111122223333:command/UserJourney1 \
    --target-arn arn:aws:iot:region:111122223333:thing/target-vehicle \
    --parameters '{
        "$actuatorPath.Vehicle.actuator3": {"S": "true"}
    }'
```

## 파라미터의 기본값을 사용하여 명령 생성
<a name="remote-command-use-case2"></a>

이 명령을 사용하면 지정된 액추에이터에서만 명령을 실행할 수 있습니다. 기본값을 제공하면 부정확한 명령을 보내지 않도록 보호할 수 있습니다. 예를 들어 문을 잠그고 잠금 해제하는 `LockDoor` 명령은 명령이 실수로 문을 잠금 해제하지 않도록 기본값으로 구성할 수 있습니다.

이 사용 사례는 동일한 명령을 여러 번 전송하고 차량 도어 잠금 및 잠금 해제와 같은 동일한 액추에이터에서 다른 작업을 수행하려는 경우에 특히 유용합니다. 액추에이터를 기본값으로 설정하려면 `start-command-execution` CLI에 qny`parameters`를 전달할 필요가 없습니다. `start-command-execution` CLI`parameters`에서에 대해 다른 값을 지정하면 기본값이 재정의됩니다.

### 에 대한 기본값을 사용하여 명령 생성 `mandatory-parameters`
<a name="remote-command-use-case2-create"></a>

다음 명령은 actuator1의 기본값을 제공하는 방법을 보여줍니다.

```
aws iot create-command \
    --command-id "UserJourney2" \
    --namespace "AWS-IoT-FleetWise" \
    --role-arn "arn:aws:iam:accountId:role/FwCommandExecutionRole" \
    --mandatory-parameters '[
        {
            "name": "$actuatorPath.Vehicle.actuator1",
            "defaultValue": {"S": "0"}
        }
    ]'
```

### 에 대한 기본값으로 생성된 명령 실행 `mandatory-parameters`
<a name="remote-command-use-case2-start"></a>

명령을 `UserJourney2` 사용하면 런타임 중에 입력 값을 전달할 필요 없이 명령을 실행할 수 있습니다. 이 경우 런타임 시 실행은 생성 중에 지정된 기본값을 사용합니다.

```
aws iot-data start-command-execution \
    --command-arn arn:aws:iot:region:111122223333:command/UserJourney3 \
    --target-arn arn:aws:iot:region:111122223333:thing/target-vehicle
```

런타임 중에 동일한 액추에이터인 actuator1에 대해 다른 값을 전달할 수도 있습니다. 그러면 기본값이 재정의됩니다.

```
aws iot-jobs-data start-command-execution \
    --command-arn arn:aws:iot:region:111122223333:command/UserJourney3 \
    --target-arn arn:aws:iot:region:111122223333:thing/target-vehicle \
    --parameters '{
        "$actuatorPath.Vehicle.actuator1": {"S": "139"}
    }'
```

## 파라미터 값을 사용하여 명령 생성
<a name="remote-command-use-case3"></a>

이 명령을 사용하면 지정된 액추에이터에서만 명령을 실행할 수 있습니다. 또한 런타임 중에 액추에이터 값을 강제로 설정합니다.

이 사용 사례는 최종 사용자가 일부 액추에이터를 차량에서 실행할 때 지정된 특정 작업만 수행하도록 하려는 경우에 특히 유용합니다.

**참고**  
`mandatory-parameters` 입력에 개 이상의 이름-값 페어가 있을 수 있으며, 일부 또는 전부에 대한 기본값이 있을 수 있습니다. 그런 다음 런타임 시 액추에이터 이름이 `$actuatorPath.` 접두사와 함께 정규화된 이름을 사용하는 경우 액추에이터에서 실행할 때 사용할 파라미터를 결정할 수 있습니다.

### 에 대한 기본값 없이 명령 생성 `mandatory-parameters`
<a name="remote-command-use-case3-create"></a>

이 명령을 사용하면 지정된 액추에이터에서만 명령을 실행할 수 있습니다. 또한 런타임 중에 액추에이터 값을 강제로 설정합니다.

```
aws iot create-command \
    --command-id "UserJourney2" \
    --namespace "AWS-IoT-FleetWise" \
    --role-arn "arn:aws:iam:accountId:role/FwCommandExecutionRole" \
    --mandatory-parameters '[
        {
            "name": "$actuatorPath.Vehicle.actuator1"
        }
    ]'
```

### 에 대한 기본값 없이 생성된 명령 실행 `mandatory-parameters`
<a name="remote-command-use-case3-start"></a>

명령을 실행할 때이 경우 actuator1 값을 지정해야 합니다. 아래 표시된 명령 실행은 값을 `actuator1`로 성공적으로 설정합니다`10`.

```
aws iot-data start-command-execution \    
    --command-arn arn:aws:iot:region:111122223333:command/UserJourney2 \
    --target-arn arn:aws:iot:region:111122223333:thing/target-vehicle \
    --parameters '{
        "$actuatorPath.Vehicle.actuator1": {"S": "10"}
    }'
```

## 상태 템플릿과 함께 명령 사용
<a name="remote-command-use-cases-templates"></a>

상태 데이터 수집 및 처리에 명령 API 작업을 사용할 수도 있습니다. 예를 들어 일회성 상태 스냅샷을 가져오거나 상태 템플릿을 활성화 또는 비활성화하여 차량 상태 데이터 수집을 시작하거나 중지할 수 있습니다. 다음 예제에서는 상태 템플릿과 함께 명령 기능을 사용하는 방법을 보여줍니다. 자세한 내용은 [데이터 수집 및 처리를 위한 상태 템플릿 작업](state-template-api-operations.md) 섹션을 참조하세요.

**참고**  
`mandatory-parameters` 입력의 일부로 지정된 이름 필드는 `$stateTemplate` 접두사를 사용해야 합니다.

### 예제 1: 기본값을 사용하여 상태 템플릿에 대한 명령 생성
<a name="remote-command-use-cases-template-ex1"></a>

이 예제에서는 `create-command` CLI를 사용하여 상태 템플릿을 활성화하는 방법을 보여줍니다.

```
aws iot create-command \
    --command-id <COMMAND_ID> \
    --display-name "Activate State Template" \
    --namespace AWS-IoT-FleetWise \    
    --mandatory-parameters '[
      {
          "name": "$stateTemplate.name"
      },
      {
          "name": "$stateTemplate.operation",
          "defaultValue": {"S": "activate"}
      }
    ]'
```

마찬가지로 다음 명령은 CLI를 상태 템플릿`start-command-execution`에 사용하는 방법의 예를 보여줍니다.

```
aws iot-data start-command-execution \
    --command-arn arn:aws:iot:region:111122223333:command/<COMMAND_ID> \
    --target-arn arn:aws:iot:region:111122223333:thing/<VEHICLE_NAME> \
    --parameters '{
       "$stateTemplate.name": {"S": "ST345"}
    }'
```

### 예제 2: 기본값 없이 상태 템플릿에 대한 명령 생성
<a name="remote-command-use-cases-template-ex2"></a>

다음 명령은 파라미터의 기본값 없이 여러 상태 템플릿을 생성합니다. 이러한 파라미터와 해당 값을 사용하여 명령을 실행하도록 강제합니다.

```
aws iot create-command \
    --command-id <COMMAND_ID> \
    --display-name "Activate State Template" \
    --namespace AWS-IoT-FleetWise \
    --mandatory-parameters '[
      {
          "name": "$stateTemplate.name",
          "defaultValue": {"S": "ST123"}
      },
      {
          "name": "$stateTemplate.operation",
          "defaultValue": {"S": "activate"}
      },
      {
          "name": "$stateTemplate.deactivateAfterSeconds",
          "defaultValue": {"L": "120"}
      } 
    ]'
```

다음 명령은 위의 예제에 `start-command-execution` CLI를 사용하는 방법을 보여줍니다.

```
aws iot-data start-command-execution \
    --command-arn arn:aws:iot:region:111122223333:command/<COMMAND_ID> \
    --target-arn arn:aws:iot:region:111122223333:thing/<VEHICLE_NAME> \
    --parameters '{
        "$stateTemplate.name": {"S": "ST345"},
        "$stateTemplate.operation": {"S": "activate"},
        "$stateTemplate.deactivateAfterSeconds" : {"L": "120"}
```