genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
514 stars 88 forks source link

Allow interface node_map before connecting camera #300

Closed Unameded closed 2 years ago

Unameded commented 2 years ago

The interface node map is used to call ForceIP for the device. ForceIP should be possible to call before connecting to the camera, however the interface node map isn't available until after an image acquirer is created. Creating an image acquirer will connect to the camera meaning that ForceIP currently can't be called before connecting.

My fix for this is to move the methods responsible for fetching the node map away from the image acquirer class. From what I have seen there is no reason that they have to be a part of it, and keeping them separated allows for creating the node map, and calling ForceIP before connecting to the device. I modified the methods as little as possible, only removing "self" as an input argument for the methods.

I somewhat arbitrarily moved the methods to the port.py file since it's relevant to them, however they could be moved to wherever it makes the most sense to keep them. It might also be worthwhile to rename some of them if they are going to be more visible to users.

Here is an example of how I can use ForceIP after this change:

from harvesters.core import Harvester from harvesters._private.core.port import _get_port_connected_node_map as get_node_map

h = Harvester() h.add_file('UsedCtiFile.cti') h.update()

node_map = get_node_map(h._interfaces[1].port)

node_map.GevDeviceForceIPAddress.value = new_address node_map.GevDeviceForceIP.execute()

Unameded commented 2 years ago

I have gotten some suggestions on how to improve this. I will leave the PR open so you can see what the basic idea with my request is.

Unameded commented 2 years ago

Closing this PR since better solution to this issue is developed on the branch: "make-node-map-exposed" by @kazunarikudo