|
|
The SBClient Class - C++
The Speech/Braille Client Class SBClient provides simple generic access to a Speech/Braille device via an sbserver. To use include SBDev.h and link the application with libsbdev.a.
class SBClient: public BNetwork {
public:
typedef void (*Function)();
enum RStatus { OK, ERROR };
enum KeyType { MAIN, STATUS1, STATUS2, BUTS1, BUTS2 };
enum Key { NONE, PROG, HOME, CURSOR, LEFT, UP, DOWN, RIGHT };
enum SoundType { PING };
enum LockMode { LOCK_NONE=0, LOCK_INPUT=1, LOCK_OUTPUT=2 };
enum Device { SPEECH, BRAILLE };
SBDev();
~SBDev();
BError Open(BString host = "", int port = 0, BString name = "");
BError Close();
BError GetVersion(int& major, int& minor, int& release);
// Lock/unlock devices to this connection
BError Lock(LockMode lock);
// Get connection history
BError GetConnectionNames(BList& names);
BError GetConnectionHistory(BString conName, int line, Device device, BString& string);
// Braille Interface
BError BrailleSetMode(BString mode);
BError BrailleGetModes(BString& modes);
BError BrailleDisplayBraille(BString str);
BError BrailleDisplayStatus(int pos, char data, char ul);
BError BrailleDisplayCursor(int pos, int show);
BError BrailleShift(int shift);
BError BrailleGetNumberDisplayed(int& num);
BError BrailleGetNumberofCells(int& num);
BError BrailleGetName(BString& name);
BError BrailleGetKey(int& key, KeyType& ktype, int& mod);
// Speech Interface
BError SpeechSpeak(BString str, int* index = 0);
BError SpeechStop();
BError SpeechSound(SoundType sound, int* index = 0);
BError SpeechSet(SpeechSettings settings);
BError SpeechGet(SpeechSettings& settings);
BError SpeechGetName(BString& name);
BError SpeechCallWhenReached(int item, Function func);
private:
int Transact(int retPacket);
SBPacket* orx;
SBPacket* otx;
};
The function members of the class have the following functionality :-
BError Open(BString host,int port,BString name);
Opens a connection to an sbserver program on the specified host machine and expected to be listening on the specified port. host is the name or IP address of the host running the SBServer deamon. port is the TCP/IP port number. Both host and port parameters are optional, where host is not specified local host is assumed and connection port determined by lookup for the service type sbserver (Ref: /etc/services). This function must be called prior to the use of any other. name is an optional name for the connection.
BError Close();
Close the connection between client and server.
BError GetVersion(int& major, int& minor, int& release);
Obtains the version details of the connected server. Version identification is in the form of three digits ordered major,minor and release. eg 3.4.6.
BError Lock(LockMode lock);
Locks the speech/braille server to the given connection. The lock parameter allows either input, output or both to be locked.
BError GetConnectionNames(BList
Return the list of connections made to the server.
BError GetConnectionHistory(BString conName, int line, Device device, BString& string);
Obtain strings passed to a Speech/braille device by the server. conName identifies the connection stream to query, device the actual device. line specifies an index as to which string to return 0 being the latest utterance, 1 the penultimate etc. The string is placed as indicated by the names parameter.
BError BrailleSetMode(BString name);
Sends configuration string name to the braille device. The functionality of the string is Braille device specific.BError BrailleGetModes(BString& modes);
Obtains the current modes in the form of a string modes.BError BrailleDisplayBraille(int pos, BString str);
Display the specified string on the braille display. The first character is positioned at cell pos.BError BrailleDisplayStatus(int pos, char data, char ul);
Display the character specified by data on the status cell pos. ul indicates if the character should be underlined.BError BrailleDisplayCursor(int pos, int show);
Indicate a cursor at cell pos. show indicates if a cursor is to be shown.BError BrailleShift(int shift);
A braille display has a limited number of cells with which to display a line of text. The shift parameter sets the first cellBError BrailleGetNumberDisplayed(int& num);
of the display shift character from the start of the line.
On return num contains the number of text cells displayed.
BError BrailleGetNumberofCells(int& num);
num is filled with the number of character cells.BError BrailleGetName(BString& name);
Obtain the name of the Braille display.
BError BrailleGetKey(int& key, Braille::KeyType& ktype,
int& mod);
The BrailleGetKey function obtains the key functionality of the braille display.BError SpeechSpeak(BString str, int* index = 0);
Output the string str as speech.The optional parameter index provides a value that may be used to triggerBError SpeechStop();
the function specified by SpeechCallWhenReached() when the sound has been ouput.
Stop speaking. This function will terminate any speech 'stacked up' and awaiting to beBError SpeechSound(Speech::SoundType sound, int* index = 0);
spoken.
Output the specified sound. The optional parameter index provides a value that may be used to triggerBError SpeechSet(SpeechSettings settings);
the function specified by SpeechCallWhenReached() when the sound has been ouput.
Configure the speech settings such as voice type, pitch and speed.BError SpeechGet(SpeechSettings& settings);
Obtain the current speech settings, voice type pitch,speed etc.BError SpeechGetName(BString& name);
name is filled with the name of the sound device.BError SpeechCallWhenReached(int item, Function func);
Call the specifed function func when item has been output
