示例#1
0
 def car_contact (self, insim, info):
     InsimClient.car_contact(self, insim, info)
     print info
     mcar=info.A
     #track='KY1R'
     
     if(info.SpClose>1):
         driv_a=''
         driv_b=''
         try:
             driv_a=self.drivers[self.driversID[info.A.PLID]].playername
             driv_b=self.drivers[self.driversID[info.B.PLID]].playername
         except:
             print 'Cant locate driver name, maybe this key is deleted PLID A:',str(info.A.PLID),' B ',info.B.PLID
             return
         m= 'Contacto ^7A '+ driv_a+ ' y B'+ driv_b
         
         
         print m
         print info.Time
         self.sendMsg(m)
         
         p=[mcar.X/16, mcar.Y/16 ]
         
         #KY1R Nodes
         t_coords=[[-461,181],[-484,295],[-485 , 681],[-104 , 845],[187 , 594],[ 250 , 260],[54 , -81],[-354 , -57]]
         t_names=['T1','T1-T2','T2','T2-T3','T3','T3-T4','T4','T4-T1']
         #KY1 Nodes
         if(self.track=='KY1'):
             t_coords.reverse()
         
         
         tmp=0
         m=9000000
         t_f=0
         for pl in t_coords:
             p1=pl
             if(t_coords.index(pl)==len(t_coords)-1):
                 #last element
                 p2=t_coords[0]
             else:
                 p2=t_coords[t_coords.index(pl)+1]
             d=self.pointline_dist(p1, p2, p)
             print 'Distance To Line ',tmp, ' D: ',d
             if(d<m):
                 m=d
                 t_f=t_names[tmp]
                 
             tmp+=1
         #print 'Precaucion en ',t_f
         #self.sendMsg('^2Precaucion en '+str(t_f))
         if(self.config.get("crash_list","reg_crash")=="yes"):
             self.crash_msg_queue.appendleft(str(t_f))
             self.last_time_crash=time.time()
             self.add_crash(Crash_event(self.get_driver(info.A.PLID).get_playername(), self.get_driver(info.B.PLID).get_playername(),info.A.PLID,info.B.PLID, float(info.SpClose), p[0],p[1], t_f,info.Time))
             
             #schedule the message destroy
             WorkDaemon(self.pop_crash_queue,10,True).start()#destroy it in ten seconds 
示例#2
0
 def set_evt(self,tm,msg):
     '''
     tm time in seconds
     '''
     print "Set evt msg: ", msg, " time ",tm
     #stop thread
     if(self.timer_thread is not None):
         self.timer_thread.stop()
     
     self.msg=msg
     #create a new timer thread
     self.tm=tm
     self.timer_thread=WorkDaemon(self.draw_evt, 1, False)
     #start it
     self.first=True
     self.timer_thread.start()
     if(self.config.get("evt","send_rcm")=="yes"):
         self.sendRCM(msg)
示例#3
0
    def cancel_start(self):
        if (self.abort_counter > 0):
            return

        self.abort_counter = 1
        WorkDaemon(self.cancel_start_t, interval=0.35, run_once=True).start()
示例#4
0
 def begin(self):
     '''
     begin all stuff
     '''
     WorkDaemon(self.c_warn_led,1, False).start();#run everytime
     self.draw_list_button()