automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Classes | Public Member Functions | List of all members
CANGenPlugin Class Reference

CAN frames generator plug-in for the AMB CAN Simulator. More...

#include <cangenplugin.h>

Inheritance diagram for CANGenPlugin:
AmbPluginImpl CANObserver WebSocketsObserver

Public Member Functions

 CANGenPlugin (AbstractRoutingEngine *re, const std::map< std::string, std::string > &config, AbstractSource &parent)
 
const std::string uuid () const
 
void propertyChanged (AbstractPropertyType *value)
 
AsyncPropertyReplysetProperty (const AsyncSetPropertyRequest &request)
 setProperty is called when a sink requests to set a value for a given property. This is only called if the source supports the Set Operation.
 
virtual void errorOccured (CANObserver::CANError error)
 
virtual void standardFrameReceived (const can_frame &frame)
 
virtual void extendedFrameReceived (const can_frame &frame)
 
virtual void errorFrameReceived (const can_frame &frame)
 
virtual void remoteTransmissionRequest (const can_frame &frame)
 
virtual void timeoutDetected (const can_frame &frame)
 
virtual void init ()
 
void dataReceived (lws *socket, const char *data, size_t len)
 
- Public Member Functions inherited from AmbPluginImpl
 AmbPluginImpl (AbstractRoutingEngine *re, const map< string, string > &config, AbstractSource &parent)
 
virtual void getPropertyAsync (AsyncPropertyReply *reply)
 getPropertyAsync is called when a sink requests the value for given property. This is only called if the source supports the Get operation.
 
virtual void getRangePropertyAsync (AsyncRangePropertyReply *reply)
 getRangePropertyAsync is called when a sink requests a series of values for a given property within a specified time or sequencial range. This will only be called if the source support the Ranged Operation.
 
virtual void subscribeToPropertyChanges (const VehicleProperty::Property &property)
 subscribeToPropertyChanges is called when a sink requests a subscription. Source plugins can keep track of subscriptions and may wish to sleep if there are no subscriptions.
 
virtual void unsubscribeToPropertyChanges (const VehicleProperty::Property &property)
 unsubscribeToPropertyChanges is called when a sink requests to unsubscribe from a given property's changes.
 
virtual PropertyList supported () const
 supported is called by the routingEngine to understand what properties this source supports.
 
virtual int supportedOperations () const
 supportedOperations
 
virtual PropertyInfo getPropertyInfo (const VehicleProperty::Property &property)
 getPropertyInfo used to return specific information about a property. The source should override this otherwise a PropertyInfo::invalid() will be returned for the property
 
virtual void supportedChanged (const PropertyList &supportedProperties)
 
template<typename T >
void setValue (std::shared_ptr< AbstractPropertyType > property, T value)
 setValue of a property
 

Additional Inherited Members

- Public Types inherited from CANObserver
enum  CANError { GENERAL_ERROR = 0 }
 
- Protected Types inherited from AmbPluginImpl
typedef std::map< Zone::Type,
std::shared_ptr
< AbstractPropertyType > > 
ZonePropertyType
 
- Protected Member Functions inherited from AmbPluginImpl
virtual AbstractPropertyTypefindPropertyType (const VehicleProperty::Property &propertyName, const Zone::Type &zone=Zone::None)
 
std::shared_ptr
< AbstractPropertyType
addPropertySupport (Zone::Type zone, std::function< AbstractPropertyType *(void)> typeFactory, std::string sourceUuid="")
 
template<class T >
std::shared_ptr
< AbstractPropertyType
addPropertySupport (Zone::Type zone)
 
- Protected Attributes inherited from AmbPluginImpl
AbstractSourcesource
 
AbstractRoutingEngineroutingEngine
 
std::map
< VehicleProperty::Property,
ZonePropertyType
properties
 
std::map< std::string,
std::string > 
configuration
 

Detailed Description

CAN frames generator plug-in for the AMB CAN Simulator.

On startup it subscribe and reads 'MappingTable' property from CANSimPlugin, parses it and build own mapping table(AMB property to CAN Id map) of all properties from CANSimPlugin that can be simulated.
In parallel to building mapping table of the AMB properties and their corresponding CAN Ids it starts listening for javascrip Simulator API commands on WebSocket port 23001.

See Also
libcanbus static library

Constructor & Destructor Documentation

CANGenPlugin::CANGenPlugin ( AbstractRoutingEngine re,
const std::map< std::string, std::string > &  config,
AbstractSource parent 
)
Parameters
reAbstractRoutingEngine
configMap of the configuration string values loaded on startup from AMB configuration file
parentAmbPlugin instance

Member Function Documentation

CANGenPlugin::dataReceived ( lws *  socket,
const char *  data,
size_t  len 
)
virtual

Called when data received from libwebsockets

Parameters
socketlws* to be used to send any reply.
dataReceived data pointer.
lenLength of the data.
Returns
None

Implements WebSocketsObserver.

CANGenPlugin::errorFrameReceived ( const can_frame &  frame)
virtual

Called when error frame was received from the bus.

Parameters
frameError frame

Implements CANObserver.

CANGenPlugin::errorOccured ( CANObserver::CANError  error)
virtual

Called when error occurred on the bus.

Parameters
errorBus error code

Implements CANObserver.

CANGenPlugin::extendedFrameReceived ( const can_frame &  frame)
virtual

Called when extended frame was is received from the bus.

Parameters
frameReceived frame

Implements CANObserver.

CANGenPlugin::init ( )
virtual

Second phase of the plugin initialization.

Reimplemented from AmbPluginImpl.

void CANGenPlugin::propertyChanged ( AbstractPropertyType value)
virtual

propertyChanged is called when a subscribed to property changes.

See Also
AbstractRoutingEngine::subscribeToPropertyChanges()
Parameters
valuevalue of the property that changed. this is a temporary pointer that will be destroyed. Do not destroy it. If you need to store the value use value.anyValue(), value.value<T>() or value->copy() to copy.

Reimplemented from AmbPluginImpl.

CANGenPlugin::remoteTransmissionRequest ( const can_frame &  frame)
virtual

Called when remote transmission frame was received from the bus.

Parameters
frameRTR frame

Implements CANObserver.

AsyncPropertyReply* CANGenPlugin::setProperty ( const AsyncSetPropertyRequest request)
virtual

setProperty is called when a sink requests to set a value for a given property. This is only called if the source supports the Set Operation.

Parameters
requestthe requested property to set.
Returns
returns a pointer to the new value for the property.

Reimplemented from AmbPluginImpl.

CANGenPlugin::standardFrameReceived ( const can_frame &  frame)
virtual

Called when standard frame was is received from the bus.

Parameters
frameReceived frame

Implements CANObserver.

CANGenPlugin::timeoutDetected ( const can_frame &  frame)
virtual

Called when timeout was detected for a cyclic message.

Parameters
frame

Implements CANObserver.

const std::string CANGenPlugin::uuid ( ) const
inlinevirtual

uuid() is a unique identifier of the plugin

Returns
a guid-style unique identifier

Implements AmbPluginImpl.


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