[tuxdroid-svn] r245 - svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment va
Status: Beta
Brought to you by:
ks156
From: svnlook:warning@affinitic.be:cannot s. L. l. <c2m...@c2...> - 2007-04-13 10:14:11
|
Author: svnlook: warning: cannot set LC_CTYPE locale Date: svnlook: warning: environment variable LANG is EN New Revision: 245 Removed: api/python/trunk/tux.py api/python/trunk/tuxapi_class.py api/python/trunk/tuxapi_const.py Modified: Log: remi 2007-04-13 12:14:08 +0200 (Fri, 13 Apr 2007) 514 UPD Start of the version 0.2.0 of the api. The api was completely remade. I Kept the changes made by Neimad lately. Sorry for this brutal update. I have implemented the 'join()' suggestion from Damien for the threads too. Consequently, this api is not fully compatible with the last one. A documentation system based on the docstring has been implemented and you can build this with the function 'tux.misc.build_documentation'. See 'tux.misc.doc(tux.misc.build_documentation)'. See 'tux.misc.doc(tux)' too svnlook: warning: cannot set LC_CTYPE locale svnlook: warning: environment variable LANG is EN svnlook: warning: please check that your locale name is correct Deleted: api/python/trunk/tux.py =================================================================== --- api/python/trunk/tux.py 2007-04-13 09:28:15 UTC (rev 244) +++ api/python/trunk/tux.py 2007-04-13 10:14:08 UTC (rev 245) @@ -1,22 +0,0 @@ -#!/usr/bin/python -# -*- coding: latin-1 -*- - -import sys -from tuxapi_const import * -import tuxapi_class -import tuxapi_wav_merger -import signal - -global tux -tux=tuxapi_class.TUXTCPCommunicator(5000, "localhost") -tux.print_api_version() -wavs=tuxapi_wav_merger.WavMerger(tux) -tux.connect_to_daemon() - -def exit(signum,frame): - print "exiting (%d) ..."%(signum) - tux.disconnect_from_daemon() - sys.exit(signum) - -signal.signal(signal.SIGTERM, exit) -signal.signal(signal.SIGINT, exit) Deleted: api/python/trunk/tuxapi_class.py =================================================================== --- api/python/trunk/tuxapi_class.py 2007-04-13 09:28:15 UTC (rev 244) +++ api/python/trunk/tuxapi_class.py 2007-04-13 10:14:08 UTC (rev 245) @@ -1,1862 +0,0 @@ -#!/usr/bin/python - -# ----------------------------------------------------------------------------- -# Tux Droid - API Class -# Copyright (C) 2007 C2ME Sa <rem...@c2...> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. -# ----------------------------------------------------------------------------- -# $Id$ -# ----------------------------------------------------------------------------- - -import sys -import os -import time -from socket import * -import thread -from tuxapi_const import * - -#============================================================================== -# Constants -#============================================================================== - -api_version ="0.1.3 (SVN/UNRELEASED)" - -HEAD_BT =1 -LEFT_WING_BT =2 -RIGHT_WING_BT =3 -NONE_BT =0 -NULL_BT =0xFF - -HEAD_BUTTON_PUSHED =1 -HEAD_BUTTON_RELEASED =2 -LEFT_WING_PUSHED =3 -LEFT_WING_RELEASED =4 -RIGHT_WING_PUSHED =5 -RIGHT_WING_RELEASED =6 - -CT_SHELL =1 -CT_FUNCTION =2 - -#============================================================================== -# TUXTCPCommunicator class -#============================================================================== -class TUXTCPCommunicator(object): - - #-------------------------------------------------------------------------- - ## Constructor of class - ## @param port : Tcp/IP Port number - ## @param ipAddress : Tcp/IP Host address - #-------------------------------------------------------------------------- - def __init__(self,port,ipAddress): - self.Server_port=port - self.Server_address=ipAddress - self.connected=False - self.last_datas=("a","a","a","a","a","a") - self.datas_threated=True - self.last_datas_for_event=("a","a","a","a","a","a") - self.bloc_datas_flag=False - self.my_name="Tux client" - self.RF_connected=False - self.print_status=False - self.print_warnings=False - self.event=TUXevent(self) - self.cmd=TUXcmd(self) - self.sys=TUXsys(self) - self.sdaemon=TUXsdaemon(self) - self.status=TUXStatus(self) - self.hw=TUXhw(self) - self.tts=TUXtts(5500,"localhost",self) - self.tts.connect_to_daemon() - self.print_warnings=True - - #-------------------------------------------------------------------------- - ## Print versionning of API - #-------------------------------------------------------------------------- - def print_api_version(self): - print "---------------------------------------------------------------" - print "TUXDROID PYTHON API %s"%(api_version) - print "---------------------------------------------------------------" - - #-------------------------------------------------------------------------- - ## Connect object to TUX daemon - #-------------------------------------------------------------------------- - def connect_to_daemon(self): - self.connected=False - self.socket = socket(AF_INET, SOCK_STREAM) - try: - self.socket.connect((self.Server_address, self.Server_port)) - except error: - if self.print_warnings: - print "WARNING : Tux droid daemon not found" - return - self.connected=True - thread.start_new_thread(self.recv_msg_Thread,()) - thread.start_new_thread(self.data_pooling,()) - if self.event.on_connected!=None: - self.event.on_connected() - time.sleep(1) - - #-------------------------------------------------------------------------- - ## Disconnect object from TUX daemon - #-------------------------------------------------------------------------- - def disconnect_from_daemon(self): - if self.connected: - self.sdaemon.disconnect_me() - self.connected=False - self.sys.wait(0.5) - while ((self.data_pooling_run) and (self.recv_msg_Thread_run)): - self.sys.wait(0.01) - self.socket.close() - if self.event.on_disconnected!=None: - self.event.on_disconnected() - self.tts.disconnect_from_daemon() - - #-------------------------------------------------------------------------- - ## Messages receiver (Thread) - ## SYSTEM function - #-------------------------------------------------------------------------- - def recv_msg_Thread(self): - self.recv_msg_Thread_run=True - while self.connected: - while self.bloc_datas_flag: - if not self.connected: return - time.sleep(0.001) - self.bloc_datas_flag=True - try: - self.last_datas=self.socket.recv(16) - except error: - self.socket.close() - self.connected=False - self.bloc_datas_flag=False - continue - self.last_datas_for_event=self.last_datas - self.datas_threated=False - if self.print_status: - struct_data = ["%.2x" % ord(data) for data in self.last_datas] - print " ".join(struct_data) - self.bloc_datas_flag=False - time.sleep(0.01) - self.recv_msg_Thread_run=False - - -#------------------------------------------------------------------------------- -# Extract event from status -#------------------------------------------------------------------------------- - - #-------------------------------------------------------------------------- - ## Converting raw status to explicit string status - ## Return a string - #-------------------------------------------------------------------------- - def explicit_status(self): - value_onoff=0 - value_10=1 - value_8b=2 - value_16b=3 - value_np=4 - - value_type=value_onoff - line="" - status=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] - for i, data in enumerate(self.last_datas_for_event): - status[i]=ord(data) - # -- Tux status - if status[4]==DATAS_STATUS_WINGS_MOTOR_BACKWARD: - line=line+"Wings motor backward->" - if status[4]==DATAS_STATUS_SPIN_MOTOR_BACKWARD: - line=line+"Spin motor backward->" - if status[4]==DATAS_STATUS_SPIN_MOTOR_FORWARD: - line=line+"Spin motor forward->" - if status[4]==DATAS_STATUS_MOUTH_OPEN_POSITION: - line=line+"Mouth open position->" - if status[4]==DATAS_STATUS_MOUTH_CLOSED_POSITION: - line=line+"Mouth closed position->" - if status[4]==DATAS_STATUS_HEAD_PUSH_POSITION: - line=line+"Head push position->" - if status[4]==DATAS_STATUS_CHARGER_INHIBIT_SIGNAL: - line=line+"Charger inhibit signal->" - if status[4]==DATAS_STATUS_WINGS_POSITION_SWITCH: - line=line+"Wings position switch->" - if status[4]==DATAS_STATUS_MOTOR_FOR_WINGS: - line=line+"Motor for wings->" - if status[4]==DATAS_STATUS_LEFT_BLUE_LED: - line=line+"Left blue led->" - if status[4]==DATAS_STATUS_HEAD_MOTOR_FOR_MOUTH: - line=line+"Head motor for beack->" - if status[4]==DATAS_STATUS_HEAD_MOTOR_FOR_EYES: - line=line+"Head motor for eyes->" - if status[4]==DATAS_STATUS_IR_RECEIVER_SIGNAL: - line=line+"Ir receiver signal->" - if status[4]==DATAS_STATUS_SPIN_POSITION_SWITCH: - line=line+"Spin position switch->" - if status[4]==DATAS_STATUS_WINGS_MOTOR_FORWARD: - line=line+"Wings motor forward->" - if status[4]==DATAS_STATUS_IR_LED: - line=line+"IR led->" - if status[4]==DATAS_STATUS_EYES_OPEN_POSITION_SWITCH: - line=line+"Eyes open position switch->" - if status[4]==DATAS_STATUS_EYES_CLOSED_POSITION_SWITCH: - line=line+"Eyes closed position switch->" - if status[4]==DATAS_STATUS_LEFT_WING_PUSH: - line=line+"Left wing push->" - if status[4]==DATAS_STATUS_RIGHT_WING_PUSH: - line=line+"Right wing push->" - if status[4]==DATAS_STATUS_POWER_PLUG_SWITCH: - line=line+"Power plug switch->" - if status[4]==DATAS_STATUS_HEAD_PUSH_SWITCH: - line=line+"Head push switch->" - if status[4]==DATAS_STATUS_CHARGER_LED_STATUS: - line=line+"Charger led status->" - if status[4]==DATAS_STATUS_MUTE_STATUS: - line=line+"Audio mute->" - if status[4]==DATAS_STATUS_LIGHT_LEVEL: - line=line+"Light level->" - value_type=value_16b - if status[4]==DATAS_STATUS_EYES_POSITION_COUNTER: - line=line+"Eyes position counter->" - value_type=value_8b - if status[4]==DATAS_STATUS_MOUTH_POSITION_COUNTER: - line=line+"Mouth position counter->" - value_type=value_8b - if status[4]==DATAS_STATUS_WINGS_POSITION_COUNTER: - line=line+"Wings position counter->" - value_type=value_8b - if status[4]==DATAS_STATUS_SPIN_POSITION_COUNTER: - line=line+"Spin position counter->" - value_type=value_8b - if status[4]==DATAS_STATUS_RIGHT_BLUE_LED: - line=line+"Right blue led->" - if status[4]==DATAS_STATUS_RF_CONNECTED: - line=line+"RF connected->" - if status[4]==DATAS_STATUS_IR_CODE: - line=line+"IR code->%s"%remote_bt_name[status[5]] - value_type=value_np - if status[4]==DATAS_STATUS_SOUND_COUNT: - line=line+"Flash sounds count->" - if status[4]==DATAS_STATUS_PONG: - line=line+"Pong-> Received : %d Remaining : %d Average : %.0f %s"\ - %(status[6],status[5],((status[6]*100)/(200-status[5])),'%') - value_type=value_np - #-- Write value - if value_type==value_onoff: - if status[5]==0: line=line+"off" - else: line=line+"on" - if value_type==value_8b: - line=line+"%d"%status[5] - if value_type==value_16b: - line=line+"%d"%((status[5]*256)+status[6]) - return line - - #-------------------------------------------------------------------------- - ## Pooling on data arrival from tcp server - ## SYSTEM function - #-------------------------------------------------------------------------- - def data_pooling(self): - self.data_pooling_run=True - while self.connected: - while self.datas_threated: - if not self.connected: return - time.sleep(0.003) - while self.bloc_datas_flag: - if not self.connected: return - time.sleep(0.001) - self.dispatch_data_from_tcp_server() - self.datas_threated=True - self.data_pooling_run=False - - #-------------------------------------------------------------------------- - ## Dispatch data from tcp server - ## SYSTEM function - #-------------------------------------------------------------------------- - def dispatch_data_from_tcp_server(self): - # from sdaemon - if ord(self.last_datas_for_event[0])==SOURCE_SUB_DAEMON: - self.dispatch_data_from_sdaemon() - # from tux droid - if ord(self.last_datas_for_event[0])==SOURCE_TUX: - self.dispatch_data_from_tux() - - #-------------------------------------------------------------------------- - ## data from sub daemon - ## SYSTEM function - #-------------------------------------------------------------------------- - def dispatch_data_from_sdaemon(self): - # data type command - if ord(self.last_datas_for_event[2])==DATA_TP_CMD: - if ord(self.last_datas_for_event[3])==SUBDATA_TP_STRUCT: - # daemon close - if ord(self.last_datas_for_event[4])==SUB_D_CMD_STRUC_DISCONNECT_CLIENT: - self.disconnect_from_daemon() - if self.print_warnings: - print "WARNING : TuxDaemon is disconnected" - - #-------------------------------------------------------------------------- - ## data from tux droid - ## SYSTEM function - #-------------------------------------------------------------------------- - def dispatch_data_from_tux(self): - # data type response - if ord(self.last_datas_for_event[2])==DATA_TP_RSP: - if ord(self.last_datas_for_event[3])==SUBDATA_TP_STATUS: - if self.event.on_status!=None: - self.event.on_status() - #Head button - if ord(self.last_datas_for_event[4])==DATAS_STATUS_HEAD_PUSH_SWITCH: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_head_bt_pushed!=None: - self.event.on_head_bt_pushed() - if self.event.on_bt_pushed!=None: - self.event.on_bt_pushed() - else: - if self.event.on_head_bt_released!=None: - self.event.on_head_bt_released() - if self.event.on_bt_released!=None: - self.event.on_bt_released() - #Left wing button - if ord(self.last_datas_for_event[4])==DATAS_STATUS_LEFT_WING_PUSH: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_lwing_bt_pushed!=None: - self.event.on_lwing_bt_pushed() - if self.event.on_bt_pushed!=None: - self.event.on_bt_pushed() - else: - if self.event.on_lwing_bt_released!=None: - self.event.on_lwing_bt_released() - if self.event.on_bt_released!=None: - self.event.on_bt_released() - #Right wing button - if ord(self.last_datas_for_event[4])==DATAS_STATUS_RIGHT_WING_PUSH: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_rwing_bt_pushed!=None: - self.event.on_rwing_bt_pushed() - if self.event.on_bt_pushed!=None: - self.event.on_bt_pushed() - else: - if self.event.on_rwing_bt_released!=None: - self.event.on_rwing_bt_released() - if self.event.on_bt_released!=None: - self.event.on_bt_released() - #Remote button - if ord(self.last_datas_for_event[4])==DATAS_STATUS_IR_CODE: - if self.event.on_remote_bt[ord(self.last_datas_for_event[5])]!=None: - self.event.on_remote_bt[ord(self.last_datas_for_event[5])]() - if self.event.on_remote!=None: - self.event.on_remote(ord(self.last_datas_for_event[5])) - #Mouth open - if ord(self.last_datas_for_event[4])==DATAS_STATUS_MOUTH_OPEN_POSITION: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_mouth_open!=None: - self.event.on_mouth_open() - #Mouth close - if ord(self.last_datas_for_event[4])==DATAS_STATUS_MOUTH_CLOSED_POSITION: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_mouth_close!=None: - self.event.on_mouth_close() - #Ledl - if ord(self.last_datas_for_event[4])==DATAS_STATUS_LEFT_BLUE_LED: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_left_blue_led_on!=None: - self.event.on_left_blue_led_on() - else: - if self.event.on_left_blue_led_off!=None: - self.event.on_left_blue_led_off() - #Ledr - if ord(self.last_datas_for_event[4])==DATAS_STATUS_RIGHT_BLUE_LED: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_right_blue_led_on!=None: - self.event.on_right_blue_led_on() - else: - if self.event.on_right_blue_led_off!=None: - self.event.on_right_blue_led_off() - #Eyes open/close - if ord(self.last_datas_for_event[4])==DATAS_STATUS_EYES_CLOSED_POSITION_SWITCH: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_eyes_close!=None: - self.event.on_eyes_close() - else: - if self.event.on_eyes_open!=None: - self.event.on_eyes_open() - #Power plug switch - if ord(self.last_datas_for_event[4])==DATAS_STATUS_POWER_PLUG_SWITCH: - if ord(self.last_datas_for_event[5])==1: - if self.event.on_power_plugged!=None: - self.event.on_power_plugged() - else: - if self.event.on_power_unplugged!=None: - self.event.on_power_unplugged() - #RF status - if ord(self.last_datas_for_event[4])==DATAS_STATUS_RF_CONNECTED: - if ord(self.last_datas_for_event[5])==1: - self.RF_connected=True - if self.event.on_rf_connected!=None: - self.event.on_rf_connected() - else: - self.RF_connected=False - if self.event.on_rf_disconnected!=None: - self.event.on_rf_disconnected() - #PONG - if ord(self.last_datas_for_event[4])==DATAS_STATUS_PONG: - if self.event.on_pong_received!=None: - rcv=ord(self.last_datas_for_event[6]) - rem=ord(self.last_datas_for_event[5]) - avg=int((100*rcv)/(200-rem)) - self.event.on_pong_received(rcv,rem,avg) - #mouth stop - if ord(self.last_datas_for_event[4])==DATAS_STATUS_MOUTH_POSITION_COUNTER: - if ord(self.last_datas_for_event[5])==0: - if self.event.on_mouth_stop!=None: - self.event.on_mouth_stop() - #eyes stop - if ord(self.last_datas_for_event[4])==DATAS_STATUS_EYES_POSITION_COUNTER: - if ord(self.last_datas_for_event[5])==0: - if self.event.on_eyes_stop!=None: - self.event.on_eyes_stop() - - #wings stop - if ord(self.last_datas_for_event[4])==DATAS_STATUS_WINGS_POSITION_COUNTER: - if ord(self.last_datas_for_event[5])==0: - if self.event.on_wings_stop!=None: - self.event.on_wings_stop() - #spin stop - if ord(self.last_datas_for_event[4])==DATAS_STATUS_SPIN_POSITION_COUNTER: - if ord(self.last_datas_for_event[5])==0: - if self.event.on_spin_stop!=None: - self.event.on_spin_stop() - -#============================================================================== -# TUXTCPCommunicator - sys - class -#============================================================================== -class TUXsys(object): - - #-------------------------------------------------------------------------- - ## class init - ## @param parent : TUXTCPCommunicator parent object - #-------------------------------------------------------------------------- - def __init__(self,parent): - self.parent=parent - self.events_list=[[0,'NONE',9999,99,99,99,99,99]] - thread.start_new_thread(self.time_events_Thread,()) - - #-------------------------------------------------------------------------- - ## Return the current time in seconds - #-------------------------------------------------------------------------- - def time(self): - return (time.localtime()[3]*3600)+(time.localtime()[4]*60)+time.localtime()[5] - - #-------------------------------------------------------------------------- - ## Wait a defined time - ## @param seconds : Number of seconds to wait - #-------------------------------------------------------------------------- - def wait(self,seconds): - time.sleep(seconds) - - #-------------------------------------------------------------------------- - ## Execute a shell command in blocking mode - ## @param command : Shell command (ex : "xmms") - #-------------------------------------------------------------------------- - def shell(self,command): - os.system(command) - - #-------------------------------------------------------------------------- - ## Execute a shell command in non blocking mode - ## @param command : Shell command (ex : "xmms") - #-------------------------------------------------------------------------- - def shell_free(self,command): - thread.start_new_thread(self.shell,(command,)) - - #-------------------------------------------------------------------------- - ## Add a time event in the time event handler - ## @param cmd_type : Command type (CT_SHELL or CT_FUNCTION) - ## @param cmd : Command to execute - ## @param year : (ex : 2006) (9999 : parameter ignored) - ## @param month : (ex : 12) (99 : parameter ignored) - ## @param day : (ex : 23) (99 : parameter ignored) - ## @param hour : (ex : 08) (99 : parameter ignored) - ## @param minute : (ex : 55) (99 : parameter ignored) - ## @param second : (ex : 30) (99 : parameter ignored) - #-------------------------------------------------------------------------- - def add_time_event(self,cmd_type,cmd,year,month,day,hour,minute,second): - self.events_list.append([cmd_type,cmd,year,month,day,hour,minute,second]) - - #-------------------------------------------------------------------------- - ## Clear the time events in the time event handler - #-------------------------------------------------------------------------- - def clear_time_events(self): - self.events_list=[[0,'NONE',9999,99,99,99,99,99]] - - #-------------------------------------------------------------------------- - ## Time event handler (Thread) - ## SYSTEM function - #-------------------------------------------------------------------------- - def time_events_Thread(self): - def event_due(event): - now = time.localtime() - return event[2] in [now[0], 9999] \ - and event[3] in [now[1], 99] \ - and event[4] in [now[2], 99] \ - and event[5] in [now[3], 99] \ - and event[6] in [now[4], 99] \ - and event[7] in [now[5], 99] - while True: - if self.parent.connected: - for event in self.events_list: - if event[0] != 0 and event_due(event): - if event[0] == CT_SHELL: - self.shell_free(event[1]) - elif event[0] == CT_FUNCTION: - event[1]() - time.sleep(1) - -#============================================================================== -# TUXTCPCommunicator - event - class -#============================================================================== -class TUXevent(object): - - #-------------------------------------------------------------------------- - ## class init - ## @param parent : TUXTCPCommunicator parent object - #-------------------------------------------------------------------------- - def __init__(self,parent): - self.parent=parent - self.clear() - - #-------------------------------------------------------------------------- - ## clear all events - #-------------------------------------------------------------------------- - def clear(self): - self.on_bt_pushed=None - self.on_head_bt_pushed=None - self.on_lwing_bt_pushed=None - self.on_rwing_bt_pushed=None - self.on_bt_released=None - self.on_head_bt_released=None - self.on_lwing_bt_released=None - self.on_rwing_bt_released=None - self.on_remote_bt=[None]*64 - self.on_status=None - self.on_remote=None - self.on_light_level=None - self.on_connected=None - self.on_disconnected=None - self.on_mouth_open=None - self.on_mouth_close=None - self.on_power_plugged=None - self.on_power_unplugged=None - self.on_left_blue_led_on=None - self.on_left_blue_led_off=None - self.on_right_blue_led_on=None - self.on_right_blue_led_off=None - self.on_eyes_open=None - self.on_eyes_close=None - self.on_rf_connected=None - self.on_rf_disconnected=None - self.on_pong_received=None - self.on_mouth_stop=None - self.on_eyes_stop=None - self.on_wings_stop=None - self.on_spin_stop=None - - #-------------------------------------------------------------------------- - ## store all events - #-------------------------------------------------------------------------- - def store(self): - self.s_on_bt_pushed=self.on_bt_pushed - self.s_on_head_bt_pushed=self.on_head_bt_pushed - self.s_on_lwing_bt_pushed=self.on_lwing_bt_pushed - self.s_on_rwing_bt_pushed=self.on_rwing_bt_pushed - self.s_on_bt_released=self.on_bt_released - self.s_on_head_bt_released=self.on_head_bt_released - self.s_on_lwing_bt_released=self.on_lwing_bt_released - self.s_on_rwing_bt_released=self.on_rwing_bt_released - self.s_on_remote_bt=self.on_remote_bt - self.s_on_status=self.on_status - self.s_on_remote=self.on_remote - self.s_on_light_level=self.on_light_level - self.s_on_connected=self.on_connected - self.s_on_disconnected=self.on_disconnected - self.s_on_mouth_open=self.on_mouth_open - self.s_on_mouth_close=self.on_mouth_close - self.s_on_power_plugged=self.on_power_plugged - self.s_on_power_unplugged=self.on_power_unplugged - self.s_on_left_blue_led_on=self.on_left_blue_led_on - self.s_on_left_blue_led_off=self.on_left_blue_led_off - self.s_on_right_blue_led_on=self.on_right_blue_led_on - self.s_on_right_blue_led_off=self.on_right_blue_led_off - self.s_on_eyes_open=self.on_eyes_open - self.s_on_eyes_close=self.on_eyes_close - self.s_on_rf_connected=self.on_rf_connected - self.s_on_rf_disconnected=self.on_rf_disconnected - self.s_on_pong_received=self.on_pong_received - self.s_on_mouth_stop=on_mouth_stop - self.s_on_eyes_stop=on_eyes_stop - self.s_on_wings_stop=on_wings_stop - self.s_on_spin_stop=on_spin_stop - - #-------------------------------------------------------------------------- - ## restore all events - #-------------------------------------------------------------------------- - def restore(self): - self.on_bt_pushed=self.s_on_bt_pushed - self.on_head_bt_pushed=self.s_on_head_bt_pushed - self.on_lwing_bt_pushed=self.s_on_lwing_bt_pushed - self.on_rwing_bt_pushed=self.s_on_rwing_bt_pushed - self.on_bt_released=self.s_on_bt_released - self.on_head_bt_released=self.s_on_head_bt_released - self.on_lwing_bt_released=self.s_on_lwing_bt_released - self.on_rwing_bt_released=self.s_on_rwing_bt_released - self.on_remote_bt=self.s_on_remote_bt - self.on_status=self.s_on_status - self.on_remote=self.s_on_remote - self.on_light_level=self.s_on_light_level - self.on_connected=self.s_on_connected - self.on_disconnected=self.s_on_disconnected - self.on_mouth_open=self.s_on_mouth_open - self.on_mouth_close=self.s_on_mouth_close - self.on_power_plugged=self.s_on_power_plugged - self.on_power_unplugged=self.s_on_power_unplugged - self.on_left_blue_led_on=self.s_on_left_blue_led_on - self.on_left_blue_led_off=self.s_on_left_blue_led_off - self.on_right_blue_led_on=self.s_on_right_blue_led_on - self.on_right_blue_led_off=self.s_on_right_blue_led_off - self.on_eyes_open=self.s_on_eyes_open - self.on_eyes_close=self.s_on_eyes_close - self.on_rf_connected=self.s_on_rf_connected - self.on_rf_disconnected=self.s_on_rf_disconnected - self.on_pong_received=self.s_on_pong_received - self.on_mouth_stop=s_on_mouth_stop - self.on_eyes_stop=s_on_eyes_stop - self.on_wings_stop=s_on_wings_stop - self.on_spin_stop=s_on_spin_stop - - #-------------------------------------------------------------------------- - ## wait until status event arrival - ## @param DATA_STATUS : Desired status - ## @param DATA_VALUE : Desired value - ## @param time_out : Time out in seconds - #-------------------------------------------------------------------------- - def wait_status(self,DATA_STATUS,DATA_VALUE,time_out): - if not self.parent.connected: - return False - time_beginin=self.parent.sys.time() - while True: - if self.parent.connected: - while self.parent.bloc_datas_flag: - if (self.parent.sys.time()-time_beginin)>=time_out and time_out!=9999: - return False - time.sleep(0.001) - if ord(self.parent.last_datas[0])==SOURCE_TUX: - if ord(self.parent.last_datas[1])==SS_DEFAULT: - if ord(self.parent.last_datas[2])==DATA_TP_RSP: - if ord(self.parent.last_datas[3])==SUBDATA_TP_STATUS: - if ord(self.parent.last_datas[4])==DATA_STATUS: - if ord(self.parent.last_datas[5])==DATA_VALUE: - return True - if (self.parent.sys.time()-time_beginin)>=time_out and time_out!=9999: - return False - time.sleep(0.001) - - #-------------------------------------------------------------------------- - ## wait for stable status event - ## @param DATA_STATUS : Desired status - ## @param DATA_VALUE : Desired value - ## @param time_out : Time out in seconds - ## @param stable_time : Time of stable status wanted in seconds - #-------------------------------------------------------------------------- - def wait_stable_status(self,DATA_STATUS,DATA_VALUE,stable_time,time_out): - if self.wait_status(DATA_STATUS,DATA_VALUE,time_out)==False: - return False - else: - if DATA_VALUE==1: - INV_DATA_VALUE=0 - else: - INV_DATA_VALUE=1 - return not self.wait_status(DATA_STATUS,INV_DATA_VALUE,stable_time) - - #-------------------------------------------------------------------------- - ## Wait until a tux button is pressed - ## @param time_out : Time out in seconds (9999 : infinite wait) - #-------------------------------------------------------------------------- - def wait_bt_pushed(self,time_out): - if not self.parent.connected: - return 0 - time_beginin=self.parent.sys.time() - while True: - while self.parent.bloc_datas_flag: - if (self.parent.sys.time()-time_beginin)>=time_out and time_out!=9999: - return 0 - time.sleep(0.001) - if ord(self.parent.last_datas[0])==SOURCE_TUX: - if ord(self.parent.last_datas[1])==SS_DEFAULT: - if ord(self.parent.last_datas[2])==DATA_TP_RSP: - if ord(self.parent.last_datas[3])==SUBDATA_TP_STATUS: - if ord(self.parent.last_datas[4])==DATAS_STATUS_HEAD_PUSH_SWITCH: - if ord(self.parent.last_datas[5])==1: - return HEAD_BT - elif ord(self.parent.last_datas[4])==DATAS_STATUS_LEFT_WING_PUSH: - if ord(self.parent.last_datas[5])==1: - return LEFT_WING_BT - elif ord(self.parent.last_datas[4])==DATAS_STATUS_RIGHT_WING_PUSH: - if ord(self.parent.last_datas[5])==1: - return RIGHT_WING_BT - if (self.parent.sys.time()-time_beginin)>=time_out and time_out!=9999: - return 0 - time.sleep(0.001) - - #-------------------------------------------------------------------------- - ## Wait until head button is pushed - ## @param time_out : Time out in seconds - #-------------------------------------------------------------------------- - def wait_head_bt_pushed(self,time_out): - return self.wait_status(DATAS_STATUS_HEAD_PUSH_SWITCH,1,time_out) - - #-------------------------------------------------------------------------- - ## Wait until head button is released - #-------------------------------------------------------------------------- - def wait_head_bt_released(self): - return self.wait_status(DATAS_STATUS_HEAD_PUSH_SWITCH,0,9999) - - #-------------------------------------------------------------------------- - ## Wait until left wing button is pushed - ## @param time_out : Time out in seconds - #-------------------------------------------------------------------------- - def wait_lwing_bt_pushed(self,time_out): - return self.wait_status(DATAS_STATUS_LEFT_WING_PUSH,1,time_out) - - #-------------------------------------------------------------------------- - ## Wait until left wing button is released - #-------------------------------------------------------------------------- - def wait_lwing_bt_released(self): - return self.wait_status(DATAS_STATUS_LEFT_WING_PUSH,0,9999) - - #-------------------------------------------------------------------------- - ## Wait until right wing button is pushed - ## @param time_out : Time out in seconds - #-------------------------------------------------------------------------- - def wait_rwing_bt_pushed(self,time_out): - return self.wait_status(DATAS_STATUS_RIGHT_WING_PUSH,1,time_out) - - #-------------------------------------------------------------------------- - ## Wait until right wing button is released - #-------------------------------------------------------------------------- - def wait_rwing_bt_released(self): - return self.wait_status(DATAS_STATUS_RIGHT_WING_PUSH,0,9999) - - #-------------------------------------------------------------------------- - ## Wait until remote button is pushed - #-------------------------------------------------------------------------- - def wait_remote_bt(self,remote_key,timeout): - return self.wait_status(DATAS_STATUS_IR_CODE,remote_key,timeout) - - # Setting of events - - #-------------------------------------------------------------------------- - ## setting of button pushed event - #-------------------------------------------------------------------------- - def set_on_bt_pushed(self,function): - self.on_bt_pushed=function - - #-------------------------------------------------------------------------- - ## setting of head button pushed event - #-------------------------------------------------------------------------- - def set_on_head_bt_pushed(self,function): - self.on_head_bt_pushed=function - - #-------------------------------------------------------------------------- - ## setting of left wing pushed event - #-------------------------------------------------------------------------- - def set_on_lwing_bt_pushed(self,function): - self.on_lwing_bt_pushed=function - - #-------------------------------------------------------------------------- - ## setting of right wing pushed event - #-------------------------------------------------------------------------- - def set_on_rwing_bt_pushed(self,function): - self.on_rwing_bt_pushed=function - - #-------------------------------------------------------------------------- - ## setting of button released event - #-------------------------------------------------------------------------- - def set_on_bt_released(self,function): - self.on_bt_released=function - - #-------------------------------------------------------------------------- - ## setting of head button released event - #-------------------------------------------------------------------------- - def set_on_head_bt_released(self,function): - self.on_head_bt_released=function - - #-------------------------------------------------------------------------- - ## setting of left wing pushed event - #-------------------------------------------------------------------------- - def set_on_lwing_bt_released(self,function): - self.on_lwing_bt_released=function - - #-------------------------------------------------------------------------- - ## setting of right wing released event - #-------------------------------------------------------------------------- - def set_on_rwing_bt_released(self,function): - self.on_rwing_bt_released=function - - #-------------------------------------------------------------------------- - ## setting of remote bt event - #-------------------------------------------------------------------------- - def set_on_remote_bt(self,key,function): - self.on_remote_bt[key]=function - -#============================================================================== -# TUXTCPCommunicator - cmd - class -#============================================================================== -class TUXcmd(object): - - ## class init - ## @param parent : TUXTCPCommunicator parent object - def __init__(self,parent): - self.parent=parent - self.last_ack=ACK_CMD_OK - self.no_ack=False - - ## SYSTEM - def cmd_ack(self): - time_beginin=self.parent.sys.time() - while True: - while self.parent.bloc_datas_flag: - if (self.parent.sys.time()-time_beginin)>=2: - return ACK_CMD_TIMEOUT - time.sleep(0.001) - if ord(self.parent.last_datas[0])==SOURCE_TUX: - if ord(self.parent.last_datas[1])==SS_DEFAULT: - if ord(self.parent.last_datas[2])==DATA_TP_ACK_CMD: - return ord(self.parent.last_datas[4]) - if (self.parent.sys.time()-time_beginin)>=2: - return ACK_CMD_TIMEOUT - time.sleep(0.001) - - - ## Send a structured command to tux - ## @param fct : function of tux - ## @param cmd : command for this function - ## @param param1 : cmd parameter 1 - ## @param param2 : cmd parameter 2 - ## @param param3 : cmd parameter 3 - def structured(self,fct,cmd,param1,param2,param3): - if not self.parent.connected: - return 2 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_STRUCT,fct,cmd,param1,param2,param3,0,0,0,0,0,0,0) - self.parent.socket.send("".join( [chr(x) for x in data] )) - if self.no_ack: - return 2 - else: - return self.cmd_ack() - - ## Send a raw command to tux - ## @param cmd : command - ## @param param1 : cmd parameter 1 - ## @param param2 : cmd parameter 2 - ## @param param3 : cmd parameter 3 - def raw(self,cmd,param1,param2,param3): - if not self.parent.connected: - return 2 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_CMD,SUBDATA_TP_RAW,cmd,param1,param2,param3,0,0,0,0,0,0,0,0) - self.parent.socket.send("".join( [chr(x) for x in data] )) - if self.no_ack: - return 2 - else: - return self.cmd_ack() - - ## Send command to tux for moving eyes - ## @param count : number of movement - def eyes_on(self,count=1): - self.last_ack=self.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_ON,count,0,0) - self.parent.event.wait_status(DATAS_STATUS_EYES_POSITION_COUNTER,0,(0.3*count)) - - ## Send command to tux for opening eyes - def eyes_open(self): - if self.parent.status.get_eyes_closed_position_switch()==0: - self.eyes_on() - - ## Send command to tux for closing eyes - def eyes_close(self): - if self.parent.status.get_eyes_closed_position_switch()==1: - self.eyes_on() - - ## Send command to tux for moving eyes - ## @param count : number of movement - def eyes_on_free(self,count=1): - thread.start_new_thread(self.eyes_on,(count,)) - - ## Send command to tux for stoping eyes movement - def eyes_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_EYES,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for moving mouth - ## @param count : number of movement - def mouth_on(self,count=1): - self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH,TUX_CMD_STRUCT_SUB_ON,count,0,0) - self.parent.event.wait_status(DATAS_STATUS_MOUTH_POSITION_COUNTER,0,(0.3*count)) - - ## Send command to tux for moving mouth - ## @param count : number of movement - def mouth_on_free(self,count=1): - thread.start_new_thread(self.mouth_on,(count,)) - - ## Send command to tux for opening mouth - def mouth_open(self): - if self.parent.status.get_mouth_open_position()==1: - self.mouth_on() - - ## Send command to tux for closing mouth - def mouth_close(self): - if self.parent.status.get_mouth_open_position()==0: - self.mouth_on() - - ## Send command to tux for stoping mouth movement - def mouth_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_MOUTH,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for moving wings - ## @param count : number of movement - def wings_on(self,count=1,speed=5): - self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS,TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_WINGS_POSITION_COUNTER,0,(0.6*count)) - - ## Send command to tux for moving wings - ## @param count : number of movement - def wings_on_free(self,count=1,speed=5): - thread.start_new_thread(self.wings_on,(count,speed,)) - - ## Send command to tux for stoping wings movement - def wings_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_WINGS,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for spinning to the left - ## @param count : number of movement - def spinl_on(self,count=4,speed=5): - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL,TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0,(0.5*count)) - - ## Send command to tux for spinning to the left - ## @param count : number of movement - def spinl_on_free(self,count=4,speed=5): - thread.start_new_thread(self.spinl_on,(count,speed,)) - - ## Send command to tux for stoping rotation - def spinl_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINL,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for spinning to the right - ## @param count : number of movement - def spinr_on(self,count=4,speed=5): - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR,TUX_CMD_STRUCT_SUB_ON,count,speed,0) - self.parent.event.wait_status(DATAS_STATUS_SPIN_POSITION_COUNTER,0,(0.5*count)) - - ## Send command to tux for spinning to the right - ## @param count : number of movement - def spinr_on_free(self,count=4,speed=5): - thread.start_new_thread(self.spinr_on,(count,speed,)) - - ## Send command to tux for stoping rotation - def spinr_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_SPINR,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - - ## Send command to tux for IR on - def ir_on(self): - ACK=self.structured(TUX_CMD_STRUCT_IR,TUX_CMD_STRUCT_SUB_ON,0,0,0) - - ## Send command to tux for IR off - def ir_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_IR,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for IR sending - def ir_send(self,address,command): - self.last_ack=self.structured(TUX_CMD_STRUCT_IR,TUX_CMD_STRUCT_SUB_SEND,address,command,0) - - ## Send command to tux for leds on - def leds_on(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,TUX_CMD_STRUCT_SUB_ON,0,0,0) - - ## Send command to tux for leds blink - ## @param count : number of blink - ## @param delay : delay in 4msec between 2 states - def leds_blink(self,count,delay): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,TUX_CMD_STRUCT_SUB_BLINK,count,delay,0) - - ## Send command to tux for leds off - def leds_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDS,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for leds on during a time - ## @param seconds : number of seconds - def leds_during(self,seconds): - self.leds_on() - time.sleep(seconds) - self.leds_off() - - ## Send command to tux for leds on during a time - ## @param seconds : number of seconds - def leds_during_free(self,seconds): - thread.start_new_thread(self.leds_during,(seconds,)) - - ## Send command to tux for left led on - def ledl_on(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL,TUX_CMD_STRUCT_SUB_ON,0,0,0) - - ## Send command to tux for left led off - def ledl_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDL,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for left led on during a time - ## @param seconds : number of seconds - def ledl_during(self,seconds): - self.ledl_on() - time.sleep(seconds) - self.ledl_off() - - ## Send command to tux for left led on during a time - ## @param seconds : number of seconds - def ledl_during_free(self,seconds): - thread.start_new_thread(self.ledl_during,(seconds,)) - - ## Send command to tux for right led on - def ledr_on(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR,TUX_CMD_STRUCT_SUB_ON,0,0,0) - - ## Send command to tux for right led off - def ledr_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_LEDR,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for right led on during a time - ## @param seconds : number of seconds - def ledr_during(self,seconds): - self.ledr_on() - time.sleep(seconds) - self.ledr_off() - - ## Send command to tux for right led on during a time - ## @param seconds : number of seconds - def ledr_during_free(self,seconds): - thread.start_new_thread(self.ledr_during,(seconds,)) - - ## Send command to tux for playing sound of tux - ## @param index : index of sound - ## @param volume : volume of sound (0-7 : max-min) - def sound_play(self,index,volume): - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_PLAY,index,volume,0) - - ## Send command to tux for storing a sound collection in tux flash - ## @param number : number of sound to storing - def sound_storing(self,number): - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_STORING,number,0,0) - - ## Send command to tux for storing a index in the TOC - ## @param highAdd : high byte address of sound - ## @param middleAdd : middle byte address of sound - ## @param lowerAdd : lower byte address of sound - def sound_store_index(self,highAdd,middleAdd,lowerAdd): - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_STORE_INDEX,highAdd,middleAdd,lowerAdd) - - ## Send command to tux for testing the tux internal sound - def sound_test(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_SOUND,TUX_CMD_STRUCT_SUB_TEST,0,0,0) - - ## Send command to tux for ping-pong - ## @param ping_count : number of pong requested - def ping(self,count): - self.last_ack=self.structured(TUX_CMD_STRUCT_PING,0,count,0,0) - - ## Send command to tux for sleep mode on - def sleep_on(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP,TUX_CMD_STRUCT_SUB_ON,0,0,0) - - ## Send command to tux for sleep mode on - def sleep_off(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_SLEEP,TUX_CMD_STRUCT_SUB_OFF,0,0,0) - - ## Send command to tux for selecting GENERAL audio channel - def audio_channel_general(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL,\ - TUX_CMD_STRUCT_SUB_CH_GENERAL,0,0,0) - - ## Send command to tux for selecting TTS audio channel - def audio_channel_tts(self): - self.last_ack=self.structured(TUX_CMD_STRUCT_AUDIO_CHANNEL,\ - TUX_CMD_STRUCT_SUB_CH_TTS,0,0,0) - -#============================================================================== -# TUXTCPCommunicator - status - class -#============================================================================== -class TUXStatus(object): - - ## class init - ## @param parent : TUXTCPCommunicator parent object - def __init__(self,parent): - self.parent=parent - thread.start_new_thread(self.capture_light_level_thread,()) - - ## SYSTEM function - def capture_light_level_thread(self): - while self.parent.connected: - if self.parent.event.on_light_level!=None: - self.parent.event.on_light_level(self.get_light_level()) - self.parent.sys.wait(0.1) - - ## wait a specified response status - ## return True if status arrival before 2 seconds - ## else return False - ## raw of status is in self.parent.last_datas - ## @param DATA_STATUS : Desired status - def rsp_status(self,DATA_STATUS): - time_beginin=self.parent.sys.time() - while True: - while self.parent.bloc_datas_flag: - if (self.parent.sys.time()-time_beginin)>=2: - return False - time.sleep(0.001) - if ord(self.parent.last_datas[0])==SOURCE_TUX: - if ord(self.parent.last_datas[1])==SS_DEFAULT: - if ord(self.parent.last_datas[2])==DATA_TP_RSP: - if ord(self.parent.last_datas[4])==DATA_STATUS: - return True - if (self.parent.sys.time()-time_beginin)>=2: - return False - time.sleep(0.001) - - ## Get a specified status - ## return True if status arrival before 2 seconds - ## else return False - ## raw of status is in self.parent.last_datas - ## @param DATA_STATUS : Desired status - def get(self,DATA_STATUS): - if not self.parent.connected: - return 0 - data=(DEST_TUX,SD_DEFAULT,DATA_TP_REQ,SUBDATA_TP_STATUS,DATA_STATUS,0,0,0,0,0,0,0,0,0,0,0) - self.parent.socket.send("".join( [chr(x) for x in data] )) - return self.rsp_status(DATA_STATUS) - - ## Get the last state of wings motor backward status - def get_wings_motor_backward(self): - if self.get(DATAS_STATUS_WINGS_MOTOR_BACKWARD): - return ord(self.parent.last_datas[5]) - - ## Get the last state of spin motor backward status - def get_spin_motor_backward(self): - if self.get(DATAS_STATUS_SPIN_MOTOR_BACKWARD): - return ord(self.parent.last_datas[5]) - - ## Get the last state of spin motor forward status - def get_spin_motor_forward(self): - if self.get(DATAS_STATUS_SPIN_MOTOR_FORWARD): - return ord(self.parent.last_datas[5]) - - ## Get the last state of mouth open position status - def get_mouth_open_position(self): - if self.get(DATAS_STATUS_MOUTH_OPEN_POSITION): - return ord(self.parent.last_datas[5]) - - ## Get the last state of mouth closed position status - def get_mouth_closed_position(self): - if self.get(DATAS_STATUS_MOUTH_CLOSED_POSITION): - return ord(self.parent.last_datas[5]) - - ## Get the last state of head push position status - def get_head_push_position(self): - if self.get(DATAS_STATUS_HEAD_PUSH_POSITION): - return ord(self.parent.last_datas[5]) - - ## Get the last state of charger inhibit signal status - def get_charger_inhibit_signal(self): - if self.get(DATAS_STATUS_CHARGER_INHIBIT_SIGNAL): - return ord(self.parent.last_datas[5]) - - ## Get the last state of wings position switch status - def get_wings_position_switch(self): - if self.get(DATAS_STATUS_WINGS_POSITION_SWITCH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of motor for wings status - def get_motor_for_wings(self): - if self.get(DATAS_STATUS_MOTOR_FOR_WINGS): - return ord(self.parent.last_datas[5]) - - ## Get the last state of left blue led status - def get_left_blue_led(self): - if self.get(DATAS_STATUS_LEFT_BLUE_LED): - return ord(self.parent.last_datas[5]) - - ## Get the last state of right blue led status - def get_right_blue_led(self): - if self.get(DATAS_STATUS_RIGHT_BLUE_LED): - return ord(self.parent.last_datas[5]) - - ## Get the last state of head motor for mouth status - def get_head_motor_for_mouth(self): - if self.get(DATAS_STATUS_HEAD_MOTOR_FOR_MOUTH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of head motor for eyes status - def get_head_motor_for_eyes(self): - if self.get(DATAS_STATUS_HEAD_MOTOR_FOR_EYES): - return ord(self.parent.last_datas[5]) - - ## Get the last state of IR receiver signal status - def get_ir_receiver_signal(self): - if self.get(DATAS_STATUS_IR_RECEIVER_SIGNAL): - return ord(self.parent.last_datas[5]) - - ## Get the last state of spin position switch status - def get_spin_position_switch(self): - if self.get(DATAS_STATUS_SPIN_POSITION_SWITCH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of wings motor forward status - def get_wings_motor_forward(self): - if self.get(DATAS_STATUS_WINGS_MOTOR_FORWARD): - return ord(self.parent.last_datas[5]) - - ## Get the last state of IR led status - def get_ir_led(self): - if self.get(DATAS_STATUS_IR_LED): - return ord(self.parent.last_datas[5]) - - ## Get the last state of eyes open position switch status - def get_eyes_open_position_switch(self): - if self.get(DATAS_STATUS_EYES_OPEN_POSITION_SWITCH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of eyes closed position switch status - def get_eyes_closed_position_switch(self): - if self.get(DATAS_STATUS_EYES_CLOSED_POSITION_SWITCH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of left wing push status - def get_left_wing_push(self): - if self.get(DATAS_STATUS_LEFT_WING_PUSH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of right wing push status - def get_right_wing_push(self): - if self.get(DATAS_STATUS_RIGHT_WING_PUSH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of power plug switch status - def get_power_plug_switch(self): - if self.get(DATAS_STATUS_POWER_PLUG_SWITCH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of head push switch status - def get_head_push_switch(self): - if self.get(DATAS_STATUS_HEAD_PUSH_SWITCH): - return ord(self.parent.last_datas[5]) - - ## Get the last state of tux mute sound status - def get_tux_mute_sound(self): - if self.get(DATAS_STATUS_MUTE_STATUS): - return ord(self.parent.last_datas[5]) - - ## Get the last state of light level status - def get_light_level(self): - if self.get(DATAS_STATUS_LIGHT_LEVEL): - return (ord(self.parent.last_datas[5])*256)+ord(self.parent.last_datas[6]) - - ## Get the last state of eyes position counter status - def get_eyes_position_counter(self): - if self.get(DATAS_STATUS_EYES_POSITION_COUNTER): - return ord(self.parent.last_datas[5]) - - ## Get the last state of mouth position counter status - def get_mouth_position_counter(self): - if self.get(DATAS_STATUS_MOUTH_POSITION_COUNTER): - return ord(self.parent.last_datas[5]) - - ## Get the last state of wings position counter status - def get_wings_position_counter(self): - if self.get(DATAS_STATUS_WINGS_POSITION_COUNTER): - return ord(self.parent.last_datas[5]) - - ## Get the last state of spin position counter status - def get_spin_position_counter(self): - if self.get(DATAS_STATUS_SPIN_POSITION_COUNTER): - return ord(self.parent.last_datas[5]) - - ## Get the last status RF - def get_RF_state(self): - if self.get(DATAS_STATUS_RF_CONNECTED): - return ord(self.pa... [truncated message content] |