examples

module
v4.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: Apache-2.0

README

examples

Code examples you can use with Horizon.

Generic edge service examples are found, perhaps unsurpringly, in:

  • edge/services

Edge examples specific to the Watson IoT Platform are found in:

  • edge/wiotp

In general to run the code from one of these examples:

  • cd into the directory
  • run make

Directories

Path Synopsis
cloud
edge
services/gps/src
Horizon GPS Data REST API This REST server enables workload access to static location or dynamic GPS receiver location and satellite data.
Horizon GPS Data REST API This REST server enables workload access to static location or dynamic GPS receiver location and satellite data.
services/gps/src/envutil
envutil -- utilities for getting configuration from environment variables.
envutil -- utilities for getting configuration from environment variables.
services/gps/src/gpsdc
gpsdc -- a Go client for the gpsd daemon Usage example: package main import ( "fmt" "gpsdc" ) func main() { var gps_monitor *gpsdc.Session var err error // Open socket to gpsd at specified address (using default here) if gps_monitor, err = gpsdc.Dial(gpsdc.DefaultAddress); err != nil { panic(fmt.Sprintf("Failed to connect to GPSD: ", err)) } // Add an inline Filter function gps_monitor.AddFilter("TPV", func (r interface{}) { report := r.(*gpsdc.TPVReport) fmt.Printf("TPV: Lat=%f, Lon=%f, Alt=%f\n", report.Lat, report.Lon, report.Alt) }) // Or a stand-alone Filter function skyfilter := func(r interface{}) { sky := r.(*gpsdc.SKYReport) fmt.Printf("SKY: %d satellites\n", len(sky.Satellites)) } gps_monitor.AddFilter("SKY", skyfilter) // Tell gpsdc to start watching (using the default watch command here) gps_monitor.SendCommand(gpsdc.DefaultWatchCommand) // Listen forever for reports (delivered to the Filters above) done := gps_monitor.Listen() <- done } This code is Based on the incomplete and apparently abandoned 2013 project: "https://github.com/stratoberry/go-gpsd" The majority of this code was copied directly from that project.
gpsdc -- a Go client for the gpsd daemon Usage example: package main import ( "fmt" "gpsdc" ) func main() { var gps_monitor *gpsdc.Session var err error // Open socket to gpsd at specified address (using default here) if gps_monitor, err = gpsdc.Dial(gpsdc.DefaultAddress); err != nil { panic(fmt.Sprintf("Failed to connect to GPSD: ", err)) } // Add an inline Filter function gps_monitor.AddFilter("TPV", func (r interface{}) { report := r.(*gpsdc.TPVReport) fmt.Printf("TPV: Lat=%f, Lon=%f, Alt=%f\n", report.Lat, report.Lon, report.Alt) }) // Or a stand-alone Filter function skyfilter := func(r interface{}) { sky := r.(*gpsdc.SKYReport) fmt.Printf("SKY: %d satellites\n", len(sky.Satellites)) } gps_monitor.AddFilter("SKY", skyfilter) // Tell gpsdc to start watching (using the default watch command here) gps_monitor.SendCommand(gpsdc.DefaultWatchCommand) // Listen forever for reports (delivered to the Filters above) done := gps_monitor.Listen() <- done } This code is Based on the incomplete and apparently abandoned 2013 project: "https://github.com/stratoberry/go-gpsd" The majority of this code was copied directly from that project.
services/gps/src/hgps
hgps -- a resource class for caching Horizon GPS data Cache your Horizon GPS data in a "smart" GpsCache instance.
hgps -- a resource class for caching Horizon GPS data Cache your Horizon GPS data in a "smart" GpsCache instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL