Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter System Testing #33

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gnd/cosmos/install_cosmos_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ adamant_assembly_name=${adamant_assembly_model%.assembly.yaml}
adamant_assembly_name=${adamant_assembly_name##*/}
adamant_assembly_dir=`dirname $adamant_assembly_model`
cosmos_plugin_dir=`realpath $cosmos_plugin_dir`
adamant_script_dir=`realpath $adamant_assembly_dir/../../../test/scripts`
cosmos_script_dir=`realpath $cosmos_plugin_dir/../plugins/DEFAULT/targets_modified`

# Get build directory:
adamant_assembly_name_short=(${adamant_assembly_name//_/ })
Expand Down Expand Up @@ -53,5 +55,10 @@ do_copy() {
do_copy "$adamant_assembly_cmdtlm_dir/${adamant_assembly_name}_ccsds_cosmos_commands.txt" $cosmos_plugin_dir/targets/$adamant_assembly_name_upper/cmd_tlm/cmd.txt
do_copy "$adamant_assembly_cmdtlm_dir/${adamant_assembly_name}_ccsds_cosmos_telemetry.txt" $cosmos_plugin_dir/targets/$adamant_assembly_name_upper/cmd_tlm/tlm.txt
do_copy "$adamant_assembly_plugin_dir/plugin.txt" $cosmos_plugin_dir/plugin.txt
do_copy "$adamant_script_dir/update-param-sys.py" $cosmos_script_dir/update-param-sys.py
do_copy "$adamant_script_dir/validate-param-sys.py" $cosmos_script_dir/validate-param-sys.py
do_copy "$adamant_script_dir/test_setup.py" $cosmos_script_dir/test_setup.py
do_copy "$adamant_script_dir/crc_16.py" $cosmos_script_dir/crc_16.py
echo "Success."
echo "Plugin files copied to $cosmos_plugin_dir."
echo "Script files copied to $cosmos_script_dir."
508 changes: 508 additions & 0 deletions src/assembly/linux/1

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/assembly/linux/linux_example.assembly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ components:
set_id_bases:
- "Command_Id_Base => 5200"
init:
- "Parameter_Table_Length => Linux_Example_Parameter_Table.Parameter_Table_Size_In_Bytes"
- "Ticks_Until_Timeout => 3"
########################################
# Telemetry system:
Expand Down Expand Up @@ -1070,9 +1069,17 @@ connections:
to_component: Parameters_Instance
to_connector: Parameters_Memory_Region_T_Recv_Async
- from_component: Parameter_Manager_Instance
from_connector: Default_Parameters_Memory_Region_Send
from_connector: Primary_Parameters_Memory_Region_Send
to_component: Parameter_Store_Instance
to_connector: Parameters_Memory_Region_T_Recv_Async
- from_component: Parameter_Manager_Instance
from_connector: Redundant_Parameters_Memory_Region_Send
to_component: Parameter_Store_Instance
to_connector: Parameters_Memory_Region_T_Recv_Async
- from_component: Parameter_Manager_Instance
from_connector: Data_Product_T_Send
to_component: Product_Database_Instance
to_connector: Data_Product_T_Recv_Sync
- from_component: Parameter_Store_Instance
from_connector: Parameters_Memory_Region_Release_T_Send
to_component: Parameter_Manager_Instance
Expand Down
1 change: 1 addition & 0 deletions src/assembly/linux/linux_example.product_packets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ packets:
- name: Cpu_Monitor_Instance.Packet_Period
- name: Queue_Monitor_Instance.Packet_Period
- name: Stack_Monitor_Instance.Packet_Period
- name: Parameter_Manager_Instance.Validation_Status
period: "1" # create every tick

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
-- Includes:
with Tick;
with Command;
with Configuration;
with Parameter_Manager_Types;
with Parameter_Manager_Table_Header;
with Parameters_Memory_Region_Release;
with Protected_Variables;
with Task_Synchronization;
with Memory_Region;

-- This component is responsible for managing the working, scratch, and default parameter tables. Its sole responsibility is to respond to commands to copy parameter tables from one region to another or to dump the scratch region.
-- This component is responsible for managing a working and default parameter
-- table. Its sole responsibility is to respond to commands to copy parameter
-- tables from one region to another.
package Component.Parameter_Manager.Implementation is

-- The component class instance record:
Expand All @@ -22,10 +26,14 @@ package Component.Parameter_Manager.Implementation is
-- Initialization parameters for the Parameter Manager.
--
-- Init Parameters:
-- parameter_Table_Length : Natural - The size of the parameter table in bytes. This must be known to the component so it can construct correct sized memory regions for the downstream components.
-- ticks_Until_Timeout : Natural - The component will wait until it has received at least this many ticks before reporting a timeout error while waiting for a parameter update/fetch response from either the active or default parameter components. For example, if the component is attached to a 10Hz rate group and this value is set to 7, then the component will wait between 700 and 800 ms before declaring a timeout error from an unresponsive downstream component.
-- Ticks_Until_Timeout : Natural - The component will wait until it has received
-- at least this many ticks before reporting a timeout error while waiting for a
-- parameter update/fetch response from either the working or default parameter
-- components. For example, if the component is attached to a 10Hz rate group and
-- this value is set to 7, then the component will wait between 700 and 800 ms
-- before declaring a timeout error from an unresponsive downstream component.
--
overriding procedure Init (Self : in out Instance; Parameter_Table_Length : in Natural; Ticks_Until_Timeout : in Natural);
overriding procedure Init (Self : in out Instance; Ticks_Until_Timeout : in Natural);

private

Expand All @@ -40,18 +48,6 @@ private
Response : Protected_Parameters_Memory_Region_Release.Variable;
-- Variables used for task synchronization and timeouts:
Sync_Object : Task_Synchronization.Wait_Release_Timeout_Counter_Object;
-- Other configuration:
Parameter_Table_Length : Natural := 0;
-- Temporary storage to allow safe copying between Default and Working.
-- We declare this here, instead of as a temporary variable within a function
-- because if a timeout error occurs, we have no guarantee that the downstream
-- component is not reading/writing from this data. If it is declared here, then
-- at least only this data can be corrupted, and not the stack, which would be
-- a much worse situation. The assembly should be designed that timeout errors
-- never occur in order to fully prevent this issue.
Parameter_Bytes : Basic_Types.Byte_Array_Access;
-- Create a memory region that points to this buffer:
Parameter_Bytes_Region : Memory_Region.T;
end record;

---------------------------------------
Expand All @@ -69,13 +65,17 @@ private
---------------------------------------
-- Invokee connector primitives:
---------------------------------------
-- The component should be attached to a periodic tick that is used to timeout waiting for a parameter update/fetch response. See the ticks_Until_Timeout initialization parameter.
-- The component should be attached to a periodic tick that is used to timeout
-- waiting for a parameter update/fetch response. See the ticks_Until_Timeout
-- initialization parameter.
overriding procedure Timeout_Tick_Recv_Sync (Self : in out Instance; Arg : in Tick.T);
-- The command receive connector.
overriding procedure Command_T_Recv_Async (Self : in out Instance; Arg : in Command.T);
-- This procedure is called when a Command_T_Recv_Async message is dropped due to a full queue.
overriding procedure Command_T_Recv_Async_Dropped (Self : in out Instance; Arg : in Command.T);
-- Parameter update/fetch responses are returned synchronously on this connector. The component waits internally for this response, or times out if the response is not received in time.
-- Parameter update/fetch responses are returned synchronously on this connector.
-- The component waits internally for this response, or times out if the response
-- is not received in time.
overriding procedure Parameters_Memory_Region_Release_T_Recv_Sync (Self : in out Instance; Arg : in Parameters_Memory_Region_Release.T);

---------------------------------------
Expand All @@ -85,20 +85,33 @@ private
overriding procedure Command_Response_T_Send_Dropped (Self : in out Instance; Arg : in Command_Response.T) is null;
-- This procedure is called when a Working_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Working_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Default_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Default_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Primary_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Primary_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Redundant_Parameters_Memory_Region_Send message is dropped due to a full queue.
overriding procedure Redundant_Parameters_Memory_Region_Send_Dropped (Self : in out Instance; Arg : in Parameters_Memory_Region.T) is null;
-- This procedure is called when a Data_Product_T_Send message is dropped due to a full queue.
overriding procedure Data_Product_T_Send_Dropped (Self : in out Instance; Arg : in Data_Product.T) is null;
-- This procedure is called when a Event_T_Send message is dropped due to a full queue.
overriding procedure Event_T_Send_Dropped (Self : in out Instance; Arg : in Event.T) is null;

-----------------------------------------------
-- Command handler primitives:
-----------------------------------------------
-- Description:
-- These are the commands for the Parameter Store component.
-- Copy parameter table from source to destination based on the enumeration provided.
overriding function Copy_Parameter_Table (Self : in out Instance; Arg : in Packed_Parameter_Table_Copy_Type.T) return Command_Execution_Status.E;
-- These are the commands for the Parameter Manager component.
-- Send received parameter table to default and working regions.
overriding function Update_Parameter_Table (Self : in out Instance; Arg : in Packed_Parameter_Table.T) return Command_Execution_Status.E;
-- Validate a received parameter table.
overriding function Validate_Parameter_Table (Self : in out Instance; Arg : in Packed_Parameter_Table.T) return Command_Execution_Status.E;

-- Invalid command handler. This procedure is called when a command's arguments are found to be invalid:
overriding procedure Invalid_Command (Self : in out Instance; Cmd : in Command.T; Errant_Field_Number : in Unsigned_32; Errant_Field : in Basic_Types.Poly_Type);

-- Compile time checks to make sure parameter manager types do not serialize longer than the size of the command buffer minus the parameter table header:
pragma Warnings (Off, "condition can only be True if invalid values present");
pragma Compile_Time_Error (
Configuration.Command_Buffer_Size - Parameter_Manager_Table_Header.Size_In_Bytes /= Parameter_Manager_Types.Parameter_Manager_Buffer_Type'Length,
"Parameter_Manager_Buffer_Length_Type has a maximum size in bytes unequal to the Command_Buffer_Size minus the Parameter_Manager_Table_Header size."
);
pragma Warnings (On, "condition can only be True if invalid values present");
end Component.Parameter_Manager.Implementation;
Binary file modified src/components/parameter_manager/doc/parameter_manager.pdf
Binary file not shown.
25 changes: 25 additions & 0 deletions src/components/parameter_manager/doc/parameter_manager.tex
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,51 @@ \subsection{Diagram}
\subsection{Connectors}
\input{build/tex/parameter_manager_connectors.tex}

\subsection{Interrupts}

\input{build/tex/parameter_manager_interrupts.tex}

\subsection{Initialization}
\input{build/tex/parameter_manager_init.tex}

\subsection{Commands}

\input{build/tex/parameter_manager_commands.tex}

\subsection{Parameters}

\input{build/tex/parameter_manager_parameters.tex}

\subsection{Events}

\input{build/tex/parameter_manager_events.tex}

\subsection{Data Products}

\input{build/tex/parameter_manager_data_products.tex}

\subsection{Data Dependencies}

\input{build/tex/parameter_manager_data_dependencies.tex}

\subsection{Packets}

\input{build/tex/parameter_manager_packets.tex}

\subsection{Faults}

\input{build/tex/parameter_manager_faults.tex}

\section{Unit Tests}

\input{build/tex/parameter_manager_unit_test.tex}

\section{Appendix}

\subsection{Preamble}

\input{build/tex/parameter_manager_preamble.tex}

\subsection{Packed Types}

\input{build/tex/parameter_manager_types.tex}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
description: Generic parameter packet for holding a parameter table
fields:
- name: Header
description: The parameter table header
type: Parameter_Manager_Table_Header.T
- name: Table_Buffer
description: A buffer that contains the parameter table
type: Parameter_Manager_Types.Parameter_Manager_Buffer_Type
format: U8x{{ command_buffer_size - 8 }}
variable_length: Header.Table_Buffer_Length
17 changes: 17 additions & 0 deletions src/components/parameter_manager/packed_validation.record.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
description: A packed validation record
fields:
- name: Last_Validation_Version
description: The version of the most recently validated table.
type: Short_Float
format: F32
- name: Crc_Table
description: The CRC of the most recently validated table.
type: Crc_16.Crc_16_Type
format: U16
skip_validation: True
byte_image: True
- name: Last_Validation_Status
description: The status of the most recent table validation operation.
type: Parameter_Enums.Parameter_Table_Update_Status.E
format: E8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
description: A packed record which holds the most recently validated parameter table header with its validation status.
fields:
- name: Last_Validation_Header
description: The header of the most recently validated parameter table.
type: Parameter_Manager_Table_Header.T
- name: Last_Validation_Status
description: The status of the most recent table validation operation.
type: Parameter_Enums.Parameter_Table_Update_Status.E
format: E8
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
description: These are the commands for the Parameter Manager component.
commands:
- name: Copy_Parameter_Table
description: Copy parameter table from source to destination based on the enumeration provided.
arg_type: Packed_Parameter_Table_Copy_Type.T
- name: Update_Parameter_Table
description: Send received parameter table to default and working regions.
arg_type: Packed_Parameter_Table.T
- name: Validate_Parameter_Table
description: Validate a received parameter table.
arg_type: Packed_Parameter_Table.T
26 changes: 18 additions & 8 deletions src/components/parameter_manager/parameter_manager.component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,44 @@ execution: active
init:
description: Initialization parameters for the Parameter Manager.
parameters:
- name: parameter_Table_Length
type: Natural
description: The size of the parameter table in bytes. This must be known to the component so it can construct correct sized memory regions for the downstream components.
- name: ticks_Until_Timeout
- name: Ticks_Until_Timeout
type: Natural
description: The component will wait until it has received at least this many ticks before reporting a timeout error while waiting for a parameter update/fetch response from either the working or default parameter components. For example, if the component is attached to a 10Hz rate group and this value is set to 7, then the component will wait between 700 and 800 ms before declaring a timeout error from an unresponsive downstream component.
connectors:
###################################
# Invokee Connectors
###################################
- description: The component should be attached to a periodic tick that is used to timeout waiting for a parameter update/fetch response. See the ticks_Until_Timeout initialization parameter.
name: Timeout_Tick_Recv_Sync
type: Tick.T
kind: recv_sync
- description: The command receive connector.
type: Command.T
kind: recv_async
- description: Parameter update/fetch responses are returned synchronously on this connector. The component waits internally for this response, or times out if the response is not received in time.
type: Parameters_Memory_Region_Release.T
kind: recv_sync
###################################
# Invoker Connectors
###################################
- description: This connector is used to send the command response back to the command router.
type: Command_Response.T
kind: send
- name: Working_Parameters_Memory_Region_Send
description: Requests to update/fetch the working parameters are made on this connector.
type: Parameters_Memory_Region.T
kind: send
- name: Default_Parameters_Memory_Region_Send
- name: Primary_Parameters_Memory_Region_Send
description: Requests to update/fetch the default parameters are made on this connector.
type: Parameters_Memory_Region.T
kind: send
- description: Parameter update/fetch responses are returned synchronously on this connector. The component waits internally for this response, or times out if the response is not received in time.
type: Parameters_Memory_Region_Release.T
kind: recv_sync
- name: Redundant_Parameters_Memory_Region_Send
description: Requests to update/fetch the default parameters are made on this connector.
type: Parameters_Memory_Region.T
kind: send
- description: The destination for fetched data products to be sent to.
type: Data_Product.T
kind: send
- description: The event send connector
type: Event.T
kind: send
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description: Data products for the Parameter Manager component
data_products:
- name: Validation_Status
description: The validation status with timestamp and last table ID/version.
type: Packed_Validation.T
16 changes: 14 additions & 2 deletions src/components/parameter_manager/parameter_manager.events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ description: Events for the Parameter Manager component.
events:
- name: Starting_Parameter_Table_Copy
description: Starting parameter table copy from source to destination.
param_type: Packed_Parameter_Table_Copy_Type.T
param_type: Parameter_Manager_Table_Header.T
- name: Finished_Parameter_Table_Copy
description: Finished parameter table copy from source to destination, without errors.
param_type: Packed_Parameter_Table_Copy_Type.T
param_type: Parameter_Manager_Table_Header.T
- name: Invalid_Command_Received
description: A command was received with invalid parameters.
param_type: Invalid_Command_Info.T
Expand All @@ -15,6 +15,18 @@ events:
- name: Parameter_Table_Copy_Failure
description: A parameter table copy failed.
param_type: Parameters_Memory_Region_Release.T
- name: Working_Table_Update_Failure
description: A parameter table copy to the working table failed.
param_type: Packed_Validation_Header.T
- name: Primary_Table_Update_Failure
description: A parameter table copy to the primary table failed.
param_type: Packed_Validation_Header.T
- name: Command_Dropped
description: A command was dropped due to a full queue.
param_type: Command_Header.T
- name: Table_Validation_Failure
description: A parameter table validation failed.
param_type: Packed_Validation_Header.T
- name: Table_Validation_Success
description: A parameter table validation was successful.
param_type: Packed_Validation_Header.T
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
description: The requirements for the Parameter Manager component are specified below.
requirements:
- text: The component shall copy a parameter table from default to working on command.
- text: The component shall copy a parameter table from working to default on command.
- text: The component shall copy a parameter table from a command payload to default and working regions, on command.
Loading
Loading