"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 {
//~ "./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"
)
"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) {
+++ /dev/null
-// (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
+++ /dev/null
-// (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
-}
+++ /dev/null
-// (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
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{}
//~ "./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 (
"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 {
"net/http"
"net/url"
"time"
- r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+ r3events "svn.spreadspace.org/realraum/go.svn/r3events"
)
--- /dev/null
+// (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
--- /dev/null
+// (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
+}
--- /dev/null
+// (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