func QueryObservations(c gossamer.Client) { o, err := c.QueryObservations().All() if err != nil { log.Fatal(err) } log.Println("Query all Observations returned records # ", len(o)) }
func InsertDatastream(c gossamer.Client) { e := gossamer.NewDatastreamEntity() e.PhenomenonTime = gossamer.NewTimePeriod(time.Now(), time.Now()) e.ResultTime = gossamer.NewTimePeriod(time.Now(), time.Now()) e.Description = "XXX" e.ObservationType = gossamer.DATASTREAM_OBSTYPE_OBSERVATION e.UnitOfMeasurement = "XXX" thing := gossamer.NewThingEntity() thing.Id = "ABC123" e.Thing = thing sensor := gossamer.NewSensorEntity() sensor.Id = "DEF312" e.Sensor = sensor obsProp := gossamer.NewObservedPropertyEntity() obsProp.Id = "GHI987" e.ObservedProperty = obsProp err := c.InsertDatastream(e) if err != nil { log.Fatal(err) } log.Println("Inserted New Datastream") }
func InsertThing(c gossamer.Client) { e := gossamer.NewThingEntity() e.Description = "XXXXX" err := c.InsertThing(e) if err != nil { log.Fatal(err) } log.Println("Inserted New Thing") }
func InsertSensor(c gossamer.Client) { e := gossamer.NewSensorEntity() e.Description = "XXXXXX" e.EncodingType = gossamer.SENSOR_ENCTYPE_SENSORML e.Metadata = "XXXXX" err := c.InsertSensor(e) if err != nil { log.Fatal(err) } log.Println("Inserted New Sensor") }
func InsertObservedProperty(c gossamer.Client) { e := gossamer.NewObservedPropertyEntity() e.Name = "XXXX" e.Description = "XXXXXX" e.Definition = "XXXXX" err := c.InsertObservedProperty(e) if err != nil { log.Fatal(err) } log.Println("Inserted New ObservedProperty") }
func InsertFeaturesOfInterest(c gossamer.Client) { e := gossamer.NewFeatureOfInterestEntity() e.Description = "XXXX" e.EncodingType = gossamer.LOCATION_ENCTYPE_GEOJSON e.Feature = "Feature ABC 1 2 3" err := c.InsertFeaturesOfInterest(e) if err != nil { log.Fatal(err) } log.Println("Inserted New Feature of Interest") }
func InsertLocation(c gossamer.Client) { e := gossamer.NewLocationEntity() e.Description = "XXXXX" e.EncodingType = gossamer.LOCATION_ENCTYPE_GEOJSON e.Location = "XOXOXO" err := c.InsertLocation(e) if err != nil { log.Fatal(err) } log.Println("Inserted New Location") }
func FindSensors(c gossamer.Client) { ol, e := c.FindSensors() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetSensor(v.GetId()) if err != nil { log.Fatal(err) } else { log.Println("Got Sensor Entity ", o.GetId()) } } }
func InsertObservation(c gossamer.Client) { obs := &gossamer.ObservationEntity{} obs.PhenomenonTime = gossamer.NewTimePeriod(time.Now(), time.Now()) obs.Result = "123" obs.ResultTime = gossamer.NewTimeInstant(time.Now()) ds := &gossamer.DatastreamEntity{} ds.Id = "Datastream-1" obs.Datastream = ds err := c.InsertObservation(obs) if err != nil { log.Fatal(err) } log.Println("Inserted New Observation") }
func FindDatastreams(c gossamer.Client) { ol, e := c.FindDatastreams() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetDatastream(v.GetId()) if err != nil { log.Fatal(err) } else { log.Println("Got Datastream Entity ", o.GetId()) } } }
func FindObservedProperties(c gossamer.Client) { ol, e := c.FindObservedProperties() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetObservedProperty(v.GetId()) if err != nil { log.Fatal(err) } else { log.Println("Got Observed Property Entity ", o.GetId()) } } }
func FindLocations(c gossamer.Client) { ol, e := c.FindLocations() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetLocation(v.GetId()) if err != nil { log.Fatal(err) } else { log.Println("Got Location Entity ", o.GetId()) } } }
func FindFeaturesOfInterest(c gossamer.Client) { ol, e := c.FindFeaturesOfInterest() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetFeaturesOfInterest(v.GetId()) if err != nil { log.Fatal(err) } else { log.Println("Got FeaturesofInterest Entity ", o.GetId()) } } }
func PatchObservations(c gossamer.Client) { l, err := c.QueryObservations().Top(1).All() if err != nil { log.Fatal(err) } var o gossamer.Observation if len(l) > 0 { o = l[0].(gossamer.Observation) n := gossamer.CloneObservationEntity(o) n.ResultQuality = "Value was changed" n.ResultTime = gossamer.NewTimeInstant(time.Now()) c.PatchObservation(n) } }
func UpdateSensors(c gossamer.Client) { l, err := c.QuerySensors().Top(1).All() if err != nil { log.Fatal(err) } var o gossamer.Sensor if len(l) > 0 { o = l[0].(gossamer.Sensor) n := gossamer.CloneSensorEntity(o) n.Description = "Updated description" err = c.UpdateSensor(n) if err != nil { log.Fatal(err) } } }
func DeleteSensors(c gossamer.Client) { ol, e := c.FindSensors() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetSensor(v.GetId()) if err != nil { log.Fatal(err) } else { // Delete Observation e := c.DeleteSensor(o.GetId()) if e != nil { log.Fatal(err) } else { log.Println("Deleted Sensor ", o.GetId()) } } } }
func DeleteObservedProperties(c gossamer.Client) { ol, e := c.FindObservedProperties() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetObservedProperty(v.GetId()) if err != nil { log.Fatal(err) } else { // Delete Observation e := c.DeleteObservedProperty(o.GetId()) if e != nil { log.Fatal(err) } else { log.Println("Deleted ObservedProperty ", o.GetId()) } } } }
func DeleteFeaturesOfInterest(c gossamer.Client) { ol, e := c.FindFeaturesOfInterest() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetFeaturesOfInterest(v.GetId()) if err != nil { log.Fatal(err) } else { // Delete Observation e := c.DeleteFeaturesOfInterest(o.GetId()) if e != nil { log.Fatal(err) } else { log.Println("Deleted FeatureOfInterest ", o.GetId()) } } } }
func DeleteDatastreams(c gossamer.Client) { ol, e := c.FindDatastreams() if e != nil { log.Fatal(e) } for _, v := range ol { o, err := c.GetDatastream(v.GetId()) if err != nil { log.Fatal(err) } else { // Delete Observation e := c.DeleteDatastream(o.GetId()) if e != nil { log.Fatal(err) } else { log.Println("Deleted Datastream ", o.GetId()) } } } }