32
32
import spectrometer .spmeters as spmeters
33
33
34
34
from spectrometer .spmeter_base import SpectraDAQ
35
- from widgets .widgets import ConnectionWidget , DaqWidget
35
+ from widgets .widgets import ConnectionWidget , DaqWidget , ConsoleWidget
36
36
37
37
from transport import api , api_param
38
38
from devices .devices import DeviceConn_MasterSlave , DevicesMap , Device , Channel , ChannelWindow , BoardsManager , BoardWindow
@@ -137,6 +137,7 @@ def setupUI(self): #sets up UI in main window
137
137
self .oscope_widget = oscope .OscilloscopeW ()
138
138
self .m_specWidget = spmeters .ChanSpectrometer ()
139
139
self .m_sumSpectrometer = spmeters .SumSpectrometer ()
140
+ self .console_widget = ConsoleWidget ()
140
141
141
142
toolbar = QToolBar ("Main toolbar" )
142
143
self .addToolBar (toolbar )
@@ -148,6 +149,8 @@ def setupUI(self): #sets up UI in main window
148
149
tabs_lyout .addTab (self .oscope_widget , "Oscilloscope" )
149
150
tabs_lyout .addTab (self .m_specWidget , "Spectrometer" )
150
151
tabs_lyout .addTab (self .m_sumSpectrometer , "SMeter (SUM)" )
152
+ tabs_lyout .addTab (self .console_widget , "SCPI console" )
153
+
151
154
152
155
hlayout .addWidget (tabs_lyout )
153
156
centerwidget = QWidget ()
@@ -161,39 +164,44 @@ def connectDevice(self, window): #sets connection configuration and connect to
161
164
self .settings ["ip" ] = window .lne_ip_edit .text ()
162
165
self .transport_param ["ip" ] = self .settings ["ip" ]
163
166
self .transport_param ["port" ] = self .settings ["port" ]
164
- self .board .connect (self .settings )
165
- self .board .transport .client .timeout = 20000 #large timeout for SCPI commands
167
+ try :
168
+ self .board .connect (self .settings )
169
+ self .board .transport .client .timeout = 20000 #large timeout for SCPI commands
170
+ #get uptime and connection status
171
+ uptime_seconds = self .board .transport .transaction ([api_param .SCPI_GET_UPTIME ], True )[1 ]
172
+ except :
173
+ print ("Cannot establish connection to device!" )
174
+ else :
175
+ window .setValuesAfterConnection (uptime_seconds , self .board .check_connect ()) #update data in connection widget
166
176
167
- #get uptime and connection status
168
- uptime_seconds = self .board .transport .transaction ([api_param .SCPI_GET_UPTIME ], True )[1 ]
169
- window .setValuesAfterConnection (uptime_seconds , self .board .check_connect ()) #update data in connection widget
177
+ #if device was not connected previously, add it to the devices table,
178
+ #otherwise update information in devices table
179
+ if not self .settings ["ip" ] in self .devicesMap :
180
+ self .cwidget .setupData_onConnected (self .board .check_connect (), uptime_seconds , self .devicesMap , False )
181
+ else :
182
+ self .cwidget .setupData_onConnected (self .board .check_connect (), uptime_seconds , self .devicesMap , True )
170
183
171
- #if device was not connected previously, add it to the devices table,
172
- #otherwise update information in devices table
173
- if not self .settings ["ip" ] in self .devicesMap :
174
- self .cwidget .setupData_onConnected (self .board .check_connect (), uptime_seconds , self .devicesMap , False )
175
- else :
176
- self .cwidget .setupData_onConnected (self .board .check_connect (), uptime_seconds , self .devicesMap , True )
177
-
178
- isConnected = self .board .check_connect ()
179
- print ("Connection:" , isConnected )
180
-
181
- if window .isTableDevices and isConnected : #if current connection manager is with TableDevices and device is connected
182
- #fill table with connected devices
183
- #assign board in devices table to currently connected device
184
- device = self .devicesMap [self .settings ["ip" ]]
185
- if device .board == None :
186
- device .board = self .board
187
- device .board .transport .client .write ('sp:channels?' )
188
- numChannels = int (device .board .transport .client .read_raw ().decode ('utf-8' ).rstrip ())
189
- device .nChannels = numChannels
190
- device .channels = [None ] * numChannels
191
-
192
- self .buildBoardTab (device ) #create tab widget with channels for board
193
-
194
- for deviceIP in self .devicesMap :
195
- self .devicesMap [deviceIP ].board .transport .client .write ('*IDN?' )
196
- print ("{0}: {1}" .format (deviceIP , self .devicesMap [deviceIP ].board .transport .client .read_raw ().decode ('utf-8' ).rstrip ()))
184
+ isConnected = self .board .check_connect ()
185
+ print ("Connection:" , isConnected )
186
+
187
+ if window .isTableDevices and isConnected : #if current connection manager is with TableDevices and device is connected
188
+ #fill table with connected devices
189
+ #assign board in devices table to currently connected device
190
+ device = self .devicesMap [self .settings ["ip" ]]
191
+ if device .board == None :
192
+ device .board = self .board
193
+ device .board .transport .client .write ('sp:channels?' )
194
+ numChannels = int (device .board .transport .client .read_raw ().decode ('utf-8' ).rstrip ())
195
+ device .nChannels = numChannels
196
+ device .channels = [None ] * numChannels
197
+
198
+ self .buildBoardTab (device ) #create tab widget with channels for board
199
+
200
+ self .console_widget .lbl_deviceIP .setText (self .settings ["ip" ]) #update device IP in console tab
201
+
202
+ for deviceIP in self .devicesMap :
203
+ self .devicesMap [deviceIP ].board .transport .client .write ('*IDN?' )
204
+ print ("{0}: {1}" .format (deviceIP , self .devicesMap [deviceIP ].board .transport .client .read_raw ().decode ('utf-8' ).rstrip ()))
197
205
198
206
def removeDevice (self , window ): #removes device from table
199
207
for i in range (self .boards_mgr .count ()):
0 commit comments