setPreset method

Future<String> setPreset(
  1. String profileToken,
  2. Preset preset
)

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.

Implementation

Future<String> setPreset(String profileToken, Preset preset) async {
  final envelope = await Soap.retrieveEnvlope(
      uri, onvif.secureRequest(SoapRequest.setPreset(profileToken, preset)),
      postProcess: (String xmlBody, dynamic jsonMap, Envelope envelope) {
    print(xmlBody);
    print('\n\n');
    print(jsonMap);
  });

  if (envelope.body.setPresetResponse == null) throw Exception();

  return envelope.body.setPresetResponse!.presetToken;
}