Skip to content

Commit

Permalink
Add start trigger to key33220
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewrankin committed Apr 23, 2024
1 parent 0f5a934 commit 7567344
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 64 deletions.
168 changes: 105 additions & 63 deletions fgen/30_value_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ const (
OutputModeNoise
)

// String implements the Stringer interface for OutputMode.
func (om OutputMode) String() string {
switch om {
case OutputModeFunction:
return "function"
case OutputModeArbitrary:
return "arbitrary"
case OutputModeSequence:
return "sequence"
case OutputModeNoise:
return "noise"
default:
return ""
outputModes := map[OutputMode]string{
OutputModeFunction: "function",
OutputModeArbitrary: "arbitrary",
OutputModeSequence: "sequence",
OutputModeNoise: "noise",
}

return outputModes[om]
}

// ClockSource models the defined values for the Reference Clock Source defined
Expand Down Expand Up @@ -63,15 +60,14 @@ const (
BurstMode
)

var operationModes = map[OperationMode]string{
ContinuousMode: "continuous mode",
BurstMode: "burst mode",
}

// String implements the Stringer interface for OperationMode.
func (om OperationMode) String() string {
switch om {
case ContinuousMode:
return "continuous mode"
case BurstMode:
return "burst mode"
default:
return ""
}
return operationModes[om]
}

// StandardWaveform models the defined values for the Standard Waveform defined
Expand Down Expand Up @@ -132,52 +128,31 @@ const (
)

func (ts OldTriggerSource) String() string {
switch ts {
case OldTriggerSourceInternal:
return "internal trigger"
case OldTriggerSourceExternal:
return "external trigger"
case OldTriggerSourceSoftware:
return "software trigger"
case OldTriggerSourceTTL0:
return "TTL0 trigger"
case OldTriggerSourceTTL1:
return "TTL1 trigger"
case OldTriggerSourceTTL2:
return "TTL2 trigger"
case OldTriggerSourceTTL3:
return "TTL3 trigger"
case OldTriggerSourceTTL4:
return "TTL4 trigger"
case OldTriggerSourceTTL5:
return "TTL5 trigger"
case OldTriggerSourceTTL6:
return "TTL6 trigger"
case OldTriggerSourceTTL7:
return "TTL7 trigger"
case OldTriggerSourceECL0:
return "ECL0 trigger"
case OldTriggerSourceECL1:
return "ECL1 trigger"
case OldTriggerSourcePXIStar:
return "PXI star trigger"
case OldTriggerSourceRTSI0:
return "RTSI0 trigger"
case OldTriggerSourceRTSI1:
return "RTSI1 trigger"
case OldTriggerSourceRTSI2:
return "RTSI2 trigger"
case OldTriggerSourceRTSI3:
return "RTSI3 trigger"
case OldTriggerSourceRTSI4:
return "RTSI4 trigger"
case OldTriggerSourceRTSI5:
return "RTSI5 trigger"
case OldTriggerSourceRTSI6:
return "RTSI6 trigger"
oldTriggerSources := map[OldTriggerSource]string{
OldTriggerSourceInternal: "internal trigger",
OldTriggerSourceExternal: "external trigger",
OldTriggerSourceSoftware: "software trigger",
OldTriggerSourceTTL0: "TTL0 trigger",
OldTriggerSourceTTL1: "TTL1 trigger",
OldTriggerSourceTTL2: "TTL2 trigger",
OldTriggerSourceTTL3: "TTL3 trigger",
OldTriggerSourceTTL4: "TTL4 trigger",
OldTriggerSourceTTL5: "TTL5 trigger",
OldTriggerSourceTTL6: "TTL6 trigger",
OldTriggerSourceTTL7: "TTL7 trigger",
OldTriggerSourceECL0: "ECL0 trigger",
OldTriggerSourceECL1: "ECL1 trigger",
OldTriggerSourcePXIStar: "PXI star trigger",
OldTriggerSourceRTSI0: "RTSI0 trigger",
OldTriggerSourceRTSI1: "RTSI1 trigger",
OldTriggerSourceRTSI2: "RTSI2 trigger",
OldTriggerSourceRTSI3: "RTSI3 trigger",
OldTriggerSourceRTSI4: "RTSI4 trigger",
OldTriggerSourceRTSI5: "RTSI5 trigger",
OldTriggerSourceRTSI6: "RTSI6 trigger",
}

return ""
return oldTriggerSources[ts]
}

// TriggerSource models the defined values for the Start Trigger Source, Stop
Expand Down Expand Up @@ -239,6 +214,62 @@ const (
TriggerSourceRTSI6
)

// String implements the Stringer interface for TriggerSource.
func (ts TriggerSource) String() string {
triggerSources := map[TriggerSource]string{
TriggerSourceNone: "none",
TriggerSourceImmediate: "immediate",
TriggerSourceExternal: "external",
TriggerSourceInternal: "internal",
TriggerSourceSoftware: "software",
TriggerSourceLAN0: "lan0",
TriggerSourceLAN1: "lan1",
TriggerSourceLAN2: "lan2",
TriggerSourceLAN3: "lan3",
TriggerSourceLAN4: "lan4",
TriggerSourceLAN5: "lan5",
TriggerSourceLAN6: "lan6",
TriggerSourceLAN7: "lan7",
TriggerSourceLXI0: "lxi0",
TriggerSourceLXI1: "lxi1",
TriggerSourceLXI2: "lxi2",
TriggerSourceLXI3: "lxi3",
TriggerSourceLXI4: "lxi4",
TriggerSourceLXI5: "lxi5",
TriggerSourceLXI6: "lxi6",
TriggerSourceLXI7: "lxi7",
TriggerSourceTTL0: "ttl0",
TriggerSourceTTL1: "ttl1",
TriggerSourceTTL2: "ttl2",
TriggerSourceTTL3: "ttl3",
TriggerSourceTTL4: "ttl4",
TriggerSourceTTL5: "ttl5",
TriggerSourceTTL6: "ttl6",
TriggerSourceTTL7: "ttl7",
TriggerSourcePXIStar: "pxi star",
TriggerSourcePXITrig0: "pxi trigger 0",
TriggerSourcePXITrig1: "pxi trigger 1",
TriggerSourcePXITrig2: "pxi trigger 2",
TriggerSourcePXITrig3: "pxi trigger 3",
TriggerSourcePXITrig4: "pxi trigger 4",
TriggerSourcePXITrig5: "pxi trigger 5",
TriggerSourcePXITrig6: "pxi trigger 6",
TriggerSourcePXITrig7: "pxi trigger 7",
TriggerSourcePXIeDStarA: "pxied star a",
TriggerSourcePXIeDStarB: "pxied star b",
TriggerSourcePXIeDStarC: "pxied stard c",
TriggerSourceRTSI0: "rtsi0",
TriggerSourceRTSI1: "rtsi1",
TriggerSourceRTSI2: "rtsi2",
TriggerSourceRTSI3: "rtsi3",
TriggerSourceRTSI4: "rtsi4",
TriggerSourceRTSI5: "rtsi5",
TriggerSourceRTSI6: "rtsi6",
}

return triggerSources[ts]
}

type SampleClockSource int

const (
Expand Down Expand Up @@ -303,3 +334,14 @@ const (
TriggerSlopeNegative
TriggerSlopeEither
)

// String implements the Stringer interface for TriggerSlope.
func (ts TriggerSlope) String() string {
triggerSlopes := map[TriggerSlope]string{
TriggerSlopePositive: "positive",
TriggerSlopeNegative: "negative",
TriggerSlopeEither: "either",
}

return triggerSlopes[ts]
}
2 changes: 1 addition & 1 deletion fgen/keysight/key33220/09_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ func (ch *Channel) SetTriggerSource(src fgen.OldTriggerSource) error {
return fmt.Errorf("trigger source %s not supported", src)
}

return ch.inst.Command("TRIGE:SOUR %s", triggerSource)
return ch.inst.Command("TRIG:SOUR %s", triggerSource)
}
143 changes: 143 additions & 0 deletions fgen/keysight/key33220/10_start_trigger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Copyright (c) 2017-2024 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 key33220

import (
"errors"
"fmt"
"strings"
"time"

"github.com/gotmc/ivi"
"github.com/gotmc/ivi/fgen"
"github.com/gotmc/query"
)

// StartTriggerDelay returns the delay from the start trigger to the first
// point in the waveform generation.
//
// StartTriggerDelay is the getter for the read-write IviFgenTrigger
// Attribute Start Trigger Delay described in Section 10.2.1 of IVI-4.3:
// IviFgen Class Specification.
func (ch *Channel) StartTriggerDelay() (time.Duration, error) {
return time.Duration(0), ivi.ErrFunctionNotSupported
}

// SetStartTriggerDelay sets the delay from the start trigger to the first
// point in the waveform generation.
//
// SetStartTriggerDelay is the setter for the read-write IviFgenTrigger
// Attribute Start Trigger Delay described in Section 10.2.1 of IVI-4.3:
// IviFgen Class Specification.
func (ch *Channel) SetStartTriggerDelay(_ time.Duration) error {
return ivi.ErrFunctionNotSupported
}

// StartTriggerSlope returns the slope of the trigger that starts the
// generator.
//
// StartTriggerSlope is the getter for the read-write IviFgenTrigger
// Attribute Start Trigger Slope described in Section 10.2.2 of IVI-4.3:
// IviFgen Class Specification.
func (ch *Channel) StartTriggerSlope() (fgen.TriggerSlope, error) {
var slope fgen.TriggerSlope

s, err := query.String(ch.inst, "TRIG:SLOP?")
if err != nil {
return slope, err
}

s = strings.TrimSpace(strings.ToUpper(s))
switch s {
case "POS":
slope = fgen.TriggerSlopePositive
case "NEG":
slope = fgen.TriggerSlopeNegative
default:
return slope, errors.New("error determining start trigger slope")
}

return slope, nil
}

// StartTriggerSlope sets the slope of the trigger that starts the generator.
//
// StartTriggerSlope is the setter for the read-write IviFgenTrigger
// Attribute Start Trigger Slope described in Section 10.2.2 of IVI-4.3:
// IviFgen Class Specification.
func (ch *Channel) SetStartTriggerSlope(slope fgen.TriggerSlope) error {
slopes := map[fgen.TriggerSlope]string{
fgen.TriggerSlopePositive: "POS",
fgen.TriggerSlopeNegative: "NEG",
}

triggerSlope, ok := slopes[slope]
if !ok {
return fmt.Errorf("trigger slope %v not supported", slope)
}

return ch.inst.Command("TRIG:SLOP %s", triggerSlope)
}

// StartTriggerSource returns the source of the start trigger.
//
// StartTriggerSource is the getter for the read-write IviFgenTrigger
// Attribute Start Trigger Source described in Section 10.2.3 of IVI-4.3:
// IviFgen Class Specification.
func (ch *Channel) StartTriggerSource() (fgen.TriggerSource, error) {
var src fgen.TriggerSource

s, err := query.String(ch.inst, "TRIG:SOUR?")
if err != nil {
return src, err
}

s = strings.TrimSpace(strings.ToUpper(s))
switch s {
case "IMM":
src = fgen.TriggerSourceInternal
case "EXT":
src = fgen.TriggerSourceExternal
case "BUS":
src = fgen.TriggerSourceSoftware
default:
return src, errors.New("error determining trigger source")
}

return src, nil
}

// SetStartTriggerSource specifies the source of the start trigger.
//
// SetStartTriggerSource is the setter for the read-write IviFgenTrigger
// Attribute Start Trigger Source described in Section 10.2.3 of IVI-4.3:
// IviFgen Class Specification.
func (ch *Channel) SetStartTriggerSource(src fgen.TriggerSource) error {
triggers := map[fgen.TriggerSource]string{
fgen.TriggerSourceInternal: "IMM",
fgen.TriggerSourceExternal: "EXT",
fgen.TriggerSourceSoftware: "BUS",
}

triggerSource, ok := triggers[src]
if !ok {
return fmt.Errorf("trigger source %v not supported", src)
}

return ch.inst.Command("TRIG:SOUR %s", triggerSource)
}

func (ch *Channel) StartTriggerThreshold() (float64, error) {
return 0.0, ivi.ErrFunctionNotSupported
}

func (ch *Channel) SetStartTriggerThreshold(_ float64) error {
return ivi.ErrFunctionNotSupported
}

func (ch *Channel) StartTriggerConfigure(_ fgen.TriggerSource, _ fgen.TriggerSlope) error {
return ivi.ErrFunctionNotSupported
}

0 comments on commit 7567344

Please sign in to comment.