more proper import
authorBernhard Tittelbach <xro@realraum.at>
Sat, 5 Oct 2013 00:41:24 +0000 (00:41 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Sat, 5 Oct 2013 00:41:24 +0000 (00:41 +0000)
13 files changed:
go/r3-eventbroker_zmq/main.go
go/r3-eventbroker_zmq/metamovement.go
go/r3-eventbroker_zmq/presence.go
go/r3-eventbroker_zmq/r3events/basicevents.go [deleted file]
go/r3-eventbroker_zmq/r3events/marshal_events.go [deleted file]
go/r3-eventbroker_zmq/r3events/metaevents.go [deleted file]
go/r3-eventbroker_zmq/smallbrain.go
go/r3-eventbroker_zmq/sockettoevent.go
go/r3-netstatus/main.go
go/r3-netstatus/webstatus.go
go/r3events/basicevents.go [new file with mode: 0644]
go/r3events/marshal_events.go [new file with mode: 0644]
go/r3events/metaevents.go [new file with mode: 0644]

index 10c87dc..0495edd 100644 (file)
@@ -8,7 +8,7 @@ import (
     "flag"
     //~ "time"
     pubsub "github.com/tuxychandru/pubsub"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
 )
 
 //~ func StringArrayToByteArray(ss []string) [][]byte {
index ecde4cb..b274092 100644 (file)
@@ -7,7 +7,7 @@ import (
     //~ "./brain"
     pubsub "github.com/tuxychandru/pubsub"
     "container/ring"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
     )
 
 
index a879332..d65788d 100644 (file)
@@ -6,7 +6,7 @@ import (
     "time"
     //~ "./brain"
     pubsub "github.com/tuxychandru/pubsub"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
     )
 
 func MetaEventRoutine_Presence(ps *pubsub.PubSub) {
diff --git a/go/r3-eventbroker_zmq/r3events/basicevents.go b/go/r3-eventbroker_zmq/r3events/basicevents.go
deleted file mode 100644 (file)
index 73776cb..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// (c) Bernhard Tittelbach, 2013
-
-package r3events
-
-
-type DoorLockUpdate struct {
-    Locked bool
-    Ts int64
-}
-
-type DoorAjarUpdate struct {
-    Shut bool
-    Ts int64
-}
-
-type BackdoorAjarUpdate struct {
-    Shut bool
-    Ts int64
-}
-
-type DoorCommandEvent struct {
-    Command string
-    Using string
-    Who string
-    Ts int64
-}
-
-type DoorProblemEvent struct {
-    Severity int
-    Ts int64
-}
-
-type BoreDoomButtonPressEvent struct {
-    Ts int64
-}
-
-type TempSensorUpdate struct {
-    Sensorindex int
-    Value float64
-    Ts int64
-}
-
-type IlluminationSensorUpdate struct {
-    Sensorindex int
-    Value int64
-    Ts int64
-}
-
-type TimeTick struct {
-    Ts int64
-}
-
-type MovementSensorUpdate struct {
-    Sensorindex int
-    Ts int64
-}
\ No newline at end of file
diff --git a/go/r3-eventbroker_zmq/r3events/marshal_events.go b/go/r3-eventbroker_zmq/r3events/marshal_events.go
deleted file mode 100644 (file)
index 830ff6b..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-// (c) Bernhard Tittelbach, 2013
-
-package r3events
-
-import (
-    "encoding/json"
-    "fmt"
-    "errors"
-    "strings"
-    )
-
-func NameOfStruct(evi interface{}) (name string) {
-    etype := fmt.Sprintf("%T", evi)
-    etype_lastsep := strings.LastIndex(etype,".")
-    return etype[etype_lastsep+1:] //works in all cases for etype_lastsep in range -1 to len(etype)-1
-}
-
-func MarshalEvent2ByteByte(event_interface interface{}) (data [][]byte, err error) {
-    var msg []byte
-    //~ fmt.Printf("%T%+v\n", event_interface, event_interface)
-       msg, err = json.Marshal(event_interface)
-       if err != nil {
-               return
-       }
-    data = [][]byte{[]byte(NameOfStruct(event_interface)), msg} //works in all cases for etype_lastsep in range -1 to len(etype)-1
-    return
-}
-
-func UnmarshalByteByte2Event(data [][]byte) (event interface{}, category string, err error) {
-    if len(data) != 2 {
-        return nil, "", errors.New("not a r3event message")
-    }
-    switch string(data[0]) {
-        case "DoorLockUpdate":
-            event = DoorLockUpdate{}
-            err = json.Unmarshal(data[1],&event)
-            category = "door"
-        case "DoorAjarUpdate":
-            event := DoorAjarUpdate{}
-            err = json.Unmarshal(data[1], &event)
-            category = "door"
-        case "BackdoorAjarUpdate":
-            event := DoorAjarUpdate{}
-            err = json.Unmarshal(data[1], &event)
-            category = "door"
-        case "DoorCommandEvent":
-            event := DoorCommandEvent{}
-            err = json.Unmarshal(data[1], &event)
-            category = "door"
-        case "DoorProblemEvent":
-            event := DoorProblemEvent{}
-            err = json.Unmarshal(data[1], &event)
-            category = "door"
-        case "BoreDoomButtonPressEvent":
-            event := BoreDoomButtonPressEvent{}
-            err = json.Unmarshal(data[1], &event)
-            category = "buttons"
-        case "TempSensorUpdate":
-            event := TempSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
-            category = "sensors"
-        case "IlluminationSensorUpdate":
-            event := IlluminationSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
-            category = "sensors"
-        case "TimeTick":
-            event := TimeTick{}
-            err = json.Unmarshal(data[1], &event)
-            category = "time"
-        case "MovementSensorUpdate":
-            event := MovementSensorUpdate{}
-            err = json.Unmarshal(data[1], &event)
-            category = "movement"
-        case "PresenceUpdate":
-            event := PresenceUpdate{}
-            err = json.Unmarshal(data[1], &event)
-            category = "presence"
-        case "SomethingReallyIsMoving":
-            event := SomethingReallyIsMoving{}
-            err = json.Unmarshal(data[1], &event)
-            category = "movement"
-        default:
-            event = nil
-            err = errors.New("cannot unmarshal unknown type")
-            category = ""
-    }
-    return
-}
diff --git a/go/r3-eventbroker_zmq/r3events/metaevents.go b/go/r3-eventbroker_zmq/r3events/metaevents.go
deleted file mode 100644 (file)
index c22a79d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// (c) Bernhard Tittelbach, 2013
-
-package r3events
-
-type PresenceUpdate struct {
-    Present bool
-    Ts int64
-}
-
-type SomethingReallyIsMoving struct {
-    Movement bool
-    Ts int64
-}
\ No newline at end of file
index c8ef95a..4a7cdeb 100644 (file)
@@ -4,7 +4,7 @@ package main
 
 import (
     zmq "github.com/vaughan0/go-zmq"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
 )
 
 type hippocampus map[string]interface{}
index 37686b8..3836580 100644 (file)
@@ -9,7 +9,7 @@ import (
     //~ "./brain"
     pubsub "github.com/tuxychandru/pubsub"
     zmq "github.com/vaughan0/go-zmq"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
     )
 
 var (
index 0a4b0c9..0af7ef8 100644 (file)
@@ -9,7 +9,7 @@ import (
     "time"
     "fmt"
     //~ "./brain"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
 )
 
 type SpaceState struct {
index 53ff92d..d29fe02 100644 (file)
@@ -9,7 +9,7 @@ import (
        "net/http"
        "net/url"
     "time"
-    r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+    r3events "svn.spreadspace.org/realraum/go.svn/r3events"
     )
 
 
diff --git a/go/r3events/basicevents.go b/go/r3events/basicevents.go
new file mode 100644 (file)
index 0000000..73776cb
--- /dev/null
@@ -0,0 +1,56 @@
+// (c) Bernhard Tittelbach, 2013
+
+package r3events
+
+
+type DoorLockUpdate struct {
+    Locked bool
+    Ts int64
+}
+
+type DoorAjarUpdate struct {
+    Shut bool
+    Ts int64
+}
+
+type BackdoorAjarUpdate struct {
+    Shut bool
+    Ts int64
+}
+
+type DoorCommandEvent struct {
+    Command string
+    Using string
+    Who string
+    Ts int64
+}
+
+type DoorProblemEvent struct {
+    Severity int
+    Ts int64
+}
+
+type BoreDoomButtonPressEvent struct {
+    Ts int64
+}
+
+type TempSensorUpdate struct {
+    Sensorindex int
+    Value float64
+    Ts int64
+}
+
+type IlluminationSensorUpdate struct {
+    Sensorindex int
+    Value int64
+    Ts int64
+}
+
+type TimeTick struct {
+    Ts int64
+}
+
+type MovementSensorUpdate struct {
+    Sensorindex int
+    Ts int64
+}
\ No newline at end of file
diff --git a/go/r3events/marshal_events.go b/go/r3events/marshal_events.go
new file mode 100644 (file)
index 0000000..830ff6b
--- /dev/null
@@ -0,0 +1,88 @@
+// (c) Bernhard Tittelbach, 2013
+
+package r3events
+
+import (
+    "encoding/json"
+    "fmt"
+    "errors"
+    "strings"
+    )
+
+func NameOfStruct(evi interface{}) (name string) {
+    etype := fmt.Sprintf("%T", evi)
+    etype_lastsep := strings.LastIndex(etype,".")
+    return etype[etype_lastsep+1:] //works in all cases for etype_lastsep in range -1 to len(etype)-1
+}
+
+func MarshalEvent2ByteByte(event_interface interface{}) (data [][]byte, err error) {
+    var msg []byte
+    //~ fmt.Printf("%T%+v\n", event_interface, event_interface)
+       msg, err = json.Marshal(event_interface)
+       if err != nil {
+               return
+       }
+    data = [][]byte{[]byte(NameOfStruct(event_interface)), msg} //works in all cases for etype_lastsep in range -1 to len(etype)-1
+    return
+}
+
+func UnmarshalByteByte2Event(data [][]byte) (event interface{}, category string, err error) {
+    if len(data) != 2 {
+        return nil, "", errors.New("not a r3event message")
+    }
+    switch string(data[0]) {
+        case "DoorLockUpdate":
+            event = DoorLockUpdate{}
+            err = json.Unmarshal(data[1],&event)
+            category = "door"
+        case "DoorAjarUpdate":
+            event := DoorAjarUpdate{}
+            err = json.Unmarshal(data[1], &event)
+            category = "door"
+        case "BackdoorAjarUpdate":
+            event := DoorAjarUpdate{}
+            err = json.Unmarshal(data[1], &event)
+            category = "door"
+        case "DoorCommandEvent":
+            event := DoorCommandEvent{}
+            err = json.Unmarshal(data[1], &event)
+            category = "door"
+        case "DoorProblemEvent":
+            event := DoorProblemEvent{}
+            err = json.Unmarshal(data[1], &event)
+            category = "door"
+        case "BoreDoomButtonPressEvent":
+            event := BoreDoomButtonPressEvent{}
+            err = json.Unmarshal(data[1], &event)
+            category = "buttons"
+        case "TempSensorUpdate":
+            event := TempSensorUpdate{}
+            err = json.Unmarshal(data[1], &event)
+            category = "sensors"
+        case "IlluminationSensorUpdate":
+            event := IlluminationSensorUpdate{}
+            err = json.Unmarshal(data[1], &event)
+            category = "sensors"
+        case "TimeTick":
+            event := TimeTick{}
+            err = json.Unmarshal(data[1], &event)
+            category = "time"
+        case "MovementSensorUpdate":
+            event := MovementSensorUpdate{}
+            err = json.Unmarshal(data[1], &event)
+            category = "movement"
+        case "PresenceUpdate":
+            event := PresenceUpdate{}
+            err = json.Unmarshal(data[1], &event)
+            category = "presence"
+        case "SomethingReallyIsMoving":
+            event := SomethingReallyIsMoving{}
+            err = json.Unmarshal(data[1], &event)
+            category = "movement"
+        default:
+            event = nil
+            err = errors.New("cannot unmarshal unknown type")
+            category = ""
+    }
+    return
+}
diff --git a/go/r3events/metaevents.go b/go/r3events/metaevents.go
new file mode 100644 (file)
index 0000000..c22a79d
--- /dev/null
@@ -0,0 +1,13 @@
+// (c) Bernhard Tittelbach, 2013
+
+package r3events
+
+type PresenceUpdate struct {
+    Present bool
+    Ts int64
+}
+
+type SomethingReallyIsMoving struct {
+    Movement bool
+    Ts int64
+}
\ No newline at end of file