コード例 #1
0
    def handle_set_buttons(self, id):
        print('handle_set_buttons: ', self, id)
        devicename, pvname, pname = id.split('::')

        property = self.device_propvectors[devicename][pvname].properties[
            pname]
        property_type = self.device_propvectors[devicename][pvname].type

        if property_type == PyIndi.INDI_TEXT:
            value = property.value_widget.text()
            print(devicename, pvname, pname, value)
            device = self.indiclient.getDevice(devicename)
            indihelper.setfindTextText(self.indiclient, device, pvname, pname,
                                       value)
#            device = self.indiclient.getDevice(devicename)
#            print(device)
#            indi_propvector = indihelper.getText(device, pvname)
#            print(indi_propvector)
#            indi_text = indihelper.findText(indi_propvector, pname)
#            print(indi_text)
#            indi_text.value = value
#            print(indihelper.dump_ITextVectorProperty(indi_propvector))
#            self.indiclient.sendNewText(indi_propvector)
        elif property_type == PyIndi.INDI_NUMBER:
            value = property.value_widget.value()
            print(devicename, pvname, pname, value)
            device = self.indiclient.getDevice(devicename)
            indihelper.setfindNumberValue(self.indiclient, device, pvname,
                                          pname, value)
#            indi_propvector = indihelper.getNumber(device, pvname)
#            indi_num = indihelper.findNumber(indi_propvector, pname)
#            indi_num.value = value
#            self.indiclient.sendNewNumber(indi_propvector)
        elif property_type == PyIndi.INDI_SWITCH:
            value = property.value_widget.isChecked()
            #print(property.value_widget, devicename, pvname, pname, value)
            device = self.indiclient.getDevice(devicename)
            #            indihelper.setfindSwitchState(self.indiclient, device, pvname, pname, value)
            indi_propvector = indihelper.getSwitch(device, pvname)
            prop = indihelper.findSwitch(indi_propvector, pname)
            prop.s = value

            # depending on rule turn off other buttons
            if indi_propvector.r != PyIndi.ISR_NOFMANY and value:
                for i in range(0, indi_propvector.nsp):
                    s = indi_propvector[i]
                    #print('scanning for buttons to turn off', s.name, pname)
                    if s.name != pname:
                        s.s = PyIndi.ISS_OFF
            self.indiclient.sendNewSwitch(indi_propvector)

            final_indi_propvector = indihelper.getSwitch(device, pvname)

            print(indihelper.dump_ISwitchVectorProperty(final_indi_propvector))
コード例 #2
0
    def stop_exposure(self):
        # had trouble using the setfindSwitchState function for some reason!
        retries = 5
        i = 0
        sw_prop = None
        while i < retries:
            #logging.info('Trying to get CCD_ABORT_EXPOSURE')
            sw_prop = indihelper.getSwitch(self.cam, 'CCD_ABORT_EXPOSURE')
            #logging.info(f'sw_prop = {sw_prop}')
            if sw_prop is not None:
                break
            time.sleep(0.1)
            i += 1
        if sw_prop is None:
            return False

        sw = None
        i = 0
        while i < retries:
            logging.debug('Trying to get ABORT')
            sw = indihelper.findSwitch(sw_prop, 'ABORT')
            logging.debug(f'sw = {sw}')
            if sw is not None:
                break
            time.sleep(0.1)

        if sw is None:
            return False

        sw.s = PyIndi.ISS_ON
        self.backend.indiclient.sendNewSwitch(sw_prop)
        return True