File : laser.ads
----------------------------------------------------------------------------
--
-- -*- Mode: Ada -*-
--
-- Filename : Laser.ads
-- Description : All you need to operate the laser range finder
-- Author : Uwe R. Zimmer
-- Created On : Wed Oct 15 16:04:34 1997
-- Last Modified By: Uwe R. Zimmer
-- Last Modified On: October 17 1997
-- Update Count : Version 0.91
-- Status : Beta
--
----------------------------------------------------------------------------
with Metrics; use Metrics;
with Ada.Real_Time; use Ada.Real_Time;
package Laser is
----------------------------------------------------------------------------
--
-- Definitions for the Laserdata
--
----------------------------------------------------------------------------
FirstLaserReading : constant Positive := 1;
LastLaserReading : constant Positive := 360;
FirstLaserAngle : constant Degrees := -90.0;
LastLaserAngle : constant Degrees := +90.0;
MinLaserDistance : constant mm := 0;
MaxLaserDistance : constant mm := 50000;
type LaserReadingRange is range FirstLaserReading .. LastLaserReading;
type LaserReading is record
Distance : mm;
Dazzled : Boolean;
end record;
type LaserReadings is array (LaserReadingRange) of LaserReading;
type LaserAngles is array (LaserReadingRange) of Degrees;
type LaserStatus is record
Readings : LaserReadings;
TimeStamp : Time;
end record;
type LaserStatusArray is array (Positive range <>) of LaserStatus;
ActualLaserAngles : LaserAngles;
----------------------------------------------------------------------------
--
-- Protected Monitor LaserInterface;
--
-- The protected monitor 'LaserInterface' offers current laser readings and
-- can be used simulataniously by multiple tasks.
--
-- Init and Shutdown is required.
--
-- 'GetCurrentLaserStatus' and 'GetCurrentLaserTimeStamp' (the TimeStamp is
-- included in the LaserStatus delivered by 'GetCurrentLaserStatus' also),
-- gives the most recent readings from the laserrangefinder device. Due to a
-- baud rate of 38400 and 180 readings per sample, a sampling rate of
--approx.
-- 5 Hz can be expected. In case the communication fails (for some reason)
--it
-- is resumed after 1 second. Thus the user should refer to the actual
-- TimeStamp for data correlation purposes or similar.
--
-- 'WaitForNewSensorData' blocks the calling task (until the next complete
-- sample is processed), but leaves the access to the laser open for all
-- other tasks.
--
-- In order to save CPU time it is possible to suspend the background tasks,
-- handling the communication with the laser device.
--
----------------------------------------------------------------------------
protected LaserInterface is
procedure InitLaser; -- Inits and Shutdowns can be recursively
entry ShutdownLaser; -- iterated (also from different tasks)
entry GetCurrentLaserStatus (Readings : out LaserStatus);
entry GetCurrentLaserTimeStamp (TimeStamp : out Time);
entry WaitforNewLaserData;
entry SuspendSensing; -- due to the laserhandling is time consuming,
entry ResumeSensing; -- the driver task can be suspended
end LaserInterface;
end Laser;