Exemplo n.º 1
0
    def start(self):
        if(not self.processing):
            if(self.ready):
                if(self.lineEdit.text() != ""):
                    self.pushButton.setEnabled(False)
                    self.slider.setVisible(False)
                    self.sliderR.setVisible(False)
                    self.label_sin.setVisible(False)
                    self.label_img.setVisible(False)
                    self.rmse.setVisible(False)
                    self.sinogram_image.setText("Miejsce na sinogram")
                    self.out_image.setText("Miejsce na obraz wyjściowy")

                    filter = self.checkBox.isChecked()
                    step = float(self.lineEdit.text())
                    gamma = int(self.lineEdit_3.text())
                    det = int(self.lineEdit_2.text())
                    self.show_process_steps = self.steps.isChecked()

                    self.image_processor = Processor(step=step, alpha=0, gamma=gamma, detectors=det, context=self,flt=filter,show_steps=self.show_process_steps)
                    if(not self.show_process_steps):
                        self.sin_prog.setVisible(True)
                        self.out_prog.setVisible(True)

                    self.processing = True
                    self.get_thread = MyThread(self.current_image,1.0,self)
                    self.get_thread.start()
                else:
                    QMessageBox.warning(self, "Brak parametrów", "Proszę wpisać wszystkie parametry")
            else:
                QMessageBox.warning(self,"Brak obrazu","Proszę wybrać obraz")
Exemplo n.º 2
0
 def test_not(self):
     processor = Processor({
         '/test/not': {
             'type': 'not'
         },
     })
     self.assertEquals(1, processor.process('/test/not', '0'))
     self.assertEquals(0, processor.process('/test/not', '1'))
     self.assertEquals(0, processor.process('/test/not', '-1'))
     self.assertEquals(0, processor.process('/test/not', '5'))
Exemplo n.º 3
0
 def test_boolean(self):
     processor = Processor({
         '/test/boolean': {
             'type': 'boolean'
         },
     })
     self.assertEquals(0, processor.process('/test/boolean', '0'))
     self.assertEquals(1, processor.process('/test/boolean', '1'))
     self.assertEquals(1, processor.process('/test/boolean', '-1'))
     self.assertEquals(1, processor.process('/test/boolean', '5'))
Exemplo n.º 4
0
 def test_round(self):
     processor = Processor({
         '/test/round/1': {
             'type': 'round',
             'parameters': {
                 'decimals': 2
             }
         },
     })
     self.assertEquals(997.54, processor.process('/test/round/1',
                                                 '997.5412'))
Exemplo n.º 5
0
 def test_format(self):
     processor = Processor({
         '/test/format1': {
             'type': 'format',
             'parameters': {
                 'format': 'Current power consumption: {value}W'
             }
         }
     })
     self.assertEquals("Current power consumption: 200W",
                       processor.process('/test/format1', '200'))
Exemplo n.º 6
0
 def test_regexp(self):
     processor = Processor({
         '/test/regexp1': {
             'type': 'regexp',
             'parameters': {
                 'pattern': '(.*): (.*)',
                 'replacement': '\\1|\\2'
             }
         }
     })
     self.assertEquals("username|text",
                       processor.process('/test/regexp1', 'username: text'))
Exemplo n.º 7
0
 def test_unknown(self):
     processor = Processor({
         '/test/linear': {
             'type': 'linear',
             'parameters': {
                 'slope': 2,
                 'offset': 1
             }
         },
     })
     self.assertEquals(21, processor.process('/test/linear', '10'))
     self.assertEquals('0', processor.process('/test/linear/1', '0'))
     self.assertEquals('10', processor.process('/test/linear/2', '10'))
Exemplo n.º 8
0
 def test_enum(self):
     processor = Processor({
         '/test/enum': {
             'type': 'enum',
             'parameters': {
                 0: 'off',
                 1: 'on'
             }
         },
     })
     self.assertEquals('on', processor.process('/test/enum', '1'))
     self.assertEquals('off', processor.process('/test/enum', '0'))
     self.assertEquals('on', processor.process('/test/enum', '3'))
