Exemplo n.º 1
0
 async def log(self):
     self.ts = time.time()
     self.format_data()
     await log_data(
         dfl.DATA_SEPARATOR.join(
             [
                 self.config['String_Label'],
                 str(unix_epoch(self.ts)),
                 iso8601(self.ts)  # yyyy-mm-ddThh:mm:ssZ (controller)
             ]
             + self.data
         )
     )
Exemplo n.º 2
0
 async def log(self):
     self.ts = time.time()
     await log_data(
         dfl.DATA_SEPARATOR.join([
             self.config['String_Label'],
             str(unix_epoch(self.ts)),
             iso8601(self.ts),  # yyyy-mm-ddThh:mm:ssZ (controller)
             '{:.4f}'.format(self.battery_level(
                 self.data[0])),  # Battery voltage [V].
             '{:.4f}'.format(self.current_level(
                 self.data[1])),  # Current consumption [A].
             '{:.4f}'.format(self.ad22103(
                 self.data[2], self.data[6])),  # Internal vessel temp [°C].
             '{:.4f}'.format(self.data[3]),  # Core temp [°C].
             '{:.4f}'.format(self.data[4]),  # Core vbat [V].
             '{:.4f}'.format(self.data[5]),  # Core vref [V].
             '{:.4f}'.format(self.data[6]),  # Vref [V].
             '{}'.format(self.data[7] // 1024)  # SD free space [kB].
         ]))
Exemplo n.º 3
0
async def data_files():
    _ = ["{:#^40}".format(" DATA FILES ")]
    try:
        data = os.listdir(dfl.DATA_DIR)
        data.sort(reverse=True)
    except:
        data = []
    size = 0
    for f in data:
        stat = os.stat(dfl.DATA_DIR + "/" + f)
        size += stat[6] // 1024
        _.append("{: <5} {: <20} {}".format(str(stat[6] // 1024),
                                            iso8601(stat[7]), f))
        await asyncio.sleep(0)
    fsstat = os.statvfs(dfl.DATA_DIR)
    _.append("{} Files {}/{} kB".format(len(data), str(size),
                                        str(fsstat[2] * fsstat[0] // 1024)))
    _.append("\r")
    print("\r\n".join(_))
Exemplo n.º 4
0
 async def log(self):
     self.ts = time.time()
     await log_data(
         '{},{},{},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:.2f},{:0d},{:.2f}'
         .format(
             self.string_label,
             str(unix_epoch(self.ts)),
             iso8601(self.ts),  # yyyy-mm-ddThh:mm:ssZ (controller)
             self.wd_vect_avg(),  # vect avg wind direction
             self.ws_avg(),  # avg wind speed
             self.temp_avg(),  # avg temp
             self.press_avg(),  # avg pressure
             self.hum_avg(),  # avg relative humidity
             self.compass_avg(),  # avg heading
             self.ws_vect_avg(),  # vectorial avg wind speed
             self.gust()[0],  # gust speed
             self.gust()[1],  # gust direction
             self.records,  # number of records
             self.radiance_avg()  # solar radiance (optional)
         ))
Exemplo n.º 5
0
    async def format_data(self, sample):

        def get_flow():
            return 0  # TODO: calc flow for rivers.

        try:
            record = [
            self.config['String_Label'],
            '{}'.format(str(unix_epoch(self.ts))),
            '{}'.format(iso8601(self.ts)),                                   # yyyy-mm-ddThh:mm:ssZ (controller)
            '{:2s}/{:2s}/20{:2s}'.format(sample[2], sample[5], sample[4]),  # dd/mm/yyyy
            '{:2s}:{:2s}'.format(sample[3], sample[0]),                     # hh:mm
            '{:.2f}'.format(sample[8]),                                     # Battery
            '{:.2f}'.format(sample[9]),                                     # SoundSpeed
            '{:.2f}'.format(sample[10]),                                    # Heading
            '{:.2f}'.format(sample[11]),                                    # Pitch
            '{:.2f}'.format(sample[12]),                                    # Roll
            '{:.2f}'.format(sample[13]),                                    # Pressure
            '{:.2f}'.format(sample[15]),                                    # Temperature
            '{:.2f}'.format(get_flow()),                                    # Flow
            '{}'.format(self.usr_cfg[17]),                                  # CoordSystem
            '{}'.format(self.usr_cfg[4]),                                   # TODO: BlankingDistance
            '{}'.format(self.usr_cfg[20]),                                  # MeasInterval
            '{:.2f}'.format(self.usr_cfg[19] * 0.01692620176 / 100),        # BinLength
            '{}'.format(self.usr_cfg[18]),                                  # NBins
            '{}'.format(sample[14][0])                                      # TiltSensorMounting
            ]

            j = 16
            for bin in range(self.usr_cfg[18]):
                record.append('#{}'.format(bin + 1))                        # (#Cell number)
                for beam in range(self.usr_cfg[10]):
                    record.append('{:.3f}'.format(sample[j+beam*self.usr_cfg[18]]))
                    await asyncio.sleep(0)
                j += 1
                await asyncio.sleep(0)
            return record
        except Exception as err:
            log(self.__qualname__, 'format_data', type(err).__name__, err)
Exemplo n.º 6
0
 def set_deployment_start(sampling_interval, avg_interval):
     # Computes the measurement starting time to be in synch with the scheduler.
     now = time.time()
     next_sampling = now - now % sampling_interval + sampling_interval
     log(self.__qualname__, 'deployment start at {}, measurement interval {}\', average interval {}\''.format(iso8601(next_sampling), sampling_interval, avg_interval))
     deployment_start = time.localtime(next_sampling + avg_interval)
     return binascii.unhexlify('{:02d}{:02d}{:02d}{:02d}{:02d}{:02d}'.format(deployment_start[4], deployment_start[5], deployment_start[2], deployment_start[3], int(str(deployment_start[0])[2:]), deployment_start[1]))