cisst-saw
|
#include <mtsComponent.h>
Public Types | |
typedef mtsComponent | ThisType |
Public Member Functions | |
mtsComponent (const std::string &deviceName) | |
virtual | ~mtsComponent () |
const std::string & | GetName (void) const |
void | GetName (std::string &placeHolder) const |
void | SetName (const std::string &componentName) |
virtual void | Configure (const std::string &filename="") |
virtual void | Create (void) |
bool | CreateAndWait (double timeoutInSeconds) |
virtual void | Start (void) |
bool | StartAndWait (double timeoutInSeconds) |
virtual void | Suspend (void) |
virtual void | Kill (void) |
bool | KillAndWait (double timeoutInSeconds) |
virtual void | Startup (void) |
virtual void | Cleanup (void) |
mtsInterfaceProvided * | AddInterfaceProvided (const std::string &interfaceProvidedName, mtsInterfaceQueueingPolicy queueingPolicy=MTS_COMPONENT_POLICY) |
virtual mtsInterfaceProvided * | AddInterfaceProvidedWithoutSystemEvents (const std::string &interfaceProvidedName, mtsInterfaceQueueingPolicy queueingPolicy=MTS_COMPONENT_POLICY, bool isProxy=false) |
CISST_DEPRECATED mtsInterfaceProvided * | AddProvidedInterface (const std::string &interfaceProvidedName) |
virtual mtsInterfaceOutput * | AddInterfaceOutput (const std::string &interfaceOutputName) |
bool | InterfaceExists (const std::string &interfaceName, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_VERBOSE) const |
bool | InterfaceProvidedOrOutputExists (const std::string &interfaceName, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_VERBOSE) const |
bool | InterfaceRequiredOrInputExists (const std::string &interfaceName, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_VERBOSE) const |
mtsInterfaceProvided * | GetInterfaceProvided (const std::string &interfaceProvidedName) const |
mtsInterfaceOutput * | GetInterfaceOutput (const std::string &interfaceOutputName) const |
size_t | GetNumberOfInterfacesProvided (void) const |
size_t | GetNumberOfInterfacesOutput (void) const |
bool | RemoveInterfaceProvided (const std::string &interfaceProvidedName, const bool skipDisconnect=false) |
mtsInterfaceRequired * | AddInterfaceRequired (const std::string &interfaceRequiredName, mtsRequiredType isRequired=MTS_REQUIRED) |
virtual mtsInterfaceRequired * | AddInterfaceRequiredWithoutSystemEventHandlers (const std::string &interfaceRequiredName, mtsRequiredType isRequired=MTS_REQUIRED) |
CISST_DEPRECATED mtsInterfaceRequired * | AddRequiredInterface (const std::string &requiredInterfaceName) |
virtual mtsInterfaceInput * | AddInterfaceInput (const std::string &interfaceInputName) |
const mtsInterfaceProvided * | GetInterfaceProvidedFor (const std::string &interfaceRequiredName) |
mtsInterfaceRequired * | GetInterfaceRequired (const std::string &interfaceRequiredName) |
mtsInterfaceInput * | GetInterfaceInput (const std::string &interfaceInputName) const |
size_t | GetNumberOfInterfacesRequired (void) const |
size_t | GetNumberOfInterfacesInput (void) const |
bool | RemoveInterfaceRequired (const std::string &interfaceRequiredName, const bool skipDisconnect=false) |
const mtsManagerComponentServices * | GetManagerComponentServices (void) const |
mtsManagerComponentServices * | GetManagerComponentServices (void) |
mtsStateTable * | GetStateTable (const std::string &stateTableName) |
bool | AddStateTable (mtsStateTable *existingStateTable, bool addInterfaceProvided=true) |
void | UseSeparateLogFileDefault (bool forwardToLogger=true) |
void | UseSeparateLogFileDefaultWithDate (bool forwardToLogger=true) |
void | UseSeparateLogFile (const std::string &filename, bool forwardToLogger=true) |
cmnLogger::StreamBufType * | GetLogMultiplexer (void) const |
bool | IsRunning (void) const |
bool CISST_DEPRECATED | Running (void) const |
bool | IsStarted (void) const |
bool | IsTerminated (void) const |
bool | IsEndTask (void) const |
const mtsComponentState & | GetState (void) const |
void | GetState (mtsComponentState &state) const |
void | ToStream (std::ostream &outputStream) const |
bool | SetReplayMode (void) |
bool | SetReplayData (const std::string &stateTableName, const std::string &fileName) |
bool | SetReplayTime (const double time) |
std::vector< std::string > | GetNamesOfInterfacesProvidedOrOutput (void) const |
std::vector< std::string > | GetNamesOfInterfacesProvided (void) const |
std::vector< std::string > | GetNamesOfInterfacesOutput (void) const |
std::vector< std::string > | GetNamesOfInterfacesRequiredOrInput (void) const |
std::vector< std::string > | GetNamesOfInterfacesRequired (void) const |
std::vector< std::string > | GetNamesOfInterfacesInput (void) const |
![]() | |
virtual | ~cmnGenericObject (void) |
virtual const cmnClassServicesBase * | Services (void) const =0 |
bool | ReconstructFrom (const cmnGenericObject &other) |
std::string | ToString (void) const |
virtual void | ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const |
virtual bool | FromStreamRaw (std::istream &inputStream, const char delimiter= ' ') |
virtual void | SerializeRaw (std::ostream &outputStream) const |
virtual void | DeSerializeRaw (std::istream &inputStream) |
virtual size_t | ScalarNumber (void) const |
virtual bool | ScalarNumberIsFixed (void) const |
virtual double | Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range) |
virtual std::string | ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const |
Protected Types | |
typedef cmnNamedMap < mtsStateTable > | StateTableMapType |
Protected Attributes | |
std::string | Name |
mtsComponentState | State |
mtsInterfaceProvided * | InterfaceProvidedToManager |
bool | UseSeparateLogFileFlag |
cmnLogger::StreamBufType * | LoDMultiplexerStreambuf |
std::ofstream * | LogFile |
StateTableMapType | StateTables |
mtsManagerComponentServices * | ManagerComponentServices |
mtsFunctionWrite | EventGeneratorChangeState |
bool | ReplayMode |
mtsComponent should be used to write wrappers around existing devices or resources. This class allows to interact with existing devices as one would interact with a task (as in mtsTask and mtsTaskPeriodic). To do so, the component maintains a list of provided interfaces (of type mtsInterfaceProvided) which contains commands.
The main differences are that the base component class doesn't have a thread and is stateless. Since the component doesn't have any thread, the commands are not queued and the class doesn't add any thread safety mechanism. The component class doesn't maintain a state as it relies on the underlying device to do so. It is basically a pass-thru or wrapper.
|
protected |
|
protected |
|
protected |
Map of provided and output interfaces. Used to store pointers on all provided interfaces. Separate lists of provided and output interfaces are maintained for efficiency.
|
protected |
Map of required interfaces. Used to store pointers on all required interfaces. Separate lists of required and input interfaces are maintained for efficiency.
|
protected |
Map of state tables, includes the default StateTable under the name "StateTable"
typedef mtsComponent mtsComponent::ThisType |
|
protected |
Default constructor. Protected to prevent creation of a component without a name.
|
protected |
Default copy constructor. Protected to prevent copy as it is not supported yet. It is not clear why one would use a copy constructor on a component anyway.
mtsComponent::mtsComponent | ( | const std::string & | deviceName | ) |
Default constructor. Sets the name.
|
virtual |
Default destructor. Does nothing.
|
virtual |
Add an input interface.
|
protected |
|
protected |
Add internal interfaces.
useMangerComponentServices | True to allow this component to use dynamic component control services through mts command pattern to control other components. If true, the internal required interface is added to this component (the internal provided interface is added by default) |
|
virtual |
Method to add an output interface to the component.
|
protected |
mtsInterfaceProvided* mtsComponent::AddInterfaceProvided | ( | const std::string & | interfaceProvidedName, |
mtsInterfaceQueueingPolicy | queueingPolicy = MTS_COMPONENT_POLICY |
||
) |
Method to add a provided interface to the component.
|
protected |
Create and add a provided interface with an existing mailbox. If the creation or addition failed (name already exists), the caller must make sure he/she deletes the unused mailbox.
|
virtual |
Method to add a bare provided interface, i.e. without all the system events. This method should not be used by regular users as it might break things like blocking commands.
This method is virtual so that mtsTask can redefine it and create a provided interface that includes queues for thread safety.
Reimplemented in mtsTask, and mtsTaskFromSignal.
mtsInterfaceRequired* mtsComponent::AddInterfaceRequired | ( | const std::string & | interfaceRequiredName, |
mtsRequiredType | isRequired = MTS_REQUIRED |
||
) |
Remove an output interface identified by its name
Add a required interface. This interface will later on be connected to another task and use the provided interface of the other task. The required interface created also contains a list of event handlers to be used as observers.
|
protected |
Add an already existing interface required to the interface, the user must pay attention to mailbox (or lack of) used to create the required interface. By default, mtsComponent uses a required interface without mailbox (i.e. doesn't queue), mtsTask uses an interface with a mailbox and mtsTaskFromSignal uses an interface with a mailbox with a post command queued command.
|
protected |
Create and add a required interface with an existing mailbox. If the creation or addition failed (name already exists), the caller must make sure he/she deletes the unused mailbox.
|
virtual |
Reimplemented in mtsTask, and mtsTaskFromSignal.
|
inline |
|
inline |
bool mtsComponent::AddStateTable | ( | mtsStateTable * | existingStateTable, |
bool | addInterfaceProvided = true |
||
) |
Add an existing state table to the list of known state tables in this task. This method will add a provided interface for the state table using the name "StateTable" + existingStateTable->GetName() unless the caller specifies that no interface should be created.
By default, all state tables added will advance at each call of the Run method. To avoid the automatic advance, use the method mtsStateTable::SetAutomaticAdvance(false).
|
inlinevirtual |
Virtual method that gets overloaded, and is run after the component gets killed using Kill() method.
Reimplemented in mtsManagerComponentClient, mtsManagerComponentBase, mtsPID, mtsMedtronicStealthlink, mtsCollectorBase, mtsSocketProxyServer, mtsMedtronicStealthlink, mtsIntuitiveResearchKitConsole, mtsCMUSphinx4, mtsManagerComponentServer, mtsSensableHD, mtsSocketProxyClient, mtsOpenALRecord, mtsNovintHDL, mtsComponentViewer, mtsOpenALPlay, mtsNDISerial, mtsGLUTManipulator, ireTask, mtsMicronTracker, mtsComponentAddLatency, mtsIntuitiveDaVinci, mtsOSGCameraTask, mtsSartoriusSerial, mts3Dconnexion, mtsOpenIGTLink, mtsWAM, mtsTrajectory, mtsRobotIO1394, mtsOSGManipulatorTask, mtsIntuitiveResearchKitUDPStreamer, mtsODEManipulatorTask, mtsOSGImage, mtsTextToSpeech, mtsATINetFTQtWidget, mtsPDGC, mtsODEWorld, mtsATINetFTSensor, mtsRobotIO1394QtWidget, mtsCollectorQtFactory, mtsIntuitiveDaVinciArmQtWidget, mtsTeleOperation, mtsPIDQtWidget, mtsCollectorFactory, mtsIntuitiveResearchKitArm, mtsGravityCompensation, mtsKeyboard, mtsIntuitiveResearchKitSUJ, mtsTeleOperationQtWidget, mtsIntuitiveResearchKitArmQtWidget, and mtsIntuitiveResearchKitConsoleQtWidget.
|
virtual |
The virtual method so that the interface or tasks can configure themselves
Reimplemented in mtsPID, mtsMedtronicStealthlink, mtsSocketProxyServer, mtsMedtronicStealthlink, sawNoteRecorderQtComponent, mtsIntuitiveResearchKitConsole, mtsLoPoMoCo, mtsSocketProxyClient, mtsNDISerial, mtsMicronTracker, mtsComponentAddLatency, mtsOpenIGTLink, mtsTrajectory, mtsRobotIO1394, mtsIntuitiveResearchKitUDPStreamer, mtsOpenALRecordQtComponent, mtsOpenALPlayQtComponent, mtsATINetFTQtWidget, mtsPDGC, mtsRobotIO1394QtWidget, mtsIntuitiveDaVinciArmQtWidget, mtsPIDQtWidget, mtsTeleOperation, mtsCollectorFactory, mtsIntuitiveResearchKitArm, mtsGravityCompensation, mtsIntuitiveResearchKitSUJ, mtsTeleOperationQtWidget, mtsRobotIO1394QtWidgetFactory, mtsIntuitiveResearchKitPSM, mtsIntuitiveResearchKitArmQtWidget, and mtsIntuitiveResearchKitConsoleQtWidget.
|
virtual |
Virtual method to create the components, e.g. for tasks create the required threads. For other components, place initialization code.
Reimplemented in mtsTask.
bool mtsComponent::CreateAndWait | ( | double | timeoutInSeconds | ) |
Call the Create method followed by WaitForState
|
protected |
Enable support for dynamic component management services.
mtsInterfaceInput* mtsComponent::GetInterfaceInput | ( | const std::string & | interfaceInputName | ) | const |
Get an input interface identified by its name
mtsInterfaceOutput* mtsComponent::GetInterfaceOutput | ( | const std::string & | interfaceOutputName | ) | const |
Get an output interface identified by its name
mtsInterfaceProvided* mtsComponent::GetInterfaceProvided | ( | const std::string & | interfaceProvidedName | ) | const |
Get a provided interface identified by its name
const mtsInterfaceProvided* mtsComponent::GetInterfaceProvidedFor | ( | const std::string & | interfaceRequiredName | ) |
Get a pointer on the provided interface that has been connected to a given required interface (defined by its name). This method will return a null pointer if the required interface has not been connected. See mtsTaskManager::Connect.
mtsInterfaceRequired* mtsComponent::GetInterfaceRequired | ( | const std::string & | interfaceRequiredName | ) |
Get a required interface identified by its name
|
virtual |
Overload GetLodMultiplexer. This method is used for all class level log (i.e. CMN_LOG_CLASS) and allows to redirect the log to a separate file for each component when activated by UseSeparateLogFile or UseSeparateLogFileDefault.
Reimplemented from cmnGenericObject.
|
inline |
Remove an input interface identified by its name
Get pointer to manager component services, which extends the internal required interface to the Manager Component Client (MCC). This is used by the IRE (Python wrapping)
|
inline |
const std::string& mtsComponent::GetName | ( | void | ) | const |
Returns the name of the component.
void mtsComponent::GetName | ( | std::string & | placeHolder | ) | const |
std::vector<std::string> mtsComponent::GetNamesOfInterfacesInput | ( | void | ) | const |
std::vector<std::string> mtsComponent::GetNamesOfInterfacesOutput | ( | void | ) | const |
std::vector<std::string> mtsComponent::GetNamesOfInterfacesProvided | ( | void | ) | const |
std::vector<std::string> mtsComponent::GetNamesOfInterfacesProvidedOrOutput | ( | void | ) | const |
Return the list of provided interfaces. This returns a list of names. To retrieve the actual interface, use GetInterfaceProvided with the provided interface name.
std::vector<std::string> mtsComponent::GetNamesOfInterfacesRequired | ( | void | ) | const |
std::vector<std::string> mtsComponent::GetNamesOfInterfacesRequiredOrInput | ( | void | ) | const |
Provide a list of existing required interfaces (by names)
size_t mtsComponent::GetNumberOfInterfacesInput | ( | void | ) | const |
Get the total number of input interfaces
size_t mtsComponent::GetNumberOfInterfacesOutput | ( | void | ) | const |
Get the total number of output interfaces
size_t mtsComponent::GetNumberOfInterfacesProvided | ( | void | ) | const |
Get the total number of provided interfaces
size_t mtsComponent::GetNumberOfInterfacesRequired | ( | void | ) | const |
Get the total number of required interfaces
const mtsComponentState& mtsComponent::GetState | ( | void | ) | const |
Return task state.
void mtsComponent::GetState | ( | mtsComponentState & | state | ) | const |
mtsStateTable* mtsComponent::GetStateTable | ( | const std::string & | stateTableName | ) |
Return a pointer to state table with the given name.
|
protected |
Initializer
bool mtsComponent::InterfaceExists | ( | const std::string & | interfaceName, |
cmnLogLevel | lod = CMN_LOG_LEVEL_INIT_VERBOSE |
||
) | const |
Check if there is any interface with the given name
|
protected |
|
protected |
|
protected |
|
protected |
Internal commands to process command execution request coming from LCM (by invoking class methods)
|
protected |
|
protected |
bool mtsComponent::InterfaceProvidedOrOutputExists | ( | const std::string & | interfaceName, |
cmnLogLevel | lod = CMN_LOG_LEVEL_INIT_VERBOSE |
||
) | const |
Check if there is any interface provided or output with the given name
bool mtsComponent::InterfaceRequiredOrInputExists | ( | const std::string & | interfaceName, |
cmnLogLevel | lod = CMN_LOG_LEVEL_INIT_VERBOSE |
||
) | const |
Check if there is any interface required or input with the given name
bool mtsComponent::IsEndTask | ( | void | ) | const |
Return true if task is marked for killing.
bool mtsComponent::IsRunning | ( | void | ) | const |
Return true if task is active.
bool mtsComponent::IsStarted | ( | void | ) | const |
Return true if task was started.
bool mtsComponent::IsTerminated | ( | void | ) | const |
Return true if task is terminated.
|
virtual |
Virtual method to stop the computations and message processing. See Start.
Reimplemented in mtsTask, mtsTaskContinuous, mtsTaskFromCallback, mtsSensableHD, mtsNovintHDL, and mtsTaskFromSignal.
bool mtsComponent::KillAndWait | ( | double | timeoutInSeconds | ) |
Call the Kill method followed by WaitForState
|
protected |
Kill all separate log, if any. This method should be used in the destructor. Once it has been called, any call to log might crash.
|
protected |
Process all messages in mailboxes. Returns number of commands processed.
|
inlineprotected |
Process all queued commands. Returns number of events processed. These are the commands provided by all interfaces of the task.
|
protected |
Process all queued events. Returns number of events processed. These are the commands queued following events currently observed via the required interfaces.
bool mtsComponent::RemoveInterfaceProvided | ( | const std::string & | interfaceProvidedName, |
const bool | skipDisconnect = false |
||
) |
Remove a provided interface identified by its name
bool mtsComponent::RemoveInterfaceRequired | ( | const std::string & | interfaceRequiredName, |
const bool | skipDisconnect = false |
||
) |
Remove a required interface identified by its name
|
inline |
void mtsComponent::SetName | ( | const std::string & | componentName | ) |
Set name. This method is useful to perform dynamic creation using the default constructor and then set the name.
bool mtsComponent::SetReplayData | ( | const std::string & | stateTableName, |
const std::string & | fileName | ||
) |
bool mtsComponent::SetReplayMode | ( | void | ) |
Method to set replay mode
bool mtsComponent::SetReplayTime | ( | const double | time | ) |
|
virtual |
Virtual method called after components are connected to start the computations and message processing.
Reimplemented in mtsTaskContinuous, mtsSensableHD, mtsTaskFromCallback, mtsNovintHDL, svlStreamManager, and mtsCMUSphinx4QtComponent.
bool mtsComponent::StartAndWait | ( | double | timeoutInSeconds | ) |
Call the Start method followed by WaitForState
|
inlinevirtual |
Virtual method that gets overloaded, and is run before the component is started.
Reimplemented in mtsManagerComponentClient, mtsManagerComponentBase, mtsPID, mtsMedtronicStealthlink, mtsCollectorBase, mtsSocketProxyServer, mtsIntuitiveResearchKitConsole, mtsMedtronicStealthlink, mtsCollectorEvent, mtsCMUSphinx4, mtsManagerComponentServer, mtsSocketProxyClient, mtsOpenALRecord, mtsQtApplication, mtsComponentViewer, mtsNDISerial, mtsGLUTManipulator, ireTask, mtsMicronTracker, mtsComponentAddLatency, mtsIntuitiveDaVinci, mtsOpenALPlay, mtsOSGCameraTask, mtsSartoriusSerial, mts3Dconnexion, mtsOpenIGTLink, mtsWAM, mtsTrajectory, mtsRobotIO1394, mtsOSGManipulatorTask, mtsIntuitiveResearchKitUDPStreamer, prmQtWidgetEventButtonsComponent, mtsODEManipulatorTask, mtsOSGImage, mtsTextToSpeech, mtsATINetFTQtWidget, mtsPDGC, mtsRobotIO1394QtWidget, mtsATINetFTSensor, mtsIntuitiveDaVinciArmQtWidget, mtsODEWorld, mtsPIDQtWidget, mtsTeleOperation, mtsIntuitiveResearchKitArm, mtsGravityCompensation, mtsKeyboard, mtsIntuitiveResearchKitSUJ, mtsTeleOperationQtWidget, mtsRobotIO1394QtWidgetFactory, mtsIntuitiveResearchKitArmQtWidget, mtsIntuitiveResearchKitConsoleQtWidget, and mtsIntuitiveResearchKitSUJQtWidget.
|
virtual |
Virtual method to suspend the component (same as Stop).
Reimplemented in mtsTaskPeriodic, mtsTaskContinuous, mtsTaskFromCallback, and svlStreamManager.
|
virtual |
Send a human readable description of the component.
Reimplemented from cmnGenericObject.
void mtsComponent::UseSeparateLogFile | ( | const std::string & | filename, |
bool | forwardToLogger = true |
||
) |
Tells this component to use its own file for log. By default the messages are also sent to cmnLogger but this can be changed setting forwardToLogger to false.
void mtsComponent::UseSeparateLogFileDefault | ( | bool | forwardToLogger = true | ) |
Tells this component to use its own file for log. By default the messages are also sent to cmnLogger but this can be changed setting forwardToLogger to false. The default file name is based on the component's name, followed by '-log.txt'
void mtsComponent::UseSeparateLogFileDefaultWithDate | ( | bool | forwardToLogger = true | ) |
Tells this component to use its own file for log. By default the messages are also sent to cmnLogger but this can be changed setting forwardToLogger to false. The default file name is based on the component's name, followed by the date and '-log.txt'
|
protectedvirtual |
Helper function to wait on a state change, with specified timeout in seconds.
Reimplemented in mtsTask.
|
friend |
|
friend |
|
protected |
Event generator to inform the manager component client of the state change of this component
|
protected |
Provided interface for component management.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Pointers on multiplexer used by this component for logging purposes. By default the file "LogFile" is the only output stream but a user can add any stream using mtsComponent::GetLogMultiplexer combined with cmnLODMultiplexerStreambuf::AddChannel.
|
protected |
Default log file used for this component logging
|
protected |
Dynamic component management service provider
|
protected |
A string identifying the 'Name' of the component.
|
protected |
|
protected |
Component state.
|
protected |
|
protected |
Flag to keep track of separate log file use