Refactor reach package

- Rename reach package to emlid
- Create generic Reach websocket client
- Add 2 new subpackages 'updater' and 'reachview' to provides specific
API
This commit is contained in:
2018-09-21 12:31:52 +02:00
parent 77a779aebe
commit 6e9df8d386
35 changed files with 427 additions and 576 deletions

14
emlid/reachview/client.go Normal file
View File

@ -0,0 +1,14 @@
package reachview
import "forge.cadoles.com/Pyxis/orion/emlid"
// Client is a ReachRS Updater client
type Client struct {
*emlid.Client
}
// NewClient returns a new ReachRS ReachView client
func NewClient(opts ...emlid.OptionFunc) *Client {
client := emlid.NewClient(opts...)
return &Client{client}
}

View File

@ -0,0 +1,44 @@
package reachview
const (
eventGetConfiguration = "get configuration"
eventCurrentConfiguration = "current configuration"
)
// Configuration is a configuration
type Configuration struct {
RTKSettings *RTKSettings `mapstructure:"rtk settings,omitempty"`
}
// RTKSettings -
type RTKSettings struct {
GLONASSARMode string `mapstructure:"glonass ar mode"`
UpdateRate string `mapstructure:"update rate"`
ElevationMaskAngle string `mapstructure:"elevation mask angle"`
MaxHorizontalAcceleration string `mapstructure:"max horizontal acceleration"`
SNRMask string `mapstructure:"snr mask"`
GPSARMode string `mapstructure:"gps ar mode"`
PositionningMode string `mapstructure:"positioning mode"`
PositioningSystems *PositionningSystems `mapstructure:"positioning systems,omitempty"`
MaxVerticalAcceleration string `mapstructure:"max vertical acceleration"`
}
// PositionningSystems -
type PositionningSystems struct {
GLONASS bool `json:"glonass"`
SBAS bool `json:"sbas"`
QZS bool `json:"qzs"`
QZSS bool `json:"qzss"`
Compass bool `json:"compass"`
Galileo bool `json:"galileo"`
GPS bool `json:"gps"`
}
// Configuration fetches and return the current configuration of the ReachRS module
func (r *Client) Configuration() (*Configuration, error) {
configuration := &Configuration{}
if err := r.ReqResp(eventGetConfiguration, nil, eventCurrentConfiguration, configuration); err != nil {
return nil, err
}
return configuration, nil
}

View File

@ -0,0 +1,38 @@
package reachview
import (
"testing"
"forge.cadoles.com/Pyxis/orion/emlid"
)
func TestReachViewConfiguration(t *testing.T) {
if !*runReachViewIntegrationTests {
t.Skip("To run this test, use: go test -reachview-integration")
}
client := NewClient(
emlid.WithStandardLogger(),
emlid.WithEndpoint(*reachHost, 80),
)
if err := client.Connect(); err != nil {
t.Fatal(err)
}
config, err := client.Configuration()
if err != nil {
t.Error(err)
}
if config == nil {
t.Fatal("config should not be nil")
}
if config.RTKSettings == nil {
t.Fatal("config.RTKSettings should not be nil")
}
defer client.Close()
}

13
emlid/reachview/test.go Normal file
View File

@ -0,0 +1,13 @@
package reachview
import "flag"
var runReachViewIntegrationTests = flag.Bool(
"reachview-integration", false,
"Run the 'ReachView' integration tests (in addition to the unit tests)",
)
var reachHost = flag.String(
"reach-host", "192.168.42.1",
"The Reach module host to use in integration tests",
)