KentuckySolarCar / Telemetry-GUI

This code will run on a desktop machine, and display the data the solar car sends from an rs 232 connection
8 stars 1 forks source link

Object Oriented Class Seperation #5

Open egtoney opened 9 years ago

egtoney commented 9 years ago

The telemetry.py file needs to be split into an object oriented layout where each class has it's own file. Be careful of cyclical imports.

weiliansong commented 9 years ago

So for this task I literally created four new .py files:

  1. MotorController.py
  2. Battery.py
  3. MPPT.py
  4. PlottingDataMonitor.py

Each of these files contains the corresponding class from telemetry.py.

I copied and pasted the import statements from telemetry.py into each of the new files since I'm not sure which ones are necessary for the operation of each.

Then in PlottingDataMonitor.py I imported the other three new .py files with syntax below:

from Battery import Battery
from Motor import Motor
from MPPT import MPPT

Apparently if I use the form from UserDict1 import UserDict2 the attribute UserDict1 is directly imported into PlottingDataMonitor's local namespace and referencing its module object UserDict2 in the program is not necessary.

Questions: