faithoflifedev / easy_onvif_workspace

This package works with a variety of ONVIF compatible devices allowing for IP Cameras and NVRs (network video recorders) to be integrated into Dart and Flutter applications.
33 stars 21 forks source link

continuousMove - how to use? #18

Closed Pioxis closed 2 years ago

Pioxis commented 2 years ago

Hello,

I'm trying to use cointinuousMove like absoluteMove or relativeMove but in that case I have error called "Null check operator used on a null value".

For example when I'm using absoluteMove:

await insertO.ptz.absoluteMove(
      profs[0].token,
      PtzPosition(
          panTilt: PanTilt(
              x: (status.position.panTilt!.x <= -0.97) ? status.position.panTilt!.x +
                  (status.position.panTilt!.x * -1) : status.position
                  .panTilt!.x - 0.035,
              y: status.position.panTilt!.y
          )
      )
  );

or

int step = 50;
await insertO.ptz.moveLeft(profs[0].token, step);

then that is working, but it is step moveing, not continuous.

But when I'm trying:

await insertO.ptz.continuousMove(
      profs[0].token,
      PtzPosition(
          panTilt: PanTilt(
              x: (status.position.panTilt!.x <= -0.97) ? status.position.panTilt!.x +
                  (status.position.panTilt!.x * -1) : status.position
                  .panTilt!.x - 0.035,
              y: status.position.panTilt!.y
          )
      )
  );

or:

int step = 25;
await insertO.ptz.continuousMove(
      profs[0].token,
      PtzPosition(
          panTilt: PanTilt.fromInt(x: 0 - step, y: 0),
      )
  );

Then I have error from log:

[log] {"Position":{"PanTilt":{"@x":-0.195,"@y":0.727778,"@space":"http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace"},"Zoom":{"@x":0.0,"@space":"http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace"}},"Error":"NO error","UtcTime":"2022-08-11T01:48:01.000Z"}
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0      SoapRequest.continuousMove.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:easy_onvif/src/soap.dart:557:47)
#1      XmlBuilder._insert (package:xml/src/xml/builder.dart:310:12)
#2      XmlBuilder.element (package:xml/src/xml/builder.dart:177:9)
#3      SoapRequest.continuousMove.<anonymous closure>.<anonymous closure> (package:easy_onvif/src/soap.dart:555:17)
#4      XmlBuilder._insert (package:xml/src/xml/builder.dart:310:12)
#5      XmlBuilder.element (package:xml/src/xml/builder.dart:177:9)
#6      SoapRequest.continuousMove.<anonymous closure> (package:easy_onvif/src/soap.dart:546:15)
#7      XmlBuilder._insert (package:xml/src/xml/builder.dart:310:12)
#8      XmlBuilder.element (package:xml/src/xml/builder.dart:177:9)
#9      SoapRequest.continuousMove (package:easy_onvif/src/soap.dart:538:13)
#10     Ptz.continuousMove (package:easy_onvif/src/ptz.dart:50:25)
#11     onvifMoveLeft (package:radio_camview/onvif_manager.dart:52:21)
<asynchronous suspension>

I'm really basic in programming with Dart and Flutter, so I will be really thankful if you will help me with that problem.

faithoflifedev commented 2 years ago

Hi @Pioxis, it looks like I had a bug in the code for the case where PtzPosition did not include a Zoom. This has been corrected in the latest v2.0.9 release.