[tuxdroid-svn] r395 - api/python/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-06-18 16:03:09
|
Author: jaguarondi Date: 2007-06-18 18:02:36 +0200 (Mon, 18 Jun 2007) New Revision: 395 Modified: api/python/trunk/tuxapi_class.py Log: * Renamed tuxdaemon and tuxttsdaemon into tuxd and tuxttsd. Modified: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-06-18 12:30:39 UTC (rev 394) +++ api/python/trunk/tuxapi_class.py 2007-06-18 16:02:36 UTC (rev 395) @@ -871,8 +871,8 @@ param 1 : Key as integer "on_light_level" as pof : On light level event param 1 : light value as integer - "on_connected" as pof : On api connected to tuxdaemon - "on_disconnected" as pof : On api disconnect from tuxdaemon + "on_connected" as pof : On api connected to tuxd + "on_disconnected" as pof : On api disconnect from tuxd "on_mouth_open" as pof : On mouth open event "on_mouth_close" as pof : On mouth close event "on_power_plugged" as pof : On power plugged event @@ -1400,7 +1400,7 @@ "last_ack" as integer : ACK value of the last command (ACK_CMD_DONGLE_NOT_PRESENT|ACK_CMD_TIMEOUT| ACK_CMD_OK|ACK_CMD_KO|ACK_CMD_ERROR) - "no_ack" as boolean : Allow to wait a ACK from tuxdaemon + "no_ack" as boolean : Allow to wait a ACK from tuxd Functions list for the users: tux.cmd.audio_channel_general @@ -3131,7 +3131,7 @@ Class which manages the daemon commands Global variables of this class: - "connected" as boolean : State of the connection to tuxdaemon + "connected" as boolean : State of the connection to tuxd Functions list for users: tux.daemon.auto_connect @@ -3163,11 +3163,11 @@ self.ac_port=5000 #-------------------------------------------------------------------------- - # Allow to connect the api to tuxdaemon automatically + # Allow to connect the api to tuxd automatically #-------------------------------------------------------------------------- def auto_connect(self,value,address='ndef',port=0): """ - Allow to connect the api to tuxdaemon automatically + Allow to connect the api to tuxd automatically Parameters: "value" as boolean : turn on/off the auto_connect mode @@ -3220,12 +3220,12 @@ if self.connected: self.parent.hw.alsa_devices_select(0) if self.parent.print_warnings: - print "CONNECTED to tuxdaemon" + print "CONNECTED to tuxd" if self.parent.event.on_connected!=None: self.parent.event.on_connected() else: if self.parent.print_warnings: - print "DISCONNECTED from tuxdaemon" + print "DISCONNECTED from tuxd" self.parent.status.rf_connected = False if self.parent.event.on_disconnected!=None: self.parent.event.on_disconnected() @@ -3234,11 +3234,11 @@ self.parent.sys.wait(0.1) #-------------------------------------------------------------------------- - # Connect object to tuxdaemon + # Connect object to tuxd #-------------------------------------------------------------------------- def connect(self,address='localhost',port=5000): """ - Connect tux object to tuxdaemon + Connect tux object to tuxd Parameters: "port" as integer : Tcp/IP Port number @@ -3293,11 +3293,11 @@ return True #-------------------------------------------------------------------------- - # Disconnect object from tuxdaemon + # Disconnect object from tuxd #-------------------------------------------------------------------------- def disconnect(self): """ - Disconnect tux object from tuxdaemon + Disconnect tux object from tuxd Example: >>> tux.daemon.disconnect() @@ -3312,7 +3312,7 @@ if free_thread.isAlive(): free_thread.join() self.free_thread_list=[] - # To inform the system and tuxdaemon that the connection + # To inform the system and tuxd that the connection # is closed self.disconnect_me() self.connected=False @@ -3383,7 +3383,7 @@ return returned_data[0] #-------------------------------------------------------------------------- - # Send a command to tuxdaemon + # Send a command to tuxd #-------------------------------------------------------------------------- def cmd(self,cmd,param1,param2,param3): """ @@ -3393,7 +3393,7 @@ return self.cmd_ack() #-------------------------------------------------------------------------- - # Send a command to tuxdaemon + # Send a command to tuxd #-------------------------------------------------------------------------- def cmd_no_ack(self,cmd,param1,param2,param3): """ @@ -3407,7 +3407,7 @@ return 0 #-------------------------------------------------------------------------- - # Send a request to tuxdaemon + # Send a request to tuxd #-------------------------------------------------------------------------- def request(self,req,param1,param2,param3): """ @@ -3421,11 +3421,11 @@ return self.rsp_info(req) #-------------------------------------------------------------------------- - # Disconnect a client from tuxdaemon + # Disconnect a client from tuxd #-------------------------------------------------------------------------- def disconnect_client(self,id_client): """ - Disconnect a client from tuxdaemon + Disconnect a client from tuxd Parameters: "id_client" as integer : id of the client to disconnect @@ -3448,11 +3448,11 @@ 0,0,0) #-------------------------------------------------------------------------- - # Kill tuxdaemon + # Kill tuxd #-------------------------------------------------------------------------- def kill(self): """ - Kill tuxdaemon + Kill tuxd Example: >>> tux.daemon.kill() @@ -3461,11 +3461,11 @@ self.last_ack=self.cmd(SUB_D_CMD_STRUC_KILL_DAEMON,0,0,0) #-------------------------------------------------------------------------- - # Set my client name on tuxdaemon + # Set my client name on tuxd #-------------------------------------------------------------------------- def set_my_client_name(self,name): """ - Set my client name on tuxdaemon + Set my client name on tuxd Parameters: "name" as string : name of this client (max 11 char) @@ -3492,11 +3492,11 @@ self.last_ack=self.cmd_ack() #-------------------------------------------------------------------------- - # Get the version of tuxdaemon + # Get the version of tuxd #-------------------------------------------------------------------------- def get_version(self): """ - Get the version of tuxdaemon + Get the version of tuxd Return a string @@ -3513,11 +3513,11 @@ return "%d.%d.%d"%(result[0],result[1],result[2]) #-------------------------------------------------------------------------- - # Get the number of clients connected to tuxdaemon + # Get the number of clients connected to tuxd #-------------------------------------------------------------------------- def get_client_count(self): """ - Get the number of clients connected to tuxdaemon + Get the number of clients connected to tuxd Return an integer @@ -3532,11 +3532,11 @@ return 0 #-------------------------------------------------------------------------- - # Get the name of a client of tuxdaemon + # Get the name of a client of tuxd #-------------------------------------------------------------------------- def get_client_name(self,id_client): """ - Get the name of a client of tuxdaemon + Get the name of a client of tuxd Return a string @@ -3552,11 +3552,11 @@ return '' #-------------------------------------------------------------------------- - # Print the name of all the clients connected to tuxdaemon + # Print the name of all the clients connected to tuxd #-------------------------------------------------------------------------- def print_clients_name(self): """ - Print the name of all the clients connected to tuxdaemon + Print the name of all the clients connected to tuxd Example: >>> tux.daemon.print_clients_name() @@ -3566,11 +3566,11 @@ print "Client %.3d : %s"%(i,self.get_client_name(i)) #-------------------------------------------------------------------------- - # Get the client id of my connection to tuxdaemon + # Get the client id of my connection to tuxd #-------------------------------------------------------------------------- def get_my_client_id(self): """ - Get the client id of my connection to tuxdaemon + Get the client id of my connection to tuxd Return an integer @@ -3829,11 +3829,11 @@ Class which manages the text to speech Global variables of this class: - "connected" as boolean : State of the connection to tuxttsdaemon + "connected" as boolean : State of the connection to tuxttsd "print_status" as boolean : Allow to print the raw statuses - "sound_on" as boolean : Speaking state of the tuxttsdaemon - "on_connected" as pof : Event on tuxttsdaemon connected - "on_disconnected" as pof : Event on tuxttsdaemon disconnected + "sound_on" as boolean : Speaking state of the tuxttsd + "on_connected" as pof : Event on tuxttsd connected + "on_disconnected" as pof : Event on tuxttsd disconnected "on_sound_on" as pof : Event on tts speaking on "on_sound_off" as pof : Event on tts speaking off "on_voice_list" as pof : Event on new authorized voices list @@ -3892,14 +3892,13 @@ self.ac_port=5500 self.ac_address='localhost' self.authorized_voices_list = [] - self.voice_loaded = False #-------------------------------------------------------------------------- - # Allow to connect the api to tuxttsdaemon automatically + # Allow to connect the api to tuxttsd automatically #-------------------------------------------------------------------------- def auto_connect(self,value,address='ndef',port=0): """ - Allow to connect the api to tuxttsdaemon automatically + Allow to connect the api to tuxttsd automatically Parameters: "value" as boolean : turn on/off the auto_connect mode @@ -3950,12 +3949,12 @@ if self.connected!=last_connect_status: if self.connected: if self.parent.print_warnings: - print "CONNECTED to tuxttsdaemon" + print "CONNECTED to tuxttsd" if self.on_connected!=None: self.on_connected() else: if self.parent.print_warnings: - print "DISCONNECTED from tuxttsdaemon" + print "DISCONNECTED from tuxttsd" if self.on_disconnected!=None: self.on_disconnected() self._tcp_threads_join() @@ -3963,7 +3962,7 @@ self.parent.sys.wait(0.1) #-------------------------------------------------------------------------- - # Connect object to tuxttsdaemon + # Connect object to tuxttsd #-------------------------------------------------------------------------- def connect_to_daemon(self): """ @@ -3972,7 +3971,7 @@ return self.connect() def connect(self,address='localhost',port=5500): """ - Connect tts object to tuxttsdaemon + Connect tts object to tuxttsd Parameters: "port" as integer : Tcp/IP Port number @@ -4010,7 +4009,7 @@ return True #-------------------------------------------------------------------------- - # Disconnect tts object from tuxttsdaemon + # Disconnect tts object from tuxttsd #-------------------------------------------------------------------------- def disconnect_from_daemon(self): """ @@ -4019,7 +4018,7 @@ self.disconnect() def disconnect(self): """ - Disconnect tts object from tuxttsdaemon + Disconnect tts object from tuxttsd Example: >>> tux.tts.disconnect() @@ -4112,12 +4111,9 @@ self.authorized_voices_list.append(ord(voice_id)-1) if self.on_voice_list != None: self.on_voice_list() - # A voice has been loaded - if ord(data[1])==CMD_INFO_VOICE_OK: - self.voice_loaded = True #-------------------------------------------------------------------------- - # Send command to tuxttsdaemon + # Send command to tuxttsd #-------------------------------------------------------------------------- def send_command_to_tts(self,cmd_type,cmd,param1,param2,param3,param4): """ @@ -4297,19 +4293,9 @@ self.send_command_to_tts(CMD_TYPE_TTS, CMD_TTS_INSERT_PLAY_SPEECH, \ (text_length & 0x0000FF00) >> 8, (text_length & 0x000000FF), \ self.my_voice, self.my_pitch) - self.voice_loaded == True + self.parent.cmd.audio_channel_tts() self.sock.send(text_to_send) counter = 0 - while ((self.voice_loaded == False) and (counter < 300)): - counter = counter + 1 - self.parent.sys.wait(0.1) - if counter == 300: - self.stop() - print "TTS Speak : Voice not loaded" - return False - print "Voice Loaded." - self.parent.cmd.audio_channel_tts() - counter = 0 while ((self.sound_on == False) and (counter < 100)): counter = counter + 1 self.parent.sys.wait(0.1) @@ -4383,11 +4369,11 @@ self.parent.sys.wait(0.1) #-------------------------------------------------------------------------- - # Send a command to tuxttsdaemon for getting the state of the sound + # Send a command to tuxttsd for getting the state of the sound #-------------------------------------------------------------------------- def get_sound_state(self): """ - Send a command to tuxttsdaemon for getting the state of + Send a command to tuxttsd for getting the state of the sound Example: @@ -4396,7 +4382,7 @@ self.send_command_to_tts(CMD_TYPE_INFO,CMD_INFO_SOUND_STATE,0,0,0,0) #-------------------------------------------------------------------------- - # Disconnect from tuxttsdaemon + # Disconnect from tuxttsd #-------------------------------------------------------------------------- def send_disconnect(self): """ @@ -4406,7 +4392,7 @@ 0,0,0,0) #-------------------------------------------------------------------------- - # Print the audio fifo state on tuxttsdaemon + # Print the audio fifo state on tuxttsd #-------------------------------------------------------------------------- def print_audio_fifo_state(self): """ @@ -4426,11 +4412,11 @@ CMD_DAEMON_PRINT_TUX_SOUND_CARDS,0,0,0,0) #-------------------------------------------------------------------------- - # Kill tuxttsdaemon + # Kill tuxttsd #-------------------------------------------------------------------------- def kill_daemon(self): """ - Kill the tuxttsdaemon + Kill the tuxttsd Example: >>> tux.tts.kill_daemon() |