class ugcs::vsm::Device

Overview

#include <device.h>

class Device: public std::enable_shared_from_this< Device >
{
public:
    // typedefs

    typedef std::shared_ptr<Device> Ptr;
    typedef std::weak_ptr<Device> Weak_ptr;
    typedef Callback_proxy<void, std::vector<Property::Ptr>> Command_handler;
    typedef Callback_proxy<void, uint32_t, Proto_msg_ptr> Response_sender;

    // classes

    class Commit_scope;

    // construction

    Device(
        proto::Device_type type,
        Request_processor::Ptr processor = nullptr,
        Request_completion_context::Ptr completion_ctx = nullptr
        );

    Device(const Device&);

    // methods

    template <typename... Args>
    static Ptr Create(Args&&... args);

    static void Set_failsafe_actions(
        Property::Ptr p,
        std::initializer_list<proto::Failsafe_action> actions
        );

    void Enable();
    void Disable();
    bool Is_enabled();

    void On_ucs_message(
        ugcs::vsm::proto::Vsm_message message,
        Response_sender completion_handler = Response_sender(),
        ugcs::vsm::Request_completion_context::Ptr completion_ctx = nullptr
        );

    void Register(ugcs::vsm::proto::Vsm_message&);

    template <typename Type>
    Property::Ptr Set_property(
        const std::string& name,
        Type value,
        proto::Field_semantic semantic = proto::FIELD_SEMANTIC_DEFAULT
        );

    uint32_t Get_session_id();
    Request_completion_context::Ptr Get_completion_ctx();
    void Register();
    void Unregister();
    bool Is_registered();
    std::string Dump_command(const ugcs::vsm::proto::Device_command&);
    Subsystem::Ptr Add_subsystem(proto::Subsystem_type);
    Request_processor::Ptr Get_processing_ctx();
    virtual void Handle_ucs_info(std::vector<Ucs_info>);
};

// direct descendants

class Adsb_vehicle;
class Vehicle;

Detailed Documentation

Typedefs

typedef std::shared_ptr<Device> Ptr

Pointer type.

typedef std::weak_ptr<Device> Weak_ptr

Pointer type.

typedef Callback_proxy<void, uint32_t, Proto_msg_ptr> Response_sender

Completion handler type of the request.

Construction

Device(const Device&)

Disable copying.

Methods

template <typename... Args>
static Ptr Create(Args&&... args)

Create an instance.

void Enable()

Enable the instance.

Should be called right after vehicle instance creation.

void Disable()

Disable the instance.

Should be called prior to intention to delete the instance.

bool Is_enabled()

Vehicle enable/disable status.

void On_ucs_message(
    ugcs::vsm::proto::Vsm_message message,
    Response_sender completion_handler = Response_sender(),
    ugcs::vsm::Request_completion_context::Ptr completion_ctx = nullptr
    )

Command has arrived from UCS and should be executed by the vehicle.

Request_completion_context::Ptr Get_completion_ctx()

Get default completion context of the device.

void Register()

Register device instance to UCS processor.

After registration is done, UCS servers sees that new vehicle is available.

void Unregister()

Unregister device instance from UCS processor.

bool Is_registered()

Returns true if vehicle is registered with cucs_processor.

Request_processor::Ptr Get_processing_ctx()

Get default processing context of the vehicle.

virtual void Handle_ucs_info(std::vector<Ucs_info>)

Called when number of ucs connections change.

Called when:

  • device registration succeeds via particular connection.

  • some ucs connection terminates before vehicle is unregistered. Device unregistration does not have response thus it can be considered unregistered as soon as Unregister() is called.

ucs_data : list of ucs connections on which device is currently registered.