|
| 1 | +-------------------------------------------------------------------------------- |
| 2 | +-- Sunline_Srukf Component Tester Body |
| 3 | +-------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +package body Component.Sunline_Srukf.Implementation.Tester is |
| 6 | + |
| 7 | + --------------------------------------- |
| 8 | + -- Initialize heap variables: |
| 9 | + --------------------------------------- |
| 10 | + procedure Init_Base (Self : in out Instance) is |
| 11 | + begin |
| 12 | + -- Initialize tester heap: |
| 13 | + -- Connector histories: |
| 14 | + Self.Data_Product_Fetch_T_Service_History.Init (Depth => 100); |
| 15 | + Self.Data_Product_T_Recv_Sync_History.Init (Depth => 100); |
| 16 | + -- Data product histories: |
| 17 | + Self.Sunline_Srukf_State_History.Init (Depth => 100); |
| 18 | + end Init_Base; |
| 19 | + |
| 20 | + procedure Final_Base (Self : in out Instance) is |
| 21 | + begin |
| 22 | + -- Destroy tester heap: |
| 23 | + -- Connector histories: |
| 24 | + Self.Data_Product_Fetch_T_Service_History.Destroy; |
| 25 | + Self.Data_Product_T_Recv_Sync_History.Destroy; |
| 26 | + -- Data product histories: |
| 27 | + Self.Sunline_Srukf_State_History.Destroy; |
| 28 | + end Final_Base; |
| 29 | + |
| 30 | + --------------------------------------- |
| 31 | + -- Test initialization functions: |
| 32 | + --------------------------------------- |
| 33 | + procedure Connect (Self : in out Instance) is |
| 34 | + begin |
| 35 | + Self.Component_Instance.Attach_Data_Product_Fetch_T_Request (To_Component => Self'Unchecked_Access, Hook => Self.Data_Product_Fetch_T_Service_Access); |
| 36 | + Self.Component_Instance.Attach_Data_Product_T_Send (To_Component => Self'Unchecked_Access, Hook => Self.Data_Product_T_Recv_Sync_Access); |
| 37 | + Self.Attach_Tick_T_Send (To_Component => Self.Component_Instance'Unchecked_Access, Hook => Self.Component_Instance.Tick_T_Recv_Sync_Access); |
| 38 | + end Connect; |
| 39 | + |
| 40 | + -- Helper function for returning data dependencies: |
| 41 | + function Return_Data_Dependency (Self : in out Instance; Arg : in Data_Product_Fetch.T) return Data_Product_Return.T is |
| 42 | + use Data_Product_Types; |
| 43 | + use Data_Product_Enums.Fetch_Status; |
| 44 | + use Sys_Time; |
| 45 | + -- Set default return values. These will be overridden below based on test configuration and |
| 46 | + -- the ID requested. |
| 47 | + Id_To_Return : Data_Product_Types.Data_Product_Id := Self.Data_Dependency_Return_Id_Override; |
| 48 | + Length_To_Return : Data_Product_Types.Data_Product_Buffer_Length_Type := Self.Data_Dependency_Return_Length_Override; |
| 49 | + Return_Status : Data_Product_Enums.Fetch_Status.E := Self.Data_Dependency_Return_Status_Override; |
| 50 | + Buffer_To_Return : Data_Product_Types.Data_Product_Buffer_Type; |
| 51 | + Time_To_Return : Sys_Time.T := Self.Data_Dependency_Timestamp_Override; |
| 52 | + begin |
| 53 | + -- Determine return data product ID: |
| 54 | + if Id_To_Return = 0 then |
| 55 | + case Arg.Id is |
| 56 | + -- ID for Spacecraft_Attitude: |
| 57 | + when 0 => Id_To_Return := 0; |
| 58 | + -- If ID can not be found, then return ID out of range error. |
| 59 | + when others => |
| 60 | + if Return_Status = Data_Product_Enums.Fetch_Status.Success then |
| 61 | + Return_Status := Data_Product_Enums.Fetch_Status.Id_Out_Of_Range; |
| 62 | + end if; |
| 63 | + end case; |
| 64 | + end if; |
| 65 | + |
| 66 | + -- Determine return data product length: |
| 67 | + if Length_To_Return = 0 then |
| 68 | + case Arg.Id is |
| 69 | + -- Length for Spacecraft_Attitude: |
| 70 | + when 0 => Length_To_Return := Nav_Att.Size_In_Bytes; |
| 71 | + -- If ID can not be found, then return ID out of range error. |
| 72 | + when others => |
| 73 | + if Return_Status = Data_Product_Enums.Fetch_Status.Success then |
| 74 | + Return_Status := Data_Product_Enums.Fetch_Status.Id_Out_Of_Range; |
| 75 | + end if; |
| 76 | + end case; |
| 77 | + end if; |
| 78 | + |
| 79 | + -- Determine return timestamp: |
| 80 | + if Time_To_Return = (0, 0) then |
| 81 | + Time_To_Return := Self.System_Time; |
| 82 | + end if; |
| 83 | + |
| 84 | + -- Fill the data product buffer: |
| 85 | + if Return_Status = Data_Product_Enums.Fetch_Status.Success then |
| 86 | + case Arg.Id is |
| 87 | + -- Length for Spacecraft_Attitude: |
| 88 | + when 0 => |
| 89 | + Buffer_To_Return (Buffer_To_Return'First .. Buffer_To_Return'First + Nav_Att.Size_In_Bytes - 1) := |
| 90 | + Nav_Att.Serialization.To_Byte_Array (Self.Spacecraft_Attitude); |
| 91 | + -- Do not fill. The ID is not recognized. |
| 92 | + when others => |
| 93 | + Return_Status := Data_Product_Enums.Fetch_Status.Id_Out_Of_Range; |
| 94 | + end case; |
| 95 | + end if; |
| 96 | + |
| 97 | + -- Return the data product with the status: |
| 98 | + return ( |
| 99 | + The_Status => Return_Status, |
| 100 | + The_Data_Product => ( |
| 101 | + Header => ( |
| 102 | + Time => Time_To_Return, |
| 103 | + Id => Id_To_Return, |
| 104 | + Buffer_Length => Length_To_Return |
| 105 | + ), |
| 106 | + Buffer => Buffer_To_Return |
| 107 | + ) |
| 108 | + ); |
| 109 | + end Return_Data_Dependency; |
| 110 | + |
| 111 | + --------------------------------------- |
| 112 | + -- Invokee connector primitives: |
| 113 | + --------------------------------------- |
| 114 | + -- Fetch a data product item from the database. |
| 115 | + overriding function Data_Product_Fetch_T_Service (Self : in out Instance; Arg : in Data_Product_Fetch.T) return Data_Product_Return.T is |
| 116 | + To_Return : constant Data_Product_Return.T := Self.Return_Data_Dependency (Arg); |
| 117 | + begin |
| 118 | + -- Push the argument onto the test history for looking at later: |
| 119 | + Self.Data_Product_Fetch_T_Service_History.Push (Arg); |
| 120 | + return To_Return; |
| 121 | + end Data_Product_Fetch_T_Service; |
| 122 | + |
| 123 | + -- The data product invoker connector |
| 124 | + overriding procedure Data_Product_T_Recv_Sync (Self : in out Instance; Arg : in Data_Product.T) is |
| 125 | + begin |
| 126 | + -- Push the argument onto the test history for looking at later: |
| 127 | + Self.Data_Product_T_Recv_Sync_History.Push (Arg); |
| 128 | + -- Dispatch the data product to the correct handler: |
| 129 | + Self.Dispatch_Data_Product (Arg); |
| 130 | + end Data_Product_T_Recv_Sync; |
| 131 | + |
| 132 | + ----------------------------------------------- |
| 133 | + -- Data product handler primitive: |
| 134 | + ----------------------------------------------- |
| 135 | + -- Description: |
| 136 | + -- Data products for the Sunline SRuKF component. |
| 137 | + -- Output state from the sunline SRuKF algorithm (timeTag, sigma_BN, omega_BN_B, |
| 138 | + -- vehSunPntBdy). |
| 139 | + overriding procedure Sunline_Srukf_State (Self : in out Instance; Arg : in Sunline_Srukf_Output.T) is |
| 140 | + begin |
| 141 | + -- Push the argument onto the test history for looking at later: |
| 142 | + Self.Sunline_Srukf_State_History.Push (Arg); |
| 143 | + end Sunline_Srukf_State; |
| 144 | + |
| 145 | +end Component.Sunline_Srukf.Implementation.Tester; |
0 commit comments