|
| 1 | +-------------------------------------------------------------------------------- |
| 2 | +-- Body_Rate_Miscompare Component Tester Body |
| 3 | +-------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +-- Includes: |
| 6 | +with Parameter; |
| 7 | + |
| 8 | +package body Component.Body_Rate_Miscompare.Implementation.Tester is |
| 9 | + |
| 10 | + --------------------------------------- |
| 11 | + -- Initialize heap variables: |
| 12 | + --------------------------------------- |
| 13 | + procedure Init_Base (Self : in out Instance) is |
| 14 | + begin |
| 15 | + -- Initialize tester heap: |
| 16 | + -- Connector histories: |
| 17 | + Self.Data_Product_Fetch_T_Service_History.Init (Depth => 100); |
| 18 | + Self.Data_Product_T_Recv_Sync_History.Init (Depth => 100); |
| 19 | + -- Data product histories: |
| 20 | + Self.Body_Rate_History.Init (Depth => 100); |
| 21 | + Self.Rate_Fault_Status_History.Init (Depth => 100); |
| 22 | + end Init_Base; |
| 23 | + |
| 24 | + procedure Final_Base (Self : in out Instance) is |
| 25 | + begin |
| 26 | + -- Destroy tester heap: |
| 27 | + -- Connector histories: |
| 28 | + Self.Data_Product_Fetch_T_Service_History.Destroy; |
| 29 | + Self.Data_Product_T_Recv_Sync_History.Destroy; |
| 30 | + -- Data product histories: |
| 31 | + Self.Body_Rate_History.Destroy; |
| 32 | + Self.Rate_Fault_Status_History.Destroy; |
| 33 | + end Final_Base; |
| 34 | + |
| 35 | + --------------------------------------- |
| 36 | + -- Test initialization functions: |
| 37 | + --------------------------------------- |
| 38 | + procedure Connect (Self : in out Instance) is |
| 39 | + begin |
| 40 | + Self.Component_Instance.Attach_Data_Product_Fetch_T_Request (To_Component => Self'Unchecked_Access, Hook => Self.Data_Product_Fetch_T_Service_Access); |
| 41 | + Self.Component_Instance.Attach_Data_Product_T_Send (To_Component => Self'Unchecked_Access, Hook => Self.Data_Product_T_Recv_Sync_Access); |
| 42 | + Self.Attach_Tick_T_Send (To_Component => Self.Component_Instance'Unchecked_Access, Hook => Self.Component_Instance.Tick_T_Recv_Sync_Access); |
| 43 | + Self.Attach_Parameter_Update_T_Provide (To_Component => Self.Component_Instance'Unchecked_Access, Hook => Self.Component_Instance.Parameter_Update_T_Modify_Access); |
| 44 | + end Connect; |
| 45 | + |
| 46 | + -- Helper function for returning data dependencies: |
| 47 | + function Return_Data_Dependency (Self : in out Instance; Arg : in Data_Product_Fetch.T) return Data_Product_Return.T is |
| 48 | + use Data_Product_Types; |
| 49 | + use Data_Product_Enums.Fetch_Status; |
| 50 | + use Sys_Time; |
| 51 | + -- Set default return values. These will be overridden below based on test configuration and |
| 52 | + -- the ID requested. |
| 53 | + Id_To_Return : Data_Product_Types.Data_Product_Id := Self.Data_Dependency_Return_Id_Override; |
| 54 | + Length_To_Return : Data_Product_Types.Data_Product_Buffer_Length_Type := Self.Data_Dependency_Return_Length_Override; |
| 55 | + Return_Status : Data_Product_Enums.Fetch_Status.E := Self.Data_Dependency_Return_Status_Override; |
| 56 | + Buffer_To_Return : Data_Product_Types.Data_Product_Buffer_Type; |
| 57 | + Time_To_Return : Sys_Time.T := Self.Data_Dependency_Timestamp_Override; |
| 58 | + begin |
| 59 | + -- Determine return data product ID: |
| 60 | + if Id_To_Return = 0 then |
| 61 | + case Arg.Id is |
| 62 | + -- ID for Imu_Body: |
| 63 | + when 0 => Id_To_Return := 0; |
| 64 | + -- ID for Star_Tracker_Attitude: |
| 65 | + when 1 => Id_To_Return := 1; |
| 66 | + -- If ID can not be found, then return ID out of range error. |
| 67 | + when others => |
| 68 | + if Return_Status = Data_Product_Enums.Fetch_Status.Success then |
| 69 | + Return_Status := Data_Product_Enums.Fetch_Status.Id_Out_Of_Range; |
| 70 | + end if; |
| 71 | + end case; |
| 72 | + end if; |
| 73 | + |
| 74 | + -- Determine return data product length: |
| 75 | + if Length_To_Return = 0 then |
| 76 | + case Arg.Id is |
| 77 | + -- Length for Imu_Body: |
| 78 | + when 0 => Length_To_Return := Imu_Sensor_Body.Size_In_Bytes; |
| 79 | + -- Length for Star_Tracker_Attitude: |
| 80 | + when 1 => Length_To_Return := St_Att.Size_In_Bytes; |
| 81 | + -- If ID can not be found, then return ID out of range error. |
| 82 | + when others => |
| 83 | + if Return_Status = Data_Product_Enums.Fetch_Status.Success then |
| 84 | + Return_Status := Data_Product_Enums.Fetch_Status.Id_Out_Of_Range; |
| 85 | + end if; |
| 86 | + end case; |
| 87 | + end if; |
| 88 | + |
| 89 | + -- Determine return timestamp: |
| 90 | + if Time_To_Return = (0, 0) then |
| 91 | + Time_To_Return := Self.System_Time; |
| 92 | + end if; |
| 93 | + |
| 94 | + -- Fill the data product buffer: |
| 95 | + if Return_Status = Data_Product_Enums.Fetch_Status.Success then |
| 96 | + case Arg.Id is |
| 97 | + -- Length for Imu_Body: |
| 98 | + when 0 => |
| 99 | + Buffer_To_Return (Buffer_To_Return'First .. Buffer_To_Return'First + Imu_Sensor_Body.Size_In_Bytes - 1) := |
| 100 | + Imu_Sensor_Body.Serialization.To_Byte_Array (Self.Imu_Body); |
| 101 | + -- Length for Star_Tracker_Attitude: |
| 102 | + when 1 => |
| 103 | + Buffer_To_Return (Buffer_To_Return'First .. Buffer_To_Return'First + St_Att.Size_In_Bytes - 1) := |
| 104 | + St_Att.Serialization.To_Byte_Array (Self.Star_Tracker_Attitude); |
| 105 | + -- Do not fill. The ID is not recognized. |
| 106 | + when others => |
| 107 | + Return_Status := Data_Product_Enums.Fetch_Status.Id_Out_Of_Range; |
| 108 | + end case; |
| 109 | + end if; |
| 110 | + |
| 111 | + -- Return the data product with the status: |
| 112 | + return ( |
| 113 | + The_Status => Return_Status, |
| 114 | + The_Data_Product => ( |
| 115 | + Header => ( |
| 116 | + Time => Time_To_Return, |
| 117 | + Id => Id_To_Return, |
| 118 | + Buffer_Length => Length_To_Return |
| 119 | + ), |
| 120 | + Buffer => Buffer_To_Return |
| 121 | + ) |
| 122 | + ); |
| 123 | + end Return_Data_Dependency; |
| 124 | + |
| 125 | + --------------------------------------- |
| 126 | + -- Invokee connector primitives: |
| 127 | + --------------------------------------- |
| 128 | + -- Fetch a data product item from the database. |
| 129 | + overriding function Data_Product_Fetch_T_Service (Self : in out Instance; Arg : in Data_Product_Fetch.T) return Data_Product_Return.T is |
| 130 | + To_Return : constant Data_Product_Return.T := Self.Return_Data_Dependency (Arg); |
| 131 | + begin |
| 132 | + -- Push the argument onto the test history for looking at later: |
| 133 | + Self.Data_Product_Fetch_T_Service_History.Push (Arg); |
| 134 | + return To_Return; |
| 135 | + end Data_Product_Fetch_T_Service; |
| 136 | + |
| 137 | + -- The data product invoker connector |
| 138 | + overriding procedure Data_Product_T_Recv_Sync (Self : in out Instance; Arg : in Data_Product.T) is |
| 139 | + begin |
| 140 | + -- Push the argument onto the test history for looking at later: |
| 141 | + Self.Data_Product_T_Recv_Sync_History.Push (Arg); |
| 142 | + -- Dispatch the data product to the correct handler: |
| 143 | + Self.Dispatch_Data_Product (Arg); |
| 144 | + end Data_Product_T_Recv_Sync; |
| 145 | + |
| 146 | + ----------------------------------------------- |
| 147 | + -- Data product handler primitive: |
| 148 | + ----------------------------------------------- |
| 149 | + -- Description: |
| 150 | + -- Data products for the Body Rate Miscompare component. |
| 151 | + -- Selected body rate output (star tracker rate if rates agree, IMU rate if they |
| 152 | + -- disagree) |
| 153 | + overriding procedure Body_Rate (Self : in out Instance; Arg : in Nav_Att.T) is |
| 154 | + begin |
| 155 | + -- Push the argument onto the test history for looking at later: |
| 156 | + Self.Body_Rate_History.Push (Arg); |
| 157 | + end Body_Rate; |
| 158 | + |
| 159 | + -- Body rate fault detection status |
| 160 | + overriding procedure Rate_Fault_Status (Self : in out Instance; Arg : in Body_Rate_Fault.T) is |
| 161 | + begin |
| 162 | + -- Push the argument onto the test history for looking at later: |
| 163 | + Self.Rate_Fault_Status_History.Push (Arg); |
| 164 | + end Rate_Fault_Status; |
| 165 | + |
| 166 | + ----------------------------------------------- |
| 167 | + -- Special primitives for aiding in the staging, |
| 168 | + -- fetching, and updating of parameters |
| 169 | + ----------------------------------------------- |
| 170 | + not overriding function Stage_Parameter (Self : in out Instance; Par : in Parameter.T) return Parameter_Update_Status.E is |
| 171 | + use Parameter_Enums.Parameter_Update_Status; |
| 172 | + use Parameter_Enums.Parameter_Operation_Type; |
| 173 | + Param_Update : Parameter_Update.T := ( |
| 174 | + Table_Id => 1, |
| 175 | + Operation => Stage, |
| 176 | + Status => Success, |
| 177 | + Param => Par |
| 178 | + ); |
| 179 | + begin |
| 180 | + Self.Parameter_Update_T_Provide (Param_Update); |
| 181 | + return Param_Update.Status; |
| 182 | + end Stage_Parameter; |
| 183 | + |
| 184 | + not overriding function Fetch_Parameter (Self : in out Instance; Id : in Parameter_Types.Parameter_Id; Par : out Parameter.T) return Parameter_Update_Status.E is |
| 185 | + use Parameter_Enums.Parameter_Update_Status; |
| 186 | + use Parameter_Enums.Parameter_Operation_Type; |
| 187 | + Param_Update : Parameter_Update.T := ( |
| 188 | + Table_Id => 1, |
| 189 | + Operation => Fetch, |
| 190 | + Status => Success, |
| 191 | + Param => (Header => (Id => Id, Buffer_Length => 0), Buffer => [others => 0]) |
| 192 | + ); |
| 193 | + begin |
| 194 | + -- Set the ID to fetch: |
| 195 | + Param_Update.Param.Header.Id := Id; |
| 196 | + Self.Parameter_Update_T_Provide (Param_Update); |
| 197 | + Par := Param_Update.Param; |
| 198 | + return Param_Update.Status; |
| 199 | + end Fetch_Parameter; |
| 200 | + |
| 201 | + not overriding function Validate_Parameters (Self : in out Instance) return Parameter_Update_Status.E is |
| 202 | + use Parameter_Enums.Parameter_Update_Status; |
| 203 | + use Parameter_Enums.Parameter_Operation_Type; |
| 204 | + Param_Update : Parameter_Update.T := ( |
| 205 | + Table_Id => 1, |
| 206 | + Operation => Validate, |
| 207 | + Status => Success, |
| 208 | + Param => ((0, 0), [others => 0]) |
| 209 | + ); |
| 210 | + begin |
| 211 | + Self.Parameter_Update_T_Provide (Param_Update); |
| 212 | + return Param_Update.Status; |
| 213 | + end Validate_Parameters; |
| 214 | + |
| 215 | + not overriding function Update_Parameters (Self : in out Instance) return Parameter_Update_Status.E is |
| 216 | + use Parameter_Enums.Parameter_Update_Status; |
| 217 | + use Parameter_Enums.Parameter_Operation_Type; |
| 218 | + Param_Update : Parameter_Update.T := ( |
| 219 | + Table_Id => 1, |
| 220 | + Operation => Update, |
| 221 | + Status => Success, |
| 222 | + Param => ((0, 0), [others => 0]) |
| 223 | + ); |
| 224 | + begin |
| 225 | + Self.Parameter_Update_T_Provide (Param_Update); |
| 226 | + return Param_Update.Status; |
| 227 | + end Update_Parameters; |
| 228 | + |
| 229 | +end Component.Body_Rate_Miscompare.Implementation.Tester; |
0 commit comments