(self)
return out
u'''Specialty output for useful ServerState monitoring.
u'''Specialty output for useful ServerState monitoring.
u Specialty output for useful ServerState monitoring .
def fancyout(self):
        u'''Specialty output for useful ServerState monitoring.'''
        out= str()
        sensors= [ # Select the ones you want in the order you want them.
        #'curLapTime',
        #'lastLapTime',
        u'stucktimer',
        #'damage',
        #'focus',
        u'fuel',
        #'gear',
        u'distRaced',
        u'distFromStart',
        #'racePos',
        u'opponents',
        u'wheelSpinVel',
        u'z',
        u'speedZ',
        u'speedY',
        u'speedX',
        u'targetSpeed',
        u'rpm',
        u'skid',
        u'slip',
        u'track',
        u'trackPos',
        u'angle',
        ]

        #for k in sorted(self.d): # Use this to get all sensors.
        for k in sensors:
            if type(self.d.get(k)) is list: # Handle list type data.
                if k == u'track': # Nice display for track sensors.
                    strout= str()
                 #  for tsensor in self.d['track']:
                 #      if   tsensor >180: oc= '|'
                 #      elif tsensor > 80: oc= ';'
                 #      elif tsensor > 60: oc= ','
                 #      elif tsensor > 39: oc= '.'
                 #      #elif tsensor > 13: oc= chr(int(tsensor)+65-13)
                 #      elif tsensor > 13: oc= chr(int(tsensor)+97-13)
                 #      elif tsensor >  3: oc= chr(int(tsensor)+48-3)
                 #      else: oc= '_'
                 #      strout+= oc
                 #  strout= ' -> '+strout[:9] +' ' + strout[9] + ' ' + strout[10:]+' <-'
                    raw_tsens= [u'%.1f'%x for x in self.d[u'track']]
                    strout+= u' '.join(raw_tsens[:9])+u'_'+raw_tsens[9]+u'_'+u' '.join(raw_tsens[10:])
                elif k == u'opponents': # Nice display for opponent sensors.
                    strout= str()
                    for osensor in self.d[u'opponents']:
                        if   osensor >190: oc= u'_'
                        elif osensor > 90: oc= u'.'
                        elif osensor > 39: oc= unichr(int(osensor/2)+97-19)
                        elif osensor > 13: oc= unichr(int(osensor)+65-13)
                        elif osensor >  3: oc= unichr(int(osensor)+48-3)
                        else: oc= u'?'
                        strout+= oc
                    strout= u' -> '+strout[:18] + u' ' + strout[18:]+u' <-'
                else:
                    strlist= [str(i) for i in self.d[k]]
                    strout= u', '.join(strlist)
            else: # Not a list type of value.
                if k == u'gear': # This is redundant now since it's part of RPM.
                    gs= u'_._._._._._._._._'
                    p= int(self.d[u'gear']) * 2 + 2  # Position
                    l= u'%d'%self.d[u'gear'] # Label
                    if l==u'-1': l= u'R'
                    if l==u'0':  l= u'N'
                    strout= gs[:p]+ u'(%s)'%l + gs[p+3:]
                elif k == u'damage':
                    strout= u'%6.0f %s' % (self.d[k], bargraph(self.d[k],0,10000,50,u'~'))
                elif k == u'fuel':
                    strout= u'%6.0f %s' % (self.d[k], bargraph(self.d[k],0,100,50,u'f'))
                elif k == u'speedX':
                    cx= u'X'
                    if self.d[k]<0: cx= u'R'
                    strout= u'%6.1f %s' % (self.d[k], bargraph(self.d[k],-30,300,50,cx))
                elif k == u'speedY': # This gets reversed for display to make sense.
                    strout= u'%6.1f %s' % (self.d[k], bargraph(self.d[k]*-1,-25,25,50,u'Y'))
                elif k == u'speedZ':
                    strout= u'%6.1f %s' % (self.d[k], bargraph(self.d[k],-13,13,50,u'Z'))
                elif k == u'z':
                    strout= u'%6.3f %s' % (self.d[k], bargraph(self.d[k],.3,.5,50,u'z'))
                elif k == u'trackPos': # This gets reversed for display to make sense.
                    cx=u'<'
                    if self.d[k]<0: cx= u'>'
                    strout= u'%6.3f %s' % (self.d[k], bargraph(self.d[k]*-1,-1,1,50,cx))
                elif k == u'stucktimer':
                    if self.d[k]:
                        strout= u'%3d %s' % (self.d[k], bargraph(self.d[k],0,300,50,u"'"))
                    else: strout= u'Not stuck!'
                elif k == u'rpm':
                    g= self.d[u'gear']
                    if g < 0:
                        g= u'R'
                    else:
                        g= u'%1d'% g
                    strout= bargraph(self.d[k],0,10000,50,g)
                elif k == u'angle':
                    asyms= [
                          u"  !  ", u".|'  ", u"./'  ", u"_.-  ", u".--  ", u"..-  ",
                          u"---  ", u".__  ", u"-._  ", u"'-.  ", u"'\.  ", u"'|.  ",
                          u"  |  ", u"  .|'", u"  ./'", u"  .-'", u"  _.-", u"  __.",
                          u"  ---", u"  --.", u"  -._", u"  -..", u"  '\.", u"  '|."  ]
                    rad= self.d[k]
                    deg= int(rad*180/PI)
                    symno= int(.5+ (rad+PI) / (PI/12) )
                    symno= symno % (len(asyms)-1)
                    strout= u'%5.2f %3d (%s)' % (rad,deg,asyms[symno])
                elif k == u'skid': # A sensible interpretation of wheel spin.
                    frontwheelradpersec= self.d[u'wheelSpinVel'][0]
                    skid= 0
                    if frontwheelradpersec:
                        skid= .5555555555*self.d[u'speedX']/frontwheelradpersec - .66124
                    strout= bargraph(skid,-.05,.4,50,u'*')
                elif k == u'slip': # A sensible interpretation of wheel spin.
                    frontwheelradpersec= self.d[u'wheelSpinVel'][0]
                    slip= 0
                    if frontwheelradpersec:
                        slip= ((self.d[u'wheelSpinVel'][2]+self.d[u'wheelSpinVel'][3]) -
                              (self.d[u'wheelSpinVel'][0]+self.d[u'wheelSpinVel'][1]))
                    strout= bargraph(slip,-5,150,50,u'@')
                else:
                    strout= str(self.d[k])
            out+= u"%s: %s\n" % (k,strout)
        return out
