/
base.go
39 lines (35 loc) · 932 Bytes
/
base.go
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
// Copyright (c) 2017-2020 The ivi developers. All rights reserved.
// Project site: https://github.com/gotmc/ivi
// Use of this source code is governed by a MIT-style license that
// can be found in the LICENSE.txt file for the project.
package fluke45
import (
"fmt"
"strings"
"github.com/gotmc/ivi/dmm"
)
// MeasurementFunction needs a better comment.
func (d *DMM) MeasurementFunction() (dmm.MeasurementFunction, error) {
fcn, err := d.QueryString("FUNC1?\n")
if err != nil {
return 0, err
}
switch strings.TrimSpace(fcn) {
case "VDC":
return dmm.DCVolts, nil
case "VAC":
return dmm.ACVolts, nil
case "ADC":
return dmm.DCCurrent, nil
case "AAC":
return dmm.ACCurrent, nil
case "OHMS":
return dmm.TwoWireResistance, nil
case "VACDC":
return dmm.ACPlusDCVolts, nil
case "AACDC":
return dmm.ACPlusDCCurrent, nil
default:
return 0, fmt.Errorf("%s is not a valid measurement function", fcn)
}
}