-- altera vhdl_input_version vhdl_2008
-- XXX: QSYS Fix (https://www.intel.com/content/www/us/en/support/programmable/articles/000079458.html)

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

use work.rtps_package.all;
use work.ros_package.all;
use work.Fibonacci_package.all;

package ros_config is
    
    -- Period of ros system clock
    constant ROS_CLOCK_PERIOD   : time := 20 ns; -- 50 MHz
    -- IPv4 Address of ROS System [192.168.0.90]
    constant ROS_ADDRESS    : std_logic_vector(IPv4_ADDRESS_WIDTH-1 downto 0) := x"C0A8005A";
    -- Random Key used to generate GUIDs
    constant ROS_RAND_KEY   : std_logic_vector(47 downto 0) := x"E2A53AA91CC5";
    
    constant NUM_NODES : natural := 1;
    
    constant ROS_NODES : ROS_NODE_ARRAY_TYPE(0 to NUM_NODES-1) := (
        0 => (
            name            => gen_user_string("fibonacci_action_server"),
            namespace       => gen_user_string(""),
            domain_id       => 0,
            NUM_PUBS        => 0,
            NUM_SUBS        => 0,
            NUM_SERVICES    => 0,
            NUM_ACTIONS     => 1
        )
    );
    
    constant NUM_PUBS       : natural := get_num_pubs(ROS_NODES);
    constant NUM_SUBS       : natural := get_num_subs(ROS_NODES);
    constant NUM_SERVICES   : natural := get_num_services(ROS_NODES);
    constant NUM_ACTIONS    : natural := get_num_actions(ROS_NODES);
    
    constant ROS_PUBLICATIONS : ROS_TOPIC_ARRAY_TYPE(0 to NUM_PUBS-1) := (
        others => (
            node_id     => 0,
            TOPICNAME   => gen_user_string(""),
            TYPENAME    => gen_user_string(""),
            QOS         => ROS_QOS_PROFILE_DEFAULT,
            MAX_SIZE    => 0
        )
    );
    
    constant ROS_SUBSCRIPTIONS : ROS_TOPIC_ARRAY_TYPE(0 to NUM_SUBS-1) := (
        others => (
            node_id     => 0,
            TOPICNAME   => gen_user_string(""),
            TYPENAME    => gen_user_string(""),
            QOS         => ROS_QOS_PROFILE_DEFAULT,
            MAX_SIZE    => 0
        )
    );
    
    constant ROS_SERVICES : ROS_SERVICE_ARRAY_TYPE(0 to NUM_SERVICES-1) := (
        others => (
            node_id     => 0,
            SERVICENAME => gen_user_string(""),
            RQ_TYPENAME => gen_user_string(""),
            RR_TYPENAME => gen_user_string(""),
            QOS         => ROS_QOS_PROFILE_SERVICES_DEFAULT,
            MAX_RQ_SIZE => 0,
            MAX_RR_SIZE => 0,
            is_client   => FALSE
        )
    );
    
    constant ROS_ACTIONS : ROS_ACTION_ARRAY_TYPE(0 to NUM_ACTIONS-1) := (
        0 => (
            node_id             => 0,
            ACTIONNAME          => gen_user_string("fibonacci"),
            GOAL_RQ_TYPENAME    => gen_user_string("action_tutorials_interfaces::action::dds_::Fibonacci_SendGoal_Request_"),
            GOAL_RR_TYPENAME    => gen_user_string("action_tutorials_interfaces::action::dds_::Fibonacci_SendGoal_Response_"),
            RESULT_RQ_TYPENAME  => gen_user_string("action_tutorials_interfaces::action::dds_::Fibonacci_GetResult_Request_"),
            RESULT_RR_TYPENAME  => gen_user_string("action_tutorials_interfaces::action::dds_::Fibonacci_GetResult_Response_"),
            FEEDBACK_TYPENAME   => gen_user_string("action_tutorials_interfaces::action::dds_::Fibonacci_FeedbackMessage_"),
            GOAL_QOS            => ROS_QOS_PROFILE_SERVICES_DEFAULT,
            RESULT_QOS          => ROS_QOS_PROFILE_SERVICES_DEFAULT,
            FEEDBACK_QOS        => ROS_QOS_PROFILE_DEFAULT,
            CANCEL_QOS          => ROS_QOS_PROFILE_SERVICES_DEFAULT,
            MAX_GOAL_RQ_SIZE    => G_RQ_MAX_FIBONACCI_SIZE,
            MAX_GOAL_RR_SIZE    => G_RR_MAX_FIBONACCI_SIZE,
            MAX_RESULT_RQ_SIZE  => R_RQ_MAX_FIBONACCI_SIZE,
            MAX_RESULT_RR_SIZE  => R_RR_MAX_FIBONACCI_SIZE,
            MAX_FEEDBACK_SIZE   => F_MAX_FIBONACCI_SIZE,
            is_client           => FALSE,
            enable_feedback     => TRUE
        )
    );
    
    -- Defines sensible RTPS timings for simulation
    constant SIMULATION_TIMING : boolean := FALSE;
end package;