| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| // Syncbase data model for Sensor Log. |
| // |
| // Every type <T> stored in Syncbase is defined as a pair of types, K<T> and |
| // V<T>, representing data stored in the key and value, respectively, in a |
| // single collection. K<T> types satisfy the PersistentDataKey interface, |
| // supporting conversion to and from the row key. |
| package sbmodel |
| |
| import ( |
| "time" |
| ) |
| |
| // devicecfg : <DevId> |
| // Measuring device handle. Master only. |
| type VDeviceCfg struct { |
| // Human-readable, not necessarily unique description of the device. |
| Desc string |
| // Syncbase instance publishing the syncgroup created by the device. |
| SgPublishSb string |
| } |
| |
| type KDeviceCfg struct { |
| DevId string |
| } |
| |
| // streamdef : <DevId>/<StreamId> |
| // Configures a stream of data to be measured. |
| type VStreamDef struct { |
| // Human-readable, not necessarily unique description of the stream. |
| Desc string |
| // Sampling configuration. |
| Sampler SamplerDef |
| // Flag to start and stop sampling. |
| Enabled bool |
| } |
| |
| type KStreamDef struct { |
| DevId string |
| StreamId string |
| } |
| |
| // Sampling script and polling frequency. |
| type SamplerDef struct { |
| // Shell script executed after every Interval, starting from Start. |
| // It should output a single data point, if available. A non-zero exit |
| // status or failure to parse the value will produce an error instead. |
| Script string |
| Start time.Time |
| Interval time.Duration |
| // TODO(ivanpi): Add timeout. |
| } |
| |
| // sdata : <DevId>/<StreamId>/<Timestamp> |
| // Measured data value or error. |
| type KDataPoint struct { |
| DevId string |
| StreamId string |
| Timestamp time.Time |
| } |
| |
| type VDataPoint union { |
| Value float64 |
| Error string |
| } |