-
Notifications
You must be signed in to change notification settings - Fork 0
Code Design
#Dash Runner Class
####init(self, parent)
sets up tkinter environment to the parent application sets up the background color, width, height sets up can store
- randomly generated values
- can read values
read in can bus ids to canStore
handles a file not found exception if initialization xml is not setup properly
calls all the widgets from widget compiler and calls create on each gauge
sets up callback to update can every 10 milliseconds
####reset(self)
void is not implemented and not used
####updateCan(self)
call for store to update from can bus
self call to update screen
####alert(self, label, message)
takes main label and message to throw to the screen
wipes the screen of all gauges and only shows the alert message to the driver
#Dash Exceptions
##Missing ID Exception
Inherits: Exception
Holds the wrong id that threw exception. Thrown when reading xml has an unidentified id.
Thrown if any parameter is operating outside the safe range
Holds warning message and the unsafe frame struct
sub process that constantly updates can data and the can data packet
listens for pipe query to send updated data packet back to the GUI program
####init(self)
initializes and starts can listening sub process
Sets up the correct CAN bus network to listen to
####__ loadConfigXml__(self, xmlPath)
reads in config xml file that defines all the frame configuration data.
All data is read into a canFrame struct
####get(self, frameId)
if the frame id is a valid frame in the can store's dictionary than return the can frame
####getPack(self, packIds)
consolidate all the data frames that correlate with the given packIds.
returns an array of canFrame structs in the same order as the given packIds
####update(self)
polls canListern sub process to update all the can frames in the data store
inherits all the methods of canStore and will override all methods that directly deal with the can bus
####init(self)
Only creates a frame dictionary
####update(self)
For every frame in the frame dictionary, generate a random value within it's min and max range, if that particular frame has a defined min and max
##canFrame class
struct class that holds a all the data for a parameter that is sent over the can network. Mirrors the structure of the xml configuration file
###instance variables:
-
canId (string)
ID that is used on the CAN network
-
parameter (string)
can frame name (i.e. RPM, TPS, coolant temp, battery voltage)
-
length (string)
length of the data packet
-
type
data type of the sent data in the can frame (i.e unsigned int, signed int, boolean)
-
data
data of the can frame
-
max
maximum safe operating range
-
warning
warning message that will display when the safe operating range is exceeded
-
min
minimum safe operating range
#EnvironmentConfig class
####instance Variables
-
bus
bus network name. This should be the same name in linux if you run the command:
ifconfig
-
framesFileDecleration
absolute path to the can ids xml configuration file
-
envType
environment type. See the environment static enums
####static enums
-
DEV
designates a developer environment where both the GUI and ecu can bus simulator is used
-
DASH
designates a production GUI environment. This should be used on the beaglebone that shows the dashboard.
-
PUSH
designates a production ecu can bus simulator environment. This should be used on the beaglebone that pushes can bus data to for the GUI to read
#Gauge Class
The gauge class is used during rendering to define how information is displayed to the driver. The three methods that are required are an init, create, and updateView method
###Gauge abstract class
####Instance Variables
-
dataIds
can bus ids that the gauge has subscribed to
-
xloc
-
yloc
-
width
-
height
####Instance Methods
-
subscribe(self, canIds*)
add all the canIds that the gauge needs to listen to
-
getSubscriptions()
return all the subscription ids that the gauge has subscribed to
###TextGauge(Gauge)
Inherits: Gauge
Can display any id or parameter, with no limit on the number of ids that can show up. If there are more than one id that is subscribed to the next id is rendered underneath the previous one.
####Instance Variables
-
fontSize
the font size when text is displayed to the screen
-
fontColor
####Instance Methods
-
init(self, x, y, *subscriptions, fontSize=12, font="Times", fontcolor="black")
-
create(self, canvas)
sets the tkinter canvas to draw to
sets up the initial drawing of the text gauge
-
updateView(self, dataPack)
redraws the gauge with the updated dataPack
dataPack should be an dictionary of <id, values>
-
renderText(self, dataPack)
for every id that has been subscribed to, renders the title and the value to the screen
###Circular Gauge(Gauge)
Inherits: Gauge
Can only display one id or parameter that has a defined min and max value in the canids.xml file.
####Instance Variables
-
startAngle
angle that the gauge 0 value should start at relative the -y vector
-
color
color of the filled in gauge
-
font
fontStyle that is used for the rendered text. Reference tkinter for available fonts
-
fontColor
####Instance Methods
-
init(self, x, y, width, height, subscription, startAngle=0, color="black", font="Times", fontcolor = "black")
-
create(self, canvas)
-
updateView(self, dataPack)
###BarGauge(Gauge)
Inherits: Gauge
Renders any number of ids or parameters that have a defined minimum and maximum value in the canids.xml file. For multiple ids that have been subscribed to, the extra ids are rendered next to the first id. The first gauge is where the xloc and yloc point to and then the rest of the gauges are rendered next to it horizontally or vertically depending on the initialization of the gauge.
####Instance Variables
-
fontColor
-
orientation = HORIZONTAL, VERTICAL
-
padding
sets the gap between multiple gauges
-
color
bar color
-
fontcolor
####Static Enums
-
HORIZONTAL - sets gauge to be rendered horizontally with text on left, bar on right, and multiple gauges rendered underneath first gauge.
-
VERTICAL - sets gauge to be rendered vertically with text at bottom, bar on top, and multiple gauges rendered to the right of the first gauge.
####Instance Methods
-
init(self, x, y, width, height, *subscriptions, orientation=HORIZONTAL, padding=5, color="black", font="Times", fontcolor="black")
-
create(self, canvas)
sets the tkinter canvas to render to
-
updateView(self, dataPack)
updates the display
#Helper Methods
####compileGauges()
Where all the gauges are added to the gauge array and were all the gauges are initialized. The Gauge array is passed back to the main runner where all the declared gauges are rendered to the screen.
To add a gauge to the gauge array:
gauges.append({guaugeType})