×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Using PyIndi client with a simple GUI

  • Posts: 10
  • Thank you received: 0
Hi,
I've been having a lot of issues creating a client for multiple devices, a filter wheel and camera. When following the PyIndi client tutorials, I'm not able to change a device property by choice. I'm now trying to control the devices through a simple button GUI to provide an interface to change a set of properties by choice. For example, I have one simple GUI with 2 buttons, one to change the filter wheel to slot 1 and the other to change it to slot 2. Going into this, I thought that it would be as simple as running a basic client in the background and import another client for the filter wheel where I could call the function newProperty through my GUI. This is the code I have for changing the filter slot (bits of it):

#######################################################
class IndiClient(PyIndi.BaseClient):
dwheel = None
def __init__(self):
super(IndiClient, self).__init__()
def newDevice(self, d):
pass #connecting the filter wheel via a basic client
def newProperty(self, p):
if p.getName() == "FILTER_SLOT":
self.nd18()
......
def nd18(self):
slot=self.dwheel.getNumber("FILTER_SLOT")
slot[0].value=1
self.sendNewNumber(slot)

##############################################################3
I imported the IndiClient class from the script to my GUI and am trying to call newProperty, but I hit an issue with the arguments. I don't know how to call the functions ie: newProperty(self, p) because of the "p", property, parameter. I'm not very well versed with Python, so I imagine I'm missing something very obvious, but its doing a dang good job of eluding me. I'm not even sure if just calling the function newProperty or even nd18 would work.

tltr: How do you connect a GUI to a PyIndi client? Can you call one of the PyIndi functions such as newProperty(self, p) and if so, how?
5 years 11 months ago #24928

Please Log in or Create an account to join the conversation.

  • Posts: 314
  • Thank you received: 95
Do you know about other INDI clients?
indilib.org/about/clients.html
You can try my open project Astronomy Linux
5 years 11 months ago #24929

Please Log in or Create an account to join the conversation.

  • Posts: 10
  • Thank you received: 0
I do, but I need a customized client. The other INDI clients have a lot of what I don't need. I'm just looking to make a simple interface.
5 years 11 months ago #24932

Please Log in or Create an account to join the conversation.

  • Posts: 314
  • Thank you received: 95
5 years 11 months ago #24933

Please Log in or Create an account to join the conversation.

  • Posts: 226
  • Thank you received: 88
Hi,
You don't have to call newproperty yourself, the IndiClient runs in its own thread and will call that function for every new property. You just have to define that function.
In your case, if every other aspects are managed from another client, you just need to remember the property and reuse it in your function:
class IndiClient(PyIndi.BaseClient):
    def __init__(self):
        super(IndiClient, self).__init__()
        self.dwheel = None
   def newDevice(self, d):
        pass #connecting the filter wheel via a basic client
   def newProperty(self, p):
        if p.getName() == "FILTER_SLOT":
             self.dwheel = p
    # you shoul define all other virtual functions and I would suggest also
    def removeProperty(self, p):
        if p.getName() == "FILTER_SLOT":
             self.dwheel = None
 
    def nd18(self):
        if self.dwheel:
            slot=self.dwheel.getNumber("FILTER_SLOT")
            slot[0].value=1
            self.sendNewNumber(slot)
I did not test but here is the idea.As the Indiclient has its own thread, calling indi client from the gui should be ok, but calling the gui from the client (refreshing a value for instance) won't work without some sort of synchronization (queue, or use a Qthread for the indi client if you're in Qt).
Jean-Luc.
The following user(s) said Thank You: Jasem Mutlaq, Aylin
5 years 11 months ago #24942

Please Log in or Create an account to join the conversation.

  • Posts: 10
  • Thank you received: 0
Hi Oleg,

This might be a really silly question, but on the gtkindiclient source (DCD-0.13 device control device) you linked to, I can't figure out where to actually download the module gtkindiclient.
5 years 10 months ago #25698

Please Log in or Create an account to join the conversation.

  • Posts: 314
  • Thank you received: 95

You can run DCD in terminal:
cd dcd
./dcd.py

At first, you have to run the indiserver with driver(-s).
You can try my open project Astronomy Linux
5 years 10 months ago #25710
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 10
  • Thank you received: 0
I don't understand though how I can edit the code for the GUI that dcd.py creates to make it my own. How would I go about doing that?
5 years 10 months ago #25745

Please Log in or Create an account to join the conversation.

  • Posts: 314
  • Thank you received: 95
You can write the letter to its author Dirk Hünniger.
You can try my open project Astronomy Linux
5 years 10 months ago #25747

Please Log in or Create an account to join the conversation.

Time to create page: 0.950 seconds