Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidimensional units #96

Open
krwq opened this issue Nov 24, 2020 · 5 comments
Open

Multidimensional units #96

krwq opened this issue Nov 24, 2020 · 5 comments

Comments

@krwq
Copy link

krwq commented Nov 24, 2020

Could you enable being able to create multidimensional units? Our (https://github.com/dotnet/iot) LSM9DS1 sensor (embedded on SenseHat) and many other sensors return 3-dimensional units but currently using array or object with units is not possible.

I.e.: (object)

{
    "@id": "dtmi:dotnet:iot:lsm9ds1:magnetometer;1",
    "@type": "Interface",
    "displayName": "LSM9DS1 - Magnetometer",
    "contents": [
        {
          "@type": [ "Telemetry" ],
          "name": "MagneticInduction",
          "displayName": "Magnetic induction",
          "description": "Magnetic induction vector in Tesla",
          "schema": {
              "@type": "Object",
              "fields": [
                  {
                      "name": "x",
                      "schema": {
                          "@type": "MagneticInduction",
                          "schema": "double",
                          "unit": "tesla"
                      }
                  },
                  {
                      "name": "y",
                      "schema": {
                          "@type": "MagneticInduction",
                          "schema": "double",
                          "unit": "tesla"
                      }
                  },
                  {
                      "name": "z",
                      "schema": {
                          "@type": "MagneticInduction",
                          "schema": "double",
                          "unit": "tesla"
                      }
                  }
              ]
          }
        }
    ],
    "@context": "dtmi:dtdl:context;2"
}

causes:

Unhandled exception. Parsing exception -- 3 errors in model -- see Errors property for details on each -- first error includes message: dtmi:dotnet:iot:lsm9ds1:magnetometer;1 has 'contents' value with name 'MagneticInduction' which has 'schema' value which has 'fields' value with name 'x' whose property 'schema' has value that does not have @type of Array, Enum, Map, or Object, nor is it a standard value for this property. Provide a value for property 'schema' with @type in the set of allowable types, or choose one of the following values for property 'schema': boolean, date, dateTime, double, duration, float, integer, long, string, time.

Array:

{
    "@id": "dtmi:dotnet:iot:lsm9ds1:magnetometer;1",
    "@type": "Interface",
    "displayName": "LSM9DS1 - Magnetometer",
    "contents": [
        {
          "@type": [ "Telemetry" ],
          "name": "MagneticInduction",
          "displayName": "Magnetic induction",
          "description": "Magnetic induction vector in Tesla",
          "schema": {
              "@type": "Array",
              "elementSchema": {
                      "@type": "MagneticInduction",
                      "unit": "tesla",
                      "schema": "double"
              },
          }
        }
    ],
    "@context": "dtmi:dtdl:context;2"
}

causes

Unhandled exception. Parsing exception -- 1 errors in model -- see Errors property for details on each -- first error includes message: dtmi:dotnet:iot:lsm9ds1:magnetometer;1 has 'contents' value with name 'MagneticInduction' which has 'schema' value whose property 'elementSchema' has value that does not have @type of Array, Enum, Map, or Object, nor is it a standard value for this property. Provide a value for property 'elementSchema' with @type in the set of allowable types, or choose one of the following values for property 'elementSchema': boolean, date, dateTime, double, duration, float, integer, long, string, time.
@krwq
Copy link
Author

krwq commented Nov 24, 2020

This might be a dup of #81

@briancr-ms
Copy link
Contributor

Yes, based on the way we've been thinking about this, this would be a dup of #81. Without going into all the details, we've been thinking about enabling semantic types at the field level in an Object. Something like this example:

{
  "@type": "Object",
  "fields": [
    {
      "@type": [ "Field", "Temperature" ],
      "name": "temp",
      "schema": "double",
      "unit": "degreeCelsius"
    },
    {
      "@type": [ "Field", "RelativeHumidity" ],
      "name": "humidity",
      "schema": "integer",
      "unit": "percent"
    }
  ]
}

Would an approach like this cover your use cases?

@krwq
Copy link
Author

krwq commented Dec 1, 2020

Yes I think so, cc: @colombod

@krwq
Copy link
Author

krwq commented Dec 1, 2020

as a side note: since all fields are under "fields" should "Field" type be implied?

@briancr-ms
Copy link
Contributor

Yes, we may be able to infer the "Field" type. That's one of the details that needs to be nailed down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants