Changeset 68030fa for src/python/bin
- Timestamp:
- Aug 24, 2017, 5:55:56 PM (9 years ago)
- Branches:
- debian/bullseye, debian/jessie
- Children:
- 30be24a
- Parents:
- 86da110 (diff), 9b1c16f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Joachim Langenbach <joachim.langenbach@…> (08/24/17 17:53:17)
- git-committer:
- Joachim Langenbach <joachim.langenbach@…> (08/24/17 17:55:56)
- Location:
- src/python/bin
- Files:
-
- 2 added
- 1 edited
-
gnuboat (modified) (6 diffs)
-
gnuboat-data-generator (added)
-
gnuboat-log-converter (added)
Legend:
- Unmodified
- Added
- Removed
-
src/python/bin/gnuboat
r86da110 r68030fa 48 48 nmeafile = None 49 49 nmeaFileDate = None 50 51 52 def rraRows(duration, resolution, step):53 return int(round(float(duration) / rraSteps(resolution, float(step)) / float(step)))54 55 56 def rraSteps(resolution, step):57 return int(round(float(resolution) / float(step)))58 59 60 def createDatabase(databaseFile):61 rrdDataSources = ['DS:latitude:GAUGE:15:-90:90',62 'DS:longitude:GAUGE:15:-180:180',63 'DS:speedthroughwater:GAUGE:15:U:U',64 'DS:speedoverground:GAUGE:15:U:U',65 'DS:waterdepth:GAUGE:15:0:10000',66 'DS:watertemperature:GAUGE:15:-10:50',67 'DS:gpsfix:GAUGE:15:-999:3']68 69 step = logperiod70 # durations: each archive should contain values for in seconds71 archives = [72 {"duration": 240, "resolution": 2},73 {"duration": 3600, "resolution": 10},74 {"duration": 86400, "resolution": 60},75 ]76 rrdArchives = []77 for i in range(0, len(archives)):78 rrdArchives += ['RRA:AVERAGE:0.5:%d:%d' % (rraSteps(archives[i]["resolution"], step), rraRows(79 archives[i]["duration"], archives[i]["resolution"], step))]80 81 if not os.path.isfile(databaseFile):82 rrdtool.create(databaseFile,83 "--start",84 "N",85 "--step",86 str(step),87 rrdDataSources,88 rrdArchives)89 50 90 51 … … 117 78 118 79 def log(gpsFix, gpsTime, gpsStatus, latitude, latitudeDirection, longitude, 119 longitudeDirection, courseOverGround, speedOverGround, waterDepth, water DepthValid):80 longitudeDirection, courseOverGround, speedOverGround, waterDepth, waterTemperature, transducerValid): 120 81 global logdir 121 82 global nmeafile … … 140 101 141 102 nmeafile.write("%s\r\n" % str(pynmea2.RMC('GN', 'RMC', 142 (gpsTime.strftime("%H%M%S"), gpsStatus, ' $%04.3f' % latitude,143 latitudeDirection, ' $%05.3f' % longitude, longitudeDirection,144 ' $%02.1f' % speedOverGround, '$%02.1f' % courseOverGround,103 (gpsTime.strftime("%H%M%S"), gpsStatus, '%08.3f' % latitude, 104 latitudeDirection, '%09.3f' % longitude, longitudeDirection, 105 '%04.1f' % speedOverGround, '%04.1f' % courseOverGround, 145 106 gpsTime.strftime("%d%m%y"), '', '', mode)))) 146 if waterDepthValid: 147 nmeafile.write("%s\r\n" % str(pynmea2.DPT('SD', 'DPT', ('%02.2f' % waterDepth, '00.00')))) 107 if transducerValid: 108 nmeafile.write("%s\r\n" % str(pynmea2.DPT('SD', 'DPT', ('%05.2f' % waterDepth, '00.00')))) 109 nmeafile.write("%s\r\n" % str(pynmea2.MTW('YX', 'MTW', ('%04.1f' % waterTemperature, 'C')))) 148 110 149 111 def main(argv): … … 203 165 sys.exit(2) 204 166 205 createDatabase(rrdfile) 167 daemon.rrd_create_database(rrdfile, logperiod) 168 169 if os.path.isfile(shutdownfile): 170 os.remove(shutdownfile) 206 171 207 172 displayHandler = daemon.DisplayHandler(displayperiod) … … 220 185 speedThroughWater = n2kd.speedThroughWater() 221 186 speedOverGround = gpsp.speedOverGround() 187 courseOverGround = gpsp.courseOverGround() 222 188 waterDepth = n2kd.waterDepth() 223 189 waterTemperature = n2kd.waterTemperature() … … 225 191 226 192 # update rrd database for the webservice 227 rrdtool.update(rrdfile, "N:%s:%s:%s:%s:%s:%s:%s" % (228 latitude, longitude, speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix))193 daemon.rrd_update(rrdfile, "N:%s:%s:%s:%s:%s:%s:%s:%s" % ( 194 latitude, longitude, speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix)) 229 195 230 196 # append to log 231 197 log(gpsFix, gpsp.timeUtc(), gpsp.status(), latitude, gpsp.latitudeDirection(), 232 longitude, gpsp.longitudeDirection(), gpsp.courseOverGround(), speedOverGround,233 waterDepth, n2kd.waterDepthValid())198 longitude, gpsp.longitudeDirection(), courseOverGround, speedOverGround, 199 waterDepth, waterTemperature, n2kd.waterDepthValid()) 234 200 235 201 # display data 236 202 displayHandler.setValues( 237 speedThroughWater, speedOverGround, waterDepth, waterTemperature, gpsFix)203 speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix) 238 204 239 205 # check for shutdown request
Note:
See TracChangeset
for help on using the changeset viewer.
