Ejemplo n.º 1
0
    def update(self):
        super(MyGUI, self).update()
        if self.ser.is_open:
            in_str = self.ser.readline().decode('utf-8').strip()
            if in_str:
                in_value = float(in_str)
                display_string = "{0:.3f}".format(
                    in_value + self.doubleSpinBox_offset.value())
                self.lcdNumber.display(display_string)

                cbsdk_conn = CbSdkConnection()
                if cbsdk_conn.is_connected and (display_string !=
                                                self.display_string):
                    cbsdk_conn.set_comments("DTT:" + display_string)
                    self.display_string = display_string
                else:
                    self.pushButton_send.setText("Send")
Ejemplo n.º 2
0
 def on_button(self, modality, region):
     import json
     from cerebuswrapper import CbSdkConnection
     if modality == 'Other':
         other_text = self.lineEdit_Other.text()
         if len(other_text) > 0:
             modality = other_text
     comment_dict = {
         'Side': 'L' if self.radioButton_L.isChecked() else 'R',
         'Region': region,
         'Modality': modality
     }
     conn = CbSdkConnection()
     if conn.is_connected:
         comment_string = json.dumps(comment_dict, sort_keys=True)
         conn.set_comments(comment_string)
         self.statusBar().showMessage("Sent: " + comment_string)
Ejemplo n.º 3
0
    def update(self):
        # Added new_value handling for playback if we ever want to post-process depth
        # on previously recorded sessions.
        new_value = False
        out_value = None

        if self.comboBox_com_port.currentText() == "cbsdk playback":
            cbsdk_conn = CbSdkConnection()
            if cbsdk_conn.is_connected:
                comments = cbsdk_conn.get_comments()
                if comments:
                    comment_strings = [x[1].decode('utf8') for x in comments]
                else:
                    comment_strings = ""
                dtts = []
                for comm_str in comment_strings:
                    if 'DTT:' in comm_str:
                        dtts.append(float(comm_str[4:]))
                if len(dtts) > 0:
                    out_value = dtts[-1]
                    new_value = True
                    self.offset_ddu.display("{0:.3f}".format(out_value))
                    offset = self.doubleSpinBox_offset.value()
                    self.raw_ddu.display("{0:.3f}".format(out_value - offset))

        elif self.ser.is_open:
            in_str = self.ser.readline().decode('utf-8').strip()
            if in_str:
                try:
                    in_value = float(in_str)
                    # in_value /= DDUSCALEFACTOR  # Uncomment this for FHC DDU V2.

                    self.raw_ddu.display("{0:.3f}".format(in_value))

                    out_value = in_value + self.doubleSpinBox_offset.value()
                    display_string = "{0:.3f}".format(out_value)
                    self.offset_ddu.display(display_string)

                    # Check if new value
                    if display_string != self.display_string:
                        new_value = True
                        self.display_string = display_string

                    # Push to NSP
                    cbsdk_conn = CbSdkConnection()
                    if cbsdk_conn.is_connected:
                        if self.chk_NSP.isChecked() and self.chk_NSP.isEnabled(
                        ) and new_value:
                            cbsdk_conn.set_comments("DTT:" + display_string)
                    else:
                        # try connecting if not connected but button is active
                        if self.chk_NSP.isChecked() and self.chk_NSP.isEnabled(
                        ):
                            cbsdk_conn.connect()
                            cbsdk_conn.cbsdk_config = {
                                'reset': True,
                                'get_events': False,
                                'get_comments': False
                            }
                        # set button to connection status
                        self.chk_NSP.setChecked(cbsdk_conn.is_connected)

                except ValueError:
                    print("DDU result: {}".format(in_str))

        # Push to LSL
        if self.depth_stream is not None and new_value:
            self.depth_stream.push_sample([out_value])