api

package
v0.0.0-...-de5a386 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ON       = "On"
	OFF      = "Off"
	YES      = "Yes"
	NO       = "No"
	ENABLED  = "Enabled"
	DISABLED = "Disabled"
	STATIC   = "Static"
	DHCP     = "DHCP"
	TE       = "te"
	TWOWAYTE = "2wayte"
	RSFEC    = "RS-FEC"
	INTERVAL = "1 packet/16 s"
	CHANNEL1 = "Channel 1"
	IPV6     = "UDP/IPv6"
	INTERNAL = "Internal"
	SPTP     = "SPTP_V2.1"
)

Calnex Status constants

Variables

View Source
var (
	// ErrBadChannel is returned when channel is not recognized
	ErrBadChannel = errors.New("channel is not recognized")
)

MeasureChannelDatatypeMap is a Map of the measurement channels to the data type. Only channels used for measurements defined here

Functions

func ToBuffer

func ToBuffer(f *ini.File) (*bytes.Buffer, error)

ToBuffer converts an INI file to a bytes.Buffer

Types

type API

type API struct {
	Client *http.Client
	// contains filtered or unexported fields
}

API is struct for accessing calnex API

func NewAPI

func NewAPI(source string, insecureTLS bool, timeout time.Duration) *API

NewAPI returns an pointer of API struct with default values.

func (*API) ClearDevice

func (a *API) ClearDevice() error

ClearDevice clears device data

func (*API) FetchChannelProbe

func (a *API) FetchChannelProbe(channel Channel) (*Probe, error)

FetchChannelProbe returns monitored protocol of the channel

func (*API) FetchChannelTarget

func (a *API) FetchChannelTarget(channel Channel, probe Probe) (string, error)

FetchChannelTarget returns the measure target of the server monitored on the channel

func (*API) FetchCsv

func (a *API) FetchCsv(channel Channel, allData bool) ([][]string, error)

FetchCsv takes channel name (like 1, 2, c, d) it returns list of CSV lines which is []string

func (*API) FetchInstrumentStatus

func (a *API) FetchInstrumentStatus() (*InstrumentStatus, error)

FetchInstrumentStatus returns the calnex instrument status

func (*API) FetchProblemReport

func (a *API) FetchProblemReport(dir string) (string, error)

FetchProblemReport saves a problem report

func (*API) FetchSettings

func (a *API) FetchSettings() (*ini.File, error)

FetchSettings returns the calnex settings

func (*API) FetchStatus

func (a *API) FetchStatus() (*Status, error)

FetchStatus returns the calnex status

func (*API) FetchUsedChannels

func (a *API) FetchUsedChannels() ([]Channel, error)

FetchUsedChannels returns list of channels in use

func (*API) FetchVersion

func (a *API) FetchVersion() (*Version, error)

FetchVersion returns current Firmware Version

func (*API) GnssStatus

func (a *API) GnssStatus() (*GNSS, error)

GnssStatus returns current GNSS status

func (*API) PowerSupplyStatus

func (a *API) PowerSupplyStatus() (*PowerSupplyStatus, error)

PowerSupplyStatus returns current PSU status

func (*API) PushCert

func (a *API) PushCert(cert []byte) (*Result, error)

PushCert uploads a new Certificate to the device

func (*API) PushLicense

func (a *API) PushLicense(path string) (*Result, error)

PushLicense uploads a new license to the device

func (*API) PushSettings

func (a *API) PushSettings(f *ini.File) error

PushSettings pushes the calnex settings

func (*API) PushVersion

func (a *API) PushVersion(path string) (*Result, error)

PushVersion uploads a new Firmware Version to the device

func (*API) Reboot

func (a *API) Reboot() error

Reboot the device

func (*API) StartMeasure

func (a *API) StartMeasure() error

StartMeasure starts measurement

func (*API) StopMeasure

func (a *API) StopMeasure() error

StopMeasure stops measurement

type Channel

type Channel string

Channel is a Calnex channel object

