AlejandroVK
AlejandroVK

Reputation: 7605

how to make an entity in ORION?

I have some doubts about how to define an Entity in ORION.

This entity will be used to contain GPS, acceleromerer, compass and gyroscope sensor data from smartphones for a specific user. The whole concept is defined as a user session. I will also want to publish when the session "starts" and when it "ends".

Given the high volume expected specially for accelerometers, compass and gyroscope sensors I don't expect to be sending this sensor info every time it happens, but say, probably once the session has finished and all data has been collected in the smartphone. Thus, I see the attributes more as list of values than discrete ones. Thus, putting something like this:

{
"contextElements": [
 {
  "type": "UserSession",
  "isPattern": "false",
  "id": "",
  "attributes": [
      {
      "name": "user_id",
      "type": "string",
      "value": "none"
      },
      {
      "name": "app_id",
      "type": "string",
      "value": "none"
      },
      {
      "name": "status",
      "type": "string",
      "value": "none"
      },
      {
      "name": "x_accelerometer",
      "type": "float",
      "value": "0.0"
      },

      {
      "name": "y_accelerometer",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "z_accelerometer",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gps_latitude",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gps_longitude",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gps_altitude",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gps_accuracy",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gps_heading",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gps_speed",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "compass",
      "type": "float",
      "value": "0.0"
      },
      {
      "name": "gyroscope",
      "type": "float",
      "value": "0.0"
      }
  ]
  }
  ],
  "updateAction": "APPEND"
}

Not sure if this is the correct way to do it. I don't want to kill the battery of the smartphone sending data every second or even less, so I might be doing that every minute, or so, thus I need a list of values for each the attributes that represent sensor data. Am I right or am I approaching this the wrong way?

In the end, I want to subscribe to these attributes, in another app, and do some reasoning based on the values to create alarms, so I will also probably need an Alarm Entity too.

Thanks!

Upvotes: 2

Views: 145

Answers (1)

fgalan
fgalan

Reputation: 12322

The Orion API is quite flexible and allow you multiple posibilities:

  • To create/update all the attributes on a given entity in a single request
  • To create/update a subset of the attributres of a given entity in a single request. For example, if you entity have 100 atributes, but you only want to update 2 of them (leaving the other 98 untouched) you can do that.
  • To create/update atributtes (either all of them or a subset) in several entities in the same request. For example, you can update attributes A and B belonging to entity E1 and attributes C and D belonging to entity E2 in the same request.

If you want to save battery in your client, then maybe the last option is the most suitable. For example, you can hold a buffer in the client with the accumulation of entities changes and flush the buffer each minute sending one updateContext request with the all the accumulated changes.

Upvotes: 1

Related Questions