当前位置: 首页>>代码示例>>Python>>正文


Python Detector.stop方法代码示例

本文整理汇总了Python中detector.Detector.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.stop方法的具体用法?Python Detector.stop怎么用?Python Detector.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在detector.Detector的用法示例。


在下文中一共展示了Detector.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DetectorUI

# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import stop [as 别名]
class DetectorUI(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.startButton,QtCore.SIGNAL("clicked()"), self.start)
        QtCore.QObject.connect(self.ui.pathButton,QtCore.SIGNAL("clicked()"), self.set_source_file_path)
        QtCore.QObject.connect(self.ui.patternCheckBox,QtCore.SIGNAL("clicked()"), self.patternClicked)
        self.detector = Detector()
        
    def start(self):
        if self.detector.isRunning():
            self.setWindowTitle('Stopped')
            self.detector.stop()
            self.ui.startButton.setText("Start")
        else:
            self.setWindowTitle('Running')
            self.detector.start()
            self.ui.startButton.setText("Stop")
            
    def set_source_file_path(self):
        dir = os.path.dirname(".")
        fileName = QtGui.QFileDialog.getOpenFileName (self,  "Open data file", dir , "Image Files (*.txt)")
        #Todo set the txt file as the data source
        self.ui.pathEdit.setText(fileName)

    def patternClicked(self):
        if self.ui.patternCheckBox.isChecked() :
            #output data pattern
            print "patern enabeled"
        else:
            #output data source
            print "patern disable"
开发者ID:WildGenie,项目名称:VirtualDetector,代码行数:35,代码来源:main.py

示例2: main

# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import stop [as 别名]
def main():
    main_parser = argparse.ArgumentParser(prog="cosmicpi", description="CosmicPi acquisition process", add_help=False)
    main_parser.add_argument("--config", help="Path to configuration file", default="/etc/cosmicpi.yaml")
    args, remaining_argv = main_parser.parse_known_args()

    # Merge the default config with the configuration file
    config = load_config(args.config)

    # Parse the command line for overrides
    parser = argparse.ArgumentParser(parents=[main_parser])
    parser.set_defaults(**config)

    parser.add_argument("-i", "--host",       **arg("broker.host",          "Message broker host"))
    parser.add_argument("-p", "--port",       **arg("broker.port",          "Message broker port", type=int))
    parser.add_argument("-a", "--username",   **arg("broker.username",      "Message broker username"))
    parser.add_argument("-b", "--password",   **arg("broker.password",      "Message broker password"))
    parser.add_argument("-n", "--no-publish", **arg("broker.enabled",       "Disable event publication"))
    parser.add_argument("-u", "--usb",        **arg("usb.device",           "USB device name"))
    parser.add_argument("-d", "--debug",      **arg("debug",                "Enable debug mode"))
    parser.add_argument("-o", "--log-config", **arg("logging.config",       "Path to logging configuration"))
    parser.add_argument("-l", "--no-log",     **arg("logging.enabled",      "Disable file logging"))
    parser.add_argument("-v", "--no-vib",     **arg("monitoring.vibration", "Disable vibration monitoring"))
    parser.add_argument("-w", "--no-weather", **arg("monitoring.weather",   "Disable weather monitoring"))
    parser.add_argument("-c", "--no-cosmics", **arg("monitoring.cosmics",   "Disable cosmic ray monitoring"))
    parser.add_argument("-k", "--patk",       **arg("patok",                "Server push notification token"))

    options = parser.parse_args()

    log_config = options.logging["config"]
    print ("INFO: using logging configuration from %s" % log_config)
    logging.config.fileConfig(log_config, disable_existing_loggers=False)
    console = logging.getLogger(__name__)

    if options.debug:
        print_config(options)

    try:
        publisher = EventPublisher(options)
    except:
        console.error("Exception: Can't connect to broker")
        sys.exit(1)

    try:
        usb = UsbHandler(options.usb['device'], 9600, 60)
        usb.open()
    except Exception as e:
        console.error("Exception: Can't open USB device: %s" % e)
        sys.exit(1)

    detector = Detector(usb, publisher, options)

    try:
        detector.start()
        command_handler = CommandHandler(detector, usb, options)
        command_handler.start()

        while True:
            time.sleep(1)

    except Exception as e:
        console.info("Exception: main: %s" % e)
        traceback.print_exc()

    finally:
        detector.stop()
        console.info("Quitting ...")
        time.sleep(1)
        usb.close()
        publisher.close()
        sys.exit(0)
开发者ID:CosmicPi,项目名称:cosmicpi-daq,代码行数:72,代码来源:cosmicpi.py


注:本文中的detector.Detector.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。