FREEDM DGI
Classes | Typedefs | Functions | Variables
freedm::broker::device Namespace Reference

Classes

class  CAdapterFactory
 Handles the creation of adapters and their associated devices. More...
 
class  CDevice
 Defines the interface used to access physical hardware. More...
 
class  CDeviceBuilder
 Handles construction of all device objects used by the DGI. More...
 
class  CDeviceManager
 The interface between broker modules and the device architecture. More...
 
class  CFakeAdapter
 Physical adapter device interface that stores settings in itself. More...
 
class  CMqttAdapter
 Provides an interface for communicating with an MQTT broker. More...
 
class  CMqttMessage
 
class  COpenDssAdapter
 Provides an interface for communicating with a opendss simulation model. More...
 
class  CPnpAdapter
 PNP adapter that maintains a TCP server for a set of plug-and-play devices. More...
 
class  CRtdsAdapter
 Provides an interface for communicating with a RTDS simulation model. More...
 
class  CTcpServer
 TCP server that handles a single client connection. More...
 
struct  DeviceInfo
 Stores the internal structure of a device object. More...
 
struct  EBadRequest
 Used when a device controller sends a bad packet. More...
 
struct  EDgiConfigError
 Used when the DGI has been misconfigured. More...
 
struct  EDuplicateSession
 Used when the adapter factory already has an open session for a controller. More...
 
class  IAdapter
 Physical adapter device interface. More...
 
class  IBufferAdapter
 Buffer adapter device interface. More...
 

Typedefs

typedef std::pair< const std::string, const std::string > DeviceSignal
 Type of the unique identifier for device values. More...
 
typedef boost::optional< boost::system::error_code > OptionalError
 Convenience typedef for the SetResult function. More...
 
typedef float SignalValue
 Type of the value for device signals. More...
 

Functions

 BOOST_STATIC_ASSERT (sizeof(SignalValue)==4)
 
std::ostream & operator<< (std::ostream &os, const DeviceInfo &info)
 Outputs the device information to the passed output stream. More...
 
void SetResult (boost::shared_ptr< OptionalError > status, const boost::system::error_code &error)
 Callback function for the timed synchronous operations. More...
 
vector< string > split (string str, char delimiter)
 
template<typename ReadStream , typename BufferSequence >
void TimedRead (ReadStream &stream, const BufferSequence &buffer, unsigned int duration)
 
template<typename ReadStream , typename Allocator >
void TimedReadUntil (ReadStream &stream, boost::asio::basic_streambuf< Allocator > &buffer, const std::string &delim, unsigned int duration)
 
template<typename WriteStream , typename BufferSequence >
void TimedWrite (WriteStream &stream, const BufferSequence &buffer, unsigned int duration)
 
template<typename WriteStream , typename Allocator >
void TimedWrite (WriteStream &stream, boost::asio::basic_streambuf< Allocator > &buffer, unsigned int duration)
 

Variables

const SignalValue NULL_COMMAND = std::pow(10, 8)
 Sent by the DGI to indicate it knows nothing about the state of a device. More...
 

Typedef Documentation

typedef std::pair<const std::string, const std::string> freedm::broker::device::DeviceSignal
typedef boost::optional<boost::system::error_code> freedm::broker::device::OptionalError

Function Documentation

freedm::broker::device::BOOST_STATIC_ASSERT ( sizeof(SignalValue = =4)
std::ostream & freedm::broker::device::operator<< ( std::ostream &  os,
const DeviceInfo info 
)

Outputs the device information structure to the passed stream.

Precondition:
None.
Postcondition:
Outputs each member variable of info on a separate line.
Parameters
osThe stream that the device information should output to.
infoThe device information to output to the stream.
Returns
A reference to the passed output stream.
Limitations:
None.
void freedm::broker::device::SetResult ( boost::shared_ptr< OptionalError status,
const boost::system::error_code &  error 
)

This function is meant to be used in conjunction with asynchronous calls to determine when a call has finished execution. Bind an asynchronous call to this function using an uninitialized boost::optional, and poll the first argument to test for completion.

Precondition:
The first argument should be uninitialized.
Postcondition:
The first argument will be set to the error code.
Parameters
statusThe optional variable that will store the error code.
errorThe error code of an asynchronous call bound to this function.
Limitations:
The optional variable will also be set in error cases when the asynchronous call fails. Check the value of the first argument to determine whether an error has occured.
vector<string> freedm::broker::device::split ( string  str,
char  delimiter 
)
template<typename ReadStream , typename BufferSequence >
void freedm::broker::device::TimedRead ( ReadStream &  stream,
const BufferSequence &  buffer,
unsigned int  duration 
)

A read that blocks until the buffer is full or a time duration expires.

Error Handling:
Throws std::runtime_error if either the read operation fails or the time duration expires.
Precondition:
The stream must receive data within the given time duration.
Postcondition:
The call will block until data is read from the stream.
Postcondition:
The result of the read will be stored in the passed buffer.
Parameters
streamThe read stream that will receive data.
bufferThe buffer to store the result of the read.
durationThe amount of time in milliseconds for the timeout.
Limitations:
None.
template<typename ReadStream , typename Allocator >
void freedm::broker::device::TimedReadUntil ( ReadStream &  stream,
boost::asio::basic_streambuf< Allocator > &  buffer,
const std::string &  delim,
unsigned int  duration 
)

A read that blocks until a delimiter is read or a time duration expires.

Error Handling:
Throws std::runtime_error if either the read operation fails or the time duration expires.
Precondition:
The stream must receive delimited data within the time duration.
Postcondition:
The call will block until the delimiter is read from the stream.
Postcondition:
The result of the read will be stored in the passed buffer.
Parameters
streamThe read stream that will receive delimited data.
bufferThe buffer to store the reuslt of the read.
delimThe delimiter that marks the end of the data.
durationThe amount of time in milliseconds for the timeout.
Limitations:
None.
template<typename WriteStream , typename BufferSequence >
void freedm::broker::device::TimedWrite ( WriteStream &  stream,
const BufferSequence &  buffer,
unsigned int  duration 
)

A write that blocks until either completion or a time duration expires.

Error Handling:
Throws std::runtime_error if the write operation fails or the time duration expires.
Precondition:
The write must complete within the given time duration.
Postcondition:
The call will block until the write is successful.
Parameters
streamThe write stream to receive the data.
bufferThe buffered data to write to the stream.
durationThe amount of time in milliseconds for the timeout.
Limitations:
None.
template<typename WriteStream , typename Allocator >
void freedm::broker::device::TimedWrite ( WriteStream &  stream,
boost::asio::basic_streambuf< Allocator > &  buffer,
unsigned int  duration 
)

A write that blocks until either completion or a time duration expires.

Error Handling:
Throws std::runtime_error if the write opertaion fails or the time duration expires.
Precondition:
The write must complete within the given time duration.
Postcondition:
The call will block until the write is successful.
Parameters
streamThe write stream to receive the data.
bufferThe buffered data to write to the stream.
durationThe amount of time in milliseconds for the timeout.
Limitations:
None.

Variable Documentation

const SignalValue freedm::broker::device::NULL_COMMAND = std::pow(10, 8)