public void RelativeMove(string profile, PTZVector translation) { RunInBackground(new Action(() => { Client.RelativeMove(profile, translation, null); })); }
public void AbsoluteMove(string profile, PTZVector position) { RunInBackground(new Action(() => { Client.AbsoluteMove(profile, position, null); })); }
public OnVifPTZController(OnVifDevice OnVifDevice) : base(OnVifDevice) { // m_onVifDevice = OnVifDevice; // m_mediaClient = null; //m_profile = null; m_Timer = null; m_velocity = null; m_vector = null; m_options = null; m_relative = false; m_initialised = false; m_direction = m_direction = Direction.None; m_Presets = null; m_capabilities = null; m_ptzClient = null; m_ErrorMessage = ""; m_configs = null; m_initialised = false; m_panDistance = 0; m_tiltDistance = 0; m_bMoveActiv = false; m_timeinmsec = 200; m_doContineousMode = false; m_ProfileRefToken = ""; }
/// <summary> /// Moves camera to specified position /// </summary> /// <param name="absolute"></param> /// <param name="profile">profile token</param> /// <param name="x">pan position (-1..1)</param> /// <param name="y">tilt position (-1..1)</param> /// <param name="z">zoom position (0..1)</param> public void AbosuteRelativeMove(bool absolute, string profile, decimal x, decimal y, decimal z) { _ptzClientWorking = true; IntializePtzClient(View.PTZAddress); PTZVector vector = new PTZVector(); vector.PanTilt = new Vector2D(); vector.PanTilt.space = absolute ? "http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace" : "http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace"; vector.PanTilt.x = (float)x; vector.PanTilt.y = (float)y; vector.Zoom = new Vector1D(); vector.Zoom.space = absolute ? "http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace" : "http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace"; vector.Zoom.x = (float)z; if (absolute) { _ptzClient.AbsoluteMove(profile, vector); } else { _ptzClient.RelativeMove(profile, vector); } }
public void AbsoluteMoveFaultTest() { RunTest(() => { PTZConfigurationOptions options; Profile profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason = null; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); if (Features.Contains(Feature.PTZAbsolutePanTilt)) { PTZVector pantilt = new PTZVector(); pantilt.PanTilt = new Vector2D(); pantilt.PanTilt.space = options.Spaces.AbsolutePanTiltPositionSpace[0].URI; pantilt.PanTilt.x = options.Spaces.AbsolutePanTiltPositionSpace[0].XRange.Max + 1; pantilt.PanTilt.y = options.Spaces.AbsolutePanTiltPositionSpace[0].YRange.Max + 1; AbsoluteInvalidMove(profile.token, pantilt); } else if (Features.Contains(Feature.PTZAbsoluteZoom)) { PTZVector zoom = new PTZVector(); zoom.Zoom = new Vector1D(); zoom.Zoom.space = options.Spaces.AbsoluteZoomPositionSpace[0].URI; zoom.Zoom.x = options.Spaces.AbsoluteZoomPositionSpace[0].XRange.Max + 1; AbsoluteInvalidMove(profile.token, zoom); } }); }
public OnvifPtzRelativeMove(string uri, string userName, string password, string profileToken, PTZVector traslation, PTZSpeed speed) : base(uri, userName, password) { ProfileToken = profileToken; Traslation = traslation; Speed = speed; }
public void MoveAbsolute(PTZVector position, PTZSpeed speed) { CurrentSession .AbsoluteMove(profileToken, position, speed) .ObserveOnCurrentDispatcher() .Subscribe(unit => {}, err => SetErrorMessage(err.Message)); }
/// <summary> /// Возвращает вектор движения и количество шагов /// </summary> /// <param name="vector">Вектор направления</param> /// <param name="steep">Количество шагов</param> /// <returns></returns> public PTZVector GetVector(PTZParameters.Vector vector, float steep = 1f) { var p = new PTZVector { PanTilt = new Vector2D() { space = "http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace", }, Zoom = new Vector1D() { x = 0, }, }; if (vector == PTZParameters.Vector.UP) { p.PanTilt.y = -steep; } if (vector == PTZParameters.Vector.DOWN) { p.PanTilt.y = steep; } if (vector == PTZParameters.Vector.LEFT) { p.PanTilt.x = -steep; } if (vector == PTZParameters.Vector.RIGHT) { p.PanTilt.x = steep; } return(p); }
public OnvifPtzAbsoluteMove(string uri, string userName, string password, string profileToken, PTZVector position, PTZSpeed speed) : base(uri, userName, password) { ProfileToken = uri; Position = position; Speed = speed; }
public static void RotatePTZ(Structures set, PTZVector vector, OPTZ.PTZSpeed speed) { try { if (set.GetPTZTokens() == "" || !set.IsActive) { return; } var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic; CustomBinding bind = new CustomBinding(messageElement, httpBinding); EndpointAddress mediaAddress = new EndpointAddress(set.GetONVIF + "/onvif/PTZ"); PTZClient mediaClient = new PTZClient(bind, mediaAddress); mediaClient.ClientCredentials.UserName.UserName = set.Login; mediaClient.ClientCredentials.UserName.Password = set.Password; var t = mediaClient.GetConfigurations()[0].DefaultPTZTimeout; mediaClient.RelativeMove(set.GetMediaTokens()[0], vector, speed); //set.GetMediaTokens()[0] //mediaClient.ContinuousMove(set.GetMediaTokens()[0], speed) } catch { return; } }
public void GenericPanTiltTranslation() { RunTest(() => { PTZNode[] nodes = GetNodes(); foreach (PTZNode node in nodes) { // select node that supports RelativePanTiltPositionSpace Space2DDescription[] relativePanTiltSpaces = node.SupportedPTZSpaces.RelativePanTiltTranslationSpace; if (relativePanTiltSpaces != null) { LogTestEvent(string.Format("Node (token = {0}) supports RelativePanTilt move{1}", node.token, System.Environment.NewLine)); } else { // if current node doesn't support RelativePanTiltPositionSpace // then check next node continue; } // verify that RelativePanTiltPositionSpace contains Translation Generic Pan/Tilt Space Space2DDescription translationGenericPanTiltSpace = relativePanTiltSpaces.FirstOrDefault(space => space.URI == _relativePanTiltSpace); Assert(translationGenericPanTiltSpace != null, "RelativePanTiltPositionSpace element doesn't contain mandatory space", "Verifying of Translation Generic Pan/Tilt Space presence"); // verify that allowed range is specified Assert(translationGenericPanTiltSpace.XRange.Max >= translationGenericPanTiltSpace.XRange.Min && translationGenericPanTiltSpace.YRange.Max >= translationGenericPanTiltSpace.YRange.Min, "Incorrect space range", "Verifying of space range"); // configure and select a media profile PTZConfigurationOptions options; Profile profile = GetPTZProfile(node, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); PTZVector vector = new PTZVector(); vector.PanTilt = new Vector2D(); // check min ranges vector.PanTilt.space = translationGenericPanTiltSpace.URI; vector.PanTilt.x = translationGenericPanTiltSpace.XRange.Min; vector.PanTilt.y = translationGenericPanTiltSpace.YRange.Min; RelativeMove(profile.token, vector, null); // check max ranges vector.PanTilt.space = translationGenericPanTiltSpace.URI; vector.PanTilt.x = translationGenericPanTiltSpace.XRange.Max; vector.PanTilt.y = translationGenericPanTiltSpace.YRange.Max; RelativeMove(profile.token, vector, null); } }); }
internal PTZPresetItem(string name, string token, PTZVector position, int nIdx) //internal PTZPresetItem(string name, string token, int nIdx) { m_nameField = name; m_tokenField = token; m_pTZPositionField = position; m_nIdx = nIdx; }
public void GenericZoomPosition() { RunTest(() => { PTZNode[] nodes = GetNodes(); foreach (PTZNode node in nodes) { // select node that supports AbsoluteZoomPositionSpace Space1DDescription[] absoluteZoomSpaces = node.SupportedPTZSpaces.AbsoluteZoomPositionSpace; if (absoluteZoomSpaces != null) { LogTestEvent(string.Format("Node (token = {0}) supports AbsoluteZoom move{1}", node.token, System.Environment.NewLine)); } else { // if current node doesn't support AbsoluteZoomPositionSpace // then check next node continue; } // verify that AbsoluteZoomPositionSpace contains Position Generic Zoom Space Space1DDescription positionGenericZoomSpace = absoluteZoomSpaces.FirstOrDefault(space => space.URI == _absoluteZoomSpace); Assert(positionGenericZoomSpace != null, "AbsoluteZoomPositionSpace element doesn't contain mandatory space", "Verifying of Position Generic Zoom Space presence"); // verify that allowed range is specified Assert(positionGenericZoomSpace.XRange.Max >= positionGenericZoomSpace.XRange.Min, "Incorrect space range", "Verifying of space range"); // configure and select a media profile PTZConfigurationOptions options; Profile profile = GetPTZProfile(node, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); PTZVector vector = new PTZVector(); vector.Zoom = new Vector1D(); // check max ranges vector.Zoom.space = positionGenericZoomSpace.URI; vector.Zoom.x = positionGenericZoomSpace.XRange.Max; AbsoluteMove(profile.token, vector, null); // check min ranges vector.Zoom.space = positionGenericZoomSpace.URI; vector.Zoom.x = positionGenericZoomSpace.XRange.Min; AbsoluteMove(profile.token, vector, null); } }); }
public override void AbsoluteMove(string ProfileToken, PTZVector Position, PTZSpeed Speed) { TestSuitInit(); int timeOut; SoapException ex; StepType stepType = m_PTZServiceTest.AbsoluteMoveTest(out ex, out timeOut, ProfileToken, Position, Speed); StepTypeProcessing(stepType, ex, timeOut); }
public void MoveRelative(PTZVector translation, PTZSpeed speed) { CurrentSession .RelativeMove(profileToken, translation, speed) .ObserveOnCurrentDispatcher() .Subscribe( unit => {}, err => { //dbg.Error(err); SetErrorMessage(err.Message); } ); }
public void AbosuteRelativeIncrementalMove( bool absolute, string profile, decimal xmin, decimal xmax, decimal ymin, decimal ymax, decimal zmin, decimal zmax) { RunInBackground(new Action(() => { PTZVector vector = new PTZVector(); vector.PanTilt = new Vector2D(); vector.PanTilt.space = absolute ? "http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace" : "http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace"; vector.Zoom = new Vector1D(); vector.Zoom.space = absolute ? "http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace" : "http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace"; for (decimal x = xmin; x <= xmax; x += (decimal)0.2) { for (decimal y = ymin; y <= ymax; y += (decimal)0.2) { for (decimal z = zmin; z <= zmax; z += (decimal)0.2) { vector.PanTilt.x = (float)x; vector.PanTilt.y = (float)y; vector.Zoom.x = (float)z; if (absolute) { Client.AbsoluteMove(profile, vector, null); } else { Client.RelativeMove(profile, vector, null); } Thread.Sleep(300); } } } })); }
public void GenericPanTiltPosition() { RunTest(() => { PTZNode[] nodes = GetNodes(); Profile[] profiles = GetProfiles(); foreach (PTZNode node in nodes) { string reason = null; Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title); Space2DDescription[] spaces = node.SupportedPTZSpaces.AbsolutePanTiltPositionSpace; Space2DDescription generic = spaces != null ? spaces.FirstOrDefault(space => string.Compare(space.URI, _absolutePanTiltSpace) == 0) : null; Assert((generic != null) && (generic.XRange != null) && (generic.YRange != null), "Node does not support generic absolute pan/tilt position space or space ranges are missing", "Validating generic absolute pan/tilt position space"); PTZConfigurationOptions options; Profile profile = GetPTZProfile(profiles, node.token, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); //check max ranges PTZVector vector = new PTZVector(); vector.PanTilt = new Vector2D(); vector.PanTilt.space = generic.URI; vector.PanTilt.x = generic.XRange.Max; vector.PanTilt.y = generic.YRange.Max; AbsoluteMove(profile.token, vector, null); //check min ranges vector.PanTilt.x = generic.XRange.Min; vector.PanTilt.y = generic.YRange.Min; AbsoluteMove(profile.token, vector, null); } }); }
public void GenericZoomTranslation() { RunTest(() => { PTZNode[] nodes = GetNodes(); foreach (PTZNode node in nodes) { string reason = null; Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title); Space1DDescription[] spaces = node.SupportedPTZSpaces.RelativeZoomTranslationSpace; Space1DDescription generic = spaces != null ? spaces.FirstOrDefault(space => string.Compare(space.URI, _relativeZoomSpace) == 0) : null; Assert((generic != null) && (generic.XRange != null), "Node does not support generic relative zoom translation space or space ranges are missing", "Validating generic relative zoom translation space"); PTZConfigurationOptions options; Profile profile = GetPTZProfile(node, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); //check max ranges PTZVector vector = new PTZVector(); vector.Zoom = new Vector1D(); vector.Zoom.space = generic.URI; vector.Zoom.x = generic.XRange.Max; RelativeMove(profile.token, vector, null); //check min ranges vector.Zoom.x = generic.XRange.Min; RelativeMove(profile.token, vector, null); } }); }
public void AbsoluteMoveTest() { RunTest(() => { PTZConfigurationOptions options; Profile profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason = null; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); Assert(options.Spaces.AbsolutePanTiltPositionSpace != null || options.Spaces.AbsoluteZoomPositionSpace != null, "Node does not support Absolute move", "Check if Absolute move is supported"); //select pantilt and zoom spaces Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; //set selected spaces as default if they are not (we need it to get position in these spaces) BeginStep("Check if configuration needs to be updated"); bool updateNeeded = false; string dump = string.Empty; if (Features.Contains(Feature.PTZAbsolutePanTilt)) { pantiltSpace = options.Spaces.AbsolutePanTiltPositionSpace[0]; bool update = false; if (string.IsNullOrEmpty(profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace)) { update = true; } else { update = (!EqualSpaces(pantiltSpace.URI, profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace)); } if (update) { updateNeeded = true; dump += string.Format("DefaultAbsolutePantTiltPositionSpace={0}", pantiltSpace.URI); profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace = pantiltSpace.URI; } } if (Features.Contains(Feature.PTZAbsoluteZoom)) { zoomSpace = options.Spaces.AbsoluteZoomPositionSpace[0]; bool update = false; if (string.IsNullOrEmpty(profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace)) { update = true; } else { update = !EqualSpaces(zoomSpace.URI, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace); } if (update) { updateNeeded = true; string localdump = string.Format( "DefaultAbsoluteZoomPositionSpace={0}", zoomSpace.URI); if (string.IsNullOrEmpty(dump)) { dump = localdump; } else { dump += string.Format(", {0}", localdump); } profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace = zoomSpace.URI; } } StepPassed(); if (updateNeeded) { SetConfiguration(profile.PTZConfiguration, false, dump); } PTZStatus status = GetPTZStatus(profile.token); PTZVector pantilt = null; PTZVector zoom = null; if (pantiltSpace != null) { PTZSpeed speed = null; if ((options.Spaces.PanTiltSpeedSpace != null) && (options.Spaces.PanTiltSpeedSpace.Length > 0)) { Space1DDescription space = options.Spaces.PanTiltSpeedSpace[0]; speed = new PTZSpeed(); speed.PanTilt = new Vector2D(); speed.PanTilt.space = space.URI; speed.PanTilt.x = space.XRange.Max; speed.PanTilt.y = space.XRange.Max; } pantilt = new PTZVector(); pantilt.PanTilt = new Vector2D(); pantilt.PanTilt.space = pantiltSpace.URI; pantilt.PanTilt.x = pantiltSpace.XRange.Max; pantilt.PanTilt.y = pantiltSpace.YRange.Max; AbsoluteMove(profile.token, pantilt, speed); } if (zoomSpace != null) { PTZSpeed speed = null; if ((options.Spaces.ZoomSpeedSpace != null) && (options.Spaces.ZoomSpeedSpace.Length > 0)) { Space1DDescription space = options.Spaces.ZoomSpeedSpace[0]; speed = new PTZSpeed(); speed.Zoom = new Vector1D(); speed.Zoom.space = space.URI; speed.Zoom.x = space.XRange.Max; } zoom = new PTZVector(); zoom.Zoom = new Vector1D(); zoom.Zoom.space = zoomSpace.URI; zoom.Zoom.x = zoomSpace.XRange.Max; AbsoluteMove(profile.token, zoom, speed); } status = GetPTZStatus(profile.token); if (status.Position != null) { CheckPTZPosition(status.Position, pantilt, zoom, pantiltSpace, zoomSpace); } }); }
public void RelativeMoveTest() { RunTest(() => { PTZConfigurationOptions options; Profile profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason = null; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); Assert(options.Spaces.RelativePanTiltTranslationSpace != null || options.Spaces.RelativeZoomTranslationSpace != null, "Node does not support Relative move", "Check if Relative move is supported"); //Set default spaces to generic, if they are not. We need it to get position in generic spaces bool changed = false; string dump = string.Empty; BeginStep("Check if configuration needs to be updated"); if (Features.Contains(Feature.PTZRelativePanTilt) && (string.IsNullOrEmpty(profile.PTZConfiguration.DefaultRelativePanTiltTranslationSpace) || !EqualSpaces(_relativePanTiltSpace, profile.PTZConfiguration.DefaultRelativePanTiltTranslationSpace))) { profile.PTZConfiguration.DefaultRelativePanTiltTranslationSpace = _relativePanTiltSpace; changed = true; dump = string.Format("DefaultRelativePanTiltTranslationSpace={0}", profile.PTZConfiguration.DefaultRelativePanTiltTranslationSpace); } if (Features.Contains(Feature.PTZRelativeZoom) && (string.IsNullOrEmpty(profile.PTZConfiguration.DefaultRelativeZoomTranslationSpace) || !EqualSpaces(_relativeZoomSpace, profile.PTZConfiguration.DefaultRelativeZoomTranslationSpace))) { profile.PTZConfiguration.DefaultRelativeZoomTranslationSpace = _relativeZoomSpace; changed = true; if (!string.IsNullOrEmpty(dump)) { dump += ", "; } dump += string.Format("DefaultRelativeZoomTranslationSpace={0}", profile.PTZConfiguration.DefaultRelativeZoomTranslationSpace); } StepPassed(); if (changed) { SetConfiguration(profile.PTZConfiguration, false, dump); } PTZStatus status = GetPTZStatus(profile.token); PTZVector oldPosition = status.Position; PTZVector pantilt = null; PTZVector zoom = null; Space1DDescription zoomOptions = null; if (Features.Contains(Feature.PTZRelativeZoom)) { zoomOptions = options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault( o => string.Compare(o.URI, _relativeZoomSpace, true) == 0); } Space2DDescription pantiltOptions = null; if (Features.Contains(Feature.PTZRelativePanTilt)) { pantiltOptions = options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault( o => string.Compare(o.URI, _relativePanTiltSpace, true) == 0); } if (Features.Contains(Feature.PTZRelativePanTilt)) { PTZSpeed speed = null; if ((options.Spaces.PanTiltSpeedSpace != null) && (options.Spaces.PanTiltSpeedSpace.Length > 0)) { Space1DDescription space = options.Spaces.PanTiltSpeedSpace[0]; speed = new PTZSpeed(); speed.PanTilt = new Vector2D(); speed.PanTilt.space = space.URI; speed.PanTilt.x = space.XRange.Max; speed.PanTilt.y = space.XRange.Max; } pantilt = new PTZVector(); pantilt.PanTilt = new Vector2D(); //use generic space, so we can calculate new position pantilt.PanTilt.space = pantiltOptions.URI; //options.Spaces.RelativePanTiltTranslationSpace[0].URI; pantilt.PanTilt.x = pantiltOptions.XRange.Max; // options.Spaces.RelativePanTiltTranslationSpace[0].XRange.Max; pantilt.PanTilt.y = pantiltOptions.YRange.Max; // options.Spaces.RelativePanTiltTranslationSpace[0].YRange.Max; RelativeMove(profile.token, pantilt, speed); } if (Features.Contains(Feature.PTZRelativeZoom)) { PTZSpeed speed = null; if ((options.Spaces.ZoomSpeedSpace != null) && (options.Spaces.ZoomSpeedSpace.Length > 0)) { Space1DDescription space = options.Spaces.ZoomSpeedSpace[0]; speed = new PTZSpeed(); speed.Zoom = new Vector1D(); speed.Zoom.space = space.URI; speed.Zoom.x = space.XRange.Max; } zoom = new PTZVector(); zoom.Zoom = new Vector1D(); zoom.Zoom.space = zoomOptions.URI; zoom.Zoom.x = zoomOptions.XRange.Max; RelativeMove(profile.token, zoom, speed); } status = GetPTZStatus(profile.token); if ((status.Position != null) && (oldPosition != null)) { //translate position if ((oldPosition.PanTilt != null) && (pantilt != null)) { pantilt.PanTilt.x = pantilt.PanTilt.x + oldPosition.PanTilt.x > 1 ? 1 : pantilt.PanTilt.x + oldPosition.PanTilt.x; pantilt.PanTilt.y = pantilt.PanTilt.y + oldPosition.PanTilt.y > 1 ? 1 : pantilt.PanTilt.y + oldPosition.PanTilt.y; } if ((oldPosition.Zoom != null) && (zoom != null)) { zoom.Zoom.x = zoom.Zoom.x + oldPosition.Zoom.x > 1 ? 1 : zoom.Zoom.x + oldPosition.Zoom.x; } //change relative spaces to absolute spaces, because status returns position in absolute space if (pantilt != null) { pantilt.PanTilt.space = _absolutePanTiltSpace; } if (zoom != null) { zoom.Zoom.space = _absoluteZoomSpace; } CheckPTZPosition(status.Position, pantilt, zoom, pantiltOptions, zoomOptions); } }); }
public void ConfigurableHome() { RunTest(() => { Assert(Features.ContainsFeature(Feature.PTZAbsoluteOrRelative), "No Absolute or Relative movement is supported", "Check that Absolute or Relative movement is supported"); PTZConfigurationOptions options; Profile profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //absolute or relative move should be supported - use generic space for position or translation bool absoluteMoveSupported = Features.Contains(Feature.PTZAbsolute); Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; // pantilt movement is used if corresponding Pan/Tilt is supported bool panTilt = (absoluteMoveSupported && Features.ContainsFeature(Feature.PTZAbsolutePanTilt)) || (!absoluteMoveSupported && Features.ContainsFeature(Feature.PTZRelativePanTilt)); bool absoluteZoom = absoluteMoveSupported && Features.Contains(Feature.PTZAbsoluteZoom); bool relativeZoom = !absoluteMoveSupported && Features.Contains(Feature.PTZRelativeZoom); bool zoom = absoluteZoom || relativeZoom; PTZVector vector = new PTZVector(); if (panTilt) { pantiltSpace = absoluteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) : options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0); vector.PanTilt = new Vector2D(); vector.PanTilt.space = pantiltSpace.URI; vector.PanTilt.x = pantiltSpace.XRange.Min; vector.PanTilt.y = pantiltSpace.YRange.Min; } if (zoom) { zoomSpace = absoluteZoom ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) : options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom = new Vector1D(); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); SetHomePosition(profile.token); //move to another position Vector2D oldPanTilt = vector.PanTilt; if (oldPanTilt != null) { vector.PanTilt = new Vector2D(); vector.PanTilt.space = oldPanTilt.space; vector.PanTilt.x = pantiltSpace.XRange.Max; vector.PanTilt.y = pantiltSpace.YRange.Max; } Vector1D oldZoom = vector.Zoom; if (oldZoom != null) { vector.Zoom = new Vector1D(); vector.Zoom.space = oldZoom.space; vector.Zoom.x = zoomSpace.XRange.Max; } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); GotoHomePosition(profile.token, null, _homeMoveTimeout); RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); PTZStatus status = GetPTZStatus(profile.token); vector.PanTilt = oldPanTilt; vector.Zoom = oldZoom; if (status.Position != null) { CheckPTZPosition(status.Position, vector, vector, pantiltSpace, zoomSpace); } }, () => { CloseVideo(); }); }
// public bool IsInitialized { get { return m_initialised; } } public override async Task <bool> InitalizeAsync() { if (this.m_onVifDevice.ServicesResponse == null) { bool b = await this.m_onVifDevice.InitalizeDeviceAsync(); if (this.m_onVifDevice.ServicesResponse == null) { return(false); } } try { foreach (var service in this.m_onVifDevice.ServicesResponse.Service) { if (service.Namespace == "http://www.onvif.org/ver20/ptz/wsdl") { string serviceAdress = service.XAddr; m_ErrorMessage = ""; // m_profile = this.m_media10Services.ProfilesResponse.Profiles[0]; HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest; var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); CustomBinding binding = new CustomBinding(messageElement, httpBinding); this.m_ptzClient = new PTZClient(binding, new EndpointAddress(serviceAdress)); /* * while (m_ptzClient.Endpoint.EndpointBehaviors.Count > 0) * { * m_ptzClient.Endpoint.EndpointBehaviors.RemoveAt(0); * } */ m_ptzClient.Endpoint.EndpointBehaviors.Add(m_onVifDevice.GetBasicBasicAuthBehaviour); m_ptzClient.Endpoint.EndpointBehaviors.Add(m_onVifDevice.GetPasswordDigestBehavior); m_configs = await m_ptzClient.GetConfigurationsAsync(); m_options = await m_ptzClient.GetConfigurationOptionsAsync(m_configs.PTZConfiguration[0].token); m_capabilities = await m_ptzClient.GetServiceCapabilitiesAsync(); m_velocity = new OnvifPTZService.PTZSpeed() { PanTilt = new OnvifPTZService.Vector2D() { x = 0, y = 0, space = m_options.Spaces.ContinuousPanTiltVelocitySpace[0].URI, } , Zoom = new OnvifPTZService.Vector1D() { x = 0, space = m_options.Spaces.ContinuousZoomVelocitySpace[0].URI, } }; m_vector = new PTZVector() { PanTilt = new OnvifPTZService.Vector2D() { x = 0, y = 0, space = m_options.Spaces.RelativePanTiltTranslationSpace[0].URI } }; m_initialised = true; m_bMoveActiv = false; if (m_relative) { m_velocity.PanTilt.space = m_options.Spaces.ContinuousPanTiltVelocitySpace[0].URI; m_velocity.PanTilt.space = m_configs.PTZConfiguration[0].DefaultPTZSpeed.PanTilt.space; m_panDistance = (m_options.Spaces.RelativePanTiltTranslationSpace[0].XRange.Max - m_options.Spaces.RelativePanTiltTranslationSpace[0].XRange.Min) / PanIncrements; m_tiltDistance = (m_options.Spaces.RelativePanTiltTranslationSpace[0].YRange.Max - m_options.Spaces.RelativePanTiltTranslationSpace[0].YRange.Min) / TiltIncrements; } break; } } } catch (Exception ex) { m_ErrorMessage = ex.Message; throw new OnVifException("OnVifPTZController.InitalizeAsync", ex); // return false; } return(m_initialised); }
internal StepType RelativeMoveTest(out SoapException ex, out int Timeout, string ProfileToken, PTZVector Translation, PTZSpeed Speed) { StepType res = StepType.None; Timeout = 0; ex = null; bool passed = true; string logMessage = ""; //Get step list for command XmlNodeList m_testList = m_TestCommon.GetStepsForCommand(string.Format("{0}.{1}", ServiceName, "RelativeMove")); if (m_testList != null) { //Get current step XmlNode test = m_testList[m_commandCount[RelativeMove]]; #region Analyze request //ProfileToken CommonCompare.StringCompare("RequestParameters/ProfileToken", "ProfileToken", ProfileToken, ref logMessage, ref passed, test); //Translation CommonCompare.PTZPositionCompare("RequestParameters/Translation", "Translation", Translation, ref logMessage, ref passed, test); //Speed CommonCompare.PTZSpeedCompare("RequestParameters/Speed", "Speed", Speed, ref logMessage, ref passed, test); #endregion //Analyze request //Generate response res = m_TestCommon.GenerateResponseStepTypeVoid(test, out ex, out Timeout); //Log message m_TestCommon.writeToLog(test, logMessage, passed); Increment(m_testList.Count, RelativeMove); } else { res = StepType.None; Timeout = 0; ex = null; res = StepType.None; } return(res); }
public void GenericZoomSpeedBis() { RunTest(() => { PTZNode[] nodes = GetNodes(); foreach (PTZNode node in nodes) { // select node that supports SpeedZoomSpace Space1DDescription[] spaces = node.SupportedPTZSpaces.ZoomSpeedSpace; if (spaces != null) { LogTestEvent(string.Format("Node (token = {0}) supports Speed for Zoom move{1}", node.token, System.Environment.NewLine)); } else { // if current node doesn't support SpeedZoomSpace // then check next node continue; } // verify that SpeedZoomSpace contains Speed Generic Zoom Space Space1DDescription generic = spaces.FirstOrDefault(space => space.URI == _speedZoomSpace); Assert((generic != null) && (generic.XRange != null), "SpeedZoomSpace element doesn't contain mandatory space", "Verifying of Speed Generic Zoom Space presence"); // verify that allowed range is specified Assert(generic.XRange.Max >= generic.XRange.Min, "Incorrect space range", "Verifying of space range"); // configure and select a media profile PTZConfigurationOptions options; Profile profile = GetPTZProfile(node, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); Assert(!(null == options.Spaces.AbsoluteZoomPositionSpace && null == options.Spaces.RelativeZoomTranslationSpace), "There are no options for Absolute command nor Relative move command in the selected PTZ configuration", "Check there are options for Absolute command or Relative move command in selected PTZ configuration"); // check max range PTZVector vector = new PTZVector(); vector.Zoom = new Vector1D(); PTZSpeed speed = new PTZSpeed(); speed.Zoom = new Vector1D(); Space1DDescription zoomSpace = null; bool Absolute = true; try { //absolute or relative move should be supported - use generic space for position or translation zoomSpace = options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Max; speed.Zoom.space = generic.URI; speed.Zoom.x = generic.XRange.Max; // correct Zoom value according to ZoomLimits field if (profile.PTZConfiguration.ZoomLimits != null) { vector.Zoom.x = profile.PTZConfiguration.ZoomLimits.Range.XRange.Max; } AbsoluteMove(profile.token, vector, speed); } catch (System.Exception) { Absolute = false; zoomSpace = options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Max; RelativeMove(profile.token, vector, speed); } // check min range vector.Zoom.x = zoomSpace.XRange.Min; speed.Zoom.x = generic.XRange.Min; if (Absolute) { // correct Zoom value according to ZoomLimits field if (profile.PTZConfiguration.ZoomLimits != null) { vector.Zoom.x = profile.PTZConfiguration.ZoomLimits.Range.XRange.Min; } AbsoluteMove(profile.token, vector, speed); } else { RelativeMove(profile.token, vector, speed); } } }); }
public System.Threading.Tasks.Task RelativeMoveAsync(string ProfileToken, PTZVector Translation, PTZSpeed Speed) { return(base.Channel.RelativeMoveAsync(ProfileToken, Translation, Speed)); }
public bool Initialise(string cameraAddress, string userName, string password) { bool result = false; try { var messageElement = new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.CreateVersion( EnvelopeVersion.Soap12, AddressingVersion.None) }; HttpTransportBindingElement httpBinding = new HttpTransportBindingElement() { AuthenticationScheme = AuthenticationSchemes.Digest }; CustomBinding bind = new CustomBinding(messageElement, httpBinding); mediaClient = new MediaClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/Media")); mediaClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; mediaClient.ClientCredentials.HttpDigest.ClientCredential.UserName = userName; mediaClient.ClientCredentials.HttpDigest.ClientCredential.Password = password; ptzClient = new PTZClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/PTZ")); ptzClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; ptzClient.ClientCredentials.HttpDigest.ClientCredential.UserName = userName; ptzClient.ClientCredentials.HttpDigest.ClientCredential.Password = password; var profs = mediaClient.GetProfiles(); profile = mediaClient.GetProfile(profs[0].token); var configs = ptzClient.GetConfigurations(); options = ptzClient.GetConfigurationOptions(configs[0].token); velocity = new OnvifPTZService.PTZSpeed() { PanTilt = new OnvifPTZService.Vector2D() { x = 0, y = 0, space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI, }, Zoom = new OnvifPTZService.Vector1D() { x = 0, space = options.Spaces.ContinuousZoomVelocitySpace[0].URI, } }; if (relative) { timer = new Timer(TimerInterval); timer.Elapsed += Timer_Elapsed; velocity.PanTilt.space = options.Spaces.RelativePanTiltTranslationSpace[0].URI; panDistance = (options.Spaces.RelativePanTiltTranslationSpace[0].XRange.Max - options.Spaces.RelativePanTiltTranslationSpace[0].XRange.Min) / PanIncrements; tiltDistance = (options.Spaces.RelativePanTiltTranslationSpace[0].YRange.Max - options.Spaces.RelativePanTiltTranslationSpace[0].YRange.Min) / TiltIncrements; } vector = new PTZVector() { PanTilt = new OnvifPTZService.Vector2D() { x = 0, y = 0, space = options.Spaces.RelativePanTiltTranslationSpace[0].URI } }; ErrorMessage = ""; result = initialised = true; } catch (Exception ex) { ErrorMessage = ex.Message; } return(result); }
public void GotoPreset() { string presetToken = null; Profile profile = null; RunTest(() => { Assert(Features.ContainsFeature(Feature.PTZAbsoluteOrRelative), "No Absolute or Relative movement is supported", "Check that Absolute or Relative movement is supported"); PTZConfigurationOptions options; profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //absolute or relative move should be supported - use generic space for position or translation bool absoluteMoveSupported = Features.Contains(Feature.PTZAbsolute); // pantilt movement is used if correcponding Pan/Tilt is supported bool panTilt = (absoluteMoveSupported && Features.ContainsFeature(Feature.PTZAbsolutePanTilt)) || (!absoluteMoveSupported && Features.ContainsFeature(Feature.PTZRelativePanTilt)); bool absoluteZoom = absoluteMoveSupported && Features.Contains(Feature.PTZAbsoluteZoom); bool relativeZoom = !absoluteMoveSupported && Features.Contains(Feature.PTZRelativeZoom); bool zoom = absoluteZoom || relativeZoom; PTZVector vector = new PTZVector(); Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; if (panTilt) { pantiltSpace = absoluteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) : options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0); vector.PanTilt = new Vector2D(); vector.PanTilt.space = pantiltSpace.URI; vector.PanTilt.x = pantiltSpace.XRange.Min; vector.PanTilt.y = pantiltSpace.YRange.Min; } if (zoom) { zoomSpace = absoluteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) : options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom = new Vector1D(); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; } if (absoluteMoveSupported) { // correct PanTilt values according to PanTiltLimits field if (profile.PTZConfiguration.PanTiltLimits != null) { vector.PanTilt.x = profile.PTZConfiguration.PanTiltLimits.Range.XRange.Min; vector.PanTilt.y = profile.PTZConfiguration.PanTiltLimits.Range.YRange.Min; } // correct Zoom value according to ZoomLimits field if (profile.PTZConfiguration.ZoomLimits != null) { vector.Zoom.x = profile.PTZConfiguration.ZoomLimits.Range.XRange.Min; } AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => Thread.Sleep(OperationDelay), string.Format("Waiting {0} seconds for camera to move", OperationDelay / 1000)); string presetName = "Test"; presetToken = SetPreset(profile.token, presetName, null); //move to another position Vector2D oldPanTilt = vector.PanTilt; if (oldPanTilt != null) { vector.PanTilt = new Vector2D(); vector.PanTilt.space = oldPanTilt.space; vector.PanTilt.x = pantiltSpace.XRange.Max; vector.PanTilt.y = pantiltSpace.YRange.Max; } Vector1D oldZoom = vector.Zoom; if (oldZoom != null) { vector.Zoom = new Vector1D(); vector.Zoom.space = oldZoom.space; vector.Zoom.x = zoomSpace.XRange.Max; } if (absoluteMoveSupported) { // correct PanTilt values according to PanTiltLimits field if (profile.PTZConfiguration.PanTiltLimits != null) { vector.PanTilt.x = profile.PTZConfiguration.PanTiltLimits.Range.XRange.Max; vector.PanTilt.y = profile.PTZConfiguration.PanTiltLimits.Range.YRange.Max; } // correct Zoom value according to ZoomLimits field if (profile.PTZConfiguration.ZoomLimits != null) { if (profile.PTZConfiguration.ZoomLimits.Range != null && profile.PTZConfiguration.ZoomLimits.Range.URI != null && vector.Zoom.space != null && profile.PTZConfiguration.ZoomLimits.Range.URI == vector.Zoom.space) { vector.Zoom.x = profile.PTZConfiguration.ZoomLimits.Range.XRange.Max; } } AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => Thread.Sleep(OperationDelay), string.Format("Waiting {0} seconds for camera to move", OperationDelay / 1000)); GotoPreset(profile.token, presetToken, null); RunStep(() => Thread.Sleep(OperationDelay), string.Format("Waiting {0} seconds for camera to move", OperationDelay / 1000)); PTZStatus status = GetPTZStatus(profile.token); vector.PanTilt = oldPanTilt; vector.Zoom = oldZoom; if (status.Position != null) { CheckPTZPosition(status.Position, vector, vector, pantiltSpace, zoomSpace); } RemovePreset(profile.token, presetToken); presetToken = null; }, () => { CloseVideo(); if ((presetToken != null) && (profile != null)) { RemovePreset(profile.token, presetToken); } }); }
public void SetGetPreset() { string presetToken = null; Profile profile = null; RunTest(() => { Assert(Features.ContainsFeature(Feature.PTZAbsoluteOrRelative), "No Absolute or Relative movement is supported", "Check that Absolute or Relative movement is supported"); PTZConfigurationOptions options; profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.NodeToken, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //absolute or relative move should be supported - use generic space for position or translation bool absoluteMoveSupported = Features.Contains(Feature.PTZAbsolute); PTZVector vector = new PTZVector(); Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; // pantilt movement is used if corresponding Pan/Tilt is supported bool panTilt = (absoluteMoveSupported && Features.ContainsFeature(Feature.PTZAbsolutePanTilt)) || (!absoluteMoveSupported && Features.ContainsFeature(Feature.PTZRelativePanTilt)); bool absoluteZoom = absoluteMoveSupported && Features.Contains(Feature.PTZAbsoluteZoom); bool relativeZoom = !absoluteMoveSupported && Features.Contains(Feature.PTZRelativeZoom); bool zoom = absoluteZoom || relativeZoom; if (panTilt) { pantiltSpace = absoluteMoveSupported ? options.Spaces.AbsolutePanTiltPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absolutePanTiltSpace, true) == 0) : options.Spaces.RelativePanTiltTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativePanTiltSpace, true) == 0); vector.PanTilt = new Vector2D(); vector.PanTilt.space = pantiltSpace.URI; vector.PanTilt.x = pantiltSpace.XRange.Min / 2; vector.PanTilt.y = pantiltSpace.YRange.Min / 2; } if (zoom) { zoomSpace = absoluteZoom ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) : options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom = new Vector1D(); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); string presetName = "Test"; presetToken = SetPreset(profile.token, presetName, null); PTZPreset[] presets = GetPresets(profile.token); CheckPreset(presets, presetToken, presetName, vector, pantiltSpace, zoomSpace); //move to another position if (vector.PanTilt != null) { vector.PanTilt.x = pantiltSpace.XRange.Max / 2; vector.PanTilt.y = pantiltSpace.YRange.Max / 2; } if (vector.Zoom != null) { vector.Zoom.x = zoomSpace.XRange.Max; } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); SetPreset(profile.token, presetName, presetToken); presets = GetPresets(profile.token); if (!absoluteMoveSupported && (vector.PanTilt != null)) { //in case of relative move consider camera should return to 0,0 vector.PanTilt.x = 0; vector.PanTilt.y = 0; } CheckPreset(presets, presetToken, presetName, vector, pantiltSpace, zoomSpace); RemovePreset(profile.token, presetToken); presetToken = null; }, () => { if ((presetToken != null) && (profile != null)) { RemovePreset(profile.token, presetToken); } }); }
public System.Threading.Tasks.Task AbsoluteMoveAsync(string ProfileToken, PTZVector Position, PTZSpeed Speed) { return(base.Channel.AbsoluteMoveAsync(ProfileToken, Position, Speed)); }
public void GenericZoomSpeed() { RunTest(() => { Assert(Features.ContainsFeature(Feature.PTZAbsoluteOrRelativeZoom), "No Absolute or Relative Zoom movement is supported", "Check that Absolute or Relative Zoom movement is supported"); PTZNode[] nodes = GetNodes(); foreach (PTZNode node in nodes) { string reason = null; Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title); Space1DDescription[] spaces = node.SupportedPTZSpaces.ZoomSpeedSpace; Space1DDescription generic = spaces != null ? spaces.FirstOrDefault(space => string.Compare(space.URI, _speedZoomSpace) == 0) : null; Assert((generic != null) && (generic.XRange != null), "Node does not support generic zoom speed space or space ranges are missing", "Validating generic zoom speed space"); PTZConfigurationOptions options; Profile profile = GetPTZProfile(node, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //check max ranges bool absoulteMoveSupported = Features.Contains(Feature.PTZAbsoluteZoom); PTZVector vector = new PTZVector(); vector.Zoom = new Vector1D(); //absolute or relative move should be supported - use generic space for position or translation Space1DDescription zoomSpace = absoulteMoveSupported ? options.Spaces.AbsoluteZoomPositionSpace.FirstOrDefault(s => string.Compare(s.URI, _absoluteZoomSpace, true) == 0) : options.Spaces.RelativeZoomTranslationSpace.FirstOrDefault(s => string.Compare(s.URI, _relativeZoomSpace, true) == 0); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; PTZSpeed speed = new PTZSpeed(); speed.Zoom = new Vector1D(); speed.Zoom.space = generic.URI; speed.Zoom.x = generic.XRange.Max; if (absoulteMoveSupported) { AbsoluteMove(profile.token, vector, speed); } else { RelativeMove(profile.token, vector, speed); } //check min ranges speed.Zoom.x = generic.XRange.Min; if (absoulteMoveSupported) { AbsoluteMove(profile.token, vector, speed); } else { RelativeMove(profile.token, vector, speed); } } }); }