當前位置: 首頁>>代碼示例>>Python>>正文


Python Recorder.record_marker方法代碼示例

本文整理匯總了Python中recorder.Recorder.record_marker方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.record_marker方法的具體用法?Python Recorder.record_marker怎麽用?Python Recorder.record_marker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在recorder.Recorder的用法示例。


在下文中一共展示了Recorder.record_marker方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: DreamCatcher

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import record_marker [as 別名]
class DreamCatcher(object):
    def __init__(self):
        config = read_config()
        self._path = os.path.abspath(
            config.get('directories', 'sessions'))
        self._recorder = None
        self._display_index = 0 # Text to show in root menu
        self._fan = Fan()
        self.create_menu()

    def create_menu(self):
        """ Create LCD menu. """
        m = LcdMenu()
        self._menu = m

        self._root_item = m.add_item("DreamCatcher", 
            self.record_marker)

        self._toggle_item = self._root_item.add_item(
            "Start\nRecording", self.toggle_recording)

        self._file_item = m.add_item(
            "File", activated=self.update_file_menu)

        self._network_item = m.add_item(
            "Network", activated=self.update_network_menu)

        m.add_item("Exit", self.stop)
        m.add_item("Shut down", self.shut_down)

    def update_root_menuitem(self):
        if self._recorder == None:
            return 

        def pow():
            return "Sig. Pow.\n{0:.2f}".format(
                self._recorder.signal_power)

        def level():
            return "Sleep Lvl.\n{0:.2f}".format(
                self._recorder.sleep_level)

        def hb():
            return "Est. Hb.\n{0:.2f}".format(
                self._recorder.hb)

        def breath():
            return "Est. Breath.\n{0:.2f}".format(
                self._recorder.breath)

        def be_clever():
            config = read_config()
            min = config.getfloat('recorder', 'power_min')
            pow = self._recorder.signal_power
            if pow < min:
                return "Thinking:\nNot in bed."
            else:
                level = self._recorder.sleep_level
                if level > 0:
                    return "Thinking:\nAwake."
                elif level > -0.5:
                    return "Thinking:\nLight sleep."
                else:
                    return "Thinking:\nSleeping."

        func = [pow, level, hb, breath, be_clever][self._display_index]
        self._root_item.header = func()
        self._display_index += 1
        if self._display_index > 4 :
            self._display_index = 0
        
 
    def delete_file(self, filename):
        """ Delete selected recording session. """
        def delete():
            logger.info("Deleting %s", filename)
        return delete

    def plot_file(self, timestamp):
        """ Plot selected recording session. """
        def plot():
            logger.info("Plotting %s", timestamp)
            config = read_config()
            self.menu.message = "Plotting..."
            plotter.plot(
                config.get('directories', 'sessions'),
                config.get('directories', 'images'),
                timestamp)
            self.menu.current_item = self._root_item
        return plot

    def update_network_menu(self):
        del self._network_item.items[:]
        for device, ip in ifconfig().items():
            self._network_item.add_item(
                '\n'.join([device, ip])) 

    def update_file_menu(self):
        """ Update file menu sub-items when file menu is activated. """
        del self._file_item.items[:]
#.........這裏部分代碼省略.........
開發者ID:SirHegel77,項目名稱:DreamCatcher,代碼行數:103,代碼來源:dreamcatcher.py

示例2: DreamCatcher

# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import record_marker [as 別名]
class DreamCatcher(object):
    def __init__(self):
        config = read_config()
        self._path = os.path.abspath(
            config.get('directories', 'sessions'))
        self._recorder = None
        self._fan = Fan()
        self.create_menu()

    def create_menu(self):
        """ Create LCD menu. """
        m = LcdMenu()
        self._menu = m

        self._root_item = m.add_item("DreamCatcher", 
            self.record_marker)

        self._toggle_item = self._root_item.add_item(
            "Start\nRecording", self.toggle_recording)

        self._file_item = m.add_item(
            "File", activated=self.update_file_menu)

        self._network_item = m.add_item(
            "Network", activated=self.update_network_menu)

        m.add_item("Exit", self.stop)
        m.add_item("Shut down", self.shut_down)
 
    def delete_file(self, filename):
        """ Delete selected recording session. """
        def delete():
            logger.info("Deleting %s", filename)
        return delete

    def plot_file(self, timestamp):
        """ Plot selected recording session. """
        def plot():
            logger.info("Plotting %s", timestamp)
            config = read_config()
            self.menu.message = "Plotting..."
            plotter.plot(
                config.get('directories', 'sessions'),
                config.get('directories', 'images'),
                timestamp)
            self.menu.current_item = self._root_item
        return plot

    def update_network_menu(self):
        del self._network_item.items[:]
        for device, ip in ifconfig().items():
            self._network_item.add_item(
                '\n'.join([device, ip])) 

    def update_file_menu(self):
        """ Update file menu sub-items when file menu is activated. """
        del self._file_item.items[:]
        datafiles = iglob(self._path + '/*.data')
        for path, name in (os.path.split(f) for f in datafiles):
            timestamp = name.split('.')[0]
            format = "%d.%m.%Y\n%H:%M"
            date = datetime.fromtimestamp(float(timestamp))
            item = self._file_item.add_item(date.strftime(format))
            item.add_item("Plot", self.plot_file(timestamp))
            item.add_item("Delete", self.delete_file(timestamp))

    def start_recording(self):
        """ Start recording data. """
        if self._recorder == None:
            logger.info("Starting recorder...")
            self._restarts = 0
            self._recorder = Recorder(self._path)
            self._recorder.start()
            self.menu.current_item = self._root_item
            self._toggle_item.header = "Stop\nRecording"
            self._root_item.header = "DreamCatcher\nRecording..."
            self.menu.lcd.backlight(self.menu.lcd.RED)

    def stop_recording(self):
        """ Stop recording data. """
        if self._recorder != None:
            logger.info("Stopping recorder...")
            self._recorder.stop()
            self._recorder = None
            self.menu.current_item = self._root_item
            self._toggle_item.header = "Start\nRecording"
            self._root_item.header = "DreamCatcher"
            self.menu.lcd.backlight(self.menu.lcd.BLUE)

    def record_marker(self):
        """ Record marker. """
        if self._recorder != None:
            self.menu.lcd.backlight(self.menu.lcd.GREEN)
            self._recorder.record_marker()
            sleep(1.0)
            self.menu.lcd.backlight(self.menu.lcd.RED)

    def verify_recorder(self):
        """ Verify worker is running """
        if self._recorder != None:
#.........這裏部分代碼省略.........
開發者ID:Paulxia,項目名稱:DreamCatcher,代碼行數:103,代碼來源:dreamcatcher.py


注:本文中的recorder.Recorder.record_marker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。