-- 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.AddTwoInts_package.all;

package ros_config is
    
    -- Period of ros system clock
    constant ROS_CLOCK_PERIOD   : time := 50 ns;
    -- IPv4 Address of ROS System [Default 192.168.0.130]
    constant ROS_ADDRESS    : std_logic_vector(IPv4_ADDRESS_WIDTH-1 downto 0) := x"C0A80082";
    -- Random Key used to generate GUIDs
    constant ROS_RAND_KEY   : std_logic_vector(47 downto 0) := x"6E6592234DB4";
    
    constant NUM_NODES : natural := 1;
    
    constant ROS_NODES : ROS_NODE_ARRAY_TYPE(0 to NUM_NODES-1) := (
        0 => (
            name            => gen_user_string("add_two_ints_client"),
            namespace       => gen_user_string(""),
            domain_id       => 0,
            NUM_PUBS        => 0,
            NUM_SUBS        => 0,
            NUM_SERVICES    => 1,
            NUM_ACTIONS     => 0
        )
    );
    
    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) := (
        0 => (
            node_id     => 0,
            SERVICENAME => gen_user_string("add_two_ints"),
            RQ_TYPENAME => gen_user_string("example_interfaces::srv::dds_::AddTwoInts_Request_"),
            RR_TYPENAME => gen_user_string("example_interfaces::srv::dds_::AddTwoInts_Response_"),
            QOS         => ROS_QOS_PROFILE_TRANSIENT,
            MAX_RQ_SIZE => MAX_ADDTWOINTS_RQ_SIZE,
            MAX_RR_SIZE => MAX_ADDTWOINTS_RR_SIZE,
            is_client   => TRUE
        )
    );
    
    constant ROS_ACTIONS : ROS_ACTION_ARRAY_TYPE(0 to NUM_ACTIONS-1) := (
        others => (
            node_id             => 0,
            ACTIONNAME          => gen_user_string(""),
            GOAL_RQ_TYPENAME    => gen_user_string(""),
            GOAL_RR_TYPENAME    => gen_user_string(""),
            RESULT_RQ_TYPENAME  => gen_user_string(""),
            RESULT_RR_TYPENAME  => gen_user_string(""),
            FEEDBACK_TYPENAME   => gen_user_string(""),
            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    => 0,
            MAX_GOAL_RR_SIZE    => 0,
            MAX_RESULT_RQ_SIZE  => 0,
            MAX_RESULT_RR_SIZE  => 0,
            MAX_FEEDBACK_SIZE   => 0,
            is_client           => FALSE,
            enable_feedback     => TRUE
        )
    );
    
    -- Defines sensible RTPS timings for simulation
    constant SIMULATION_TIMING : boolean := TRUE;
end package;