def fancyout ( self ) : out = str ( ) sensors = [ # Select the ones you want in the order you want them. #'curLapTime', #'lastLapTime', u'stucktimer' , #'damage', #'focus', u'fuel' , #'gear', u'distRaced' , u'distFromStart' , #'racePos', u'opponents' , u'wheelSpinVel' , u'z' , u'speedZ' , u'speedY' , u'speedX' , u'targetSpeed' , u'rpm' , u'skid' , u'slip' , u'track' , u'trackPos' , u'angle' , ] #for k in sorted(self.d): # Use this to get all sensors. for k in sensors : if type ( self . d . get ( k ) ) is list : # Handle list type data. if k == u'track' : # Nice display for track sensors. strout = str ( ) #  for tsensor in self.d['track']: #      if   tsensor >180: oc= '|' #      elif tsensor > 80: oc= ';' #      elif tsensor > 60: oc= ',' #      elif tsensor > 39: oc= '.' #      #elif tsensor > 13: oc= chr(int(tsensor)+65-13) #      elif tsensor > 13: oc= chr(int(tsensor)+97-13) #      elif tsensor >  3: oc= chr(int(tsensor)+48-3) #      else: oc= '_' #      strout+= oc #  strout= ' -> '+strout[:9] +' ' + strout[9] + ' ' + strout[10:]+' <-' raw_tsens = [ u'%.1f' % x for x in self . d [ u'track' ] ] strout += u' ' . join ( raw_tsens [ : 9 ] ) + u'_' + raw_tsens [ 9 ] + u'_' + u' ' . join ( raw_tsens [ 10 : ] ) elif k == u'opponents' : # Nice display for opponent sensors. strout = str ( ) for osensor in self . d [ u'opponents' ] : if osensor > 190 : oc = u'_' elif osensor > 90 : oc = u'.' elif osensor > 39 : oc = unichr ( int ( osensor / 2 ) + 97 - 19 ) elif osensor > 13 : oc = unichr ( int ( osensor ) + 65 - 13 ) elif osensor > 3 : oc = unichr ( int ( osensor ) + 48 - 3 ) else : oc = u'?' strout += oc strout = u' -> ' + strout [ : 18 ] + u' ' + strout [ 18 : ] + u' <-' else : strlist = [ str ( i ) for i in self . d [ k ] ] strout = u', ' . join ( strlist ) else : # Not a list type of value. if k == u'gear' : # This is redundant now since it's part of RPM. gs = u'_._._._._._._._._' p = int ( self . d [ u'gear' ] ) * 2 + 2 # Position l = u'%d' % self . d [ u'gear' ] # Label if l == u'-1' : l = u'R' if l == u'0' : l = u'N' strout = gs [ : p ] + u'(%s)' % l + gs [ p + 3 : ] elif k == u'damage' : strout = u'%6.0f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] , 0 , 10000 , 50 , u'~' ) ) elif k == u'fuel' : strout = u'%6.0f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] , 0 , 100 , 50 , u'f' ) ) elif k == u'speedX' : cx = u'X' if self . d [ k ] < 0 : cx = u'R' strout = u'%6.1f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] , - 30 , 300 , 50 , cx ) ) elif k == u'speedY' : # This gets reversed for display to make sense. strout = u'%6.1f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] * - 1 , - 25 , 25 , 50 , u'Y' ) ) elif k == u'speedZ' : strout = u'%6.1f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] , - 13 , 13 , 50 , u'Z' ) ) elif k == u'z' : strout = u'%6.3f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] , .3 , .5 , 50 , u'z' ) ) elif k == u'trackPos' : # This gets reversed for display to make sense. cx = u'<' if self . d [ k ] < 0 : cx = u'>' strout = u'%6.3f %s' % ( self . d [ k ] , bargraph ( self . d [ k ] * - 1 , - 1 , 1 , 50 , cx ) ) elif k == u'stucktimer' : if self . d [ k ] : strout = u'%3d %s' % ( self . d [ k ] , bargraph ( self . d [ k ] , 0 , 300 , 50 , u"'" ) ) else : strout = u'Not stuck!' elif k == u'rpm' : g = self . d [ u'gear' ] if g < 0 : g = u'R' else : g = u'%1d' % g strout = bargraph ( self . d [ k ] , 0 , 10000 , 50 , g ) elif k == u'angle' : asyms = [ u"  !  " , u".|'  " , u"./'  " , u"_.-  " , u".--  " , u"..-  " , u"---  " , u".__  " , u"-._  " , u"'-.  " , u"'\.  " , u"'|.  " , u"  |  " , u"  .|'" , u"  ./'" , u"  .-'" , u"  _.-" , u"  __." , u"  ---" , u"  --." , u"  -._" , u"  -.." , u"  '\." , u"  '|." ] rad = self . d [ k ] deg = int ( rad * 180 / PI ) symno = int ( .5 + ( rad + PI ) / ( PI / 12 ) ) symno = symno % ( len ( asyms ) - 1 ) strout = u'%5.2f %3d (%s)' % ( rad , deg , asyms [ symno ] ) elif k == u'skid' : # A sensible interpretation of wheel spin. frontwheelradpersec = self . d [ u'wheelSpinVel' ] [ 0 ] skid = 0 if frontwheelradpersec : skid = .5555555555 * self . d [ u'speedX' ] / frontwheelradpersec - .66124 strout = bargraph ( skid , - .05 , .4 , 50 , u'*' ) elif k == u'slip' : # A sensible interpretation of wheel spin. frontwheelradpersec = self . d [ u'wheelSpinVel' ] [ 0 ] slip = 0 if frontwheelradpersec : slip = ( ( self . d [ u'wheelSpinVel' ] [ 2 ] + self . d [ u'wheelSpinVel' ] [ 3 ] ) - ( self . d [ u'wheelSpinVel' ] [ 0 ] + self . d [ u'wheelSpinVel' ] [ 1 ] ) ) strout = bargraph ( slip , - 5 , 150 , 50 , u'@' ) else : strout = str ( self . d [ k ] ) out += u"%s: %s\n" % ( k , strout ) return out