setPreset method

Future<String> setPreset(
  1. String profileToken, {
  2. String? presetName,
  3. String? presetToken,
})

The setPreset command saves the current device position parameters so that the device can move to the saved preset position through the gotoPreset operation. In order to create a new Preset, the SetPresetRequest contains no PresetToken. If creation is successful, the Response contains the PresetToken which uniquely identifies the Preset. An existing Preset can be overwritten by specifying the PresetToken of the corresponding Preset. In both cases (overwriting or creation) an optional PresetName can be specified. The operation fails if the PTZ device is moving during the setPreset operation. The device may internally save additional states such as imaging properties in the PTZ Preset which then should be recalled in the gotoPreset operation.

ACCESS CLASS: ACTUATE

Implementation

Future<String> setPreset(
  String profileToken, {
  String? presetName,
  String? presetToken,
}) async {
  loggy.debug('setPreset');

  final responseEnvelope = await transport.securedRequest(
      uri,
      soap.Body(
        request: PtzRequest.setPreset(
          profileToken,
          presetName: presetName,
          presetToken: presetToken,
        ),
      ));

  if (responseEnvelope.body.hasFault) {
    throw Exception(responseEnvelope.body.fault.toString());
  }

  return SetPresetResponse.fromJson(responseEnvelope.body.response!)
      .presetToken;
}