1. -- 
  2. -- Jan & Uwe R. Zimmer, Australia, 2013 
  3. -- 
  4.  
  5. package body Swarm_Structures is 
  6.  
  7.    -- 
  8.  
  9.    protected body Vehicle_Comms is 
  10.  
  11.       procedure Send (Message : Inter_Vehicle_Messages) is 
  12.  
  13.       begin 
  14.          Put (Sent_Messages, Message); 
  15.       end Send; 
  16.  
  17.       -- 
  18.  
  19.       procedure Push_Message (Message : Inter_Vehicle_Messages) is 
  20.  
  21.       begin 
  22.          Put (Received_Messages, Message); 
  23.       end Push_Message; 
  24.  
  25.       -- 
  26.  
  27.       procedure Fetch_Message (Message : out Inter_Vehicle_Messages) is 
  28.  
  29.       begin 
  30.          Get (Sent_Messages, Message); 
  31.       end Fetch_Message; 
  32.  
  33.       -- 
  34.  
  35.       function Has_Incoming_Messages return Boolean is (Element_Available (Received_Messages)); 
  36.  
  37.       function Has_Outgoing_Messages return Boolean is (Element_Available (Sent_Messages)); 
  38.  
  39.       -- 
  40.  
  41.       entry Receive (Message : out Inter_Vehicle_Messages) when Element_Available (Received_Messages) is 
  42.  
  43.       begin 
  44.          Get (Received_Messages, Message); 
  45.       end Receive; 
  46.  
  47.    end Vehicle_Comms; 
  48.  
  49.    -- 
  50.    -- 
  51.    -- 
  52.  
  53.    protected body Vehicle_Controls is 
  54.  
  55.       procedure Set_Steering (V : Vector_3D) is 
  56.  
  57.       begin 
  58.          Steering_Direction := V; 
  59.       end Set_Steering; 
  60.  
  61.       -- 
  62.  
  63.       procedure Set_Throttle (T : Throttle_T) is 
  64.  
  65.       begin 
  66.          Throttle := T; 
  67.       end Set_Throttle; 
  68.  
  69.       -- 
  70.  
  71.       function Read_Steering return Vector_3D is (Steering_Direction); 
  72.  
  73.       function Read_Throttle return Throttle_T is (Throttle); 
  74.  
  75.       -- 
  76.  
  77.    end Vehicle_Controls; 
  78.  
  79.    --------- 
  80.    -- "<" -- 
  81.    --------- 
  82.  
  83.    function "<" (L, R : Distance_Entries) return Boolean is (L.Distance < R.Distance); 
  84.  
  85.    -- 
  86.  
  87.    protected body Simulator_Tick is 
  88.  
  89.       entry Wait_For_Next_Tick when Trigger is 
  90.  
  91.       begin 
  92.          Trigger := Wait_For_Next_Tick'Count > 0; 
  93.       end Wait_For_Next_Tick; 
  94.  
  95.       procedure Tick is 
  96.  
  97.       begin 
  98.          Trigger := True; 
  99.       end Tick; 
  100.  
  101.    end Simulator_Tick; 
  102.  
  103.    -- 
  104.  
  105. end Swarm_Structures;