def test(self): current_path = os.getcwd() bitstreams_path = os.path.join(current_path, 'bitstreams') host = os.getenv('HOST', '192.168.1.100') client = KClient(host) assert client.is_connected ssh = ZynqSSH(host, 'koheron') ssh.load_pl(os.path.join(bitstreams_path, 'oscillo.bit')) driver = Oscillo(client, current_mode='pwm') current = 30 #mA driver.set_laser_current(current) driver.start_laser() assert driver.get_laser_power() > 400
def connect(self): if not self.is_connected: self.client = KClient(self.host) self.connection_info.setText('Connecting to ' + self.host + ' ...') if self.client.is_connected: self.connection_info.setText('Connected to ' + self.host) self.is_connected = True self.connect_button.setStyleSheet('QPushButton {color: red;}') self.connect_button.setText('Disconnect') self.parent.connected() self.ssh = ZynqSSH(self.host, 'koheron') else: self.connection_info.setText('Failed to connect to ' + self.host) else: if hasattr(self, 'client'): self.client.__del__() self.connection_info.setText('Disconnected') self.parent.disconnected() self.connect_button.setStyleSheet('QPushButton {color: green;}') self.connect_button.setText('Connect') self.is_connected = False
def connect(self): if not self.is_connected: self.client = KClient(self.host) self.connection_info.setText('Connecting to '+self.host+' ...') if self.client.is_connected: self.connection_info.setText('Connected to '+self.host) self.is_connected = True self.connect_button.setStyleSheet('QPushButton {color: red;}') self.connect_button.setText('Disconnect') self.parent.connected() self.ssh = ZynqSSH(self.host, 'koheron') else: self.connection_info.setText('Failed to connect to '+self.host) else: if hasattr(self,'client'): self.client.__del__() self.connection_info.setText('Disconnected') self.parent.disconnected() self.connect_button.setStyleSheet('QPushButton {color: green;}') self.connect_button.setText('Connect') self.is_connected = False
class ConnectWidget(QtGui.QWidget): def __init__(self, parent, ip_path=None): super(ConnectWidget, self).__init__() self.parent = parent self.ip_path = ip_path self.host = '' self.is_connected = False self.lay = QtGui.QVBoxLayout() self.lay_connectButton = QtGui.QHBoxLayout() self.lay_connectionInfo = QtGui.QHBoxLayout() self.line = [] for i in range(4): self.line.append(QtGui.QLineEdit()) self.line[i].setFixedWidth(40) self.line[i].setAlignment(QtCore.Qt.AlignCenter) self.point = [] for i in range(3): self.point.append(QtGui.QLabel('.')) for i in range(3): self.lay_connectButton.addWidget(self.line[i]) self.lay_connectButton.addWidget(self.point[i]) self.lay_connectButton.addWidget(self.line[3]) self.connect_button = QtGui.QPushButton() self.connect_button.setStyleSheet('QPushButton {color: green;}') self.connect_button.setText('Connect') self.connect_button.setFixedWidth(80) self.lay_connectButton.addWidget(self.connect_button) self.lay.addLayout(self.lay_connectButton) self.connection_info = QtGui.QLabel('') self.lay_connectionInfo.addWidget(self.connection_info) self.lay.addLayout(self.lay_connectionInfo) self.setLayout(self.lay) if not os.path.exists(self.ip_path): os.makedirs(self.ip_path) if os.path.exists(self.ip_path): try: with open(os.path.join(self.ip_path, 'ip_address' + '.json')) as fp: json_data = fp.read() parameters = json.loads(json_data) IP = parameters['TCP_IP'] except: IP = ['192','168','1','1'] for i in range(4): self.line[i].setText(str(IP[i])) for i in range(3): self.host += self.line[i].text() + '.' self.host += self.line[3].text() self.host = str(self.host) self.line[0].textChanged.connect(lambda: self.ip_changed(0)) self.line[1].textChanged.connect(lambda: self.ip_changed(1)) self.line[2].textChanged.connect(lambda: self.ip_changed(2)) self.line[3].textChanged.connect(lambda: self.ip_changed(3)) self.connect_button.clicked.connect(self.connect) def ip_changed(self, index): self.host = '' IP = [] for i in range(3): self.host += self.line[i].text() + '.' self.host += self.line[3].text() self.host = str(self.host) for i in range(4): IP.append(str(self.line[i].text())) parameters = {} parameters['TCP_IP'] = IP if not os.path.exists(self.ip_path): os.makedirs(self.ip_path) with open(os.path.join(self.ip_path, 'ip_address' + '.json'), 'w') as fp: json.dump(parameters, fp) if self.line[index].cursorPosition() == 3 and index < 3 : self.line[index+1].setFocus() self.line[index+1].selectAll() def connect(self): if not self.is_connected: self.client = KClient(self.host) self.connection_info.setText('Connecting to '+self.host+' ...') if self.client.is_connected: self.connection_info.setText('Connected to '+self.host) self.is_connected = True self.connect_button.setStyleSheet('QPushButton {color: red;}') self.connect_button.setText('Disconnect') self.parent.connected() self.ssh = ZynqSSH(self.host, 'koheron') else: self.connection_info.setText('Failed to connect to '+self.host) else: if hasattr(self,'client'): self.client.__del__() self.connection_info.setText('Disconnected') self.parent.disconnected() self.connect_button.setStyleSheet('QPushButton {color: green;}') self.connect_button.setText('Connect') self.is_connected = False
class ConnectWidget(QtGui.QWidget): def __init__(self, parent, ip_path=None): super(ConnectWidget, self).__init__() self.parent = parent self.ip_path = ip_path self.host = '' self.is_connected = False self.lay = QtGui.QVBoxLayout() self.lay_connectButton = QtGui.QHBoxLayout() self.lay_connectionInfo = QtGui.QHBoxLayout() self.line = [] for i in range(4): self.line.append(QtGui.QLineEdit()) self.line[i].setFixedWidth(40) self.line[i].setAlignment(QtCore.Qt.AlignCenter) self.point = [] for i in range(3): self.point.append(QtGui.QLabel('.')) for i in range(3): self.lay_connectButton.addWidget(self.line[i]) self.lay_connectButton.addWidget(self.point[i]) self.lay_connectButton.addWidget(self.line[3]) self.connect_button = QtGui.QPushButton() self.connect_button.setStyleSheet('QPushButton {color: green;}') self.connect_button.setText('Connect') self.connect_button.setFixedWidth(80) self.lay_connectButton.addWidget(self.connect_button) self.lay.addLayout(self.lay_connectButton) self.connection_info = QtGui.QLabel('') self.lay_connectionInfo.addWidget(self.connection_info) self.lay.addLayout(self.lay_connectionInfo) self.setLayout(self.lay) if not os.path.exists(self.ip_path): os.makedirs(self.ip_path) if os.path.exists(self.ip_path): try: with open(os.path.join(self.ip_path, 'ip_address' + '.json')) as fp: json_data = fp.read() parameters = json.loads(json_data) IP = parameters['TCP_IP'] except: IP = ['192', '168', '1', '1'] for i in range(4): self.line[i].setText(str(IP[i])) for i in range(3): self.host += self.line[i].text() + '.' self.host += self.line[3].text() self.host = str(self.host) self.line[0].textChanged.connect(lambda: self.ip_changed(0)) self.line[1].textChanged.connect(lambda: self.ip_changed(1)) self.line[2].textChanged.connect(lambda: self.ip_changed(2)) self.line[3].textChanged.connect(lambda: self.ip_changed(3)) self.connect_button.clicked.connect(self.connect) def ip_changed(self, index): self.host = '' IP = [] for i in range(3): self.host += self.line[i].text() + '.' self.host += self.line[3].text() self.host = str(self.host) for i in range(4): IP.append(str(self.line[i].text())) parameters = {} parameters['TCP_IP'] = IP if not os.path.exists(self.ip_path): os.makedirs(self.ip_path) with open(os.path.join(self.ip_path, 'ip_address' + '.json'), 'w') as fp: json.dump(parameters, fp) if self.line[index].cursorPosition() == 3 and index < 3: self.line[index + 1].setFocus() self.line[index + 1].selectAll() def connect(self): if not self.is_connected: self.client = KClient(self.host) self.connection_info.setText('Connecting to ' + self.host + ' ...') if self.client.is_connected: self.connection_info.setText('Connected to ' + self.host) self.is_connected = True self.connect_button.setStyleSheet('QPushButton {color: red;}') self.connect_button.setText('Disconnect') self.parent.connected() self.ssh = ZynqSSH(self.host, 'koheron') else: self.connection_info.setText('Failed to connect to ' + self.host) else: if hasattr(self, 'client'): self.client.__del__() self.connection_info.setText('Disconnected') self.parent.disconnected() self.connect_button.setStyleSheet('QPushButton {color: green;}') self.connect_button.setText('Connect') self.is_connected = False
import initExample from lase.core import KClient # Driver to use from lase.drivers import Oscillo # Modules to import import numpy as np import matplotlib.pyplot as plt import time # Connect to Lase host = '192.168.1.4' # Lase IP address client = KClient(host) driver = Oscillo(client) # Replace with appropriate driver # Enable laser driver.start_laser() # Set laser current current = 15 #mA driver.set_laser_current(current) # Modulation on DAC amp_mod = 0.2 freq_mod = 1e6 driver.dac[1,:] = amp_mod*np.sin(2*np.pi*freq_mod*driver.sampling.t) driver.set_dac()