Example #1
0
    def Connect(self):

        # now try to start our services
        try:

            i = 0
            while i < 3:
                # set the camera led off
                self.led_flash.setPixelColor(0, Color(0, 0, 0))
                self.led_flash.show()
                sleep(0.25)
                i += 1
                # set the camera led to warn
                self.led_flash.setPixelColor(0, Color(255, 255, 0))
                self.led_flash.show()
                sleep(0.25)

            if self.script_cfg['debug']:
                print(' run all of our prechecks ')

            # cleanup any old jobs
            FileStruct.CleanUp(FileStruct, self.script_cfg)

            # create our directories
            FileStruct.CreateStructure(FileStruct, self.script_cfg)

            # init connection to a new sqlite database
            self.process['connection'] = DBLite.StartDB(
                DBLite, self.script_cfg)

            #create a new databse table
            DBLite.InitDB(DBLite, self.process['connection'], self.script_cfg)
            if self.script_cfg['debug']:
                print(' new database connection successful ')

            # get the IMU data
            self.process['pid'] = IMUDevice.StartIMU(IMUDevice, self.imu_cfg,
                                                     self.script_cfg)

            # if this fails so should the script
            if not self.process['pid']:

                if self.script_cfg['debug']:
                    print(' new imu connection failed ')

                # close the database connection we no longer need it
                DBLite.CloseDB(DBLite, self.process['connection'],
                               self.script_cfg)
                return False

            else:
                if self.script_cfg['debug']:
                    print(' new imu connection started ')

            print("| connection(s) successful, waiting on",
                  self.script_cfg['triggers'], "trigger(s) |")
            return True

        except:
            # something went bad halt
            print("| connection(s) failed |")
            # fail
            return False
Example #2
0
    def Connect(self):

        # now try to start our services
        try:

            if self.script_cfg['debug']:
                print(' run all of our prechecks ')

            # create our directories
            FileStruct.CreateStructure(FileStruct, self.script_cfg)

            # cleanup any old jobs
            FileStruct.CleanUp(FileStruct, self.script_cfg)

            # init connection to a new sqlite database
            self.process['connection'] = DBLite.StartDB(
                DBLite, self.script_cfg)

            #create a new databse table
            DBLite.InitDB(DBLite, self.process['connection'], self.script_cfg)
            if self.script_cfg['debug']:
                print(' new database connection successful ')

            # get the IMU data
            self.process['pid'] = IMUDevice.StartIMU(IMUDevice, self.imu_cfg,
                                                     self.script_cfg)

            # if this fails so should the script
            if not self.process['pid']:

                if self.script_cfg['debug']:
                    print(' new imu connection failed ')

                # close the database connection we no longer need it
                DBLite.CloseDB(DBLite, self.process['connection'],
                               self.script_cfg)
                return False

            else:
                if self.script_cfg['debug']:
                    print(' new imu connection started ')

            # try to open the camera
            camera = CameraDevice.Connect(CameraDevice, self.camera_cfg,
                                          self.script_cfg)
            if not camera:

                # close the database connection we no longer need it
                #DBLite.CloseDB(DBLite, self.process['connection'], self.script_cfg)
                # hault the imu device
                #IMUDevice.StopIMU(IMUDevice, self.process['pid'], self.script_cfg)
                self.End()

                if self.script_cfg['debug']:
                    print(' new camera connection failed ')

            else:

                # set the camera process
                self.process['camera'] = camera

            # CameraDevice.ClearImages(CameraDevice, camera, self.camera_cfg, self.script_cfg)

            print("| connection(s) successful, waiting on",
                  self.script_cfg['triggers'], "trigger(s) |")
            return True

        except:
            # something went bad halt
            print("| connection(s) failed |")
            # fail
            return False