motor plot almost done, trying to add title, didn't work
This commit is contained in:
@ -36,7 +36,7 @@ class BECAdapter:
|
||||
if self.monitor:
|
||||
self.grum_client_monitor.new_plot( "monitor",{'xlabel':'time', 'ylabel':"sls_ring_current", "time": True, "frmt":"Line" })
|
||||
if self.motor_pos:
|
||||
# self.grum_client_motor_pos_static.new_plot("Motor position static", {'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp" })
|
||||
self.grum_client_motor_pos_static.new_plot("Motor position static", {'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp" , "frmt": "Dots"})
|
||||
self.grum_client_motor_pos_moving.new_plot("Motor position move", {'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp" , 'frmt':"Motor pos move"})
|
||||
|
||||
def start(self):
|
||||
@ -56,16 +56,18 @@ class BECAdapter:
|
||||
# whenever a new scan starts or ends, for now changes scan nr both in start and end
|
||||
segment = BECMessage.ScanStatusMessage.loads(segment.value)
|
||||
if segment.content["status"] == "open":
|
||||
self.grum_client_motor_pos_moving.new_plot("Motor position move", {'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp" })
|
||||
self.scan_nr = segment.content["info"]["scan_number"]
|
||||
self.positions = segment.content["info"]["positions"]
|
||||
self.grum_client_motor_pos_moving.new_plot("Motor position move", {"title":"scan number:" + str(self.scan_nr),'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp" })
|
||||
xpos = [x for x,y in self.positions]
|
||||
ypos = [y for x,y in self.positions]
|
||||
if len(segment.content["info"]["primary"]) == 2:
|
||||
self.scan_running = True
|
||||
if self.motor_pos:
|
||||
print("new plot")
|
||||
self.grum_client_motor_pos_static.new_plot( "Motor position static", {"xs": xpos, "ys":ypos, 'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp", "frmt": "Dots"})
|
||||
# for point in self.positions
|
||||
# self.grum_client_motor_pos_static.append_data("Motor position static", self.positions)
|
||||
self.grum_client_motor_pos_static.new_plot( "Motor position static", { "xs": xpos, "ys":ypos, 'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp", "frmt": "Dots"})
|
||||
#Trying to update plots with "open new plots" unticked
|
||||
# self.grum_client_motor_pos_static.new_plot( "Motor position static", {"xs": xpos[:-1], "ys":ypos[:-1], 'xlabel':'average_x_st_fzp', 'ylabel':"average_y_st_fzp", "frmt": "Dots"})
|
||||
# self.grum_client_motor_pos_static.append_data( "Motor position static", [xpos[-1], ypos[-1]] )
|
||||
@ -91,7 +93,7 @@ class BECAdapter:
|
||||
|
||||
point = [x_val, y_val]
|
||||
if self.motor_pos:
|
||||
self.grum_client_motor_pos_moving.append_data( "Motor position move", point)
|
||||
self.grum_client_motor_pos_moving.append_data("Motor position move", point)
|
||||
|
||||
def start_monitor_sub(self):
|
||||
self._monitor_sub = self.redis_connector.consumer(
|
||||
@ -182,6 +184,6 @@ if __name__ == "__main__":
|
||||
print("initializing redis-connector")
|
||||
redis_url = "129.129.122.75:6379" # for LamNI
|
||||
redis_connector = RedisConnector(redis_url)
|
||||
ba = BECAdapter(redis_connector, recon=True, motor_pos=True, monitor=True)# monitor = True)
|
||||
ba = BECAdapter(redis_connector, recon=True) #, motor_pos=True) #, monitor=True)
|
||||
ba.start()
|
||||
ba.plot_img_from_h5()
|
||||
|
@ -116,7 +116,46 @@ class MainWindow(QMainWindow):
|
||||
if not self.mdi.findSubWindow(name):
|
||||
self.sig_make_new_plot.emit(name, desc)
|
||||
|
||||
def append_data(self, name, point):
|
||||
# else:
|
||||
# print("else")
|
||||
# if desc.title:
|
||||
|
||||
# print("---------------------------------------------")
|
||||
# print("self mdi exist, new title:", desc.title)
|
||||
# sub = self.mdi.findSubWindow(name)
|
||||
# print(sub.pw.plotItem.titleLabel)
|
||||
# print(sub.pw.plotItem.titleLabel.text)
|
||||
# vbox = sub.pw.getViewBox()
|
||||
# vbox.removeItem(sub.pw.plotItem.titleLabel)
|
||||
# #maybe add title? or just settitle?
|
||||
# vbox.addItem(pg.LabelItem(desc.title, size='50pt'))
|
||||
# # sub.pw.plotItem.titleLabel.setText(desc.title)
|
||||
# print("------------------------------------")
|
||||
|
||||
# print("clearing")
|
||||
# if desc.title:
|
||||
# sub.pw.clear()
|
||||
# print("setting new title: ", desc.title)
|
||||
# sub.pw.setTitle(desc.title)
|
||||
# vbox = sub.pw.getView()
|
||||
# vbox.addItem(pg.LabelItem(desc.title, size='50pt'))
|
||||
# vbox.addItem(pg.titel)
|
||||
|
||||
# allchildren = vbox.allChildren()
|
||||
# for child in allchildren:
|
||||
# print(child)
|
||||
# if isinstance(child, pg.graphicsItems.ViewBox.ChildGroup):
|
||||
# print("Found childGroup")
|
||||
# allgrandchildren = vbox.allChildren(child)
|
||||
# for grandchild in allgrandchildren:
|
||||
# print(grandchild)
|
||||
# # print("Removing label")
|
||||
# # vbox.removeItem(child)
|
||||
# print("-------------done-------------")
|
||||
# vbox.addItem(pg.LabelItem(desc.title, size='50pt'))
|
||||
# sub.pw.setTitle(desc.title)
|
||||
|
||||
def append_data(self, name, point): #, title=None):
|
||||
"""
|
||||
Append a new data point <point> to the (existing) plot <name>.
|
||||
The point is forwarded to the append method of PlotDescription.
|
||||
@ -124,6 +163,8 @@ class MainWindow(QMainWindow):
|
||||
item = self.lst.get(name)
|
||||
desc = item.value
|
||||
desc.append(point)
|
||||
# if title:
|
||||
# desc.changeTitle(title)
|
||||
self.sync_item_and_plots(item)
|
||||
|
||||
def extend_data(self, name, data):
|
||||
@ -161,7 +202,6 @@ class MainWindow(QMainWindow):
|
||||
allchildren = vbox.allChildren()
|
||||
for child in allchildren:
|
||||
if isinstance(child, pg.LabelItem):
|
||||
# print("Removing label")
|
||||
vbox.removeItem(child)
|
||||
vbox.addItem(pg.LabelItem(desc.xlabel, size='50pt'))
|
||||
|
||||
|
@ -27,6 +27,9 @@ class PlotDescription:
|
||||
self.xs.append(x)
|
||||
self.ys.append(y)
|
||||
|
||||
# def changeTitle(self, title):
|
||||
# self.title = title
|
||||
|
||||
def extend(self, data):
|
||||
xs, ys = data
|
||||
self.xs.extend(xs)
|
||||
|
Reference in New Issue
Block a user