-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalibration_instrument.py
114 lines (90 loc) · 4.47 KB
/
calibration_instrument.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /usr/bin/env python3
# -*- coding: utf-8 -*
'''
Abstract class to define the API for a measurement instrument
@file
@date Created on Apr 16, 2015
@author Felipe Torres (torresfelipex1<AT>gmail.com)
@copyright LGPL v2.1
@ingroup measurement
'''
#------------------------------------------------------------------------------|
# GNU LESSER GENERAL PUBLIC LICENSE |
# ------------------------------------ |
# This source file is free software; you can redistribute it and/or modify it |
# under the terms of the GNU Lesser General Public License as published by the |
# Free Software Foundation; either version 2.1 of the License, or (at your |
# option) any later version. This source is distributed in the hope that it |
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warrant |
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
# General Public License for more details. You should have received a copy of |
# the GNU Lesser General Public License along with this source; if not, |
# download it from http://www.gnu.org/licenses/lgpl-2.1.html |
#------------------------------------------------------------------------------|
#-------------------------------------------------------------------------------
# Import --
#-------------------------------------------------------------------------------
# Import system modules
import abc
# This attribute permits dynamic loading inside wrcalibration class.
__meas_instr__ = "Calibration Instrument"
class Calibration_instrument() :
'''
Calibration instrument API
Abstract class that represents the API that a generic measurement instrument
must implement to be accepted as calibration instrument for WR Calibration
procedure.
The main calibration procedure expects a homogeneus interface to any instrument
that could be used to measure skew between PPS signals from WR devices.
'''
__metaclass__ = abc.ABCMeta
## The input channel for the slave signal
slave_chan = ""
## The input channel for the master signal
master_chan = ""
## Trigger level array. Each position i stores the trigger level for the input i.
trigger_level = []
# The following methods must be implemented by a concrete class for a WR device.
@abc.abstractmethod
def __init__(self, port, master_chan=None, slave_chan=None) :
'''
Constructor
Args:
port (int) : Port for the Tektronix FCA3103 using the USB connection.
master_chan (int) : Input channel for master's PPS signal.
slave_chan (int) : Input channel for slave's PPS signal.
'''
# ------------------------------------------------------------------------ #
@abc.abstractmethod
def trigger_level(self, v_min=0, v_max=5) :
'''
Abstract method to determine a good trigger level for a input channel.
It's important to run this method at least once before doing any
measurement for achieving good time interval measures.
Ensure that 2 WR devices are connected and servo state is TRACK PHASE.
Args:
v_min (float) : Minimum voltage level for the input signal
v_max (float) : Maximum voltage level for the input signal
Raises:
ValueError if master_chan or slave_chan are not set.
InputNotSet if input channels are not set.
'''
# ------------------------------------------------------------------------ #
@abc.abstractmethod
def mean_time_interval(self, n_samples, t_samples) :
'''
Abstract method to measure time interval between two input signals.
This method measures time interval between the PPS input from the master
to the PPS input from the slave. It makes n_samples and calculates the
mean value.
Before using this method, master_chan and slave_chan must be set.
Args:
n_samples (int) : Number of measures to be done.
t_samples (int) : Time between samples (should be greater than 1ms)
Returns:
The mean time interval master to slave.
Raises:
ValueError if master_chan or slave_chan are not set.
TriggerNotSet if trigger levels are not set.
MeasuringError if a time interval value is higher than expected.
'''