|
1 <?xml version='1.0' encoding='utf-8'?> |
|
2 <PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
|
3 <variables> |
|
4 <variable name="Power_ON" type="BOOL"/> |
|
5 <variable name="Power_OFF" type="BOOL"/> |
|
6 <variable name="DrawTest" type="BOOL"/> |
|
7 <variable name="DrawLogo" type="BOOL"/> |
|
8 <variable name="DrawEscher" type="BOOL"/> |
|
9 <variable name="Detect_Circle" type="BOOL"/> |
|
10 <variable name="XaxisPos" type="INT"/> |
|
11 <variable name="YaxisPos" type="INT"/> |
|
12 <variable name="ZaxisPos" type="INT"/> |
|
13 <variable name="TaxisPos" type="INT"/> |
|
14 <variable name="XaxisMinus" type="BOOL"/> |
|
15 <variable name="YaxisMinus" type="BOOL"/> |
|
16 <variable name="ZaxisMinus" type="BOOL"/> |
|
17 <variable name="TaxisMinus" type="BOOL"/> |
|
18 <variable name="XaxisPlus" type="BOOL"/> |
|
19 <variable name="YaxisPlus" type="BOOL"/> |
|
20 <variable name="ZaxisPlus" type="BOOL"/> |
|
21 <variable name="TaxisPlus" type="BOOL"/> |
|
22 </variables> |
|
23 <globals> |
|
24 <xhtml:p><![CDATA[ |
|
25 import ctypes |
|
26 import wx, sys |
|
27 |
|
28 AxisList = ["X","Y","Z","T"] |
|
29 |
|
30 PwrButtons = ['Power_ON', |
|
31 'Power_OFF'] |
|
32 |
|
33 ActionButtons = ['Detect_Circle', |
|
34 'DrawTest', |
|
35 'DrawLogo', |
|
36 'DrawEscher'] |
|
37 |
|
38 class ThreeDee(wx.StaticText): |
|
39 def __init__(self, *args, **kwargs): |
|
40 self.initialized = False |
|
41 kwargs["style"] = wx.ALIGN_CENTRE_HORIZONTAL |
|
42 super(ThreeDee, self).__init__(*args, **kwargs) |
|
43 |
|
44 self.SetFont(wx.Font(24, wx.SWISS, wx.NORMAL, wx.BOLD)) |
|
45 |
|
46 self.positions = [0.]*4 |
|
47 |
|
48 self.Message = None |
|
49 self.NegLimits = None |
|
50 self.Disk = None |
|
51 |
|
52 |
|
53 def UpdatePositions(self, positions): |
|
54 # get globals from PLC |
|
55 self.positions = positions |
|
56 self.SetLabel( |
|
57 ((self.Message +'\n\n') if self.Message else '' )+ |
|
58 " ".join(["%s %+.2f"%(axis,self.positions[i]) |
|
59 for i,axis in enumerate(AxisList)])) |
|
60 |
|
61 def MakeButtonFunc(window, sizer, btname): |
|
62 def ButtonDown(event): |
|
63 setattr(PLCGlobals,btname,1) |
|
64 event.Skip() |
|
65 def ButtonUp(event): |
|
66 setattr(PLCGlobals,btname,0) |
|
67 event.Skip() |
|
68 obj = wx.BitmapButton(window, -1, wx.Bitmap('%s.png'%btname)) |
|
69 sizer.Add(obj, 2, wx.EXPAND, 0) |
|
70 obj.Bind(wx.EVT_LEFT_DOWN, ButtonDown) |
|
71 obj.Bind(wx.EVT_LEFT_UP, ButtonUp) |
|
72 return obj |
|
73 |
|
74 def UpdPos(self): |
|
75 positions = [getattr(PLCGlobals,axname+"axisPos") for axname in AxisList] |
|
76 |
|
77 self.window_1.UpdatePositions(positions) |
|
78 |
|
79 Class_wxglade_hmi.UpdPos = UpdPos |
|
80 |
|
81 |
|
82 #def UpdatePositions(self, event): |
|
83 # |
|
84 # positions = [getattr(PLCGlobals,axname+"axisPos") for axname in AxisList] |
|
85 # |
|
86 # self.window_1.UpdatePositions(positions) |
|
87 # |
|
88 # event.Skip() |
|
89 |
|
90 #Class_wxglade_hmi.UpdatePositions = UpdatePositions |
|
91 |
|
92 initorig = Class_wxglade_hmi.__init__ |
|
93 def Init(self,*args,**kargs): |
|
94 initorig(self,*args,**kargs) |
|
95 sizer = self.GetSizer().GetItem(1).GetSizer().GetItem(0).GetSizer() |
|
96 self.main_buttons = map( |
|
97 lambda btname: MakeButtonFunc(self, sizer, btname), PwrButtons) |
|
98 sizer = self.GetSizer().GetItem(1).GetSizer().GetItem(1).GetSizer() |
|
99 self.main_buttons = map( |
|
100 lambda btname: MakeButtonFunc(self, sizer, btname), ActionButtons) |
|
101 self.axis_buttons = map( |
|
102 lambda axis:( MakeButtonFunc(self, sizer, axis+"axisMinus"), |
|
103 MakeButtonFunc(self, sizer, axis+"axisPlus")), |
|
104 AxisList) |
|
105 # self.timer = wx.Timer(self, -1) |
|
106 # self.Bind(wx.EVT_TIMER, self.UpdatePositions, self.timer) |
|
107 # self.ShowFullScreen(True,wx.FULLSCREEN_ALL) |
|
108 # wx.CallAfter(self.timer.Start,200) |
|
109 |
|
110 Class_wxglade_hmi.__init__ = Init |
|
111 |
|
112 def SetPLCGlobalVar(self, evt): |
|
113 tglbtname = evt.GetEventObject().GetName() |
|
114 setattr(PLCGlobals, tglbtname, evt.GetEventObject().GetValue()) |
|
115 |
|
116 ]]></xhtml:p> |
|
117 </globals> |
|
118 <init> |
|
119 <xhtml:p><![CDATA[ |
|
120 ]]></xhtml:p> |
|
121 </init> |
|
122 <cleanup> |
|
123 <xhtml:p><![CDATA[ |
|
124 ]]></xhtml:p> |
|
125 </cleanup> |
|
126 <start> |
|
127 <xhtml:p><![CDATA[ |
|
128 ]]></xhtml:p> |
|
129 </start> |
|
130 <stop> |
|
131 <xhtml:p><![CDATA[ |
|
132 ]]></xhtml:p> |
|
133 </stop> |
|
134 </PyFile> |