コード例 #1
0
ファイル: runServer.py プロジェクト: apextw/arduino-projects
    def __init__(self,port = None):
        print "runServer.__init__()"
        print os.path.realpath(__file__)
        configPath = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)),
                                self.configFname)
        print configPath
        self.cfg = ConfigUtil(configPath,self.configSection)

        self.debug = self.cfg.getConfigBool("debug")
        if (self.debug): print "Debug Mode"

        self._wkdir = self.cfg.getConfigStr("working_directory")
        if (self.debug): print "working_directory=%s\n" % self._wkdir
        self._tmpdir = self.cfg.getConfigStr("tmpdir")
        if (self.debug): print "tmpdir=%s\n" % self._tmpdir


        if (port == None):
            port = '/dev/ttyUSB0'
        print "Opening Serial Connection on %s" % port
        self.ser = serial.Serial(port,9600,timeout=1)
        print "Waiting for serial comms to settle..."
        time.sleep(2)
        print "Reading first line of data, and ignoring it."
        line = self.ser.readline() # throw away any part lines
        print "line=%s" % line

        self.start()
        print "waiting for some data..."
        while(self.ser.inWaiting() < 10): 
            print "waiting - inWaiting()=%d" % self.ser.inWaiting()
            time.sleep(1)
        print "wait over!"
        print "ignoring a few lines for start command to register..."
        for n in range(0,5):
            line = self.ser.readline() # throw away any part lines
            print "line=%s" % line
    
        #Initialise data lists.
        self.t=[] # initialize the data lists
        self.d1=[]
        self.d2=[]
        self.d3=[]
        self.d4=[]
        self.d5=[]
        self.d6=[]


        # Start web server
        self._ws = webServer.WebServer(self)
        webServer.setRoutes(self._ws)

        # Run our main loop.
        self.run()
コード例 #2
0
    def __init__(self, save=False, inFile=None):
        print "benFinder.__init__()"
        print os.path.realpath(__file__)
        configPath = "%s/%s" % (os.path.dirname(
            os.path.realpath(__file__)), self.configFname)
        print configPath
        self.cfg = ConfigUtil(configPath, self.configSection)

        self.debug = self.cfg.getConfigBool("debug")
        if (self.debug): print "Debug Mode"

        self._wkdir = self.cfg.getConfigStr("working_directory")
        if (self.debug): print "working_directory=%s\n" % self._wkdir
        self._tmpdir = self.cfg.getConfigStr("tmpdir")
        if (self.debug): print "tmpdir=%s\n" % self._tmpdir

        # Check if we are running from live kinect or a file.
        if (inFile):
            device = depth.CV_CAP_FILE
        else:
            device = depth.CV_CAP_FREENECT

        # Initialise the captureManager
        self._captureManager = CaptureManager(device,
                                              None,
                                              True,
                                              inFile=inFile)
        self._captureManager.channel = depth.CV_CAP_OPENNI_DEPTH_MAP

        # If we are runnign from a file, use the first frame as the
        # background image.
        if (inFile):
            self.saveBgImg()

        # If we have asked to save the background image, do that, and exit,
        # otherwise initialise the seizure detector.
        if (save):
            self.saveBgImg()
        else:
            self.loadBgImg()
            self.autoBackgroundImg = None
            self._status = self.ALARM_STATUS_OK
            self._ts = TimeSeries(
                tslen=self.cfg.getConfigInt("timeseries_length"))
            self._frameCount = 0
            self._outputFrameCount = 0
            self._nPeaks = 0
            self._ts_time = 0
            self._rate = 0
            self._ws = webServer.benWebServer(self)
            self._ws.setBgImg(
                "%s/%s" %
                (self._tmpdir, self.cfg.getConfigStr("background_depth")))
            self._ws.setChartImg(
                "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("chart_fname")))
            self._ws.setRawImg(
                "%s/%s" %
                (self._tmpdir, self.cfg.getConfigStr("raw_image_fname")))
            self._ws.setMaskedImg(
                "%s/%s" %
                (self._tmpdir, self.cfg.getConfigStr("masked_image_fname")))
            self._ws.setDataFname(
                "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("data_fname")))
            self._ws.setAnalysisResults({})
            webServer.setRoutes(self._ws)
            self.run()
コード例 #3
0
    def __init__(self,save=False, inFile = None):
        print "benFinder.__init__()"
        print os.path.realpath(__file__)
        configPath = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)),
                                self.configFname)
        print configPath
        self.cfg = ConfigUtil(configPath,self.configSection)

        self.debug = self.cfg.getConfigBool("debug")
        if (self.debug): print "Debug Mode"

        self._wkdir = self.cfg.getConfigStr("working_directory")
        if (self.debug): print "working_directory=%s\n" % self._wkdir
        self._tmpdir = self.cfg.getConfigStr("tmpdir")
        if (self.debug): print "tmpdir=%s\n" % self._tmpdir


        # Check if we are running from live kinect or a file.
        if (inFile):
            device = depth.CV_CAP_FILE
        else:
            device = depth.CV_CAP_FREENECT

        # Initialise the captureManager
        self._captureManager = CaptureManager(
            device, None, True, inFile=inFile)
        self._captureManager.channel = depth.CV_CAP_OPENNI_DEPTH_MAP

        # If we are runnign from a file, use the first frame as the
        # background image.
        if (inFile):
            self.saveBgImg()

        # If we have asked to save the background image, do that, and exit,
        # otherwise initialise the seizure detector.
        if (save):
            self.saveBgImg()
        else:
            self.loadBgImg()
            self.autoBackgroundImg = None
            self._status = self.ALARM_STATUS_OK
            self._ts = TimeSeries(tslen=self.cfg.getConfigInt("timeseries_length"))
            self._frameCount = 0
            self._outputFrameCount = 0
            self._nPeaks = 0
            self._ts_time = 0
            self._rate = 0
            self._ws = webServer.benWebServer(self)
            self._ws.setBgImg("%s/%s" % (self._tmpdir,
                    self.cfg.getConfigStr("background_depth")))
            self._ws.setChartImg("%s/%s" % (self._tmpdir,
                    self.cfg.getConfigStr("chart_fname")))
            self._ws.setRawImg("%s/%s" % (self._tmpdir,
                    self.cfg.getConfigStr("raw_image_fname")))
            self._ws.setMaskedImg("%s/%s" % (self._tmpdir,
                    self.cfg.getConfigStr("masked_image_fname")))
            self._ws.setDataFname("%s/%s" % (self._tmpdir,
                    self.cfg.getConfigStr("data_fname")))
            self._ws.setAnalysisResults({})
            webServer.setRoutes(self._ws)
            self.run()