Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions modules/logs/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ def read_log_as_json(self, log_type, log_id): # pylint: disable=no-self-use
array = []
with open(filename, 'r', encoding='utf-8') as csv_file:
reader = csv.reader(csv_file)
l_time=0
for row in reader:
try:
array.append([
int((datetime.datetime.strptime(
row[0], "%Y-%m-%d %H:%M:%S") -
datetime.datetime(1970, 1, 1)).total_seconds()) *
1000,
float(row[1])
])
p_time=int((datetime.datetime.strptime( # get point timestamp
row[0], "%Y-%m-%d %H:%M:%S") -
datetime.datetime(1970, 1, 1)).total_seconds()) * 1000
if ( abs(float(row[1])) < 110 ) and # filter invalid points
( p_time >= l_time ): # only plot if more than 60 sec from previus point
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, but IMO should be configurable...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the enable/disable or the time interval ( 60 sec )?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lalo-uy I think you could have a parameter plot_period to configure that and have the default of 60.

So you replace the line: l_time = p_time + 60000;
With: l_time = p_time + 1000 * cbpi.get_config_parameter("plot_period", 60)

It that what you meant @jpgimenez?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 agree... the parameter is better than a hardcoded value

l_time = p_time + 60000;
array.append([p_time , float(row[1])])

except IndexError:
pass
return array
Expand Down