Module Class

class ModuleClass

ModuleClass. Provides a generic interface to a BrainStem hardware module. The Module class is the parent class for all BrainStem modules. Each module inherits from Module and implements its hardware specific features.

Public Functions

ModuleClass(Acroname::BrainStem::Module &module)

Constructor.

~ModuleClass()

Destructor.

Acroname::BrainStem2CLI::ModuleClass::!ModuleClass()

Finalizer.

BrainStem2CLI::aErr discoverAndConnect(m_linkType transport)

A discovery-based connect. This member function will attempt to connect to the first BrainStem module found. If this module does not match the object type the connection will fail.

Return

aErrBusy - if the module is already in use.

Return

aErrParam - if the transport type is undefined.

Return

aErrNotFound - if the module cannot be found.

Return

aErrNone If the connect was successful.

Parameters
  • type: - Transport on which to search for available BrainStem link modules. See the transport enum for supported transports.

BrainStem2CLI::aErr discoverAndConnect(m_linkType transport, unsigned int SN)

A discovery-based connect. This member function will connect to the first available BrainStem found on the given transport. If the serial number is passed, it will only connect to the module with that serial number. Passing 0 as the serial number will create a link to the first link module found on the specified transport. If a link module is found on the specified transport, a connection will

Return

aErrBusy - if the module is already in use.

Return

aErrParam - if the transport type is undefined.

Return

aErrNotFound - if the module cannot be found.

Return

aErrNone If the connect was successful.

Parameters
  • type: - Transport on which to search for available BrainStem link modules. See the transport enum for supported transports.

  • serialNum: - Specify a serial number to connect to a specific link module. Use 0 to connect to the first link module found.

BrainStem2CLI::aErr connectFromSpec(m_linkSpec spec)

Connect to a link with a fully defined specifier.

Return

aErrInitialization - If there is currently no link object.

Return

aErrBusy - If the link is currently connected.

Return

aErrParam - if the specifier is incorrect.

Return

aErrNotFound - if the module cannot be found.

Return

aErrNone If the connect was successful.

Parameters
  • linkSpecifier: - Connect to module with specifier.

BrainStem2CLI::aErr connect(m_linkType transport)

Connect using the current link specifier.

Return

aErrBusy - if the module is already in use.

Return

aErrParam - if the type is incorrect or serialNum is not specified

Return

aErrNotFound - if the module cannot be found.

Return

aErrNone If the connect was successful.

Parameters
  • type: - Transport on which to search for available BrainStem link modules. See the transport enum for supported transports.

BrainStem2CLI::aErr connect(m_linkType transport, unsigned int SN)

Connect using the current link specifier.

Return

aErrBusy - if the module is already in use.

Return

aErrParam - if the type is incorrect or serialNum is not specified

Return

aErrNotFound - if the module cannot be found.

Return

aErrNone If the connect was successful.

Parameters
  • type: - Transport on which to search for available BrainStem link modules. See the transport enum for supported transports.

  • serialNum: - Specify a serial number to connect to a specific link module. Use 0 to connect to the first link module found.

BrainStem2CLI::aErr connectThroughLinkModule(BrainStem2CLI::ModuleClass %module)

Connect using link from another Module. This member function will connect to the same BrainStem used by given Module. If a link module is found on the specified transport, a connection will

Return

aErrParam - if the module is undefined.

Return

aErrNone - if the connect was successful.

Parameters
  • pModule: - Pointer to a valid Module class object.

BrainStem2CLI::aErr disconnect()

Disconnect from the BrainStem module.

Return

aErrResource - If the there is no valid connection.

Return

aErrConnection - If the disconnect failed, due to a communication issue.

Return

aErrNone If the disconnect was successful.

BrainStem2CLI::aErr reconnect()

Reconnect using the current link specifier.

Return

aErrBusy - if the module is already in use.

Return

aErrParam - if the specifier is incorrect.

Return

aErrNotFound - if the module cannot be found.

Return

aErrNone If the connect was successful.

bool isConnected()

Is the link connected to the BrainStem Module.

void setModuleAddress(const unsigned char address)

Accessor to set the address of the BrainStem module associated with the instance on the host machine. (Not to be confused with the System entity which effects the device hardware.)

Parameters
  • address: The module address.

unsigned char getModuleAddress()

Accessor to get the address of the BrainStem module associated with the instance on the host machine. (Not to be confused with the System entity which effects the device hardware.)

Return

The module address.

void setNetworkingMode(const bool mode)

Sets the networking mode of the module object. By default the module object is configure to automatically adjust its address based on the devices current module address. So that, if the device has a software or hardware offset it will still be able to communication with the device. If advanced networking is required the auto networking mode can be turned off.

Parameters
  • mode: True/1 for Auto Networking, False/0 for manual networking

Public Static Functions

static BrainStem2CLI::m_linkSpec findFirstModule(BrainStem2CLI::m_linkType type)

Finds the first module found on the given transport

Return

If found, the linkspec will be populated with the devices information. Values will be all zeros otherwise.

Parameters
  • type: The transport type on which to search for devices. Valid #linkType “linktypes” are accepted.

static BrainStem2CLI::m_linkSpec findModule(BrainStem2CLI::m_linkType type, unsigned int SN)

Finds the module with the given serial number on the given transport type.

Return

If found the linkspec will be populated with the devices information. Values will be all zeros otherwise.

Parameters
  • type: The trasport type on which search for devices. Valid #linkType “linktypes” are accepted

static BrainStem2CLI::aErr sDiscover(BrainStem2CLI::m_linkType type, List<m_linkSpec> ^%specList)

Discover is called with a specified transport to search for link modules on that transport. The devices list is filled with device scecifiers. sDiscover returns aErrNone if the discovery process is successful, regardless of whether any links are found. An error is only returned if the link discovery process fails. Discovery can take some time.

Return

aErrNotFound if no devices were found.

Return

aErrNone on success.

Parameters
  • type: Transport to search for available BrainStem link modules on. See the transport enum for supported transports.

  • devices: an empty list of specifiers that will be filled in.