comp.lang.ada
 help / color / mirror / Atom feed
From: Markus E Leypold <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
Subject: Re: AW: Translating an embedded C algorithm
Date: Thu, 18 Jan 2007 10:53:09 +0100
Date: 2007-01-18T10:53:09+01:00	[thread overview]
Message-ID: <rxlkk0y83e.fsf@hod.lan.m-e-leypold.de> (raw)
In-Reply-To: 87k5zk7m8j.fsf@ludovic-brenta.org


Ludovic Brenta <ludovic@ludovic-brenta.org> writes:

> Markus E Leypold writes:
>> Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>>> Right, and there would be no need for a silly INVALID_TEMPERATURE.
>>> What *is* an invalid temperature anyway?  One that needs crutches?
>>> One that is excused from military service? And why would you ever
>>> return an invalid temperature to your caller? etc. etc.
>>
>> | >> --| Temperature in �C x 10. INVALID_TEMPERATURE if out of range.
>>
>> If the sensor is out of order or the temperature leaves the range
>> where it functions properly?
>>
>> :-). 
>
> My point it this: if the sensor is out of order, then there is no
> known temperature; not a known "invalid" temperature.  The proper way

Yep, certainly. Actually 'temperature' is the wrong description for
this type. It's actually "the result of reading the temperature
sensor" which is a union type between a finite temperature range and
the "invalid result".

> to handle that in Ada is with an exception, 

That depends on how "exceptional" that event is. If it is a hardware
failure an exception would perhaps be better, but if it just means
"temperature went out of range" (or better "too high") dependend on
what kind of apparatus we have here, it might be better to handle that
as a special case (like: a very high temperature we don't don't knoe
exactly). A (very primitive and perhaps incomplete) example: A
temperature sensor for some kind of nuclear or chemical process. If
the the temperature becomes > t2 we'd want the emergency cooling to be
activated. We'd also want this if the it becomes > t3, the temperature
where the sensor stops to work properly (which is higher than t2, but
where we still know that the temperature is too high). In that case an
exception or even an emergency shutdown of the controlling unit would
be wrong.

> not a special value of type Degrees_C.

Agreed. Degrees_C is misleading. What about Sensor_Result?

Regards -- Markus




  reply	other threads:[~2007-01-18  9:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E473CA319B6D514981A06AE6742A1FD82B067D@GLDMS10607.goldlnk.rootlnka.net>
2007-01-17  7:07 ` AW: Translating an embedded C algorithm Grein, Christoph (Fa. ESG)
2007-01-17 10:26   ` Ludovic Brenta
2007-01-17 16:44     ` Markus E Leypold
2007-01-18  8:49       ` Ludovic Brenta
2007-01-18  9:53         ` Markus E Leypold [this message]
2007-01-19  9:33         ` Stephen Leake
2007-01-19 19:23           ` Cesar Rabak
2007-01-19 20:27             ` Robert A Duff
2007-01-19 23:15               ` Cesar Rabak
2007-01-20  9:54               ` Dmitry A. Kazakov
2007-01-20 21:03               ` AW: " Jeffrey Carter
2007-01-20 21:38                 ` Robert A Duff
2007-01-22  2:30                   ` Jeffrey Carter
2007-01-23  7:43                     ` Stephen Leake
2007-01-23 19:34                       ` Jeffrey R. Carter
     [not found]     ` <1%trh.15628$X72.889@newsread3.news.pas.earthlink.net>
2007-01-17 18:44       ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox