Skip to content

Commit 53b3291

Browse files
committed
Fixed logging directory issue on S500, Omniscan, and Surveyor. Added calc_msec_per_ping to S500.
1 parent f4a3fc5 commit 53b3291

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

generate/templates/omniscan450.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Omniscan450(PingDevice):
245245
save_name = dt.strftime("%Y-%m-%d-%H-%M")
246246

247247
if log_directory is None:
248-
project_root = Path.cwd().parent
248+
project_root = Path.cwd()
249249
self.log_directory = project_root / "logs/omniscan"
250250
else:
251251
self.log_directory = Path(log_directory)

generate/templates/s500.py.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ from brping import pingmessage
1414
import time
1515
import struct
1616
import socket
17+
import math
1718
from datetime import datetime, timezone
1819
from pathlib import Path
1920

@@ -158,6 +159,11 @@ class S500(PingDevice):
158159
except ConnectionResetError as e:
159160
raise ConnectionError("Socket connection was reset: %s" % str(e))
160161

162+
# Calculate the milliseconds per ping from a ping rate
163+
@staticmethod
164+
def calc_msec_per_ping(ping_rate):
165+
return math.floor(1000.0 / ping_rate)
166+
161167
# Converts power results to correct format
162168
@staticmethod
163169
def scale_power(msg):
@@ -276,7 +282,7 @@ class S500(PingDevice):
276282
save_name = dt.strftime("%Y-%m-%d-%H-%M")
277283

278284
if log_directory is None:
279-
project_root = Path.cwd().parent
285+
project_root = Path.cwd()
280286
self.log_directory = project_root / "logs/s500"
281287
else:
282288
self.log_directory = Path(log_directory)

generate/templates/surveyor240.py.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ from brping import pingmessage
1414
import time
1515
import struct
1616
import socket
17+
import math
1718
from datetime import datetime, timezone
1819
from pathlib import Path
1920

@@ -232,7 +233,7 @@ class Surveyor240(PingDevice):
232233
save_name = dt.strftime("%Y-%m-%d-%H-%M")
233234

234235
if log_directory is None:
235-
project_root = Path.cwd().parent
236+
project_root = Path.cwd()
236237
self.log_directory = project_root / "logs/surveyor"
237238
else:
238239
self.log_directory = Path(log_directory)
@@ -395,6 +396,10 @@ class Surveyor240(PingDevice):
395396
yz_list = struct.unpack('<' + 'f' * int(msg.num_points) * 2, raw_array)
396397
return yz_list
397398

399+
# Calculate the milliseconds per ping from a ping rate
400+
@staticmethod
401+
def calc_msec_per_ping(ping_rate):
402+
return math.floor(1000.0 / ping_rate)
398403

399404
if __name__ == "__main__":
400405
import argparse

0 commit comments

Comments
 (0)