Scan-o-Matic / scanomatic-standalone

GNU General Public License v3.0
0 stars 0 forks source link

Simpler power manager for modern scanners #161

Open skymandr opened 2 years ago

skymandr commented 2 years ago

📋 Info

The V800 and V850 scanners can be kept alive and unlit directly, without an external power switch. This would be more convenient for most purposes. Unfortunately this isn't the case for V700, so if we add this, we still have to keep support for the current way as well.

🏁 DoD

joakimmoller commented 2 years ago

Port is the physical port number on the usb hub, there might be several usb hubs separated by bus number:

pi@raspberrypi:~ $ scanimage -L
device `epson2:libusb:001:007' is a Epson GT-X980 flatbed scanner
device `epson2:libusb:001:006' is a Epson GT-X980 flatbed scanner

Bus 1 has two devices 6 and 7.

pi@raspberrypi:~ $ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
        |__ Port 2: Dev 7, If 0, Class=Vendor Specific Class, Driver=, 480M
        |__ Port 5: Dev 6, If 0, Class=Vendor Specific Class, Driver=, 480M

Device 7 is connected to port 2, device 6 is connected to port 5. The Device number changes after a scanner restarts or is unplugged and plugged in again or after rebooting the host. As long as it is connected to the physical port i keeps the port number.

The scanner turns itself off after 2 hours. But can be kept alive by sending a message to it like scanimage -n -d epson2:libusb:001:007 now and then. In reality this is not needed if scans are made every ~20min.

This means there is no need for keeping the scanner alive forever, just during the time it is active doing a sequence of scans. The user turns on the scanner before each experiment and tells the scanner manager to allocate them for data collection, to execute scans. When the scanning sequence is finished it can be turned off (or the scanner will turn off itself)

local-minimum commented 2 years ago

Sounds good, but we need to validate that the colors/transparency doesn't drift over the scope of scanning every 20 minutes for 3 - 5 days

skymandr commented 2 years ago

Sounds good, but we need to validate that the colors/transparency doesn't drift over the scope of scanning every 20 minutes for 3 - 5 days

Sure, but a couple of points:

It might be nice to not have to turn them on and off again at regular intervals, but that is not necessarily the proposal here. I think we need to clarify the aim.

local-minimum commented 2 years ago

Sure, but a couple of points:

* In your comment you specify 3–5 days of testing, but the DoD specifies weeks. Which is it? That being said...

Original plan was to keep scanner on permanently then it would be needed to watch behavior over weeks. New is to allow them downtime between experiments. @joakimmoller new scheme we only need to see there's no negative effects during the scope of experiments, and they are typically 20min scan 3 days but sometimes longer and we should assure it with some margin so 5 days is probably good.

Ideally we should repeat that experiment a couple of times with some minutes of downtime in-between. But the primary investigation into the effects hopefully gives us enough confidence.

* ... in @joakimmoller's comment, he suggests that the scanner be kept alive _only_ for the duration of the experiment, so...

* ... in what way is this scenario different from using the USB power hub?

The power hub (USB or LAN connected) turns off the power to the scanners between scans. It's not an USB hub it is a power hub with toggles for the sockets connected via LAN (old versions via USB)

It might be nice to not have to turn them on and off again at regular intervals, but that is not necessarily the proposal here. I think we need to clarify the aim.

It the aim is to actually let them be on more or less permanently then we are back to needing weeks of images to investigate.

Further, the scanner should be placed in a controlled light environment that doesn't fluctuate over the experiment, preferably in darkness (e.g. in a cardboard box) to not introduce variations to the images that way (which we know can happen from our first setup at GU).

skymandr commented 2 years ago

All good. I feel that maybe long term usability verification is beyond the scope for what we can/should do, however. Might be cheaper to put a phd-student on that... ;)

local-minimum commented 2 years ago

Given they know enough about images to be able to do analysis of hundreds of images to see if shifts occur, then I agree.

dodslaser commented 11 months ago

I'm a PhD student currently maintaining the OG SoM set-up at GU. I would be happy to assist in anything that will simplify our current setup. Currently, we have 15 scanners (V800 and V850) divided between 5 computers (3 each) with one PM each.

Ideally, I want 3 computers with 5 scanners per instance, to match what the cabinets can fit. I can get a new PM that can manage 5 outlets and make a new class for it, but if removing the need for PMs is an option, I think we would prefer that to reduce the complexity.

Re: identifying scanners between power-cycles. Why not just use the serial number? You can poll it over USB, and (at least together with the VID/PID) it is guaranteed by the manufacturer to be unique. When a scanner connects, it is checked against a list of known (VID/PID+)SNs. If no match is found, the user is asked to assign it an identifier (or one is automatically assigned).

local-minimum commented 11 months ago

@dodslaser if the scanners now actually have a public serial number that would be great! Previous version of the scanners didn't actually publish their serial numbers though the documentation hinted that there existed one.

dodslaser commented 11 months ago

@dodslaser if the scanners now actually have a public serial number that would be great! Previous version of the scanners didn't actually publish their serial numbers though the documentation hinted that there existed one.

Ah, I see. I can test on our V800 and V850, but I guess deprecating old/EOL hardware is not an option either way?

For reference, this SHOULD work:

import usb

scanners = {
    dev: usb.util.get_string(dev, dev.iSerialNumber)
    for pid in [0x012c, 0x0151]
    for dev in usb.core.find(
        find_all=True,
        idVendor=0x04b8,
        idProduct=pid,
    )
}

print(scanners)
local-minimum commented 11 months ago

That looks very nice (though I've never fully gotten my head around multiple fors in those types of expressions).

It's been a long while since I worked on the code, but I would guess making a new simplified version of the scanner_manager: https://github.com/Scan-o-Matic/scanomatic-standalone/blob/main/scanomatic/io/scanner_manager.py

And then having configuration for which one to use would be the way to go.