コード例 #1
0
ファイル: WiimoteThrottle2.py プロジェクト: AlanUS/ALM_JMRI
 def init(self):
     self.getContext().addPropertyChangeListener(
         self)  #ThrottleFrame change
     self.addressPanel = self.getContext().getCurrentThrottleFrame(
     ).getAddressPanel()
     self.addressPanel.addAddressListener(
         self)  # change of throttle in Current frame
     self.throttle = self.getContext().getCurrentThrottleFrame(
     ).getAddressPanel().getThrottle()  # the throttle
     self.speedAction = SpeedAction()  #Speed increase thread
     self.speedAction.setThrottle(self.throttle)
     self.speedTimer = Timer(
         valueSpeedTimerRepeat, self.speedAction
     )  # Very important to use swing Timer object (see Swing and multithreading doc)
     self.speedTimer.setRepeats(True)
     self.label = JButton(
         ImageIcon(self.getFolder() + "/WiimoteThrottle2.png",
                   "WiiMote"))  #label
     self.label.addMouseListener(
         self.getMouseListeners()
         [0])  # In order to get the popupmenu on the button too
     self.add(self.label)
     self.lastTimeButton1 = Calendar.getInstance().getTimeInMillis()
     self.lastTimeButton2 = Calendar.getInstance().getTimeInMillis()
     self.advFunctions = AdvFunctions()
     self.lastTimeEStop = Calendar.getInstance().getTimeInMillis()
     self.wiiDevice = None
     self.sync = thread.allocate_lock()  # A lock protecting bellow self.evt
     self.evt = None
     java.lang.System.setProperty("bluecove.jsr82.psm_minimum_off", "true")
     # Required for Bluecove + WiiRemoteJ
     WiiRemoteJ.findRemotes(self, 1)  # Search for 1 Wiimote, and call back
コード例 #2
0
ファイル: WiimoteThrottle.py プロジェクト: Klb4ever/JMRI
 def quit(self):
     self.speedTimer.stop() 
     WiiRemoteJ.stopFind()
     if ((self.wiiDevice != None) and (self.wiiDevice.isConnected())):
         self.wiiDevice.removeWiiRemoteListener(self)
         self.wiiDevice.disconnect()
     self.wiiDevice = None
     self.speedAction = None
     self.speedTimer = None
     self.throttle = None
     self.getContext().removePropertyChangeListener(self)
     self.addressPanel.removeAddressListener(self)
     self.addressPanel = None
コード例 #3
0
 def quit(self):
     self.speedTimer.stop()
     WiiRemoteJ.stopFind()
     if ((self.wiiDevice != None) and (self.wiiDevice.isConnected())):
         self.wiiDevice.removeWiiRemoteListener(self)
         self.wiiDevice.disconnect()
     self.wiiDevice = None
     self.speedAction = None
     self.speedTimer = None
     self.throttle = None
     self.getContext().removePropertyChangeListener(self)
     self.addressPanel.removeAddressListener(self)
     self.addressPanel = None
コード例 #4
0
ファイル: WiimoteThrottle.py プロジェクト: Klb4ever/JMRI
 def init(self):
     self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
     self.addressPanel=self.getContext().getCurrentThrottleFrame().getAddressPanel();
     self.addressPanel.addAddressListener(self) # change of throttle in Current frame
     self.throttle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
     self.speedAction =  SpeedAction()  #Speed increase thread
     self.speedAction.setThrottle( self.throttle )
     self.speedTimer = Timer(valueSpeedTimerRepeat, self.speedAction ) # Very important to use swing Timer object (see Swing and multithreading doc)
     self.speedTimer.setRepeats(True)
     self.label = JButton(ImageIcon(self.getFolder() + "/WiimoteThrottle.png","WiiMote")) #label
     self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
     self.add(self.label)
     self.lastTimeButton1 = Calendar.getInstance().getTimeInMillis()
     self.lastTimeButton2 = Calendar.getInstance().getTimeInMillis()
     self.lastTimeEStop = Calendar.getInstance().getTimeInMillis()
     self.wiiDevice = None
     self.sync = thread.allocate_lock() # A lock protecting bellow self.evt
     self.evt = None
     java.lang.System.setProperty("bluecove.jsr82.psm_minimum_off", "true"); # Required for Bluecove + WiiRemoteJ
     WiiRemoteJ.findRemotes(self, 1) # Search for 1 Wiimote, and call back