OpenRoberta / robertalab-ev3dev

roberta lab connector for ev3dev
Apache License 2.0
17 stars 14 forks source link

refactor lab.py to make the server protocol code portable #68

Open ensonic opened 5 years ago

ensonic commented 5 years ago

We'd like to refactor https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/lab.py to not import ev3dev and Hal anymore. Instead when initializing the roberta.lab.Service() we'd like to pass a device module.

The device module will have function such as:

def updateDeviceState():   # set firmware name, update battery status
def notifyConnect():       # eg play a beep, or toggle a led
def notifyDisconnect():
def reset():               # resets actors, sensors
...
sroopsai commented 5 years ago

Should create a communication library(pull out lab.py and refactoring it) somewhat similar to ev3dev library??

ensonic commented 5 years ago

Yes, the idea is to start a new git repository 'openroberta' and extract the code from lab.py. Lab.py contains multiple things (the actual protocol state machine, a dbus service, the code execution sandbox). Ideally those will be split into separate files and will be covered by separate tests. But step by step :)

sroopsai commented 5 years ago

should Hal(Hardware Abstraction Library) also be included in new library ('openroberta') as previously Hal is an import into lab.py but now after refactoring no more imports into the library as mentioned above.

ensonic commented 5 years ago

No, the hal will stay here (robertalab-ev3dev) and there will be a separate hal.py for eg robertalab-raspberrypi. Whenever the current lab.py calls function from hal.py we need an interface instead.

sroopsai commented 5 years ago

OK got it for each separate hardware separate Hal file

ensonic commented 5 years ago

FYI: a 2nd use for the new library could be the naoclient: https://github.com/OpenRoberta/robertalab-naoclient/tree/master/oraclient-choreographe-app/app/scripts

sroopsai commented 5 years ago

@ensonic what do you mean by an interface through which lab.py calls hal.py functions at some instants.

ensonic commented 5 years ago

See my answer in gitter.