GithubHelp home page GithubHelp logo

sensor_server's Introduction

Simple API for sensor project

Description

To start the server use: node server.js

  1. / - main page
  2. /data/:sensorID - top 20 data entries for sensor ID :sensorID
  3. /api - path for API
    1. GET /api/box - returns all boxes
    2. GET /api/sensors - returns all sensors
    3. GET /api/box/:id/sensors - return all sensors or box with ID :id
    4. GET /api/sensors/:id - returns info about sensor ID :id
    5. GET /api/sensors/:id/dataentries - returns top 20 data entries of sensor ID :id
    6. POST /api/box - create a new sensor box
    7. POST /api/box/:id/sensors - creates a new sensor for box ID :id
    8. POST /api/sensors/:id/dataentries - creates a new data entry for sensor ID :id

Data Model

Sensor box (/models/box.js) is the main entity in the system Each sensor box consists of 0 or more sensors.

var BoxSchema = new Schema({
    address: String, // address where we deploy the sensor box
    deployment_date: { type: Date }, // when we deployed it
    sensors: [ { type: Schema.Types.ObjectId, ref: 'Sensor' } ]  // a set of Sensors inside the sensor box (0 or more)
});

Sensor (/models/sensor.js) - could any sensor we want.

var SensorSchema = new Schema({
    _box: { type: Schema.Types.ObjectId, ref: 'Box'}, // foreign key to the Sensor Box
    name: String, // name of the sensor
    description: String, // description
    n_outputs: Number, // number of outputs
    dataEntries: [ { type: Schema.Types.ObjectId, ref: 'DataEntry' } ] // a set of Data Entries
});

Data Entry (/models/sensor.js) - here we store sensor's data. For now we keep the data model simple and assume that a sensor can output at most 5 values.

var DataEntrySchema = new Schema({
    _sensor : {type: Schema.Types.ObjectId, ref: "Sensor"}, // foreign key to the Sensor
    date: { type: Date }, // timestamp of the data entry
    o1: Number, // output value 1
    o2: Number, // output value 2
    o3: Number, // output value 3
    o4: Number, // output value 4
    o5: Number  // output value 5
});

Dependencies

  1. Mongo DB
  2. Node JS with npm (express, mongoose, body-parser)
  3. bower (bootstrap, jquery)

sensor_server's People

Contributors

omega-eol avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.