[tuxdroid-svn] r5905 - in software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies:
Status: Beta
Brought to you by:
ks156
From: remi <c2m...@c2...> - 2009-11-18 11:40:42
|
Author: remi Date: 2009-11-18 12:40:32 +0100 (Wed, 18 Nov 2009) New Revision: 5905 Removed: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/data/web_interface/user_01/ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/00_resourceTuxDriver.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/01_resourceTuxOSL.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/00_resourceAttitune.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/01_resourceEyes.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/02_resourceFlippers.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/03_resourceLeds.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/04_resourceMacro.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/05_resourceMouth.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/06_resourceSoundFlash.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/07_resourceSpinning.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/08_resourceTTS.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/09_resourceWav.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/10_resourceRF.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/03_content_servers/00_resourceAttituneManager.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/07_web_interfaces/01_resourceWIUser01.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/util/driver/ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/util/osl/ Modified: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/TDSAutoUpdater.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/03_content_servers/01_resourcePluginsServer.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/03_content_servers/03_resourceUgcServer.py software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/05_user_configurations/00_resourceUsers.py Log: * Removed TuxDriver and TuxOsl dependencies * Removed TuxBox interface * Please uses the page "http://127.0.0.1:<port>/devel/" to configure and launch plugins/gadgets/ugcs Modified: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/TDSAutoUpdater.py =================================================================== --- software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/TDSAutoUpdater.py 2009-11-18 10:32:56 UTC (rev 5904) +++ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/TDSAutoUpdater.py 2009-11-18 11:40:32 UTC (rev 5905) @@ -30,32 +30,9 @@ PART_CVER_FILE = 2 PART_DEFAULT_VER = 3 -UPDATES_PARTS = { - 'smart_server' : [ - 'http://ftp.kysoh.com/ssv3/smart_core/smart_server/%s.conf' % DIST_STATE, - 'smart_server.conf', - 'smart_server.cver', - __version__, - ], - 'smart_api' : [ - 'http://ftp.kysoh.com/ssv3/smart_core/smart_api/%s.conf' % DIST_STATE, - 'smart_api.conf', - 'smart_api.cver', - '', - ], - 'smart_content' : [ - 'http://ftp.kysoh.com/ssv3/smart_core/smart_content/%s.conf' % DIST_STATE, - 'smart_content.conf', - 'smart_content.cver', - '', - ], -} +UPDATES_PARTS = {} -PART_NAMES = [ - 'smart_content', - 'smart_api', - 'smart_server', -] +PART_NAMES = [] # ------------------------------------------------------------------------------ # Tux Droid Server : Auto updater. Deleted: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/00_resourceTuxDriver.py =================================================================== --- software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/00_resourceTuxDriver.py 2009-11-18 10:32:56 UTC (rev 5904) +++ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/00_resourceTuxDriver.py 2009-11-18 11:40:32 UTC (rev 5905) @@ -1,704 +0,0 @@ -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -from util.driver import * - -# ============================================================================== -# ****************************************************************************** -# RESOURCE DECLARATION -# ****************************************************************************** -# ============================================================================== - -# ============================================================================== -# Declaration of the resource "tuxdriver". -# ============================================================================== -class TDSResourceTuxDriver(TDSResource): - """Resource tuxdriver class. - """ - - # ========================================================================== - # Inherited methods from TDSResource - # ========================================================================== - - # -------------------------------------------------------------------------- - # Configure the resource. - # -------------------------------------------------------------------------- - def configure(self): - """Configure the resource. - """ - # General configuration (inherited from ancestor) - self.name = "tuxdriver" - self.comment = "Resource to handling the TuxDriver library." - self.fileName = RESOURCE_FILENAME - # Specific - # Registering the Tuxdriver statuses - for statusName in SW_NAME_DRIVER: - eventsHandler.insert(statusName) - # Registering the statuses which must be excluded by default by the - # clients. - clientsManager.addDefaultExcludedEvent(ST_NAME_BATTERY_STATE) - clientsManager.addDefaultExcludedEvent(ST_NAME_BATTERY_LEVEL) - clientsManager.addDefaultExcludedEvent(ST_NAME_LIGHT_LEVEL) - # Registering the statuses which need an exlusive access for the - # RESTRICTED clients. - clientsManager.addRestrictedEvent(ST_NAME_HEAD_BUTTON) - clientsManager.addRestrictedEvent(ST_NAME_LEFT_BUTTON) - clientsManager.addRestrictedEvent(ST_NAME_RIGHT_BUTTON) - clientsManager.addRestrictedEvent(ST_NAME_REMOTE_BUTTON) - # Create and configure a Tux Driver object - self.__tuxDriver = TuxDrv() - self.__tuxDriver.SetLogLevel(TDS_CONF_LOG_LEVEL) - self.__tuxDriver.SetLogTarget(TDS_CONF_LOG_TARGET) - self.__tuxDriver.SetStatusCallback(self.__onStatusCallback) - self.__tuxDriver.SetEndCycleCallback(self.__onEndOfCycleCallback) - eventsHandler.getEventHandler(ST_NAME_DONGLE_PLUG).register(self.__onDonglePlugCallback) - # Others - self.__donglePlugged = False - self.__statusesStruct = [] - - # -------------------------------------------------------------------------- - # Start the resource. - # -------------------------------------------------------------------------- - def start(self): - """Start the resource. - """ - t = threading.Thread(target = self.__tuxDriver.Start) - t.start() - - # -------------------------------------------------------------------------- - # Stop the resource. - # -------------------------------------------------------------------------- - def stop(self): - """Stop the resource. - """ - self.__tuxDriver.Stop() - - # ========================================================================== - # Private methods - # ========================================================================== - - # -------------------------------------------------------------------------- - # Event on status. - # -------------------------------------------------------------------------- - def __onStatusCallback(self, status): - """Event on status. - @param status: The status. - """ - self.__statusesStruct.append(self.__tuxDriver.GetStatusStruct(status)) - - # -------------------------------------------------------------------------- - # Event on tuxdriver end of cycle ~100msec. - # -------------------------------------------------------------------------- - def __onEndOfCycleCallback(self): - """Event on tuxdriver end of cycle ~100msec. - """ - def async(): - clientsManager.pushEvents(self.__statusesStruct) - for statusStruct in self.__statusesStruct: - eventsHandler.emit(statusStruct['name'], (statusStruct['value'], - float(statusStruct['delay']))) - self.__statusesStruct = [] - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Event on dongle plug/unplug. - # -------------------------------------------------------------------------- - def __onDonglePlugCallback(self, value, delay): - """Event on dongle plug/unplug. - """ - self.__donglePlugged = value - if value: - self.__initializeStatesInEventsHandler() - - # -------------------------------------------------------------------------- - # Initialize statuses state in the events handler. - # -------------------------------------------------------------------------- - def __initializeStatesInEventsHandler(self): - """Initialize statuses state in the events handler. - """ - def async(): - states = self.__tuxDriver.GetAllStatusState() - if len(states) > 0: - states = states[:-1] - states = states.split('\n') - for state in states: - stateStruct = self.__tuxDriver.GetStatusStruct(state) - if stateStruct['name'] != "None": - eventsHandler.updateState(stateStruct['name'], ( - stateStruct['value'], float(stateStruct['delay']))) - t = threading.Thread(target = async) - t.start() - - # ========================================================================== - # Public methods - # ========================================================================== - - # Misc --------------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Get if the dongle is plugged or not. - # -------------------------------------------------------------------------- - def getDonglePlugged(self): - """Get if the dongle is plugged or not. - @return: True or False. - """ - return self.__donglePlugged - - # -------------------------------------------------------------------------- - # Reset the body positions and clear the commands stack. - # -------------------------------------------------------------------------- - def clearAll(self): - """Reset the body positions and clear the commands stack. - """ - self.__tuxDriver.ClearCommandStack() - self.__tuxDriver.ResetPositions() - self.__tuxDriver.PerformCommand(0.0,'TUX_CMD:LED:ON:LED_BOTH,1.0') - - # -------------------------------------------------------------------------- - # Execute a macro text. - # -------------------------------------------------------------------------- - def executeMacro(self, macro): - """Execute a macro text. - @param macro: Macro text. - """ - self.__tuxDriver.PerformMacroText(macro) - - # -------------------------------------------------------------------------- - # Execute a RAW command. - # -------------------------------------------------------------------------- - def executeRawCommand(self, rawCommand, delay = 0.0): - """Execute a RAW command. - @param rawCommand: RAW command. - @param delay: Delay before to execute the command. - """ - self.__tuxDriver.PerformCommand(0.0, rawCommand) - - # Sound -------------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Set the current sound channel in the dongle. - # -------------------------------------------------------------------------- - def setSoundChannel(self, channelName): - """Set the current sound channel in the dongle. - @param channelName: Name of the channel. <GENERAL|TTS> - """ - def async(): - cmd = "TUX_CMD:AUDIO:CHANNEL_%s" % channelName - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Play a sound flash. - # -------------------------------------------------------------------------- - def playSound(self, track, volume): - """Play a sound flash. - @param track: Number of the sound to play <1..255> - @param volume: Volume of the sound <0.0 .. 100.0> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SOUND_FLASH:PLAY:%d,%f' % (track, volume) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Reflash the sound flash memory of Tux Droid. - # -------------------------------------------------------------------------- - def reflashSoundMemory(self, tracks): - """Reflash the sound flash memory of Tux Droid. - @param tracks: Tracks list. "<wav_path_1>|<wav_path_2>|...|<wav_path_n>" - """ - self.__tuxDriver.SoundReflash(tracks) - - # Eyes --------------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Open the eyes. - # -------------------------------------------------------------------------- - def openEyes(self): - """Open the eyes. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:EYES:OPEN') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Close the eyes. - # -------------------------------------------------------------------------- - def closeEyes(self): - """Close the eyes. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:EYES:CLOSE') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a movement of the eyes. - # -------------------------------------------------------------------------- - def eyesOn(self, count, finalState): - """Start a movement of the eyes. - @param count: Number of movements. - @param finalState: Final state of the eyes at the end of movements. - <NDEF|OPEN|CLOSE> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:EYES:ON:%d,%s' % (count, finalState) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a movement of the eyes. - # -------------------------------------------------------------------------- - def eyesOnDuring(self, duration, finalState): - """Start a movement of the eyes. - @param duration: Duration of the eyes movement. - @param finalState: Final state of the eyes at the end of movements. - <NDEF|OPEN|CLOSE> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:EYES:ON_DURING:%f,%s' % (duration, finalState) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Stop the eyes movement. - # -------------------------------------------------------------------------- - def eyesOff(self): - """Stop the eyes movement. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:EYES:OFF') - t = threading.Thread(target = async) - t.start() - return True - - # Mouth -------------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Open the mouth. - # -------------------------------------------------------------------------- - def openMouth(self): - """Open the mouth. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:MOUTH:OPEN') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Close the mouth. - # -------------------------------------------------------------------------- - def closeMouth(self): - """Close the mouth. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:MOUTH:CLOSE') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a movement of the mouth. - # -------------------------------------------------------------------------- - def mouthOn(self, count, finalState): - """Start a movement of the mouth. - @param count: Number of movements. - @param finalState: Final state of the mouth at the end of movements. - <NDEF|OPEN|CLOSE> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:MOUTH:ON:%d,%s' % (count, finalState) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a movement of the mouth. - # -------------------------------------------------------------------------- - def mouthOnDuring(self, duration, finalState): - """Start a movement of the mouth. - @param duration: Duration of the mouth movement. - @param finalState: Final state of the mouth at the end of movements. - <NDEF|OPEN|CLOSE> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:MOUTH:ON_DURING:%f,%s' % (duration, finalState) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Stop the mouth movement. - # -------------------------------------------------------------------------- - def mouthOff(self): - """Stop the mouth movement. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:MOUTH:OFF') - t = threading.Thread(target = async) - t.start() - return True - - # Flippers ----------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Set the flippers position to up. - # -------------------------------------------------------------------------- - def upFlippers(self): - """Set the flippers position to up. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:FLIPPERS:UP') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Set the flippers position to down. - # -------------------------------------------------------------------------- - def downFlippers(self): - """Set the flippers position to down. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:FLIPPERS:DOWN') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a movement of the filppers. - # -------------------------------------------------------------------------- - def flippersOn(self, count, finalState): - """Start a movement of the filppers. - @param count: Number of movements. - @param finalState: Final state of the flippers at the end of movements. - <NDEF|UP|DOWN> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:FLIPPERS:ON:%d,%s' % (count, finalState) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a movement of the filppers. - # -------------------------------------------------------------------------- - def flippersOnDuring(self, duration, finalState): - """Start a movement of the filppers. - @param duration: Duration of the flippers movement. - @param finalState: Final state of the flippers at the end of movements. - <NDEF|UP|DOWN> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:FLIPPERS:ON_DURING:%f,%s' % (duration, finalState) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Stop the flippers movement. - # -------------------------------------------------------------------------- - def flippersOff(self): - """Stop the flippers movement. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - self.__tuxDriver.PerformCommand(0.0, 'TUX_CMD:FLIPPERS:OFF') - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Set the speed of the flippers movements. - # -------------------------------------------------------------------------- - def setFlippersSpeed(self, speed): - """Set the speed of the flippers movements. - @param speed: Speed. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:FLIPPERS:SPEED:%d' % speed - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # Spinning ----------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Start a rotation to the left. - # -------------------------------------------------------------------------- - def spinLeftOn(self, count): - """Start a rotation to the left. - @param count: Number of quarter of turns. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SPINNING:LEFT_ON:%d' % count - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a rotation to the right. - # -------------------------------------------------------------------------- - def spinRightOn(self, count): - """Start a rotation to the right. - @param count: Number of quarter of turns. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SPINNING:RIGHT_ON:%d' % count - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a rotation to the left. - # -------------------------------------------------------------------------- - def spinLeftOnDuring(self, duration): - """Start a rotation to the left. - @param duration: Duration of the rotation in seconds. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SPINNING:LEFT_ON_DURING:%f' % duration - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a rotation to the right. - # -------------------------------------------------------------------------- - def spinRightOnDuring(self, duration): - """Start a rotation to the right. - @param duration: Duration of the rotation in seconds. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SPINNING:RIGHT_ON_DURING:%f' % duration - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Stop the rotation. - # -------------------------------------------------------------------------- - def spinningOff(self): - """Stop the rotation. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SPINNING:OFF' - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Set the speed of the rotation. - # -------------------------------------------------------------------------- - def setSpinningSpeed(self, speed): - """Set the speed of the rotation. - @param speed: Speed. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:SPINNING:SPEED:%d' % speed - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # Leds --------------------------------------------------------------------- - - # -------------------------------------------------------------------------- - # Start a blink of the leds. - # -------------------------------------------------------------------------- - def ledsBlink(self, leds, count, delay): - """Start a blink of the leds. - @param leds: Leds. <LED_BOTH|LED_RIGHT|LED_LEFT> - @param count: Number of blinks. - @param delay: Delay between 2 blinks in seconds. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:LED:BLINK:%s,%d,%f' % (leds, count, delay) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Stop any leds state changes. - # -------------------------------------------------------------------------- - def ledsOff(self, leds): - """Stop any leds state changes. - @param leds: Leds. <LED_BOTH|LED_RIGHT|LED_LEFT> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:LED:OFF:%s' % leds - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Turn on the leds. - # -------------------------------------------------------------------------- - def ledsOn(self, leds, intensity): - """Turn on the leds. - @param leds: Leds. <LED_BOTH|LED_RIGHT|LED_LEFT> - @param intensity: Leds intensity. <0.0 .. 1.0> - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:LED:ON:%s,%f' % (leds, intensity) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a transition of the leds state. - # -------------------------------------------------------------------------- - def ledsSet(self, leds, intensity, fxType, fxSpeed, fxStep): - """Start a transition of the leds state. - @param leds: Leds. <LED_BOTH|LED_RIGHT|LED_LEFT> - @param intensity: Final leds intensity. <0.0 .. 1.0> - @param fxType: <UNAFFECTED|LAST|NONE|DEFAULT|FADE_DURATION|FADE_RATE|GRADIENT_NBR|GRADIENT_DELTA> - @param fxSpeed: Speed of the transition. - @param fxStep: Number of steps while the leds transition. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:LED:SET:%s,%f,%s,%f,%d' % (leds, intensity, fxType, - fxSpeed, fxStep) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - - # -------------------------------------------------------------------------- - # Start a pluse effect of the leds. - # -------------------------------------------------------------------------- - def ledsPulse(self, leds, minIntensity, maxIntensity, count, period, fxType, - fxSpeed, fxStep): - """Start a pluse effect of the leds. - @param leds: Leds. <LED_BOTH|LED_RIGHT|LED_LEFT> - @param minIntensity: Minimal leds intensity. <0.0 .. 1.0> - @param maxIntensity: Maximal leds intensity. <0.0 .. 1.0> - @param count: Number of pulses. - @param period: Period duration of the pulse transitions. - @param fxType: <UNAFFECTED|LAST|NONE|DEFAULT|FADE_DURATION|FADE_RATE|GRADIENT_NBR|GRADIENT_DELTA> - @param fxSpeed: Speed of the transitions. - @param fxStep: Number of steps while the leds transition. - @return: True or False. (depend of the dongle plug state) - """ - if not self.__donglePlugged: - return False - def async(): - cmd = 'TUX_CMD:LED:PULSE:%s,%f,%f,%d,%f,%s,%f,%d' % (leds, - minIntensity, maxIntensity, count, period, fxType, fxSpeed, - fxStep) - self.__tuxDriver.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - return True - -# Create an instance of the resource -resourceTuxDriver = TDSResourceTuxDriver("resourceTuxDriver") -# Register the resource into the resources manager -resourcesManager.addResource(resourceTuxDriver) Deleted: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/01_resourceTuxOSL.py =================================================================== --- software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/01_resourceTuxOSL.py 2009-11-18 10:32:56 UTC (rev 5904) +++ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/01_drivers/01_resourceTuxOSL.py 2009-11-18 11:40:32 UTC (rev 5905) @@ -1,336 +0,0 @@ -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -from util.osl import * - -# ============================================================================== -# ****************************************************************************** -# RESOURCE DECLARATION -# ****************************************************************************** -# ============================================================================== - -# ============================================================================== -# Declaration of the resource "tuxosl". -# ============================================================================== -class TDSResourceTuxOSL(TDSResource): - """Resource tuxosl class. - """ - - # ========================================================================== - # Inherited methods from TDSResource - # ========================================================================== - - # -------------------------------------------------------------------------- - # Configure the resource. - # -------------------------------------------------------------------------- - def configure(self): - """Configure the resource. - """ - # General configuration (inherited from ancestor) - self.name = "tuxosl" - self.comment = "Resource to handling the TuxOSL library." - self.fileName = RESOURCE_FILENAME - # Registering the TuxOSL statuses - for statusName in SW_NAME_OSL: - eventsHandler.insert(statusName) - # Create and configure a Tux OSL object - self.__tuxOSL = TuxOSL() - self.__tuxOSL.SetLogLevel(TDS_CONF_LOG_LEVEL) - self.__tuxOSL.SetStatusCallback(self.__onStatusCallback) - # Others - self.__oslMutex = threading.Lock() - - # -------------------------------------------------------------------------- - # Start the resource. - # -------------------------------------------------------------------------- - def start(self): - """Start the resource. - """ - eventsHandler.getEventHandler(ST_NAME_DONGLE_PLUG).register(self.__onDonglePlugCallback) - eventsHandler.getEventHandler(ST_NAME_OSL_SOUND_STATE).register(self.__onSoundStateCallback) - if resourceTuxDriver.getDonglePlugged(): - self.__onDonglePlugCallback(True, 0.0) - - # -------------------------------------------------------------------------- - # Stop the resource. - # -------------------------------------------------------------------------- - def stop(self): - """Stop the resource. - """ - self.__tuxOSL.Stop() - - # ========================================================================== - # Private methods - # ========================================================================== - - # -------------------------------------------------------------------------- - # Event on status. - # -------------------------------------------------------------------------- - def __onStatusCallback(self, status): - """Event on status. - @param status: The status. - """ - # Parse the structure of the status - statusStruct = self.__tuxOSL.GetStatusStruct(status) - # Send the status/event to the events handler - def async1(): - eventsHandler.emit(statusStruct['name'], (statusStruct['value'], - float(statusStruct['delay']))) - t = threading.Thread(target = async1) - t.start() - # Send the status/events to the clients manager - def async2(): - clientsManager.pushEvents([statusStruct,]) - t = threading.Thread(target = async2) - t.start() - - # -------------------------------------------------------------------------- - # Event on dongle plug/unplug. - # -------------------------------------------------------------------------- - def __onDonglePlugCallback(self, value, delay): - """Event on dongle plug/unplug. - """ - def startTuxOsl(): - self.__tuxOSL.Start("Acapela") - time.sleep(0.5) - resourceTuxDriver.ledsBlink("LED_BOTH", 100, 0.5) - self.__initializeStatesInEventsHandler() - time.sleep(1.5) - # Load first voice - pitch = resourceUsers.getCurrentUserConfiguration()['pitch'] - firstLocutor = resourceUsers.getCurrentUserConfiguration()['locutor1'] - self.ttsSpeak(" ", firstLocutor, pitch) - time.sleep(1.5) - # Load second voice - secondLocutor = resourceUsers.getCurrentUserConfiguration()['locutor2'] - self.ttsSpeak(" ", secondLocutor, pitch) - time.sleep(1.5) - # Reference locutors list - resourcePluginsServer.getPluginsContainer().setLocutorsList(self.ttsVoicesList()) - # Play the opening attitune. - resourceTuxDriver.ledsOn("LED_BOTH", 1.0) - resourceAttituneManager.playAttitune("TuxBox Ready", 0.0) - # Start the robot/content interactions - resourceRobotContentInteractions.startMe() - if value: - t = threading.Thread(target = startTuxOsl) - t.start() - else: - t = threading.Thread(target = self.stop) - t.start() - - # -------------------------------------------------------------------------- - # Event on sound state changed. - # -------------------------------------------------------------------------- - def __onSoundStateCallback(self, value, delay): - """Event on sound state changed. - """ - if value == "ON": - resourceTuxDriver.setSoundChannel("TTS") - else: - resourceTuxDriver.setSoundChannel("GENERAL") - - # -------------------------------------------------------------------------- - # Reencode text from utf-8 to cp1252. - # -------------------------------------------------------------------------- - def __reencodeText(self, text): - """Reencode text from utf-8 to cp1252. - @param text: Original text. - @return: The reencoded text. - """ - try: - u = unicode(text, "utf-8") - text = u.encode("cp1252", "replace") - except: - pass - return text - - # -------------------------------------------------------------------------- - # Initialize statuses state in the events handler. - # -------------------------------------------------------------------------- - def __initializeStatesInEventsHandler(self): - """Initialize statuses state in the events handler. - """ - def async(): - states = self.__tuxOSL.GetAllStatusState() - if len(states) > 0: - states = states[:-1] - states = states.split('\n') - for state in states: - stateStruct = self.__tuxOSL.GetStatusStruct(state) - if stateStruct['name'] != "None": - eventsHandler.updateState(stateStruct['name'], ( - stateStruct['value'], float(stateStruct['delay']))) - t = threading.Thread(target = async) - t.start() - - # ========================================================================== - # Public methods - # ========================================================================== - - # -------------------------------------------------------------------------- - # Perform a speech. - # -------------------------------------------------------------------------- - def ttsSpeak(self, text, locutor, pitch): - """Perform a speech. - @param text: Text to speak. - @param locutor: Locutor voice. - @param pitch: Pitch of the voice. <50..250> - """ - text = self.__reencodeText(text) - if locutor.find('8k') == -1: - locutor += '8k' - def async(): - self.__oslMutex.acquire() - cmd = 'OSL_CMD:TTS:STOP' - self.__tuxOSL.PerformCommand(0.0, cmd) - cmd = 'OSL_CMD:TTS:SET_LOCUTOR:%s' % locutor - self.__tuxOSL.PerformCommand(0.0, cmd) - cmd = 'OSL_CMD:TTS:SET_PITCH:%d' % pitch - self.__tuxOSL.PerformCommand(0.0, cmd) - cmd = 'OSL_CMD:TTS:SPEAK:%s' % text - self.__tuxOSL.PerformCommand(0.0, cmd) - time.sleep(0.1) - self.__oslMutex.release() - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Set if the current speech is paused or not. - # -------------------------------------------------------------------------- - def ttsPause(self, value = 'True'): - """Set if the current speech is paused or not. - @param value: Pause value. <True|False> as string. - """ - def async(): - cmd = 'OSL_CMD:TTS:SET_PAUSE:%s' % value - self.__tuxOSL.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Stop the current performed speech. - # -------------------------------------------------------------------------- - def ttsStop(self): - """Stop the current performed speech. - """ - def async(): - cmd = 'OSL_CMD:TTS:STOP' - self.__tuxOSL.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Retrieve the locutors/voices list. - # -------------------------------------------------------------------------- - def ttsVoicesList(self): - """Retrieve the locutors/voices list. - @return: The voices list. - """ - result = eventsHandler.getEventHandler(ST_NAME_VOICE_LIST).getLastState() - voices = [] - if result != None: - tmpVoices = result[0][1:-1].split(',') - for voice in tmpVoices: - if len(voice) < 2: - continue - voices.append(voice) - return voices - - # -------------------------------------------------------------------------- - # Reencode the sentences included in a macro to "cp1252" if they are in - # "utf-8". - # -------------------------------------------------------------------------- - def reencodeTTSTextInMacro(self, macro): - """Reencode the sentences included in a macro to "cp1252" if they are - in "utf-8". - @param macro: Macro text. - @return: The reencoded macro. - """ - spText = macro.split("\n") - result = "" - for cmd in spText: - if cmd.find("OSL_CMD:TTS:SPEAK:") != -1: - try: - u = unicode(cmd, "utf-8") - text = u.encode("cp1252", "replace") - cmd = text - except: - pass - result += cmd + "\n" - return result - - # -------------------------------------------------------------------------- - # Play a wave file (8K - 8bit - Mono) - # -------------------------------------------------------------------------- - def wavPlay(self, path, begin, end): - """Play a wave file (8K - 8bit - Mono) - @param path: Path of the wave file. - @param begin: Beginning second. - @param end: Ending second. - @return: The used channel by TuxOSL or not. - - The used channel is important when you wait for the end of wav playing. - """ - if not resourceTuxDriver.getDonglePlugged(): - return None - # Check the file extension - if path.lower().rfind(".wav") == -1: - return None - # Create a cached file with the wav file - cFile = filesCacheManager.createFileCache(path) - # If the attitune can't be cached then FAIL - if cFile == None: - return None - cmd = 'OSL_CMD:WAV:PLAY:%f,%f,%s' % (begin, end, - cFile.getOutputFilePath()) - return self.__tuxOSL.PerformCommand(0.01, cmd) - - # -------------------------------------------------------------------------- - # Set if the current waves played is paused or not. - # -------------------------------------------------------------------------- - def wavPause(self, value): - """Set if the current waves played is paused or not. - @param value: Pause value. <True|False> as string. - """ - def async(): - cmd = 'OSL_CMD:WAV:SET_PAUSE:%s' % value - self.__tuxOSL.PerformCommand(0.0, cmd) - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Stop the current played wave files. - # -------------------------------------------------------------------------- - def wavStop(self): - """Stop the current played wave files. - """ - def async(): - self.__tuxOSL.PerformCommand(0.0, 'OSL_CMD:WAV:STOP') - t = threading.Thread(target = async) - t.start() - - # -------------------------------------------------------------------------- - # Clear all the current played wave files and performed speech. - # -------------------------------------------------------------------------- - def clearAll(self): - """Clear all the current played wave files and performed speech. - """ - self.__tuxOSL.ClearCommandStack() - self.__tuxOSL.PerformCommand(0.0, "OSL_CMD:TTS:STOP") - self.__tuxOSL.PerformCommand(0.0, "OSL_CMD:WAV:STOP") - - # -------------------------------------------------------------------------- - # Execute a macro text. - # -------------------------------------------------------------------------- - def executeMacro(self, macro): - """Execute a macro text. - @param macro: Macro text. - """ - self.__tuxOSL.PerformMacroText(macro) - -# Create an instance of the resource -resourceTuxOSL = TDSResourceTuxOSL("resourceTuxOSL") -# Register the resource into the resources manager -resourcesManager.addResource(resourceTuxOSL) Deleted: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/00_resourceAttitune.py =================================================================== --- software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/00_resourceAttitune.py 2009-11-18 10:32:56 UTC (rev 5904) +++ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/00_resourceAttitune.py 2009-11-18 11:40:32 UTC (rev 5905) @@ -1,205 +0,0 @@ -# ============================================================================== -# Attitune resource. -# ============================================================================== - -# This resource depends of the following resources : -# - resourceTuxDriver -# - resourceTuxOSL - -from util.attitunes.AttitunesFileReader import * - -# ------------------------------------------------------------------------------ -# Declaration of the resource "attitune". -# ------------------------------------------------------------------------------ -class TDSResourceAttitune(TDSResource): - - # -------------------------------------------------------------------------- - # Inherited methods from TDSResource - # -------------------------------------------------------------------------- - - def configure(self): - self.name = "attitune" - self.comment = "Resource to manage the playing of attitune files." - self.fileName = RESOURCE_FILENAME - self.__attituneMutex = threading.Lock() - self.__currentAttitune = None - - def stop(self): - if self.__currentAttitune != None: - self.__currentAttitune.destroy() - - # -------------------------------------------------------------------------- - # Public methods - # -------------------------------------------------------------------------- - - def loadAttitune(self, fileName): - """Load an attitune file. - @param fileName: File name path of the attitune. (internet URL or local) - @return: True or False. - """ - # Check the file extension - if fileName.lower().rfind(".att") == -1: - return False - self.__attituneMutex.acquire() - # Create a cached file with the attitune file - cFile = filesCacheManager.createFileCache(fileName) - # If the attitune can't be cached then FAIL - if cFile == None: - self.__attituneMutex.release() - return False - # If an attitune is currently loaded in the attitunes reader then - # destroy it. - if self.__currentAttitune != None: - self.__currentAttitune.destroy() - # Load the attitune in the attitunes reader. - self.__currentAttitune = AttitunesFileReader(cFile.getOutputFilePath()) - # If the attitune is invalid the FAIL - if not self.__currentAttitune.getValid(): - self.__currentAttitune = None - self.__attituneMutex.release() - return False - self.__attituneMutex.release() - # Success ! - return True - - def playAttitune(self, begin): - """Play the current loaded attitune file. - @param begin: Begining position. - @return: True or False. - """ - if not resourceTuxDriver.getDonglePlugged(): - return False - self.__attituneMutex.acquire() - if self.__currentAttitune != None: - resourceTuxOSL.clearAll() - resourceTuxDriver.clearAll() - macro = self.__currentAttitune.toMacro(begin) - macro = resourceTuxOSL.reencodeTTSTextInMacro(macro) - if len(macro) <= 16384: - resourceTuxDriver.executeMacro(macro) - resourceTuxOSL.executeMacro(macro) - else: - self.__attituneMutex.release() - return False - else: - self.__attituneMutex.release() - return False - self.__attituneMutex.release() - return True - - def stopAttitune(self): - """Stop the current played attitune. - """ - def async(): - self.__attituneMutex.acquire() - if self.__currentAttitune != None: - resourceTuxOSL.clearAll() - resourceTuxDriver.clearAll() - self.__attituneMutex.release() - t = threading.Thread(target = async) - t.start() - -# Create an instance of the resource -resourceAttitune = TDSResourceAttitune("resourceAttitune") -# Register the resource into the resources manager -resourcesManager.addResource(resourceAttitune) - -# ------------------------------------------------------------------------------ -# Declaration of the service "load". -# ------------------------------------------------------------------------------ -class TDSServiceAttituneLoad(TDSService): - - def configure(self): - self.parametersDict = { - 'path' : 'string', - } - self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS - self.exclusiveExecution = False - self.name = "load" - self.comment = "Load an attitune." - - def execute(self, id, parameters): - headersStruct = self.getDefaultHeadersStruct() - contentStruct = self.getDefaultContentStruct() - contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS) - if not resourceAttitune.loadAttitune(parameters['path']): - contentStruct['root']['result'] = getStrError(E_TDREST_FAILED) - return headersStruct, contentStruct - -# Register the service into the resource -resourceAttitune.addService(TDSServiceAttituneLoad) - -# ------------------------------------------------------------------------------ -# Declaration of the service "play". -# ------------------------------------------------------------------------------ -class TDSServiceAttitunePlay(TDSService): - - def configure(self): - self.parametersDict = { - 'begin' : 'float', - } - self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS - self.exclusiveExecution = False - self.name = "play" - self.comment = "Play an attitune." - - def execute(self, id, parameters): - headersStruct = self.getDefaultHeadersStruct() - contentStruct = self.getDefaultContentStruct() - contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS) - if not resourceAttitune.playAttitune(parameters['begin']): - contentStruct['root']['result'] = getStrError(E_TDREST_FAILED) - return headersStruct, contentStruct - -# Register the service into the resource -resourceAttitune.addService(TDSServiceAttitunePlay) - -# ------------------------------------------------------------------------------ -# Declaration of the service "load_and_play". -# ------------------------------------------------------------------------------ -class TDSServiceAttituneLoadPlay(TDSService): - - def configure(self): - self.parametersDict = { - 'path' : 'string', - } - self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS - self.exclusiveExecution = False - self.name = "load_and_play" - self.comment = "Load and play an attitune." - - def execute(self, id, parameters): - headersStruct = self.getDefaultHeadersStruct() - contentStruct = self.getDefaultContentStruct() - contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS) - if not resourceAttitune.loadAttitune(parameters['path']): - contentStruct['root']['result'] = getStrError(E_TDREST_FAILED) - else: - if not resourceAttitune.playAttitune(0.0): - contentStruct['root']['result'] = getStrError(E_TDREST_FAILED) - return headersStruct, contentStruct - -# Register the service into the resource -resourceAttitune.addService(TDSServiceAttituneLoadPlay) - -# ------------------------------------------------------------------------------ -# Declaration of the service "stop". -# ------------------------------------------------------------------------------ -class TDSServiceAttituneStop(TDSService): - - def configure(self): - self.parametersDict = {} - self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS - self.exclusiveExecution = False - self.name = "stop" - self.comment = "Stop the played attitune." - - def execute(self, id, parameters): - headersStruct = self.getDefaultHeadersStruct() - contentStruct = self.getDefaultContentStruct() - contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS) - resourceAttitune.stopAttitune() - return headersStruct, contentStruct - -# Register the service into the resource -resourceAttitune.addService(TDSServiceAttituneStop) Deleted: software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/01_resourceEyes.py =================================================================== --- software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/01_resourceEyes.py 2009-11-18 10:32:56 UTC (rev 5904) +++ software_suite_v3/smart-core/smart-server/branches/no_tux_dependencies/resources/02_robot/01_resourceEyes.py 2009-11-18 11:40:32 UTC (rev 5905) @@ -1,158 +0,0 @@ -# ============================================================================== -# Eyes resource. -# ============================================================================== - -# This resource depends of the following resources : -# - resourceTuxDriver - -# ------------------------------------------------------------------------------ -# Declaration of the resource "eyes". -# ------------------------------------------------------------------------------ -class TDSResourceEyes(TDSResource): - - # -------------------------------------------------------------------------- - # Inherited methods from TDSResource - # -------------------------------------------------------------------------- - - def configure(self): - self.name = "eyes" - self.comment = "Resource to control the eyes of Tux Droid." - self.fileName = RESOURCE_FILENAME - -# Create an instance of the resource -resourceEyes = TDSResourceEyes("resourceEyes") -# Register the resource into the resources manager -resourcesManager.addResource(resourceEyes) - -# --------------------------------... [truncated message content] |