## Copyright (C) 2010 Thomas Weidenfeller
## 
## This file is part of gds2000tools/gds-octave.
## 
## gds2000tools/gds-octave is free software: you can redistribute it
## and/or modify it under the terms of the GNU General Public License
## version 3 as published by the Free Software Foundation.
## 
## gds2000tools/gds-octave is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with gds2000tools/gds-octave.  If not,
## see <http://www.gnu.org/licenses/>.
##

## usage: dt = __gds_sampling_period(GDSSTRUCT)
##
## Returns then sampling period of GDSSTRUCT.

## Author: Thomas Weidenfeller
## Created: 2010-07-12
## Version: $Id: __gds_sampling_period.m,v 1.2 2010/12/31 02:28:33 tw Exp $
## Keywords: Oscilloscope, GDS-2000, gds2000tools, plot

function dt = __gds_sampling_period(gs)
	if(nargin !=1 || !isstruct(gs))
		print_usage();
	endif

	##
	## Determine sampling period
	##
	if(isfield(gs, "Sampling_Period"))
		dt = gs.Sampling_Period;
	elseif(isfield(gs, "Horizontal_Scale"))
		dt = gds_wd2val(gs.Horizontal_Scale, 1);
	else
		error("Neither Sampling_Period or Horizontal_Scale defined");
	endif
endfunction
