Re: [Asdf] PR#22: Actually define scaleMinimum and scaleMaximum

Carsten Bormann <cabo@tzi.org> Mon, 08 March 2021 07:36 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: asdf@ietfa.amsl.com
Delivered-To: asdf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 633573A2700 for <asdf@ietfa.amsl.com>; Sun, 7 Mar 2021 23:36:59 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.89
X-Spam-Level:
X-Spam-Status: No, score=0.89 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FSL_BULK_SIG=0.001, RAZOR2_CF_RANGE_51_100=1.886, RAZOR2_CHECK=0.922, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XEUkTBQ8n5Op for <asdf@ietfa.amsl.com>; Sun, 7 Mar 2021 23:36:56 -0800 (PST)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AADC03A26EB for <asdf@ietf.org>; Sun, 7 Mar 2021 23:36:55 -0800 (PST)
Received: from [192.168.217.152] (p5089a828.dip0.t-ipconnect.de [80.137.168.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4Dv9C92MfLzyWP; Mon, 8 Mar 2021 08:36:53 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <9E91F3C2-9316-4B5E-8473-9E08CCE9F4C8@gmail.com>
Date: Mon, 08 Mar 2021 08:36:50 +0100
Cc: asdf@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <949962A2-824C-4DA4-B5C0-0EC2088C1A87@tzi.org>
References: <E1E12630-C759-4B6A-A532-1B86B10EED00@tzi.org> <72A6EBD7-AE5B-4F5C-B309-77705C40F98A@tzi.org> <7EDA3D19-12B6-4C11-9EF6-45C7912F1493@gmail.com> <113FB539-F4F6-4E7E-BE9A-F6D0B09F7341@gmail.com> <D8B88EA7-DD13-4454-B3C0-AB77C47F2F1F@tzi.org> <9E91F3C2-9316-4B5E-8473-9E08CCE9F4C8@gmail.com>
To: Michael Koster <michaeljohnkoster@gmail.com>
X-Mailer: Apple Mail (2.3654.60.0.2.21)
Archived-At: <https://mailarchive.ietf.org/arch/msg/asdf/w-xNIhfLD7YpYO5iLOlgwxJ_toU>
Subject: Re: [Asdf] PR#22: Actually define scaleMinimum and scaleMaximum
X-BeenThere: asdf@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "A Semantic Description Format \(SDF\) for Things and their Interactions and Data" <asdf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/asdf>, <mailto:asdf-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/asdf/>
List-Post: <mailto:asdf@ietf.org>
List-Help: <mailto:asdf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/asdf>, <mailto:asdf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 08 Mar 2021 07:36:59 -0000

So why do we need two SDF property definitions to represent this single property?

We probably want to have all three qualities:

dataMinimum..dataMaximum (here 0..1023), as an integer (“multipleOf = 1”)
measurementMinimum..measurementMaximum (here 0..2000), as an abstract value only (compute the multipleOf from these four corners)
quantityMinimum..quantityMaximum (here 0..2e-3), again as an abstract value only

There may be no need to actually express measurementMinimum..measurementMaximum unless the whole thing is composed from a data model and a mapping/binding.

How would that composition split?

If the data model knows this is about a specific quantity (say temperature), it would give the unit for that quantity.
The actual quantityMinimum..quantityMaximum may be a specific property of the sensor, or it may be hardcoded in the model.

If the SDF model only has the measurement level (measurementMinimum..measurementMaximum), then it becomes (contextual) binding information how to obtain the unit, quantityMinimum..quantityMaximum.

(The below example says 0..1024, which is also interesting, because in practice you wouldn’t get 1024, only 1023, out of a 10-bit ADC.  
In the linear transform, 1024 might still map to 0.002, so that quantity value would actually be off-scale!)

Grüße, Carsten



> On 8. Mar 2021, at 00:15, Michael Koster <michaeljohnkoster@gmail.com> wrote:
> 
> 
> I think we're in agreement. My 4-20 mA example is the ADC rationalization that happens in the PID controller, and the Modbus decimal value scaling is what happens in the client. The model works for both cases, and I do have some SDF models for building C++ code that scale raw a/d counts to values using the same vocabulary. There is a case where one SDF file describes the a/d scaling to a modbus (decimal) integer, then another to scale the modbus value to the correct decimal scale.
> 
> "ihv_counts" : {
>  "type": "number",
>  "minimum": 0,
>  "maximum": 1024,
>  "multipleOf" :1,
>  "scaleMinimum": 0,
>  "scaleMaximum": 2000
> }
> 
>        "IHVData": {
>          "type": "number",
>          "units": "A",
>          "minimum": 0,
>          "maximum": 2000,
>          "multipleOf": 1,
>          "scaleMinimum": 0,
>          "scaleMaximum": 0.002
>        },
> 
> 
> 
> 
>> On Mar 7, 2021, at 2:42 PM, Carsten Bormann <cabo@tzi.org> wrote:
>> 
>> On 2021-03-07, at 23:14, Michael Koster <michaeljohnkoster@gmail.com> wrote:
>>> 
>>> Another point to be made here, is that all of these constraints are usually applied in the binding, when the SDF model is mapped to an implementation. In the base model we might only indicate number and that it is a Voltage unit, the assignment of raw values *and* scaled values are done in the binding.
>> 
>> One of the reasons for doing a data model is that we want to be able to interpret data when it has become detached from the physical device.  In which case you are better off when the value given is already referenced to a unit.  This was the idea behind SenML.
>> 
>> Now if I have a 4–20 mA ADC, that may be all the data I get, so I need some context information to know the range that this actually stands for.
>> This is one of the points of adding a mapping (binding): Being able to provide this context.
>> 
>> So we have:
>> 
>> — data item transferred: 0..65535
>> - measured value: 4..20 mA
>> — indicated sensor reading: 700..1100 K
>> 
>> (This ignores off-scale detection etc.)
>> 
>> I do like being able to put down the ranges to be mapped and essentially use the formula in https://raw.githack.com/ietf-wg-asdf/SDF/scaleminmax/sdf.html#section-4.7-10 for computing the linear transform.
>> 
>> The data model (really: information model) of a temperature sensor should talk about 700..1100 K.  The data model of an instrumentation ADC should talk about 4..20 mA and rely on additional information given by the usage context mapping (binding) to derive the 700..1100 K.  The mapping (binding) information to a bluetooth characteristic may tell you this range is represented by 0..65535.
>> 
>> Grüße, Carsten
>> 
>