summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-11-19 10:21:42 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-11-19 10:21:42 (GMT)
commiteaa9c42fbe5adad0af5b71c7544080cff42d6850 (patch)
tree972f058cae8bf4e2d1c32a3a7562b991ae071255
parent220d64723c2d286a6575216645c4f00edb2c78b8 (diff)
added public command functions
-rw-r--r--src/pira32ctl/command.go102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/pira32ctl/command.go b/src/pira32ctl/command.go
index 9291ef9..5a8e860 100644
--- a/src/pira32ctl/command.go
+++ b/src/pira32ctl/command.go
@@ -22,7 +22,10 @@
package main
import (
+ "fmt"
"time"
+
+ "code.helsinki.at/goserial"
)
const (
@@ -38,6 +41,10 @@ const (
type Command interface {
AllowedMethods() (get, assign, store, assignstore bool)
+ Get(port *goserial.Port, params ...interface{}) (interface{}, error)
+ Assign(port *goserial.Port, params ...interface{}) error
+ Store(port *goserial.Port, params ...interface{}) error
+ AssignStore(port *goserial.Port, params ...interface{}) error
}
type BasicCommand struct {
@@ -54,6 +61,38 @@ func (c BasicCommand) AllowedMethods() (bool, bool, bool, bool) {
return c.get, c.assign, c.store, c.assignStore
}
+func (c BasicCommand) Get(port *goserial.Port, params ...interface{}) (interface{}, error) {
+ if len(params) != 0 {
+ return nil, fmt.Errorf("this command takes no arguments")
+ }
+ // TODO: implement this
+ return nil, nil
+}
+
+func (c BasicCommand) Assign(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 1 {
+ return fmt.Errorf("this command takes exactly one argument")
+ }
+ // TODO: implement this
+ return nil
+}
+
+func (c BasicCommand) Store(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 0 {
+ return fmt.Errorf("this command takes no arguments")
+ }
+ // TODO: implement this
+ return nil
+}
+
+func (c BasicCommand) AssignStore(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 1 {
+ return fmt.Errorf("this command takes exactly one argument")
+ }
+ // TODO: implement this
+ return nil
+}
+
type ParamCommand struct {
code string
description string
@@ -70,6 +109,38 @@ func (c ParamCommand) AllowedMethods() (bool, bool, bool, bool) {
return c.get, c.assign, c.store, c.assignStore
}
+func (c ParamCommand) Get(port *goserial.Port, params ...interface{}) (interface{}, error) {
+ if len(params) != 1 {
+ return nil, fmt.Errorf("this command takes exactly one argument")
+ }
+ // TODO: implement this
+ return nil, nil
+}
+
+func (c ParamCommand) Assign(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 2 {
+ return fmt.Errorf("this command takes exactly two arguments")
+ }
+ // TODO: implement this
+ return nil
+}
+
+func (c ParamCommand) Store(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 1 {
+ return fmt.Errorf("this command takes exactly one argument")
+ }
+ // TODO: implement this
+ return nil
+}
+
+func (c ParamCommand) AssignStore(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 2 {
+ return fmt.Errorf("this command takes exactly two argument")
+ }
+ // TODO: implement this
+ return nil
+}
+
type Param2Command struct {
code string
description string
@@ -85,6 +156,37 @@ type Param2Command struct {
func (c Param2Command) AllowedMethods() (bool, bool, bool, bool) {
return c.get, c.assign, c.store, c.assignStore
}
+func (c Param2Command) Get(port *goserial.Port, params ...interface{}) (interface{}, error) {
+ if len(params) != 1 {
+ return nil, fmt.Errorf("this command takes exactly one argument")
+ }
+ // TODO: implement this
+ return nil, nil
+}
+
+func (c Param2Command) Assign(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 2 {
+ return fmt.Errorf("this command takes exactly two arguments")
+ }
+ // TODO: implement this
+ return nil
+}
+
+func (c Param2Command) Store(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 1 {
+ return fmt.Errorf("this command takes exactly one argument")
+ }
+ // TODO: implement this
+ return nil
+}
+
+func (c Param2Command) AssignStore(port *goserial.Port, params ...interface{}) error {
+ if len(params) != 2 {
+ return fmt.Errorf("this command takes exactly two argument")
+ }
+ // TODO: implement this
+ return nil
+}
var (
// Basic: