Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: amend GetOperationalState() return in camera module in @observerly/alpacago. #295

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/observerly/alpacago/pkg/alpacago/alpaca.go:34.13,36.3 1 52
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:38.2,40.35 2 52
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:40.35,42.3 1 10
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:45.2,58.16 4 52
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:68.56,70.2 1 216
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:79.104,81.2 1 408
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:68.56,70.2 1 215
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:79.104,81.2 1 406
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:96.119,103.16 3 13
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:103.16,105.3 1 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:108.2,108.20 1 13
Expand All @@ -26,11 +26,11 @@ github.com/observerly/alpacago/pkg/alpacago/alpaca.go:208.16,210.3 1 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:213.2,213.20 1 57
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:213.20,216.3 2 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:219.2,221.26 2 57
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:237.117,243.16 3 51
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:237.117,243.16 3 50
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:243.16,245.3 1 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:248.2,248.20 1 51
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:248.2,248.20 1 50
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:248.20,251.3 2 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:254.2,256.26 2 51
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:254.2,256.26 2 50
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:272.125,278.16 3 2
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:278.16,280.3 1 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:283.2,283.20 1 2
Expand All @@ -41,13 +41,13 @@ github.com/observerly/alpacago/pkg/alpacago/alpaca.go:314.16,316.3 1 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:319.2,319.20 1 2
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:319.20,322.3 2 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:325.2,327.39 2 2
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:337.119,343.16 3 192
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:337.119,343.16 3 191
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:343.16,345.3 1 0
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:348.2,348.20 1 192
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:348.2,348.20 1 191
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:348.20,351.3 2 1
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:354.2,356.29 2 192
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:354.2,356.29 2 191
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:356.29,358.3 1 4
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:360.2,362.12 2 188
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:360.2,362.12 2 187
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:371.96,373.2 1 1
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:381.101,383.2 1 6
github.com/observerly/alpacago/pkg/alpacago/alpaca.go:391.100,393.2 1 1
Expand All @@ -67,22 +67,22 @@ github.com/observerly/alpacago/pkg/alpacago/calibrator.go:154.52,163.2 3 1
github.com/observerly/alpacago/pkg/alpacago/calibrator.go:171.46,180.2 3 1
github.com/observerly/alpacago/pkg/alpacago/calibrator.go:188.45,197.2 3 1
github.com/observerly/alpacago/pkg/alpacago/calibrator.go:205.45,214.2 3 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:20.43,25.9 3 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:26.25,27.17 1 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:20.43,25.9 3 3
github.com/observerly/alpacago/pkg/alpacago/camera.go:26.25,27.17 1 3
github.com/observerly/alpacago/pkg/alpacago/camera.go:28.10,29.30 1 0
github.com/observerly/alpacago/pkg/alpacago/camera.go:44.37,49.9 3 7
github.com/observerly/alpacago/pkg/alpacago/camera.go:50.46,51.17 1 7
github.com/observerly/alpacago/pkg/alpacago/camera.go:52.10,53.30 1 0
github.com/observerly/alpacago/pkg/alpacago/camera.go:62.111,71.2 3 5
github.com/observerly/alpacago/pkg/alpacago/camera.go:79.46,81.2 1 2
github.com/observerly/alpacago/pkg/alpacago/camera.go:90.53,101.2 3 71
github.com/observerly/alpacago/pkg/alpacago/camera.go:90.53,101.2 3 70
github.com/observerly/alpacago/pkg/alpacago/camera.go:109.51,111.2 1 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:119.51,121.2 1 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:129.43,131.2 1 2
github.com/observerly/alpacago/pkg/alpacago/camera.go:139.44,149.2 3 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:157.43,159.2 1 2
github.com/observerly/alpacago/pkg/alpacago/camera.go:167.44,177.2 3 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:186.66,189.2 2 3
github.com/observerly/alpacago/pkg/alpacago/camera.go:186.56,189.2 2 2
github.com/observerly/alpacago/pkg/alpacago/camera.go:197.47,199.2 1 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:207.47,209.2 1 1
github.com/observerly/alpacago/pkg/alpacago/camera.go:217.51,219.2 1 1
Expand Down
4 changes: 2 additions & 2 deletions pkg/alpacago/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ GetOperationalState()
The operational state is specified as an integer value from the OperationalState Enum.
@see https://ascom-standards.org/api/#/Camera%20Specific%20Methods/get_camera__device_number__camerastate
*/
func (c *Camera) GetOperationalState() (OperationalState, error) {
func (c *Camera) GetOperationalState() (string, error) {
state, err := c.Alpaca.GetInt32Response("camera", c.DeviceNumber, "camerastate")
return OperationalState(state), err
return OperationalState(state).String(), err
}

/*
Expand Down
22 changes: 5 additions & 17 deletions pkg/alpacago/camera_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestNewCameraGetOperationalState(t *testing.T) {

var got, err = camera.GetOperationalState()

var want = CameraIdle
var want = "idle"

if err != nil {
t.Errorf("got %q, wanted %q", err, want)
Expand All @@ -254,29 +254,17 @@ func TestNewCameraGetOperationalState(t *testing.T) {
t.Errorf("got %q, wanted %q", got, want)
}

if telescope.Alpaca.ErrorNumber != 0 {
t.Errorf("got %q, wanted %d", telescope.Alpaca.ErrorMessage, want)
if camera.Alpaca.ErrorNumber != 0 {
t.Errorf("got %q, wanted %q", camera.Alpaca.ErrorMessage, want)
}
}

func TestNewCameraGetOperationalStateToStringRepresentation(t *testing.T) {
camera.SetConnected(true)

var got, err = camera.GetOperationalState()

var state = OperationalState.String(got)
var state = OperationalState.String(CameraIdle)

if state == "" {
t.Errorf("got %q, wanted %q", state, "the operational status to represnet an iota in range 0 to 5")
}

if err != nil {
t.Errorf("got %q", err)
}

if telescope.Alpaca.ErrorNumber != 0 {
t.Errorf("got %q", telescope.Alpaca.ErrorMessage)
}
}

func TestNewCameraGetCCDSizeX(t *testing.T) {
Expand Down Expand Up @@ -1517,7 +1505,7 @@ func TestNewCameraStopExposure(t *testing.T) {

var got, _ = camera.GetOperationalState()

var want = CameraIdle
var want = "idle"

if got != want {
t.Errorf("got %q, wanted %q", got, want)
Expand Down
Loading