public PTZStatus GetPtzLocation() { Onvif_Interface.OnvifMediaServiceReference.Profile mediaProfile = GetMediaProfile(); PTZStatus status = PtzClient.GetStatus(mediaProfile.token); return(status); }
private void UpdatePtzLocation(PTZClient ptzClient, string profileToken) { // Get Status PTZStatus status = ptzClient.GetStatus(profileToken); lblPtzLocationX.Text = "x: " + status.Position.PanTilt.x.ToString(); lblPtzLocationY.Text = "y: " + status.Position.PanTilt.y.ToString(); lblPtzLocationZoom.Text = "zoom: " + status.Position.Zoom.x.ToString(); }
public Model( Profile profile, PTZPreset[] presets, PTZStatus status, PTZNode node ) { this.profile = profile; this.presets = presets; this.status = status; this.node = node; }
public static Model Create( Profile profile, PTZPreset[] presets, PTZStatus status, PTZNode node ) { var _this = new Model(); _this.profile = profile; _this.presets = presets; _this.status = status; _this.node = node; return(_this); }
internal StepType GetStatusTest(out PTZStatus target, out SoapException ex, out int Timeout, string ProfileToken) { StepType res = StepType.None; Timeout = 0; ex = null; target = null; bool passed = true; string logMessage = ""; //Get step list for command XmlNodeList m_testList = m_TestCommon.GetStepsForCommand(string.Format("{0}.{1}", ServiceName, "GetStatus")); if (m_testList != null) { //Get current step XmlNode test = m_testList[m_commandCount[GetStatus]]; #region Analyze request //ProfileToken CommonCompare.StringCompare("RequestParameters/ProfileToken", "ProfileToken", ProfileToken, ref logMessage, ref passed, test); #endregion //Analyze request //Generate response object targetObj; res = m_TestCommon.GenerateResponseStepTypeNotVoid(test, out targetObj, out ex, out Timeout, typeof(PTZStatus)); target = (PTZStatus)targetObj; //Log message m_TestCommon.writeToLog(test, logMessage, passed); Increment(m_testList.Count, GetStatus); } else { res = StepType.None; Timeout = 0; target = null; ex = null; res = StepType.None; } return(res); }
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 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) { 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); //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")); GotoPreset(profile.token, presetToken, null); 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); } RemovePreset(profile.token, presetToken); presetToken = null; }, () => { CloseVideo(); if ((presetToken != null) && (profile != null)) { RemovePreset(profile.token, presetToken); } }); }
public void FixedHome() { 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); GotoHomePosition(profile.token, null, OperationDelay); //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.Max; vector.PanTilt.y = pantiltSpace.YRange.Max; } 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.Max; } //make sure current position is different to destination PTZStatus status = GetPTZStatus(profile.token); PTZVector homePosition = status.Position; if ((homePosition != null) && (EqualPositions(homePosition, vector))) { if (vector.PanTilt != null) { vector.PanTilt.x = 0; } else if (vector.Zoom != null) { vector.Zoom.x = 0; } } 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) { vector.Zoom.x = profile.PTZConfiguration.ZoomLimits.Range.XRange.Max; } // make sure current position is different to destination if ((homePosition != null) && (EqualPositions(homePosition, vector))) { if (vector.PanTilt != null) { vector.PanTilt.x = profile.PTZConfiguration.PanTiltLimits.Range.XRange.Min; } else if (vector.Zoom != 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)); SetFixedHomePosition(profile.token); GotoHomePosition(profile.token, null, OperationDelay); status = GetPTZStatus(profile.token); if (status.Position != null) { CheckPTZPosition(status.Position, homePosition, homePosition, pantiltSpace, zoomSpace); } }, () => { CloseVideo(); }); }
private void UpdatePtzLocation(PTZStatus status) { lblPtzLocationX.Text = "x: " + status.Position.PanTilt.x.ToString(); lblPtzLocationY.Text = "y: " + status.Position.PanTilt.y.ToString(); lblPtzLocationZoom.Text = "zoom: " + status.Position.Zoom.x.ToString(); }
public void GotoPreset() { string presetToken = null; Media.Profile profile = null; RunTest(() => { PTZConfigurationOptions options; profile = GetPTZProfile(_ptzNodeToken, out options); Assert((profile != null) && (profile.PTZConfiguration != null), Resources.ErrorNoPTZProfile, Resources.StepValidatePTZProfile); string reason; Assert(ValidatePTZConfigurationOptions(options, profile.PTZConfiguration.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); //absolute or relative move should be supported - use generic space for position or translation bool absoulteMoveSupported = Features.Contains(Feature.PTZAbsolute); PTZVector vector = new PTZVector(); Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; if (Features.Contains(Feature.PTZAbsolutePanTilt) || Features.Contains(Feature.PTZRelativePanTilt)) { pantiltSpace = absoulteMoveSupported ? 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 (Features.Contains(Feature.PTZAbsoluteZoom) || Features.Contains(Feature.PTZRelativeZoom)) { 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 = new Vector1D(); vector.Zoom.space = zoomSpace.URI; vector.Zoom.x = zoomSpace.XRange.Min; } if (absoulteMoveSupported) { 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); //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 (absoulteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } RunStep(() => { Thread.Sleep(10000); }, string.Format("Waiting 10 seconds for camera to move")); GotoPreset(profile.token, presetToken, null); 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); } else { OpenVideo(); Assert(_operator.GetYesNoAnswer(string.Format("Is camera in position [{0}]?", PositionToString(vector))), "Camera is in wrong position", "Camera position check (manual)"); CloseVideo(); } RemovePreset(profile.token, presetToken); presetToken = null; }, () => { CloseVideo(); if ((presetToken != null) && (profile != null)) { RemovePreset(profile.token, presetToken); } }); }
public void FixedHome() { 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.token, out reason), reason, Resources.StepValidatePTZConfigOptions_Title); GotoHomePosition(profile.token, null, _homeMoveTimeout); //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.Max; vector.PanTilt.y = pantiltSpace.YRange.Max; } 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.Max; } //make sure current position is different to destination PTZStatus status = GetPTZStatus(profile.token); PTZVector homePosition = status.Position; if ((homePosition != null) && (EqualPositions(homePosition, vector))) { if (vector.PanTilt != null) { vector.PanTilt.x = 0; } else if (vector.Zoom != null) { vector.Zoom.x = 0; } } if (absoluteMoveSupported) { AbsoluteMove(profile.token, vector, null); } else { RelativeMove(profile.token, vector, null); } SetFixedHomePosition(profile.token); GotoHomePosition(profile.token, null, _homeMoveTimeout); status = GetPTZStatus(profile.token); if (status.Position != null) { CheckPTZPosition(status.Position, homePosition, homePosition); } else { OpenVideo(); Assert(_operator.GetYesNoAnswer(string.Format("Is camera in position [{0}]?", PositionToString(homePosition))), "Camera is in wrong position", "Camera position check (manual)"); CloseVideo(); } }, () => { CloseVideo(); }); }
public void AbsoluteMoveTest() { RunTest(() => { PTZConfigurationOptions options; Media.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); //select pantilt and zoom spaces Space2DDescription pantiltSpace = null; Space1DDescription zoomSpace = null; if (Features.Contains(Feature.PTZAbsolutePanTilt)) { pantiltSpace = options.Spaces.AbsolutePanTiltPositionSpace[0]; } if (Features.Contains(Feature.PTZAbsoluteZoom)) { zoomSpace = options.Spaces.AbsoluteZoomPositionSpace[0]; } //set selected spaces as default if they are not (we need it to get position in these spaces) if (((pantiltSpace != null) && !EqualSpaces(pantiltSpace.URI, profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace)) || ((zoomSpace != null) && !EqualSpaces(zoomSpace.URI, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace))) { profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace = pantiltSpace != null ? pantiltSpace.URI : null; profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace = zoomSpace != null ? zoomSpace.URI : null; SetConfiguration(profile.PTZConfiguration, false, string.Format("DefaultAbsolutePantTiltPositionSpace={0}, DefaultAbsoluteZoomPositionSpace={1}", profile.PTZConfiguration.DefaultAbsolutePantTiltPositionSpace, profile.PTZConfiguration.DefaultAbsoluteZoomPositionSpace)); } 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); } }); }