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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d253eb7042ff641 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!a21g2000yqc.googlegroups.com!not-for-mail From: Phil Thornley Newsgroups: comp.lang.ada Subject: Re: a slight problem need some help. Simulation Control System Date: Fri, 13 Nov 2009 08:54:27 -0800 (PST) Organization: http://groups.google.com Message-ID: <0e354dda-8ba6-498e-a7d9-a577edcc22e3@a21g2000yqc.googlegroups.com> References: <1ca4f848-7e5e-4524-8df3-43ea76caafbc@s15g2000yqs.googlegroups.com> NNTP-Posting-Host: 80.177.171.182 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1258131268 14659 127.0.0.1 (13 Nov 2009 16:54:28 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 13 Nov 2009 16:54:28 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a21g2000yqc.googlegroups.com; posting-host=80.177.171.182; posting-account=Fz1-yAoAAACc1SDCr-Py2qBj8xQ-qC2q User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8086 Date: 2009-11-13T08:54:27-08:00 List-Id: On 13 Nov, 16:09, "Mr.Spark" wrote: > I had a problem when I run examiner to check if the body package is > working fine but the problem it gives me: > > Specification Part: > > with Sensor, Pump; > > --# inherit Sensor, Pump; > > package Tank > > --# own Tank_Level; > --# initializes Tank_Level; > > is > =A0 =A0procedure Control; > > =A0 =A0--# global out Tank_Level; > =A0 =A0--# =A0 =A0 =A0 =A0in Sensor.Level; > =A0 =A0--# =A0 =A0 =A0 =A0in out Pump.Pump_Open; > =A0 =A0--# derives Tank_Level from Sensor.Level & > =A0 =A0--# =A0 =A0 =A0 =A0 Pump.Pump_Open from Sensor.Level, Pump.Pump_Op= en; > > end Tank; > > Body Package Is : > > with Sensor, Pump; > > package body Tank > > is > > =A0 =A0Empty: constant Sensor.Level_Type :=3D 10; > =A0 =A0Full: constant Sensor.Level_Type :=3D 60; > > =A0 =A0-- this procedure controls the operation of pumps when they should > be opened > =A0 =A0-- or closed for the safety of the system. The pump will be closed > if the > =A0 =A0-- Water Level Tank is <=3D 10 and it will be Opened if the Water > Level > =A0 =A0-- in Tank >=3D 60. > > =A0 =A0procedure Control > =A0 =A0is > =A0 =A0 =A0 Tank_Level: Sensor.Level_Type; > =A0 =A0begin > > =A0 =A0 =A0 Tank_Level:=3D Sensor.Get_Level; > =A0 =A0 =A0 if Tank_Level <=3D Empty then > =A0 =A0 =A0 =A0 =A0Pump.Close; > =A0 =A0 =A0 elsif Tank_Level >=3D Full then > =A0 =A0 =A0 =A0 =A0Pump.Open; > =A0 =A0 =A0 end if; > =A0 =A0end Control; > > end Tank; > > The errors that it shows are : > > 1.Semantic Error : Ilegal redeclaration of identifier Tank_Level; > 2.Semantic Error : The Identifier is either undeclared or not visible > at his point > 3.Semantic Error : The Identifier is either undeclared or not visible > at his point1. > 4.Semantic Error : The Identifier is either undeclared or not visible > at his point > 5.Semantic Error : The own variable Tank_Level does not have a > definition > > If you could give me a hint how to solve this problem it would be > great. The main problem is that the 'own' annotation on the spec states that the variable Tank_Level will be declared in the package body - as permanent data. But the code only creates it as local data within the Control procedure. So Tank_Level is created as uninitialised data each time that the Control procedure is invoked. If you move the declaration of Tank_Level to the package body then you will remove some of the errors. Alterntively if the data should be local to the Control procedure then it should not be declared as 'own' data in the package specification. For more accurate error diagnosis, include at least the specs of all the other referenced packages (ie Sensor and Pump in this case) so that we can do a complete SPARK run. Cheers, Phil