func NewDefaultObservation() *gossamer.ObservationEntity {
	e := gossamer.NewObservationEntity()
	e.PhenomenonTime = gossamer.NewTimePeriod(time.Now(), time.Now())
	e.ResultTime = gossamer.NewTimeInstant(time.Now())
	e.Result = 123

	return e
	//		"Datastream":{"@iot.id":100}
}
Example #2
0
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")
}
Example #3
0
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)
	}
}