-- cd to the installation examples directory, update the example program, -- then compile with: -- gnatmake -I../include dtraq_logging_example.adb -largs -L../lib -ldtraq with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; -- with Dtraq.Client_Transport; -- use Dtraq.Client_Transport; -- with Dtraq.Tap; procedure Dtraq_Logging_Example is type Counter_256_Type is mod 2 ** 8; -- procedure Tap is new Dtraq.Tap(Counter_256_Type, 256, "Counter_256_Type"); Counter : Counter_256_Type := 0; subtype Cs_Indexes is Positive range 1 .. 10; subtype Capped_String_Type is String(Cs_Indexes); -- procedure Tap is new Dtraq.Tap(Capped_String_Type, 10, "Capped_String_Type"); Capped_String : Capped_String_Type := (others => ('a')); S : Cs_Indexes := 1; -- procedure Tap is new Dtraq.Tap(Float, 100, "Standard float"); F : Float := 300_000.0; type Color_Type is (Red, Orange, Yellow, Green, Blue, Violet); -- procedure Tap is new Dtraq.Tap(Color_Type, 6, "Rainbows"); Color : Color_Type := Red; type Flight_Modes is (Off, Parked, Taxi_In, Taxi_Out, Loading, Departure, Cruise, Approach, Landed); type Latitudes is digits 6 range -90.0 .. 90.0; type Longitudes is digits 6 range -180.0 .. 180.0; type Altitudes is digits 6 range -100.0 .. 50_000.0; subtype Home_Base_Name is String(1..3); type Position is record Latitude : Latitudes := 45.0; Longitude : Longitudes := -93.0; Altitude : Altitudes := 47.0; end record; type Position_History is array (1 .. 5) of Position; type Flight_Status is record Destination : String(1 .. 3) := "HSV"; Curr_Pos : Position; Mode : Flight_Modes := Off; History : Position_History; Home_Base : Home_Base_Name := "MSP"; end record; -- procedure Tap is new Dtraq.Tap(Flight_Status, 1979, "Flight Status"); Fs : Flight_Status; Dlat : Latitudes := -1.0; Dlong : Longitudes := 1.0; procedure Update_Flight(Flight_Data : in out Flight_Status) is begin -- Update the history Flight_Data.History(2 .. Position_History'Last) := Flight_Data.History(1 .. Position_History'Last - 1); Flight_Data.History(1) := Flight_Data.Curr_Pos; Flight_Data.Curr_Pos.Latitude := Flight_Data.Curr_Pos.Latitude + Dlat; Flight_Data.Curr_Pos.Longitude := Flight_Data.Curr_Pos.Longitude + Dlong; if Flight_Data.Mode = Flight_Modes'Last then Flight_Data.Mode := Flight_Modes'First; Dlat := - Dlat; Dlong := -Dlong; if Flight_Data.Destination = "HSV" then Flight_Data.Destination := "MSP"; else Flight_Data.Destination := "HSV"; end if; else Flight_Data.Mode := Flight_Modes'Succ(Flight_Data.Mode); end if; end Update_Flight; begin -- Connect_To_Server; loop Counter := Counter + 1; -- Tap(Counter); if Color = Color_Type'Last then Color := Color_Type'First; else Color := Color_Type'Succ(Color); end if; -- Tap(Color); if S = Cs_Indexes'Last then S := Cs_Indexes'First; else S := S + 1; end if; Capped_String(S) := To_Upper(Capped_String(S)); -- Tap(Capped_String); Capped_String(S) := To_Lower(Capped_String(S)); F := F * 0.999_999; -- Tap(F); delay 0.25; -- Tap(Fs); Update_Flight(Fs); end loop; -- Disconnect_From_Server; end Dtraq_Logging_Example;