const (
	ChannelA    Channel = "A"
	ChannelB    Channel = "B"
	ChannelC    Channel = "C"
	ChannelD    Channel = "D"
	ChannelE    Channel = "E"
	ChannelF    Channel = "F"
	ChannelONE  Channel = "1"
	ChannelTWO  Channel = "2"
	ChannelREF  Channel = "REF"
	ChannelVP1  Channel = "VP1"
	ChannelVP2  Channel = "VP2"
	ChannelVP3  Channel = "VP3"
	ChannelVP4  Channel = "VP4"
	ChannelVP5  Channel = "VP5"
	ChannelVP6  Channel = "VP6"
	ChannelVP7  Channel = "VP7"
	ChannelVP8  Channel = "VP8"
	ChannelVP9  Channel = "VP9"
	ChannelVP10 Channel = "VP10"
	ChannelVP11 Channel = "VP11"
	ChannelVP12 Channel = "VP12"
	ChannelVP13 Channel = "VP13"
	ChannelVP14 Channel = "VP14"
	ChannelVP15 Channel = "VP15"
	ChannelVP16 Channel = "VP16"
	ChannelVP17 Channel = "VP17"
	ChannelVP18 Channel = "VP18"
	ChannelVP19 Channel = "VP19"
	ChannelVP20 Channel = "VP20"
	ChannelVP21 Channel = "VP21"
	ChannelVP22 Channel = "VP22"
	ChannelVP23 Channel = "VP23"
	ChannelVP24 Channel = "VP24"
	ChannelVP25 Channel = "VP25"
	ChannelVP26 Channel = "VP26"
	ChannelVP27 Channel = "VP27"
	ChannelVP28 Channel = "VP28"
	ChannelVP29 Channel = "VP29"
	ChannelVP30 Channel = "VP30"
	ChannelVP31 Channel = "VP31"
	ChannelVP32 Channel = "VP32"
)

Available Calnex channels

func ChannelFromInt

func ChannelFromInt(value int) (*Channel, error)

ChannelFromInt returns channel from int

func ChannelFromString

func ChannelFromString(value string) (*Channel, error)

ChannelFromString returns channel from string

func (Channel) Calnex

func (c Channel) Calnex() int

Calnex returns calnex friendly channel name like 1 or 7

func (Channel) CalnexAPI

func (c Channel) CalnexAPI() string

CalnexAPI returns channel name in API format like "ch2"

func (*Channel) UnmarshalText

func (c *Channel) UnmarshalText(value []byte) error

UnmarshalText channel from string version

type ChannelStatus

type ChannelStatus struct {
	Progress int
	Slot     string
	State    string
	Type     string
}

ChannelStatus is a struct representing Calnex channel instrument status

type Channels

type Channels []Channel

Channels is a list of Channel

func (*Channels) Set

func (cs *Channels) Set(channel string) error

Set Channel to Channels

func (*Channels) String

func (cs *Channels) String() string

String returns all channels

func (*Channels) Type

func (cs *Channels) Type() string

Type is required by the cobra.Value interface

type GNSS

type GNSS struct {
	AntennaStatus         string
	Locked                bool
	LockedSatellites      int
	SurveyComplete        bool
	SurveyPercentComplete int
}

GNSS is a struct representing Calnex GNSS JSON response

type InstrumentStatus

type InstrumentStatus struct {
	Channels map[Channel]ChannelStatus
	Modules  map[Channel]ModuleStatus
}

InstrumentStatus is a struct representing Calnex instrument status JSON response

type ModuleStatus

type ModuleStatus struct {
	Channels []string
	Progress int
	State    string
	Type     string
}

ModuleStatus is a struct representing Calnex channel module status

type PowerSupply

type PowerSupply struct {
	CommsGood  bool `json:"comms_good"`
	Name       string
	StatusGood bool `json:"status_good"`
}

PowerSupply is a struct representing a single power supply unit

type PowerSupplyStatus

type PowerSupplyStatus struct {
	PowerSupplyGood bool `json:"power_supply_good"`
	Supplies        []PowerSupply
}

PowerSupplyStatus is a struct representing Calnex Power Supply JSON response

type Probe

type Probe string

Probe is a Calnex probe protocol

const (
	ProbePTP Probe = "PTP"
	ProbeNTP Probe = "NTP"
	ProbePPS Probe = "PPS"
)

Probe numbers by calnex

func ProbeFromCalnex

func ProbeFromCalnex(calnex string) (*Probe, error)

ProbeFromCalnex returns Channel object from String version

func ProbeFromString

func ProbeFromString(value string) (*Probe, error)

ProbeFromString returns Channel object from String version

func (Probe) CalnexAPI

func (p Probe) CalnexAPI() string

CalnexAPI returns probe name (lower case)

func (Probe) CalnexName

func (p Probe) CalnexName() string

CalnexName returns Calnex Name like "PTP slave" or "NTP client"

func (Probe) ServerType

func (p Probe) ServerType() string

ServerType returns server type like "server_ip" or "master_ip"

func (*Probe) UnmarshalText

func (p *Probe) UnmarshalText(value []byte) error

UnmarshalText probe from string version

type Result

type Result struct {
	Result  bool
	Message string
}

Result is a struct representing Calnex result JSON response

type Status

type Status struct {
	ChannelLinksReady bool
	IPAddressReady    bool
	MeasurementActive bool
	MeasurementReady  bool
	ModulesReady      bool
	ReferenceReady    bool
}

Status is a struct representing Calnex status JSON response

type Version

type Version struct {
	Firmware string
}

Version is a struct representing Calnex version JSON response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL