with Ada.Task_Identification; use Ada.Task_Identification;
with Swarm_Configuration; use Swarm_Configuration;
with Swarm_Data; use Swarm_Data;
with Swarm_Structures; use Swarm_Structures;
with Vehicle_Task_Id; use Vehicle_Task_Id;
package body Vehicle_Interface is
use Swarm_Vectors;
function Position return Positions is
begin
return Element (Swarm_State, Id_Task (Current_Task)).Position;
end Position;
function Velocity return Velocities is
begin
return Element (Swarm_State, Id_Task (Current_Task)).Velocity;
end Velocity;
function Acceleration return Accelerations is
begin
return Element (Swarm_State, Id_Task (Current_Task)).Acceleration;
end Acceleration;
procedure Set_Destination (V : Vector_3D) is
begin
Element (Swarm_State, Id_Task (Current_Task)).Controls.Set_Steering (V);
end Set_Destination;
procedure Set_Throttle (T : Throttle_T) is
begin
Element (Swarm_State, Id_Task (Current_Task)).Controls.Set_Throttle (T);
end Set_Throttle;
function Throttle_Is_On_Idle return Boolean is
begin
return Element (Swarm_State, Id_Task (Current_Task)).Controls.Read_Throttle = Idle_Throttle;
end Throttle_Is_On_Idle;
procedure Send (Message : Inter_Vehicle_Messages) is
begin
Element (Swarm_State, Id_Task (Current_Task)).Comms.Send (Message);
end Send;
procedure Receive (Message : out Inter_Vehicle_Messages) is
begin
Element (Swarm_State, Id_Task (Current_Task)).Comms.Receive (Message);
end Receive;
function Messages_Waiting return Boolean is
begin
return Element (Swarm_State, Id_Task (Current_Task)).Comms.Has_Incoming_Messages;
end Messages_Waiting;
function Current_Charge return Vehicle_Charges is
begin
return Element (Swarm_State, Id_Task (Current_Task)).Charge.Level;
end Current_Charge;
function Discharge_Per_Sec return Float is
begin
return Charging_Setup.Discharge_Rate_Per_Sec;
end Discharge_Per_Sec;
function Energy_Globes_Around return Energy_Globes_A is
Globes_Found : Natural := 0;
Globes_Detected : array (Globes'Range) of Boolean := (others => False);
This_Element_Position : constant Positions := Element (Swarm_State, Id_Task (Current_Task)).Position;
begin
for Globe_Ix in Globes'Range loop
if abs (This_Element_Position - Globes (Globe_Ix).Position) <= Energy_Globe_Detection then
Globes_Detected (Globe_Ix) := True;
Globes_Found := Globes_Found + 1;
end if;
end loop;
declare
Found_Globes : Energy_Globes_A (1 .. Globes_Found);
Found_Globes_Ix : Natural := Globes'First;
begin
for Globe_Ix in Globes'Range loop
if Globes_Detected (Globe_Ix) then
Found_Globes (Found_Globes_Ix) := Globes (Globe_Ix);
Found_Globes_Ix := Found_Globes_Ix + 1;
end if;
end loop;
return Found_Globes;
end;
end Energy_Globes_Around;
procedure Wait_For_Next_Physics_Update is
begin
Simulator_Tick.Wait_For_Next_Tick;
end Wait_For_Next_Physics_Update;
end Vehicle_Interface;