Changeset 1106
- Timestamp:
- 11/10/08 14:57:18 (2 months ago)
- Files:
-
- analog/pyeac/trunk/eeepc/controlpanel.py (modified) (2 diffs)
- analog/pyeac/trunk/eeepc/controlpanel.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/eac_physical.py (modified) (1 diff)
- analog/pyeac/trunk/eeepc/eac_physical.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/__init__.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/__init__.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/app.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/area.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/basic.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/button.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/const.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/container.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/deprecated.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/dialog.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/document.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/form.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/group.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/input.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/keysym.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/layout.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/menus.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/misc.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/select.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/slider.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/style.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/surface.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/table.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/theme.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pgu/gui/widget.pyc (modified) (previous)
- analog/pyeac/trunk/eeepc/pyeac.py (modified) (5 diffs)
- analog/pyeac/trunk/eeepc/visualizer.pyc (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
analog/pyeac/trunk/eeepc/controlpanel.py
r1094 r1106 19 19 20 20 self.tr() 21 g= gui.Group(name="%s,type"%(params['pin']),value='V')22 self.td(gui.Radio( g,value='V'))23 self.td(gui.Radio( g,value='I'))24 self.td(gui.Radio( g,value='L'))21 self.type_selector = gui.Group(name="%s,type"%(params['pin']),value='V') 22 self.td(gui.Radio(self.type_selector,value='V')) 23 self.td(gui.Radio(self.type_selector,value='I')) 24 self.td(gui.Radio(self.type_selector,value='L')) 25 25 26 26 self.tr() 27 27 self.td(gui.Label("",color=fg),align=0,width=50) 28 e= gui.HSlider(0,-200,200,size=8,width=50,height=16,name="%s,current"%(params['pin']))29 self.td( e)30 31 e= gui.Input(value="1",name="%s,function"%(params['pin']),size=5)32 self.td( e)28 self.current_slider = gui.HSlider(0,-200,200,size=8,width=50,height=16,name="%s,current"%(params['pin'])) 29 self.td(self.current_slider) 30 31 self.lla_function_input = gui.Input(value="1",name="%s,function"%(params['pin']),size=5) 32 self.td(self.lla_function_input) 33 33 34 34 class EacPanel(gui.Table): … … 96 96 self.ledofff() 97 97 98 class Context_Sensitive_Panel(gui.Table): 99 100 def __init__(self, pin_grid, active_cell, **params): 101 gui.Table.__init__(self,**params) 102 103 # self.cc = CellControl(pin="1,1") 104 fg = (255,255,255) 105 self.id_label = gui.Label("%d,%d"%(active_cell),color=fg) 106 self.voltage_label = gui.Label("%4.3f"%(0.000),color=fg) 107 self.input_current_label = gui.Label("%4.3f" % (0.0),color=fg) 108 self.output_current_label = gui.Label("%4.3f" % (0.0),color=fg) 109 self.cell_type = gui.Select(value="voltage",name="cell_type") 110 self.cell_type.add("Voltage","voltage") 111 self.cell_type.add("Current","current") 112 self.cell_type.add("LLA","lla") 113 self.current_slider = gui.HSlider(0,-200,200,size=8,width=150,height=20,name="cslider") 114 self.current_input = gui.Input(value="0",name="ctext_box",size=10) 115 self.lla_function_input = gui.Input(value="1",name="lla_f_select",size=10,align=0) 116 117 if active_cell != (0,0): 118 gui.Table.__init__(self,**params) 119 self.tr() 120 self.td(gui.Label("Edit Cell = ",color=fg),align=-1) 121 self.td(self.id_label,align=-1) 122 self.tr() 123 self.td(gui.Label("Voltage = ",color=fg),align=-1) 124 self.td(self.voltage_label,align=-1) 125 self.tr() 126 self.td(gui.Label("Mode = ",color=fg),align=-1) 127 self.td(self.cell_type,align=-1) 128 self.tr() 129 self.td(gui.Label("Input Current = ",color=fg),align=-1) 130 self.td(self.input_current_label,align=-1) 131 self.tr() 132 self.td(gui.Label("Output Current = ",color=fg),align=-1) 133 self.td(self.output_current_label,align=-1) 134 self.tr() 135 self.td(gui.Label("Current Source/Sink = ",color=fg),align=-1) 136 self.td(self.current_slider,align=-1) 137 self.td(self.current_input,align=0) 138 self.tr() 139 self.td(gui.Label("LLA Function = ",color=fg),align=-1) 140 self.td(self.lla_function_input,align=-1) 141 142 def set_controls (self, pg, active_cell): 143 self.id_label.value = "%d,%d"%(active_cell) 144 (ax,ay) = active_cell 145 146 self.voltage_label.value = "%4.3f"%(float(pg.grid[ay-1][ax-1].voltage)) 147 148 if pg.grid[ay-1][ax-1].mode == "V": 149 self.input_current_label.value = "%d"%(0) 150 self.output_current_label.value = "%d"%(0) 151 152 elif pg.grid[ay-1][ax-1].mode == "S": 153 self.input_current_label.value = "%d"%(0) 154 if pg.grid[ay-1][ax-1].current_output != None: 155 self.output_current_label.value = "%d"%(int(pg.grid[ay-1][ax-1].current_output)) 156 else: 157 self.output_current_label.value = "%d"%(0) 158 159 elif pg.grid[ay-1][ax-1].mode == "L": 160 value = pg.lla_dict[pg.grid[ay-1][ax-1].lla_tag].input_current 161 if value != None: 162 self.input_current_label.value = "%d"%(int(value)) 163 value = pg.lla_dict[pg.grid[ay-1][ax-1].lla_tag].output_current 164 165 if value != None: 166 self.output_current_label.value = "%d"%(int(value)) 167 168 # if pg.grid[ay-1][ax-1].current_input != None: 169 # self.input_current_label.value = "%d"%(int(pg.grid[ay-1][ax-1].current_input)) 170 # else: 171 # self.input_current_label.value = "%d"%(0) 172 # 173 # if pg.grid[ay-1][ax-1].current_output != None: 174 # self.output_current_label.value = "%d"%(int(pg.grid[ay-1][ax-1].current_output)) 175 # else: 176 # self.output_current_label.value = "%d"%(0) 177 178 179 def update_selector_text(self, pg, active_cell): 180 (ax,ay) = active_cell 181 if pg.grid[ay-1][ax-1].mode == "V": 182 self.cell_type.value = "voltage" 183 self.current_slider.value = "0" 184 self.lla_function_input.value = "1" 185 elif pg.grid[ay-1][ax-1].mode == "S": 186 self.cell_type.value = "current" 187 self.current_slider.value = int(pg.grid[ay-1][ax-1].current_output) 188 self.lla_function_input.value = "1" 189 elif pg.grid[ay-1][ax-1].mode == "L": 190 self.cell_type.value = "lla" 191 self.current_slider.value = "0" 192 value = pg.lla_dict[pg.grid[ay-1][ax-1].lla_tag].function 193 self.lla_function_input.value = value 194 98 195 if __name__ == '__main__': 99 196 screen = pygame.display.set_mode((1024,600)) analog/pyeac/trunk/eeepc/eac_physical.py
r1104 r1106 193 193 self.ueac.lon() 194 194 195 def update(self, update_dict, full_form): 196 for key in update_dict.keys(): 197 (x,y,op) = key.split(',') 198 x = int(x) 199 y = int(y) 200 value = update_dict[key] 201 if op == 'type': 202 if value == 'V': 203 self.set_voltage_input((x,y)) 204 if value == 'I': 205 current_value_key = "%s,%s,current"%(x,y) 206 self.set_current_source((x,y),int(full_form[current_value_key])) 207 if value == 'L': 208 current_value_key = "%d,%d,function"%(x,y) 209 value = int(full_form[current_value_key]) 210 if value > 0 and value < 27: 211 self.lla_add("L%d,%d"%(x,y),(x,y),(0,0),value,1) 212 elif op == 'function': 213 if self.grid[y-1][x-1].mode == 'L': 214 try: 215 value = int(value) 216 valid_value = True 217 except ValueError: 218 valid_value = False 219 220 if valid_value and value > 0 and value < 28: 221 self.lla_add("L%d,%d"%(x,y),(x,y),(0,0),value,1) 222 223 elif op == "current": 224 if self.grid[y-1][x-1].mode == 'S': 225 self.set_current_source((x,y),int(value)) 195 def update(self, form, active_cell): 196 # print form, active_cell 197 if form['cell_type'] == 'voltage': 198 self.set_voltage_input(active_cell) 199 elif form['cell_type'] == 'current': 200 self.set_current_source(active_cell,int(form['cslider'])) 201 elif form['cell_type'] == 'lla': 202 self.lla_add("L%d,%d"%(active_cell),active_cell,(0,0),int(form['lla_f_select']),1) 203 204 # for key in update_dict.keys(): 205 # (x,y,op) = key.split(',') 206 # x = int(x) 207 # y = int(y) 208 # value = update_dict[key] 209 # if op == 'type': 210 # if value == 'V': 211 # self.set_voltage_input((x,y)) 212 # if value == 'I': 213 # current_value_key = "%s,%s,current"%(x,y) 214 # self.set_current_source((x,y),int(full_form[current_value_key])) 215 # if value == 'L': 216 # current_value_key = "%d,%d,function"%(x,y) 217 # value = int(full_form[current_value_key]) 218 # if value > 0 and value < 27: 219 # self.lla_add("L%d,%d"%(x,y),(x,y),(0,0),value,1) 220 # elif op == 'function': 221 # if self.grid[y-1][x-1].mode == 'L': 222 # try: 223 # value = int(value) 224 # valid_value = True 225 # except ValueError: 226 # valid_value = False 227 # 228 # if valid_value and value > 0 and value < 28: 229 # self.lla_add("L%d,%d"%(x,y),(x,y),(0,0),value,1) 230 # 231 # elif op == "current": 232 # if self.grid[y-1][x-1].mode == 'S': 233 # self.set_current_source((x,y),int(value)) 226 234 227 235 analog/pyeac/trunk/eeepc/pyeac.py
r1095 r1106 22 22 return(None) 23 23 24 def get_grid_square(pos): 25 (gbx,gby) = (315,0) 26 (gsx,gsy) = (60,60) 27 (posx,posy) = pos 28 29 posnx = posx - gbx 30 posny = posy - gby 31 32 if posnx < 0 or posny < 0: 33 sq = (0,0) 34 elif posnx >= 300 or posny >= 300: 35 sq = (0,0) 36 else: 37 sq = (int(posnx/gsx) + 1, int(posny/gsy) + 1) 38 return sq 39 40 def get_highlighted_square(grid_sq, color): 41 (gx,gy) = grid_sq 42 rx = (gx-1) * 60 43 ry = (gy-1) * 60 44 hlsurf = pygame.Surface((300,300)) 45 hlsurf.set_colorkey((0,0,0)) 46 hlsurf.fill((0,0,0)) 47 pygame.draw.rect(hlsurf, color, Rect(rx,ry,60,60), 3) 48 return hlsurf 49 24 50 if __name__ == '__main__': 25 51 from visualizer import Visualizer … … 31 57 import sys; sys.path.insert(0, ".") 32 58 from pgu import gui 33 from controlpanel import EacPanel, ButtonPanel 59 from controlpanel import EacPanel, ButtonPanel, Context_Sensitive_Panel 34 60 from raw_display import RawDisplay 35 61 … … 49 75 form = gui.Form() 50 76 app = gui.App() 51 ecc = EacPanel()77 # ecc = EacPanel() 52 78 bcc = ButtonPanel(pg.reset, pg.lon, pg.lof) 53 79 54 80 c = gui.Container(align=-1,valign=-1) 55 c.add(ecc,0,325) 81 # c.add(ecc,0,325) 82 83 84 csp = Context_Sensitive_Panel(pg, (1,1)) 85 c.add(csp,0,325) 86 56 87 c.add(bcc,650,100) 57 88 … … 62 93 63 94 clock = pygame.time.Clock() 95 mousepos = (315,0) 96 mouseb1pressed = False 97 98 chl_grid = (3,3) 99 operating_grid = (3,3) 100 highlighted_surface = get_highlighted_square((3,3), (255,255,255)) 101 selected_square_surface = get_highlighted_square((3,3), (255,0,0)) 102 active_cell = (3,3) 103 loop_counter = 0 104 64 105 while True: 65 106 _form_last = _form 66 107 _form = form.results() 67 108 changes = diff_dict(_form_last,_form) 109 68 110 if changes != None: 69 pg.update( changes,_form)111 pg.update(_form,active_cell) 70 112 71 113 for event in pygame.event.get(): 72 114 if event.type == QUIT: 73 115 exit() 116 if event.type == MOUSEMOTION: 117 active_grid = get_grid_square(event.pos) 118 if active_grid != (0,0) and active_grid != chl_grid: 119 chl_grid = active_grid 120 highlighted_surface = get_highlighted_square(active_grid, (255,255,255)) 121 122 if event.type == MOUSEBUTTONDOWN: 123 if event.button == 1: 124 selected_grid = get_grid_square(event.pos) 125 if selected_grid != (0,0): 126 selected_square_surface = get_highlighted_square(selected_grid, (255,0,0)) 127 active_cell = selected_grid 128 csp.update_selector_text(pg, active_cell) 74 129 app.event(event) 75 130 … … 77 132 phyeac_vis.update(pg) 78 133 phyeac_raw.update(pg) 134 csp.set_controls(pg, active_cell) 79 135 80 136 screen.fill((0,0,0)) 81 137 screen.blit(phyeac_vis.surface,(0,0)) 82 138 screen.blit(phyeac_raw.master_surface,(315,0)) 139 screen.blit(highlighted_surface,(315,0)) 140 if selected_square_surface != None: 141 screen.blit(selected_square_surface,(315,0)) 142 83 143 84 144 app.paint(screen)
