def __init__(self):
        '''Initialize and create a CSV file
        '''
        start_time = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
        self.rover_properties = utility.load_configuration(os.path.join('setting', 'rover.json'))
        if not self.rover_properties:
            os._exit(1)
        if not os.path.exists('data/'):
            os.mkdir('data/')
        self.output_packets = self.rover_properties['userMessages']['outputPackets']
        self.log_file_rows = {}
        self.log_file_names = {}
        self.log_files_obj = {}
        self.log_files = {}
        self.user_file_name = '' # the prefix of log file name.
        self.msgs_need_to_log = []
        self.ws = False
        # azure app.
        self.user_id = ''
        self.file_name = ''
        self.sas_token = '' 
        self.db_user_access_token = ''
        self.host_url = self.rover_properties['userConfiguration']['hostURL']

        #
        self.threads = []  # thread of receiver and paser
        self.exit_thread = False  # flag of exit threads
        self.exit_lock = threading.Lock()  # lock of exit_thread
        self.data_dict = {}  # data container
        self.data_lock = threading.Lock()  # lock of data_queue
Beispiel #2
0
 def __init__(self):
     ''' initialization
     '''
     self.cmt = communicator.SerialPort()
     # self.cmt = communicator.TCPIP()
     self.threads = []  # thread of receiver and paser
     self.exit_thread = False  # flag of exit threads
     self.exit_lock = threading.Lock()  # lock of exit_thread
     self.data_queue = Queue()  # data container
     self.data_lock = threading.Lock()  # lock of data_queue
     self.web_clients = []
     self.web_clients_lock = threading.Lock()  # lock of web_clients
     self.web_cmds = []
     self.web_cmds_lock = threading.Lock()  # lock of web_cmds
     self.app = None
     self.msgs = {}
     self.cmds = {}
     self.connection_status = 0  # status of connection with device. 0: unconnected 1:connected.
     self.cmds['queryProductId'] = b'\xAF\x20\x06\x0B\x01\x00\x01\x01\x01'
     self.cmds[
         'queryEngineVersion'] = b'\xAF\x20\x06\x0B\x01\x00\x02\x02\x02'
     self.cmds[
         'queryFirmwareVersion'] = b'\xAF\x20\x06\x0B\x01\x00\x0C\x0C\x0C'
     self.cmds[
         'queryInternalLeverArm'] = b'\xAF\x20\x06\x0B\x01\x00\x04\x04\x04'
     self.cmds[
         'queryUserConfiguration'] = b'\xAF\x20\x06\x0B\x01\x00\x0A\x0A\x0A'
     self.cmds[
         'queryNTRIPConfiguration'] = b'\xAF\x20\x06\x0A\x01\x00\x01\x01\x01'
     self.nav_pos_vel_mode = {
         0: 'INVALID',
         1: 'DEAD_RECKON',
         2: 'STAND_ALONE',
         3: 'PRECISE_POINT_POSITIONING',
         4: 'CODE_DIFF',
         5: 'RTK_FLOAT',
         6: 'RTK_FIXED',
         7: 'USER_AIDING'
     }
     self.nav_att_mode = {0: 'INVALID', 1: 'COARSE', 2: 'FINE'}
     self.setting_folder = os.path.join(
         os.getcwd(), r'setting')  # use to store some configuration files.
     self.connection_file = os.path.join(self.setting_folder,
                                         'connection.json')
     self.rover_properties = utility.load_configuration(
         os.path.join(self.setting_folder, 'rover.json'))
     if not self.rover_properties:
         os._exit(1)
     print('Rover driver start at:{0}'.format(
         datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
     threading.Thread(target=self.auto_del_timeout_web_cmds,
                      args=()).start()
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        tornado.websocket.WebSocketHandler.__init__(self, *args, **kwargs)

        self.newest_packets = {}
        self.all_packets = []
        self.msgs_send2web = []
        self.data_lock = threading.Lock(
        )  # lock of all_packets and msgs_send2web.
        self.start_stream = False
        self.file_loger = FileLoger()
        self.file_loger_lock = threading.Lock(
        )  # lock of file_loger and file_uploader.
        self.ii = 0

        rover_properties = utility.load_configuration(
            os.path.join('setting', 'rover.json'))
        if not rover_properties:
            os._exit(1)
        for packet in rover_properties['userMessages']['outputPackets']:
            if 1 == packet['send2web']:
                self.msgs_send2web.append(packet['name'])
    return _update_lock(path)

def _update_lock(path):
    t = datetime.datetime.now()

    logging.info('Updated lock on %s from %s to %s.',
                 path, _locks[path].last_used, t)

    l = _locks[path]
    l = Lock(l.lock_id, l.granted, t)
    _locks[path] = l


def _cancel_lock(path):
    if path in _locks:
        logging.info('Cancel lock on %s.', path)
        del _locks[path]



_config = {
            'dbfile': 'locks.db',
            'lock_lifetime': 60,
         }

logging.info('Loading config file lockserver.dfs.json.')
utility.load_configuration(_configuration, 'lockserver.dfs.json')
_locks = shelve.open(_configuration['dbfile'])

atexit.register(lambda: _locks.close())