Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge commit
- Loading branch information
Showing
191 changed files
with
12,551 additions
and
3,183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# pylint: disable=line-too-long | ||
|
||
DEVICE_PROBES = { | ||
'LGE: LGLS740': { | ||
'name': 'LG Volt (LGLS740)', | ||
'missing_probes': [ | ||
'edu.northwestern.cbits.purple_robot_manager.probes.sensors.LightSensorProbe', | ||
] | ||
}, | ||
'LGE: LGL34C': { | ||
'name': 'Optimus Fuel (LGL34C)', | ||
'missing_probes': [ | ||
'edu.northwestern.cbits.purple_robot_manager.probes.sensors.LightSensorProbe', | ||
] | ||
}, | ||
'LGE: LGLS660': { | ||
'name': 'LG Tribute (LGLS660)', | ||
'missing_probes': [ | ||
'edu.northwestern.cbits.purple_robot_manager.probes.sensors.LightSensorProbe', | ||
] | ||
}, | ||
'LGE: LGL41C': { | ||
'name': 'LG Ultimate 2 (LGL41C)', | ||
'missing_probes': [ | ||
'edu.northwestern.cbits.purple_robot_manager.probes.sensors.LightSensorProbe', | ||
] | ||
} | ||
} | ||
|
||
|
||
def can_sense(manufacturer, model, probe): | ||
if manufacturer is None or model is None or probe is None: | ||
return None | ||
|
||
# Until contrary evidence surfaces, assume that all devices have all sensors. | ||
|
||
key = manufacturer + ': ' + model | ||
|
||
if key in DEVICE_PROBES: | ||
device = DEVICE_PROBES[key] | ||
|
||
if probe in device['missing_probes']: | ||
return False | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
import math | ||
# pylint: disable=line-too-long, unused-argument | ||
|
||
import json | ||
|
||
from django.template.loader import render_to_string | ||
|
||
def format(probe_name, json_payload): | ||
|
||
def format_reading(probe_name, json_payload): | ||
item = json.loads(json_payload) | ||
app = item['CURRENT_APP_NAME'] | ||
category = item['CURRENT_CATEGORY'] | ||
|
||
return app + ' (' + category + ')' | ||
|
||
|
||
def visualize(probe_name, readings): | ||
return '' | ||
''' | ||
report = [] | ||
for reading in readings: | ||
payload = json.loads(reading.payload) | ||
timestamp = payload['TIMESTAMP'] | ||
device_active = payload['DEVICE_ACTIVE'] | ||
if device_active == True: | ||
device_active = 1 | ||
elif device_active == False: | ||
device_active = 0 | ||
rep_dict = {} | ||
rep_dict["y"] = device_active | ||
rep_dict["x"] = timestamp | ||
report.append(rep_dict) | ||
return render_to_string('visualization_device.html', { 'probe_name' : probe_name, 'readings' : readings, 'device_report' : json.dumps(report) }) | ||
''' | ||
|
||
# | ||
# report = [] | ||
# | ||
# for reading in readings: | ||
# payload = json.loads(reading.payload) | ||
# | ||
# timestamp = payload['TIMESTAMP'] | ||
# device_active = payload['DEVICE_ACTIVE'] | ||
# | ||
# if device_active == True: | ||
# device_active = 1 | ||
# elif device_active == False: | ||
# device_active = 0 | ||
# | ||
# rep_dict = {} | ||
# rep_dict["y"] = device_active | ||
# rep_dict["x"] = timestamp | ||
# report.append(rep_dict) | ||
# | ||
# return render_to_string('visualization_device.html', { 'probe_name' : probe_name, 'readings' : readings, 'device_report' : json.dumps(report) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
# pylint: disable=line-too-long, unused-argument | ||
|
||
import json | ||
|
||
from django.template.loader import render_to_string | ||
|
||
def format(probe_name, json_payload): | ||
|
||
def format_reading(probe_name, json_payload): | ||
item = json.loads(json_payload) | ||
|
||
status = 'Unknown' | ||
|
||
if item['status'] == 2: | ||
status = 'Charging' | ||
elif item['status'] == 3: | ||
status = 'Discharging' | ||
elif item['status'] == 5: | ||
status = 'Full' | ||
|
||
return str(item['level']) + '% (' + status + ')' | ||
|
||
|
||
def visualize(probe_name, readings): | ||
return render_to_string('visualization_probe.html', { 'probe_name': probe_name, 'readings': readings }) | ||
return render_to_string('visualization_probe.html', {'probe_name': probe_name, 'readings': readings}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
import math | ||
# pylint: disable=line-too-long, unused-argument | ||
|
||
import json | ||
|
||
from django.template.loader import render_to_string | ||
|
||
def format(probe_name, json_payload): | ||
|
||
def format_reading(probe_name, json_payload): | ||
item = json.loads(json_payload) | ||
state = item['CALL_STATE'] | ||
|
||
return state | ||
|
||
|
||
def visualize(probe_name, readings): | ||
report = [] | ||
|
||
for reading in readings: | ||
payload = json.loads(reading.payload) | ||
|
||
timestamp = payload['TIMESTAMP'] | ||
call_state = payload['CALL_STATE'] | ||
|
||
if call_state == "Off-Hook": | ||
call_state = 2 | ||
elif call_state == "Ringing": | ||
call_state = 1 | ||
elif call_state == "Idle": | ||
call_state = 0 | ||
|
||
rep_dict = {} | ||
rep_dict["y"] = call_state | ||
rep_dict["x"] = timestamp | ||
report.append(rep_dict) | ||
return render_to_string('visualization_callstate.html', { 'probe_name' : probe_name, 'readings' : readings, 'callstate_report' : json.dumps(report) }) | ||
|
||
return render_to_string('visualization_callstate.html', {'probe_name': probe_name, 'readings': readings, 'callstate_report': json.dumps(report)}) |
Oops, something went wrong.