Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/TCC/html/fake_axis_ctrl_wdg_8py_source.html
Дата изменения: Tue Sep 15 02:25:37 2015
Дата индексирования: Sun Apr 10 04:20:19 2016
Кодировка:

Поисковые слова: m 17
lsst.tcc: python/tcc/axis/fakeAxisCtrlWdg.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fakeAxisCtrlWdg.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 
3 import Tkinter
4 
5 from twisted.internet import defer
6 import RO.Comm.Generic
7 RO.Comm.Generic.setFramework("twisted")
8 import RO.Wdg
9 
10 from .fakeAxisCtrl import FakeAxisCtrl
11 
12 __all__ = ["FakeAxisCtrlWdg", "FakeAxisCtrlSetWdg"]
13 
14 sampleMSDump ="""time position velocity error edge correction
15  1266860307.600 74.814029 0.241533 0.000954 1 0.000524
16  1266816131.180 59.597493 1.485286 -0.003319 0 0.000000
17  1266816131.330 59.819334 1.485286 -0.000797 1 -0.002057
18  1266839360.530 59.810348 -1.376835 0.006240 0 0.000000
19  1266839360.680 59.590300 -1.376835 0.001925 1 0.004082
20  1266839369.990 44.817815 -1.607564 0.012479 0 0.000000
21  1266839370.120 44.606302 -1.605523 -0.007002 1 0.002738
22  1266860253.490 44.615251 0.252483 -0.014001 0 0.000000
23  1266860254.160 44.825963 0.252483 0.006281 1 -0.003860
24  1266860268.360 59.597959 1.462901 -0.003784 0 0.000000
25  1266860268.510 59.821265 1.462901 -0.002728 1 -0.003256
26  1266860306.680 74.595496 0.336560 0.000096 0 0.000000
27  1266860307.600 74.814029 0.241533 0.000954 1 0.000524"""
28 
29 sampleID = "axis code: 2009-10-16 379M, axis.ini version $Revision: 1.41 $"
30 
31 class FakeAxisCtrlWithWdg(FakeAxisCtrl):
32  """!Variant of FakeAxisCtrl that sets some widgets
33  """
34  def __init__(self, name, port, logReplies, logWdg, cmdPVTWdg, advTimeStatsWdg):
35  """!Construct a FakeAxisCtrlWithWdg
36 
37  @param[in] name name of axis controller
38  @param[in] port port on which to command axis controller
39  @param[in] logReplies log all replies? Set False for less chatter
40  @param[in] logWdg an RO.Wdg.LogWdg in which to log replies
41  @param[in] cmdPVTWdg a RO.Wdg.StrLabel in which to display commanded position, velocity and time
42  @param[in] advTimeStatsWdg a RO.Wdg.StrLabel in which to display advanced time statistics
43  """
44  self.logWdg = logWdg
45  self.cmdPVTWdg = cmdPVTWdg
46  self.advTimeStatsWdg = advTimeStatsWdg
47  FakeAxisCtrl.__init__(self, name=name, port=port, logReplies=logReplies)
48 
49  def logMsg(self, msgStr):
50  self.logWdg.addMsg(msgStr)
51 
52  @FakeAxisCtrl.cmdPVT.setter
53  def cmdPVT(self, pvt):
54  self._cmdPVT = pvt
55  self.cmdPVTWdg.set("%0.3f %0.3f %0.3f" % (self.cmdPVT.pos, self.cmdPVT.vel, self.cmdPVT.t))
56 
57  def addAdvTime(self, advTime):
58  FakeAxisCtrl.addAdvTime(self, advTime)
59  advTimeStatsDict = self.advTimeStats.getStats()
60  self.advTimeStatsWdg.set("min=%(min)0.2f, median=%(median)0.2f stdDev=%(stdDev)0.2f" % advTimeStatsDict)
61 
62 
63 class FakeAxisCtrlWdg(Tkinter.Frame):
64  """!A widget that emulates an axis controller and displays information as a summary and log
65  """
66  def __init__(self, master, name, port, borderwidth=0, logReplies=True):
67  """!Construct a fake axis controller widget
68 
69  @param[in] master master widget
70  @param[in] name name of axis controller
71  @param[in] port port on which to command axis controller
72  @param[in] borderwidth border width of enclosing frame
73  @param[in] logReplies log all replies? Set False for a very slow connection
74  """
75  self.name = name
76  self.logReplies = bool(logReplies)
77  Tkinter.Frame.__init__(self, master, borderwidth=borderwidth)
78 
79  statusFrame = Tkinter.Frame(self)
80  row = 0
81  RO.Wdg.StrLabel(master=statusFrame, text="%s Last PVT" % (self.name,)).grid(row=row, column=0, sticky="e")
82  self.cmdPVTWdg = RO.Wdg.StrLabel(master=statusFrame)
83  self.cmdPVTWdg.grid(row=row, column=1, sticky="w")
84  row += 1
85  RO.Wdg.Button(master=statusFrame, text="Adv Time", callFunc=self.resetAdvTime).grid(row=row, column=0, sticky="e")
86  self.advTimeStatsWdg = RO.Wdg.StrLabel(master=statusFrame)
87  self.advTimeStatsWdg.grid(row=row, column=1, sticky="w")
88  row += 1
89  statusFrame.grid(row=0, column=0, sticky="w")
90 
91  self.logWdg = RO.Wdg.LogWdg(master=self, height=10)
92  self.logWdg.grid(row=1, column=0, sticky="nsew")
93  self.grid_rowconfigure(0, weight=1)
94  self.grid_columnconfigure(0, weight=1)
95 
97  name=name,
98  port=port,
99  logReplies=logReplies,
100  logWdg=self.logWdg,
101  cmdPVTWdg=self.cmdPVTWdg,
102  advTimeStatsWdg=self.advTimeStatsWdg,
103  )
104 
105  def resetAdvTime(self, wdg=None):
106  self.advTimeStats.clear()
107  self.advTimeStatsWdg.set("")
108 
109 
110 class FakeAxisCtrlSetWdg(Tkinter.Frame):
111  def __init__(self, master, namePortList, logReplies=True):
112  """!Create a FakeAxisCtrlSetWdg
113 
114  @param[in] master master widget
115  @param[in] namePortList list of (dev name, port)
116  @param[in] logReplies log all replies? Set False for a very slow connection
117  """
118  Tkinter.Frame.__init__(self, master)
119  rdList = []
120  for axisName, port in namePortList:
121  wdg = FakeAxisCtrlWdg(
122  master=self,
123  name=axisName,
124  port=port,
125  logReplies=logReplies,
126  borderwidth=1,
127  )
128  rdList.append(wdg.fakeAxisCtrl.readyDeferred)
129  wdg.pack(side="top", fill="both", expand=True)
130  self.readyDeferred = defer.gatherResults(rdList, consumeErrors=True)
def __init__
Create a FakeAxisCtrlSetWdg.
def __init__
Construct a FakeAxisCtrlWithWdg.
A widget that emulates an axis controller and displays information as a summary and log...
Variant of FakeAxisCtrl that sets some widgets.
def __init__
Construct a fake axis controller widget.