Exemplo n.º 9
0
 def test_step(self):
     processor = Processor({
         '/test/step': {
             'type': 'step',
             'parameters': {
                 2: 1,
                 4: 2,
                 5: 3
             }
         },
     })
     self.assertEquals(1, processor.process('/test/step', '0'))
     self.assertEquals(1, processor.process('/test/step', '2'))
     self.assertEquals(2, processor.process('/test/step', '3'))
     self.assertEquals(3, processor.process('/test/step', '10'))
Exemplo n.º 10
0
 def test_chained(self):
     processor = Processor({
         '/test/chained': [
             {
                 'type': 'linear',
                 'parameters': {
                     'slope': 0.5,
                     'offset': 1
                 }
             },
             {
                 'type': 'round',
                 'parameters': {
                     'decimals': 0
                 }
             },
         ],
     })
     self.assertEquals(7, processor.process('/test/chained', '11'))
Exemplo n.º 11
0
 def test_linear(self):
     processor = Processor({
         '/test/linear/1': {
             'type': 'linear',
             'parameters': {
                 'slope': 2,
                 'offset': 1
             }
         },
         '/test/linear/2': {
             'type': 'linear',
             'parameters': {
                 'slope': 0,
                 'offset': 1
             }
         },
         '/test/linear/3': {
             'type': 'linear',
             'parameters': {
                 'slope': -1,
                 'offset': 0
             }
         },
         '/test/linear/4': {
             'type': 'linear',
             'parameters': {
                 'slope': .01,
                 'offset': 0
             }
         },
     })
     self.assertEquals(21, processor.process('/test/linear/1', '10'))
     self.assertEquals(1, processor.process('/test/linear/1', '0'))
     self.assertEquals(1, processor.process('/test/linear/2', '10'))
     self.assertEquals(1, processor.process('/test/linear/2', '4'))
     self.assertEquals(0, processor.process('/test/linear/3', '0'))
     self.assertEquals(-6, processor.process('/test/linear/3', '6'))
     self.assertEquals(997.5412,
                       processor.process('/test/linear/4', '99754.12'))
Exemplo n.º 12
0
    try:
        serial = Serial(
            config.get('radio', 'port', '/dev/ttyUSB0'),
            config.get('radio', 'baudrate', 9600)
        )
    except SerialException as e:
        sys.exit(e)

    xbee = XBeeWrapper()
    xbee.serial = serial
    xbee.default_port_name = config.get('radio', 'default_port_name', 'serial')
    xbee.sample_rate = config.get('general', 'sample_rate', 0)
    xbee.change_detection = config.get('general', 'change_detection', False)

    processor = Processor(config.get('processor', 'filters', []))

    xbee2mqtt = Xbee2MQTT(resolve_path(config.get('daemon', 'pidfile', '/tmp/xbee2mqtt.pid')))
    xbee2mqtt.stdout = resolve_path(config.get('daemon', 'stdout', '/dev/null'))
    xbee2mqtt.stderr = resolve_path(config.get('daemon', 'stderr', xbee2mqtt.stdout))
    xbee2mqtt.discovery_on_connect = config.get('general', 'discovery_on_connect', True)
    xbee2mqtt.duplicate_check_window = config.get('general', 'duplicate_check_window', 5)
    xbee2mqtt.default_output_topic_pattern = config.get(
        'general', 'default_output_topic_pattern', '/raw/xbee/{address}/{port}'
    )
    xbee2mqtt.default_topic_pattern = config.get(
        'general', 'default_topic_pattern', xbee2mqtt.default_output_topic_pattern
    )
    xbee2mqtt.default_input_topic_pattern = config.get(
        'general', 'default_input_topic_pattern', xbee2mqtt.default_topic_pattern + '/set'
    )