예제 #1
0
    def __init__(self, shotMgr):
        self.shotMgr = shotMgr
        self.connected = False
        self.buttonsInitialized = False
        self.connectingThread = None
        self.connect()
        # These are the mappings for the A,B buttons during Free Flight
        # The A+B buttons are mapped to shot, mode tuples
        # only one of which should ever be active at any time
        self.freeButtonMappings = [(-1, -1), (-1, -1)]

        try:
            aMapping = settings.readSetting("A")
            bMapping = settings.readSetting("B")

            values = string.split(aMapping, ",")
            self.freeButtonMappings[0] = (int(values[0]), int(values[1]))
            values = string.split(bMapping, ",")
            self.freeButtonMappings[1] = (int(values[0]), int(values[1]))

        except:
            logger.log("[button]: error reading config file")
        else:
            logger.log("[button]: read in button mappings")
            logger.log("[button]: Button A - shot %s, mode %s" %
                       (shots.SHOT_NAMES[self.freeButtonMappings[0][0]],
                        modes.MODE_NAMES[self.freeButtonMappings[0][1]]))
            logger.log("[button]: Button B - shot %s, mode %s" %
                       (shots.SHOT_NAMES[self.freeButtonMappings[1][0]],
                        modes.MODE_NAMES[self.freeButtonMappings[1][1]]))
예제 #2
0
 def testReadBadSetting(self):
     """ Test that we get an exception from a failed get """
     self.parser.get = Mock(return_value = "foo", side_effect=KeyError("Boo"))
     try:
         value = settings.readSetting("bleh")
     except:
         pass
     else:
         self.assertFalse(True)
예제 #3
0
    def __init__(self, shotMgr):
        # GoPro heartbeat state
        self.status = mavutil.mavlink.GOPRO_HEARTBEAT_STATUS_DISCONNECTED
        self.captureMode = CAPTURE_MODE_VIDEO
        self.isRecording = False
        # Additional GoPro state
        self.battery = 0
        self.model = MODEL_NONE
        self.videoFormat = VIDEO_FORMAT_NTSC
        self.videoResolution = 0
        self.videoFrameRate = 0
        self.videoFieldOfView = 0
        self.videoLowLight = False
        self.photoResolution = 0
        self.photoBurstRate = 0
        self.videoProtune = False
        self.videoProtuneWhiteBalance = 0
        self.videoProtuneColor = 0
        self.videoProtuneGain = 0
        self.videoProtuneSharpness = 0
        self.videoProtuneExposure = 0

        self.shotMgr = shotMgr
        # This exists because we can't seem to send multiple messages in a stream to the gopro.
        # Instead, we'll queue up all our messages and wait for a response before sending the next message
        self.msgQueue = Queue.Queue()
        # is the GoPro currently handling a message?
        self.isGoproBusy = False
        # when the last message was sent
        self.lastRequestSent = 0.0
        # lock access to shot manager state
        self.lock = threading.Lock()

        # check if we should enable GoPro messages at all
        try:
            enabled = int(settings.readSetting("GoProEnabled"))
            logger.log("[gopro]: read enabled value from settings of %d." %
                       (enabled))
            self.enabled = enabled > 0
            self.setGimbalEnabledParam()
        except Exception as ex:
            logger.log("[gopro]: Error reading config file.")
            logger.log(str(ex))
            self.enabled = True

        logger.log("[gopro]: Inited GoProManager")
예제 #4
0
 def testReadSetting(self):
     """ Test that we attempt to read the correct thing """
     self.parser.get = Mock(return_value = "foo")
     value = settings.readSetting("bleh")
     self.parser.get.assert_called_with("shotManager", "bleh")
     self.assertEqual(value, "foo")
예제 #5
0
# 主程序
from ui import BookManager
from PyQt5.QtWidgets import QApplication
import sys
import os
from settings import readSetting, storeSetting

setting_file_name = 'setting.json'
if not os.path.exists(setting_file_name):
    initialSetting = {
        "toolbarSize": "大",
        "treeSize": "大",
        "bookInfoSize": "大",
        "searchAttr": "按书名",
        "searchMode": "准确匹配",
    }
    storeSetting(initialSetting, setting_file_name)
setting = readSetting(setting_file_name)
app = QApplication(sys.argv)
bookManager = BookManager(setting, setting_file_name)
sys.exit(app.exec_())