public OnvifPtzGotoPreset(string uri, string userName, string password, string profileToken, string presetToken, PTZSpeed speed) : base(uri, userName, password) { ProfileToken = profileToken; PresetToken = presetToken; Speed = speed; }
public OnvifPtzRelativeMove(string uri, string userName, string password, string profileToken, PTZVector traslation, PTZSpeed speed) : base(uri, userName, password) { ProfileToken = profileToken; Traslation = traslation; Speed = speed; }
/// <summary> /// Starts continuous move with specified speed /// </summary> /// <param name="profile">profile</param> /// <param name="panTilt">if true, move pan/tilt</param> /// <param name="zoom">if true, move zoom</param> /// <param name="x">pan speed (-1..1)</param> /// <param name="y">tilt speed (-1..1)</param> /// <param name="z">zoom speed (0..1)</param> /// <param name="timeout">movement timeout. No timeout if value is less than zero</param> public void ContinuousMove(string profile, bool panTilt, bool zoom, decimal x, decimal y, decimal z, int timeout) { _ptzClientWorking = true; IntializePtzClient(View.PTZAddress); Onvif.PTZSpeed speed = new PTZSpeed(); if (panTilt) { speed.PanTilt = new Vector2D(); speed.PanTilt.space = "http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace"; speed.PanTilt.x = (float)x; speed.PanTilt.y = (float)y; } if (zoom) { speed.Zoom = new Vector1D(); speed.Zoom.space = "http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace"; speed.Zoom.x = (float)z; } string duration = null; if (timeout > 0) { TimeSpan span = TimeSpan.FromMilliseconds((double)timeout); duration = System.Xml.XmlConvert.ToString(span); } _ptzClient.ContinuousMove(profile, speed, duration); }
/// <summary> /// Move PTZ to provided preset number (defaults to media profile 0) /// </summary> /// <param name="presetNumber">Preset to use</param> public void ShowPreset(int presetNumber) { string presetToken = string.Empty; Onvif_Interface.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); string profileToken = mediaProfile.token; PTZPreset[] presets = PtzClient.GetPresets(profileToken); if (presets.Length >= presetNumber) { presetToken = presets[presetNumber - 1].token; PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = (float)-0.5, y = 0 };; PtzClient.GotoPreset(profileToken, presetToken, velocity); } else { throw new Exception(string.Format("Invalid Preset requested - preset number {0}", presetNumber)); } }
public void MoveAbsolute(PTZVector position, PTZSpeed speed) { CurrentSession .AbsoluteMove(profileToken, position, speed) .ObserveOnCurrentDispatcher() .Subscribe(unit => {}, err => SetErrorMessage(err.Message)); }
private void TurnRightButton_MouseDown(object sender, MouseEventArgs e) { rightButtonDown = true; do { lock (sync) { var speed = new PTZSpeed { zoom = null, panTilt = new Vector2D { x = GetPanSpeed(), y = 0 } }; session.ContinuousMove(profileToken, speed, null).RunSynchronously(); session.Stop(profileToken, true, true).RunSynchronously(); Application.DoEvents(); } } while (rightButtonDown); }
public void ContinuousMoveStopTest() { 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); //check pan\tilt movement if (options.Spaces.ContinuousPanTiltVelocitySpace != null && options.Spaces.ContinuousPanTiltVelocitySpace.Length > 0) { PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D(); velocity.PanTilt.space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI; velocity.PanTilt.x = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max; velocity.PanTilt.y = options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max; CheckContinuousMove(profile.token, velocity, null, options); } if ((options.Spaces.ContinuousZoomVelocitySpace != null) && (options.Spaces.ContinuousZoomVelocitySpace.Length > 0)) { //check zoom movement if supported PTZSpeed zoomVelocity = new PTZSpeed(); zoomVelocity.Zoom = new Vector1D(); zoomVelocity.Zoom.space = options.Spaces.ContinuousZoomVelocitySpace[0].URI; zoomVelocity.Zoom.x = options.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max; CheckContinuousMove(profile.token, zoomVelocity, null, options); } }); }
private PTZSpeed CreatePTZSpeed(PTZParameters.Vector vector, float speed = 0.5f) { var p = new PTZSpeed { PanTilt = new Vector2D() /*space = "http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace",*/ } { , //Zoom = new Vector1D() { x = 0, }, }; if (vector == PTZParameters.Vector.UP) { p.PanTilt.y = -speed; } else if (vector == PTZParameters.Vector.DOWN) { p.PanTilt.y = speed; } else if (vector == PTZParameters.Vector.LEFT) { p.PanTilt.x = -speed; } else if (vector == PTZParameters.Vector.RIGHT) { p.PanTilt.x = speed; } 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 void ContinuousMove(string profile, PTZSpeed speed, string timeout) { RunInBackground(new Action(() => { Client.ContinuousMove(profile, speed, timeout); })); }
public OnvifPtzContinuousMove(string uri, string userName, string password, string profileToken, PTZSpeed velocity, XsDuration timeout) : base(uri, userName, password) { ProfileToken = profileToken; Velocity = velocity; Timeout = timeout; }
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); }
//a. Test Suite: "PTZ(PTZ-3-1-4)TestSuit.xml", Test Case: "TC.PTZ-3-1-4.01" //a. Test Group Name: "PTZ-3-1-4 PTZ CONTINUOUS MOVE" //a.0. CORRECT XML RESPONSE //[XmlReplySubstituteExtension("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> <soap:Body> <ContinuousMoveResponse xmlns=\"http://www.onvif.org/ver20/ptz/wsdl\" /> </soap:Body></soap:Envelope>")] //a.1. TC.PTZ-3-1-4.08: "Delete namespace (in main response ContinuousMove)" (delete namespace from tag <ContinuousMove>) //[XmlReplySubstituteExtension("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> <soap:Body> <ContinuousMoveResponse/> </soap:Body></soap:Envelope>")] #endregion //XmlReplySubstituteExtension for testing public override void ContinuousMove(string ProfileToken, PTZSpeed Velocity, [System.Xml.Serialization.XmlElementAttribute(DataType = "duration")] string Timeout) { TestSuitInit(); int timeOut; SoapException ex; StepType stepType = m_PTZServiceTest.ContinuousMoveTest(out ex, out timeOut, ProfileToken, Velocity, Timeout); StepTypeProcessing(stepType, ex, timeOut); }
public override void GotoHomePosition(string ProfileToken, PTZSpeed Speed) { TestSuitInit(); int timeOut; SoapException ex; StepType stepType = m_PTZServiceTest.GotoHomePositionTest(out ex, out timeOut, ProfileToken, Speed); StepTypeProcessing(stepType, ex, timeOut); }
public System.Threading.Tasks.Task <Mictlanix.DotNet.Onvif.Ptz.ContinuousMoveResponse> ContinuousMoveAsync( string ProfileToken, PTZSpeed Velocity, string Timeout) { Mictlanix.DotNet.Onvif.Ptz.ContinuousMoveRequest inValue = new Mictlanix.DotNet.Onvif.Ptz.ContinuousMoveRequest(); inValue.ProfileToken = ProfileToken; inValue.Velocity = Velocity; inValue.Timeout = Timeout; return(((Mictlanix.DotNet.Onvif.Ptz.PTZ)(this)).ContinuousMoveAsync(inValue)); }
public Task <ContinuousMoveResponse> ContinuousMoveAsync( string ProfileToken, PTZSpeed Velocity, string Timeout) { ContinuousMoveRequest inValue = new ContinuousMoveRequest(); inValue.ProfileToken = ProfileToken; inValue.Velocity = Velocity; inValue.Timeout = Timeout; return(((PTZ)(this)).ContinuousMoveAsync(inValue)); }
public void ContinuousMoveTest() { 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.ContinuousPanTiltVelocitySpace != null || options.Spaces.ContinuousZoomVelocitySpace != null, "Node does not support Continuous move", "Check if Continuous move is supported"); string timeout = "PT60S";//60 seconds by default //check ranges TimeSpan min = System.Xml.XmlConvert.ToTimeSpan(options.PTZTimeout.Min); TimeSpan max = System.Xml.XmlConvert.ToTimeSpan(options.PTZTimeout.Max); if (min.TotalMinutes > 1) { timeout = options.PTZTimeout.Min; } else if (max.TotalMinutes < 1) { timeout = options.PTZTimeout.Max; } //check pan\tilt movement if (Features.ContainsFeature(Feature.PTZContinuousPanTilt)) { PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D(); velocity.PanTilt.space = options.Spaces.ContinuousPanTiltVelocitySpace[0].URI; velocity.PanTilt.x = options.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max; velocity.PanTilt.y = options.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max; CheckContinuousMove(profile.token, velocity, timeout, options); } if (Features.Contains(Feature.PTZContinuousZoom)) { //check zoom movement if supported PTZSpeed zoomVelocity = new PTZSpeed(); zoomVelocity.Zoom = new Vector1D(); zoomVelocity.Zoom = new Vector1D(); zoomVelocity.Zoom.space = options.Spaces.ContinuousZoomVelocitySpace[0].URI; zoomVelocity.Zoom.x = options.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max; CheckContinuousMove(profile.token, zoomVelocity, timeout, options); } }); }
public void MoveRelative(PTZVector translation, PTZSpeed speed) { CurrentSession .RelativeMove(profileToken, translation, speed) .ObserveOnCurrentDispatcher() .Subscribe( unit => {}, err => { //dbg.Error(err); SetErrorMessage(err.Message); } ); }
/// <summary> /// Tilt the camera (uses the first media profile that is PTZ capable) /// </summary> /// <param name="speed">Percent of max speed to move the camera (1-100)</param> public void Tilt(float speed) { Onvif_Interface.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); PTZConfigurationOptions ptzConfigurationOptions = PtzClient.GetConfigurationOptions(mediaProfile.PTZConfiguration.token); PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = 0, y = speed * ptzConfigurationOptions.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max }; PtzClient.ContinuousMove(mediaProfile.token, velocity, null); }
/// <summary> /// Pan the camera (uses the first media profile that is PTZ capable) /// </summary> /// <param name="speed">Percent of max speed to move the camera (1-100)</param> public void Pan(float speed) { Onvif_Interface.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); PTZConfigurationOptions ptzConfigurationOptions = PtzClient.GetConfigurationOptions(mediaProfile.PTZConfiguration.token); File.AppendAllText("info.txt", string.Format("Media Profile [Name: {0}, Token: {1}, PTZ Config. Name: {2}, PTZ Config. Token: {3}]\n", mediaProfile.Name, mediaProfile.token, mediaProfile.PTZConfiguration.Name, mediaProfile.PTZConfiguration.token)); PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = speed * ptzConfigurationOptions.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max, y = 0 }; PtzClient.ContinuousMove(mediaProfile.token, velocity, null); }
/// <summary> /// Pan the camera (uses the media profile provided to the constructor) /// </summary> /// <param name="speed">Percent of max speed to move the camera (-1.00 to 1.00)</param> private void Pan(float speed) { RTSP_Viewer.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); PTZConfigurationOptions ptzConfigurationOptions = PtzClient.GetConfigurationOptions(mediaProfile.PTZConfiguration.token); PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = speed * ptzConfigurationOptions.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max, y = 0 }; PtzClient.ContinuousMove(mediaProfile.token, velocity, null); PtzMoving = true; }
public void GenericPanTiltVelocity() { RunTest(() => { PTZNode[] nodes = GetNodes(); foreach (PTZNode node in nodes) { string reason = null; Assert(ValidatePTZNode(node, out reason), reason, Resources.StepValidatePTZNode_Title); Space2DDescription[] spaces = node.SupportedPTZSpaces.ContinuousPanTiltVelocitySpace; Space2DDescription generic = spaces != null ? spaces.FirstOrDefault(space => string.Compare(space.URI, _continuousPanTiltSpace) == 0) : null; Assert((generic != null) && (generic.XRange != null) && (generic.YRange != null), "Node does not support generic continuous pan/tilt velocity space or space ranges are missing", "Validating generic continuous pan/tilt velocity space"); PTZConfigurationOptions options; Profile profile = GetPTZProfile(node, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); //PTZNode node = GetNode(profile.PTZConfiguration.NodeToken); //check max ranges PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D(); velocity.PanTilt.space = generic.URI; velocity.PanTilt.x = generic.XRange.Max; velocity.PanTilt.y = generic.YRange.Max; ContinuousMove(profile.token, velocity, null); RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); //check min ranges velocity.PanTilt.x = generic.XRange.Min; velocity.PanTilt.y = generic.YRange.Min; ContinuousMove(profile.token, velocity, null); RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); Stop(profile.token, true, false); } }); }
/// <summary> /// *DON'T USE - not completed. Call up a preset by Profile/Preset token /// </summary> /// <param name="profileToken"></param> /// <param name="presetToken"></param> private void ShowPreset(string profileToken, string presetToken) { Onvif_Interface.OnvifMediaServiceReference.Profile[] mediaProfiles = MediaClient.GetProfiles(); profileToken = mediaProfiles[0].token; if (IsValidPresetToken(profileToken, presetToken)) { PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = (float)-0.5, y = 0 };; PtzClient.GotoPreset(profileToken, presetToken, velocity); } else { throw new Exception(string.Format("Invalid Preset requested - preset token {0}", presetToken)); } }
/// <summary> /// Move PTZ to provided preset number (uses the media profile provided to the constructor) /// </summary> /// <param name="presetNumber">Preset to use</param> public void ShowPreset(int presetNumber) { string presetToken = string.Empty; RTSP_Viewer.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); string profileToken = mediaProfile.token; // This could be used to cache presets to avoid unecessary HTTP requests // This could also cause an issue when presets are modified so it is not used currently //if (Presets == null) // Presets = PtzClient.GetPresets(profileToken); Presets = PtzClient.GetPresets(profileToken); PTZPreset[] presets = Presets; // PtzClient.GetPresets(profileToken); if (presets.Length >= presetNumber) { presetToken = presets[presetNumber - 1].token; PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = (float)-0.5, y = 0 };; try { PtzClient.GotoPreset(profileToken, presetToken, velocity); } catch (Exception ex) { log.Error(string.Format("Exception executing ShowPreset command. {0}", ex.Message)); } } else { log.Warn(string.Format("Preset #{0} not defined for this camera [{1}]", presetNumber, PtzClient.Endpoint.Address.Uri.AbsoluteUri)); throw new IndexOutOfRangeException(string.Format("Preset #{0} not defined for this camera [{1}]", presetNumber, PtzClient.Endpoint.Address.Uri.AbsoluteUri)); } }
/// <summary> /// Zoom the camera (uses the media profile provided to the constructor) /// </summary> /// <param name="speed">Percent of max speed to move the camera (-100 to 100). Negative zooms out, Positive zooms in</param> public void Zoom(int speed) { if (speed > 100) { speed = 100; } if (speed < -100) { speed = -100; } log.Debug(string.Format("Zoom @ velocity of {0}", speed)); RTSP_Viewer.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); PTZConfigurationOptions ptzConfigurationOptions = PtzClient.GetConfigurationOptions(mediaProfile.PTZConfiguration.token); PTZSpeed velocity = new PTZSpeed(); velocity.Zoom = new Vector1D() { x = ((float)speed / 100) * ptzConfigurationOptions.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max }; string timeout = null; //"PT5S"; try { PtzClient.ContinuousMove(mediaProfile.token, velocity, timeout); PtzMoving = true; } catch (Exception ex) { log.Error(string.Format("Exception executing Zoom command. {0}", ex.Message)); } }
/// <summary> /// Combined Pan and Tilt of the camera (uses the media profile provided to the constructor) /// </summary> /// <param name="panSpeed">Percent of max speed to move the camera (-1.00 to 1.00)</param> /// <param name="tiltSpeed">Percent of max speed to move the camera (-1.00 to 1.00)</param> public void PanTilt(float panSpeed, float tiltSpeed) { RTSP_Viewer.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); PTZConfigurationOptions ptzConfigurationOptions = PtzClient.GetConfigurationOptions(mediaProfile.PTZConfiguration.token); PTZSpeed velocity = new PTZSpeed(); velocity.PanTilt = new Vector2D() { x = panSpeed * ptzConfigurationOptions.Spaces.ContinuousPanTiltVelocitySpace[0].XRange.Max, y = tiltSpeed * ptzConfigurationOptions.Spaces.ContinuousPanTiltVelocitySpace[0].YRange.Max }; try { PtzClient.ContinuousMove(mediaProfile.token, velocity, null); PtzMoving = true; log.Debug("Pan/Tilt Ptz command sent"); } catch (Exception ex) { log.Error(string.Format("Exception executing Pan/Tilt command. {0}", ex.Message)); } }
public System.Threading.Tasks.Task GeoMoveAsync(string ProfileToken, GeoLocation Target, PTZSpeed Speed, float AreaHeight, float AreaWidth) { return(base.Channel.GeoMoveAsync(ProfileToken, Target, Speed, AreaHeight, AreaWidth)); }
public System.Threading.Tasks.Task AbsoluteMoveAsync(string ProfileToken, PTZVector Position, PTZSpeed Speed) { return(base.Channel.AbsoluteMoveAsync(ProfileToken, Position, Speed)); }
public System.Threading.Tasks.Task RelativeMoveAsync(string ProfileToken, PTZVector Translation, PTZSpeed Speed) { return(base.Channel.RelativeMoveAsync(ProfileToken, Translation, Speed)); }
public System.Threading.Tasks.Task GotoHomePositionAsync(string ProfileToken, PTZSpeed Speed) { return(base.Channel.GotoHomePositionAsync(ProfileToken, Speed)); }