Notifications
Clear all

Dummy driver for cam and serial connection.  

Page 1 / 2

mario
Posts: 442
Admin
(@mario)
Member
Joined: 2 years ago

@Dangerdad137

Development would be easier if we have a dummy driver for the camera device and the serial connection. Such drivers would allow to run the FabScanPi-Server without the hardware. 

https://github.com/mariolukas/FabScanPi-Server/tree/develop/src/fabscan/scanner/laserscanner/driver

What i have in my mind is:

Dummy cam driver: 

A camera class which is implemented such as the one for the picamera, but it should grab the images from a folder instead of a camera. This folder should keep different plain pictures which i will make with the fabscan hardware. One set during a scan and one set during the settings window is opened.

Serial dummy driver:

The serial driver is quite easy, it should be a the serial driver as it is now but only as a stub/mock which will do nothing expect to confirm that the message was send.

Both dummy drivers should be encapsulated in a way that you can set the driver in the config. There is already something like that for the camera driver, because in an early stage of implementing that i experimented to write a driver for usb cams (parts of this code are still there).

I think that might be an excellent entry point for you and it will help us all and especially the guy who is developing the current frontend version because he does not own a working hardware setup at the moment. I would appreciate that.

By the way we are the only core developers by now 🙂

Reply
7 Replies
Dangerdad137
Posts: 19
(@dangerdad137)
Active Member
Joined: 3 months ago

I'm used to doing this in C# moving entry points to services implementing interfaces so they can be implemented by mocks or by real backends.  Not sure what the typical approach is in python.  Are we moved to python3?  Do I just clone the project and go to town?

Reply
1 Reply
mario
Admin
(@mario)
Joined: 2 years ago

Member
Posts: 442
Posted by: @dangerdad137

I'm used to doing this in C# moving entry points to services implementing interfaces so they can be implemented by mocks or by real backends.  Not sure what the typical approach is in python.  Are we moved to python3?  Do I just clone the project and go to town?

Yes python2 reached EOL in january. You can start from the python3 feature branch. I am doing some final test with this branch. If all things work i will merge it to the dev branch and after the release also to the master.

I know that i was a little bit lazy in the past when i started to use interfaces in python. You are right there should be clear interfaces. I started using interfaces for the main independet classes. https://github.com/mariolukas/FabScanPi-Server/tree/develop/src/fabscan/scanner

My idea was that fabscan should support different scan approaches (laser scanner, photogrammetry, projector based structured light... etc.). Until now only the laser scanning approach works. I had still not the time to implement another scanning approach. Long story short... i introduced the interfaces. 

https://github.com/mariolukas/FabScanPi-Server/tree/develop/src/fabscan/scanner/interfaces

FSCalibration.py - serves the calibration algorithm for the selected approach.

FSHardwareController.py - serves an abstraction layer to the hardware drivers (camera, serial, turntable etc.)

FSImageProcessor.py - should implement a class which does all the heavy calculations based on images.

FSScanProcessor.py - should implement an actor which does the logic part of the scanning approach

(Don't be confused, i know the interfaces are empty classes. I definetly need to add the needed function definitions which are needed)

Python does not support the DI pattern by default. I build an injector class which is used to provide the implementations for the interfaces when the application is booting up. 

https://github.com/mariolukas/FabScanPi-Server/blob/develop/src/fabscan/server/FSScanServer.py#L86

The scanning approach is set in the config file. A factory created the scanner type.

https://github.com/mariolukas/FabScanPi-Server/blob/develop/src/fabscan/scanner/interfaces/__init__.py

I am thinking about refactoring the drivers 

https://github.com/mariolukas/FabScanPi-Server/tree/develop/src/fabscan/scanner/laserscanner/driver

for using them in a similar way within the FSHardwareController.py implementation, where the drivers are created.

 

Reply
Dangerdad137
Posts: 19
(@dangerdad137)
Active Member
Joined: 3 months ago

Yah, it seems like a stub would be more useful than a mock inside of a formal testing framework.  I went ahead and got PyCharm Pro -- the monthly fee is reasonable and using the same tools as yours will likely save more than the $8 / month in frustration.

How do you go about launching the dev code headless?  What's your typical work flow when running the code?

Reply
mario
Posts: 442
Admin
(@mario)
Member
Joined: 2 years ago

I will add a dev setup guide with screenshots to the documentation this evening. (8:00 pm CET). 

Reply
Dangerdad137
Posts: 19
(@dangerdad137)
Active Member
Joined: 3 months ago

I'm happy to help with the doc FYI, if the steps aren't to complex to figure out, I'd be happy to document them as I go.

Reply
Page 1 / 2
Share: