VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ugcs::vsm::Device Class Reference
Inheritance diagram for ugcs::vsm::Device:
Adsb_vehicle ugcs::vsm::Vehicle

Classes

class  Commit_scope
 

Public Types

typedef std::shared_ptr< DevicePtr
 Pointer type.
 
typedef std::weak_ptr< DeviceWeak_ptr
 Pointer type.
 
typedef Callback_proxy< void,
std::vector< Property::Ptr > > 
Command_handler
 
typedef Callback_proxy< void,
uint32_t, Proto_msg_ptr > 
Response_sender
 Completion handler type of the request. More...
 

Public Member Functions

 Device (proto::Device_type type, Request_processor::Ptr processor=nullptr, Request_completion_context::Ptr completion_ctx=nullptr)
 
void Enable ()
 Enable the instance. More...
 
void Disable ()
 Disable the instance. More...
 
bool Is_enabled ()
 Vehicle enable/disable status. More...
 
 Device (const Device &)=delete
 Disable copying. More...
 
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.
 
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 ()
 Get default completion context of the device. More...
 
void Register ()
 Register device instance to UCS processor. More...
 
void Unregister ()
 Unregister device instance from UCS processor. More...
 
bool Is_registered ()
 Returns true if vehicle is registered with ucs. More...
 
std::string Dump_command (const ugcs::vsm::proto::Device_command &)
 
Subsystem::Ptr Add_subsystem (proto::Subsystem_type)
 

Static Public Member Functions

template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
static void Set_failsafe_actions (Property::Ptr p, std::initializer_list< proto::Failsafe_action > actions)
 

Protected Member Functions

Request_processor::Ptr Get_processing_ctx ()
 Get default processing context of the vehicle. More...
 
virtual void On_enable ()
 Device enable event handler. More...
 
virtual void On_disable ()
 Device disable event handler. More...
 
virtual void Handle_ucs_command (Ucs_request::Ptr request)
 Message from ucs arrived called by VSM SDK in vehicle context and should be overridden by user code.
 
void Report_progress (Ucs_request::Ptr request, float progress=-1.0, const std::string &description=std::string())
 Sends Device_response with status code==STATUS_IN_PROGRESS with optional progress and description. More...
 
void Send_ucs_message (Proto_msg_ptr msg)
 
Vsm_command::Ptr Get_command (int id)
 
void Add_status_message (const std::string &m)
 
void Commit_to_ucs (bool log_message=false)
 

Protected Attributes

const proto::Device_type device_type
 
Request_processor::Ptr processor
 
Request_completion_context::Ptr completion_ctx
 
std::chrono::time_point
< std::chrono::system_clock > 
begin_of_epoch
 
std::vector< Subsystem::Ptrsubsystems
 

Detailed Description

Member Typedef Documentation

typedef Callback_proxy<void, uint32_t, Proto_msg_ptr> ugcs::vsm::Device::Response_sender

Completion handler type of the request.

Constructor & Destructor Documentation

ugcs::vsm::Device::Device ( const Device )
delete

Disable copying.

Member Function Documentation

template<typename... Args>
static Ptr ugcs::vsm::Device::Create ( Args &&...  args)
inlinestatic

Create an instance.

void ugcs::vsm::Device::Disable ( )

Disable the instance.

Should be called prior to intention to delete the instance.

void ugcs::vsm::Device::Enable ( )

Enable the instance.

Should be called right after vehicle instance creation.

Request_completion_context::Ptr ugcs::vsm::Device::Get_completion_ctx ( )

Get default completion context of the device.

Examples:
hello_world_vsm.cpp.
Request_processor::Ptr ugcs::vsm::Device::Get_processing_ctx ( )
protected

Get default processing context of the vehicle.

bool ugcs::vsm::Device::Is_enabled ( )
inline

Vehicle enable/disable status.

bool ugcs::vsm::Device::Is_registered ( )

Returns true if vehicle is registered with ucs.

virtual void ugcs::vsm::Device::On_disable ( )
inlineprotectedvirtual

Device disable event handler.

Can be overridden by derived class, if necessary. Always called in Device context.

Reimplemented in ugcs::vsm::Vehicle.

Examples:
hello_world_vsm.cpp.
virtual void ugcs::vsm::Device::On_enable ( )
inlineprotectedvirtual

Device enable event handler.

Can be overridden by derived class, if necessary. Always called in Device context.

Reimplemented in ugcs::vsm::Vehicle.

Examples:
hello_world_vsm.cpp.
void ugcs::vsm::Device::Register ( )

Register device instance to UCS processor.

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

void ugcs::vsm::Device::Report_progress ( Ucs_request::Ptr  request,
float  progress = -1.0,
const std::string &  description = std::string() 
)
protected

Sends Device_response with status code==STATUS_IN_PROGRESS with optional progress and description.

Used to display progress-bar and/or some description.

Parameters
progressfloat in range [0..1]. If progress < 0, it is not sent.
descriptionDescription of current progress. Not sent if empty.
void ugcs::vsm::Device::Unregister ( )

Unregister device instance from UCS processor.


The documentation for this class was generated from the following file: