-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.py
50 lines (37 loc) · 1.81 KB
/
dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from networktables import NetworkTables
from robotconfig import dashboardConfig, MODULE_NAMES
from wpilib import SmartDashboard
class Dashboard:
theDashboard = None
def __init__(self, testMode):
self.tableName = 'SmartDashboard'
self.server = 'roborio-1076-frc.local'
if testMode:
self.server = 'localhost'
NetworkTables.initialize(server=self.server) # Necessary for vision to
self.dashboard = NetworkTables.getTable('SmartDashboard')
def getTable(self):
return self.dashboard
def putNumber(self, moduleName, key, value):
if dashboardConfig[moduleName]:
self.dashboard.putNumber(moduleName + '/' + key, value)
def putBoolean(self, moduleName, key, value):
if dashboardConfig[moduleName]:
self.dashboard.putBoolean(moduleName + '/' + key, value)
def putString(self, moduleName, key, value):
if dashboardConfig[moduleName]:
self.dashboard.putString(moduleName + '/' + key, value)
def putField(self, moduleName, key, value):
#if dashboardConfig[moduleName]:
#self.dashboard.putRaw(moduleName + '/' + key, value)
SmartDashboard.putData("Field", value)
def getNumber(self, moduleName, key, defaultValue = -1):
return self.dashboard.getNumber(moduleName + '/' + key, defaultValue)
def getBoolean(self, moduleName, key, defaultValue = False):
return self.dashboard.getBoolean(moduleName + '/' + key, defaultValue)
def getString(self, moduleName, key, defaultValue = ''):
return self.dashboard.getBoolean(moduleName + '/' + key, defaultValue)
def getDashboard(testMode=False):
if not Dashboard.theDashboard:
Dashboard.theDashboard = Dashboard(testMode)
return Dashboard.theDashboard