From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f822ae7b0f7433c1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!wns13feed!worldnet.att.net!63.218.45.10!nx01.iad01.newshosting.com!newshosting.com!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder2.news.saunalahti.fi!feeder1.news.saunalahti.fi!nntp.inet.fi!inet.fi!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Thu, 18 Jan 2007 22:02:10 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Translating an embedded C algorithm References: <1168871816.263502.212100@11g2000cwr.googlegroups.com> <45acc0c3$0$22514$39db0f71@news.song.fi> <45af9c60$0$22524$39db0f71@news.song.fi> <87y7o01e4y.fsf@ludovic-brenta.org> In-Reply-To: <87y7o01e4y.fsf@ludovic-brenta.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <45afd103$0$22509$39db0f71@news.song.fi> Organization: TDC Song Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1169150211 news.song.fi 22509 81.17.205.61:32891 X-Complaints-To: abuse@song.fi Xref: g2news2.google.com comp.lang.ada:8278 Date: 2007-01-18T22:02:10+02:00 List-Id: Ludovic Brenta wrote: > Niklas Holsti writes: > [...] > > Hi Niklas, > > I think your program is excellent. You are the first who used a fixed > point real type and never to return an "invalid" temperature; both > were the Right Thing to Do, IMHO. Thanks. > Would you like to work in avionics? :) I used to work on space SW (www.ssf.fi). I quit partly (but not mainly) because the customers started to specify C as the implementation language "for reasons of business strategy" or some such phrase. >>The function to convert ADC counts to temperatures then seems suitable >>for a child of package ADC. > > > It does not need to be a child of ADC; it could be another top-level > package. True. Firstly, I wanted to demonstrate child packages; secondly, the conversion is very dependent on the type ADC.Count_T (its nature and range), so a child package feels natural to me. > Better yet, reverse the relationship to hide the ADC in a > private child package: > > package Thermometer is > function Temperature return Temperatures.Reading_T; > function Temperature return Temperatures.Celsius_T; > Out_Of_Range : exception; > end Thermometer; I agree "in the large" that those SW parts that need to know the temperature should be able to get it from a top-level package like that, without knowing that the temperature (in this version of the application) is acquired through the ADC. My code focuses on the issues of "programming in the small". > private package Thermometer.Some_Particular_Kind_Of_Sensor is > type Count_T is range 0 .. 1024; > ... > end Thermometer.Some_Particular_Kind_Of_Sensor; I assumed that the ADC would be used to read various voltages, not just thermometer voltages. All these ADC channels share the same type Count_T (defined by the nature of the ADC itself), so its definition should not depend on the Sensor that is being read, which is why I defined Count_T in the package ADC. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .