H3D API  2.4.1
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
H3D::DeviceLog Class Reference

DeviceLog records haptic device data to a binary data file. More...

#include <H3D/DeviceLog.h>

Inheritance diagram for H3D::DeviceLog:
Inheritance graph

Public Member Functions

 DeviceLog (Inst< SFNode > _metadata=0, Inst< MFString > _url=0, Inst< SFInt32 > _frequency=0, Inst< MFInt32 > _deviceIndex=0, Inst< SFBool > _logBinary=0, Inst< MFString > _logData=0, Inst< OnClose > _close=0)
 Constructor.
 
virtual ~DeviceLog ()
 Destructor. More...
 
virtual void traverseSG (TraverseInfo &ti)
 Adds the effect to be rendered in the haptics loop. More...
 
- Public Member Functions inherited from H3D::H3DForceEffect
 H3DForceEffect (Inst< SFNode > _metadata=0, Inst< MFInt32 > _deviceIndex=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DChildNode
 X3DChildNode (Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL)
 Returns a new instance of this node type with the same state as this one. More...
 
virtual ~Node ()
 Destructor.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More...
 
void setProtoInstanceParent (X3DPrototypeInstance *p)
 Set the X3DPrototypeInstance this node is the the root node if applicaple.
 
virtual void render ()
 the render() function is used for the depth-first rendering traversal of the scene-graph. More...
 
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the Node. More...
 
virtual void closestPoint (const Vec3f &p, NodeIntersectResult &result)
 Find closest point on Node to p. More...
 
virtual bool movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result)
 Detect collision between a moving sphere and the Node. More...
 
virtual string defaultXMLContainerField ()
 Returns the default xml containerField attribute value. More...
 
virtual FieldgetField (const string &_name) const
 return a pointer to the field specified by name within this instance
 
int addDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
int removeDestructCallback (void(*func)(Node *, void *), void *args)
 Add a callback function to be run on destruction of node. More...
 
- Public Member Functions inherited from H3D::X3DUrlObject
 X3DUrlObject (Inst< MFString > _url=0)
 Constructor.
 
virtual LoadStatus loadStatus ()
 The loadStatus function returns the status of the loading of the current urls in order to be used with the LoadSensor node.
 
virtual H3DFloat loadProgress ()
 The loadProgress() functions returns a value between 0 and 1 indicating how much of the current url has been loaded. More...
 
void setURLUsed (const string &_url_used)
 Set the url that is currently loaded.
 
const string & getURLUsed ()
 Get the url that is currently loaded.
 
void setURLBase (const string &_url_base)
 Set the url base address.
 
const string & getURLBase ()
 Get the current url base address.
 
string resolveURLAsFile (const string &url, bool *is_tmp_file=NULL)
 Get the url as a local file.
 
string resolveURLAsString (const string &url)
 Get the content of the URL as a string.
 
bool removeTmpFile (const string &file)
 Remove a tmpfile with the given name. More...
 

Public Attributes

H3DUniquePtr< SFInt32frequency
 The log frequency. More...
 
H3DUniquePtr< SFBoollogBinary
 If true the logging will be done to a binary file. More...
 
H3DUniquePtr< MFStringlogData
 Specifies what to log. More...
 
H3DUniquePtr< OnClose > close
 If set to true the log file is closed immediately. More...
 
- Public Attributes inherited from H3D::H3DForceEffect
H3DUniquePtr< MFInt32deviceIndex
 A list of indices that tells which haptics devices to render the force on. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 
- Public Attributes inherited from H3D::X3DUrlObject
H3DUniquePtr< MFStringurl
 The urls in decreasing order of preference.
 

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::H3DForceEffect
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 

Protected Member Functions

void createLogForceEffect (int index)
 Internal function used to create a log force effect for the haptics device of the given index.
 
virtual HAPI::DeviceLog * createHAPIDeviceLog (const std::string &_url)
 Create a new instance of the HAPI DeviceLog class used to implement the recording.
 
HAPI::DeviceLog::LogTypeVector getLogTypes ()
 Returns a list of parameters to be logged by the HAPI DeviceLog class.
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 
- Protected Member Functions inherited from H3D::X3DUrlObject
string resolveURL (const string &_url, bool return_contents, bool *is_tmp_file=NULL)
 Helper function for resolveURLAs*() functions.
 
void addInlinePrefix (const string &s)
 Add a inline prefix that this node supports.
 
int getInlinedContentOffset (const std::string &url)
 If the URL contains any inline prefix, return the index of the start of the inlined content. More...
 

Protected Attributes

AutoRefVector< HAPI::DeviceLog > log_force_effect
 Internal haptic force effect instance.
 
- Protected Attributes inherited from H3D::X3DUrlObject
string url_used
 If loadStatus() returns LOADED this string should contain the url that is loaded. More...
 
string url_base
 The base URL for urls in this url object. More...
 
list< string > supported_inline_prefixes
 A list of inline prefixes that are supported by this url object. More...
 

Additional Inherited Members

- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Public Types inherited from H3D::X3DUrlObject
enum  LoadStatus { INIT , LOADED , LOADING , FAILED }
 The load status of the given url. More...
 
- Static Public Member Functions inherited from H3D::Node
static unsigned int nrNodesAlive ()
 Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
 
static int nrNodesCreated ()
 Returns the number of nodes created in total since the start of the program.
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 

Detailed Description

DeviceLog records haptic device data to a binary data file.

It is essentially a ForceEffect that always calculates a zero force and logs data for the haptics device.

Warning. If any of the fields of this node changes ( with the exception of metadata ) a new log will be created and possibly old data in the file(s) pointed to in the url field will be overwritten.

For information on how to read the log created by this node see comments for the logBinary field.

Examples:

Constructor & Destructor Documentation

◆ ~DeviceLog()

DeviceLog::~DeviceLog ( )
virtual

Destructor.

Note: It is guaranteed that the logging file will be flushed and closed once the DeviceLog node is destroyed.

Member Function Documentation

◆ traverseSG()

void DeviceLog::traverseSG ( TraverseInfo ti)
virtual

Adds the effect to be rendered in the haptics loop.

Parameters
tiThe TraverseInfo object containing information about the traversal.

Reimplemented from H3D::Node.

References H3D::TraverseInfo::addForceEffect(), createLogForceEffect(), H3D::H3DForceEffect::deviceIndex, H3D::TraverseInfo::getHapticsDevices(), H3D::TraverseInfo::hapticsEnabled(), log_force_effect, and H3DUtil::AutoRefVector< class >::size().

Member Data Documentation

◆ close

H3DUniquePtr< OnClose > H3D::DeviceLog::close

If set to true the log file is closed immediately.

Access type: inputOnly

◆ frequency

H3DUniquePtr< SFInt32 > H3D::DeviceLog::frequency

The log frequency.

Access type: initializeOnly
Default value: 100

Referenced by DeviceLog().

◆ logBinary

H3DUniquePtr< SFBool > H3D::DeviceLog::logBinary

If true the logging will be done to a binary file.

If false The logging will be done to a ASCII-text file. When logging to a text file the first line will contain information about what will be logged encoded as strings which is one of the strings which are valid for the logData field. The ALL string will never show up. When logging to a binary file the file format will be the following. The first bytes should be read as characters into a string. When two consecutive '\0'-characters are found the section with different strings are over. These strings correspond to the first line in a text file. When the first strings are read the data that follows will be in the order listed by the strings. In an ascii-file each line will contain one log entry for each of the strings, each number is separated by space. In the binary file the numbers will follow eachother without any separating bytes. The encoding will be as follows: TIME - double TIMESTAMP - double TRACKER_POSITION - double double double TRACKER_ORIENTATION - double double double double TRACKER_VELOCITY - double double double DEVICE_POSITION - double double double DEVICE_ORIENTATION - double double double double DEVICE_VELOCITY - double double double BUTTONS - int FORCE - double double double TORQUE - double double double

The data type of the containing value in the field corresponding to the value decides how to interpret the value when reading from file later. For example, TRACKER_POSITION could be put in an Vec3f type. For an example on how to read from a binary log file see HAPI::DeviceLog.

Access type: initializeOnly
Default value: false

Referenced by DeviceLog().

◆ logData

H3DUniquePtr< MFString > H3D::DeviceLog::logData

Specifies what to log.

The allowed values correspond to the following. ALL - All possible information will be stored. TIME - The time of logging. The first log entry counts as time 0. TRACKER_POSITION - The trackerPosition field of H3DHapticsDevice. TRACKER_ORIENTATION - The trackerOrientation field of H3DHapticsDevice. TRACKER_VELOCITY - The trackerVelocity field of H3DHapticsDevice. DEVICE_POSITION - The devicePosition field of H3DHapticsDevice. DEVICE_ORIENTATION - The deviceOrientation field of H3DHapticsDevice. DEVICE_VELOCITY - The deviceVelocity field of H3DHapticsDevice. BUTTONS - The buttons field of H3DHapticsDevice. FORCE - The force field of H3DHapticsDevice. TORQUE - The torque field of H3DHapticsDevice.

Access type: initializeOnly
Default value: "ALL"
Allowed values: "ALL", "TIME", "TRACKER_POSITION", "TRACKER_ORIENTATION", "TRACKER_VELOCITY" "DEVICE_POSITION", "DEVICE_ORIENTATION" "DEVICE_VELOCITY", "BUTTONS" "FORCE", "TORQUE","TIMESTAMP"

Referenced by DeviceLog(), and getLogTypes().


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