def p_Factor(t): '''Factor : NUMBER | ImaginaryNumber | NapierNumber | ID | INFINITY | Symbol | IteratedExpression | DivisorFunction | Derivative | Integral | Limit | DifferentialVariable | ChooseExpression | Matrix | Determinant | Norm | FractionalExpression | ID CARET LBRACE Expression RBRACE | LPAREN Expression RPAREN''' if len(t) > 4: t[1] = Identifier(ID(t[1])) t[0] = ExpressionWithBinaryOperation(BinaryOperator(BinaryOperator.POW), t[1], t[4]) elif len(t) > 2: t[0] = ExpressionBetweenParenthesis(t[2]) else: if t.slice[1].type == "ID": t[1] = Identifier(ID(t[1])) t[0] = t[1]
def p_DifferentialVariable2(t): '''DifferentialVariable : ID CARET LBRACE LPAREN NUMBER RPAREN RBRACE LPAREN ExpressionList RPAREN | ID CARET LBRACE LPAREN NUMBER RPAREN RBRACE''' isOrder = False try: order = int(t[5].getNumber()) isOrder = True except Exception as msg: order = t[5] if isOrder: if order > 0: primeList = [Symbol(Symbol.PRIME)]*int(order) else: primeList = [] if len(t) > 8: t[0] = DifferentialVariable(Identifier(ID(t[1])), primeList, t[9]) else: t[0] = DifferentialVariable(Identifier(ID(t[1])), primeList) else: if len(t) > 8: raise SyntaxException(t.slice[5].lineno, t.slice[5].lexpos, t.slice[5].value, t.slice[5]) else: t[0] = ExpressionWithBinaryOperation(BinaryOperator(BinaryOperator.POW), Identifier(ID(t[1])), t[5])
def p_LIMIT(t): '''Limit : LIMIT UNDERLINE LBRACE ID TO Expression RBRACE Expression | LIMIT UNDERLINE LBRACE ID TO Expression PLUS RBRACE Expression | LIMIT UNDERLINE LBRACE ID TO Expression MINUS RBRACE Expression | LIMIT UNDERLINE LBRACE ID TO Expression CARET LBRACE PLUS RBRACE RBRACE Expression | LIMIT UNDERLINE LBRACE ID TO Expression CARET LBRACE MINUS RBRACE RBRACE Expression | LIMIT UNDERLINE LBRACE ID TO Term CARET LBRACE PLUS RBRACE RBRACE Expression | LIMIT UNDERLINE LBRACE ID TO Term CARET LBRACE MINUS RBRACE RBRACE Expression''' if len(t) > 10: if t.slice[9].type == "PLUS": approachesFrom = Limit.FROM_RIGHT else: approachesFrom = Limit.FROM_LEFT t[0] = Limit(Identifier(ID(t[4])), t[6], t[12], approachesFrom) elif len(t) > 9: if t.slice[7].type == "PLUS": approachesFrom = Limit.FROM_RIGHT else: approachesFrom = Limit.FROM_LEFT t[0] = Limit(Identifier(ID(t[4])), t[6], t[9], approachesFrom) else: t[0] = Limit(Identifier(ID(t[4])), t[6], t[8])
def __init__(self, **kwargs): self.params = kwargs if kwargs['speed'] > 5: self.params['texture'] = "rotor2.png" else: self.params['texture'] = "rotor.png" self.params['__objID__'] = ID.next() self.params['__objID2__'] = ID.next()
def p_DifferentialVariable1(t): '''DifferentialVariable : ID PrimeList LPAREN ExpressionList RPAREN | ID PrimeList''' if len(t) > 3: t[0] = DifferentialVariable(Identifier(ID(t[1])), t[2], t[4]) else: t[0] = DifferentialVariable(Identifier(ID(t[1])), t[2])
def turnback(): # 还书 global win win = tk.Tk() win.title('读者') win.geometry('550x600') db = pymysql.connect("localhost", "root", "sunhao2268411762", "library") cursor = db.cursor() sql0 = "SELECT COUNT(*) FROM borrow WHERE id='%s'" % (ID.getid()) cursor.execute(sql0) result = cursor.fetchone() if result[0] == 0: msg.showinfo(title='错误', message='您还没借过书呢!') else: lable1 = tk.Label(win, text='查询到您有以下书目未还:', bg='pink', font=('微软雅黑', 20)).place(x=80, y=20) tree = ttk.Treeview(win, columns=('1', '2'), show="headings") tree.column('1', width=150, anchor='center') tree.column('2', width=150, anchor='center') tree.heading('1', text='书名') tree.heading('2', text='作者') tree.place(x=100, y=100) sql1 = "SELECT bookname,author FROM borrow WHERE id='%s'" % ( ID.getid()) cursor.execute(sql1) result1 = cursor.fetchall() for i in range(0, result[0]): tree.insert('', i, values=(result1[i])) lable2 = tk.Label(win, text='请输入还书信息:', bg='pink', font=('微软雅黑', 20)).place(x=80, y=360) lable22 = tk.Label(win, text='书名作者都要填写正确无误!', bg='pink', font=('微软雅黑', 20)).place(x=80, y=400) global b_name tk.Label(win, text='书名:', font=('宋体', 12)).place(x=80, y=480) b_name = tk.Entry(win, font=('宋体', 12), width=10) b_name.place(x=130, y=480) global author tk.Label(win, text='作者:', font=('宋体', 12)).place(x=230, y=480) author = tk.Entry(win, font=('宋体', 12), width=10) author.place(x=280, y=480) tk.Button(win, text='确认还书', font=('宋体', 12), width=10, command=confirm_turnback).place(x=395, y=480) db.close()
def __init__(self, **kwargs): self.params = kwargs self.addDefault('classname', 'EnemySprite') self.addDefault('scaling', 2) self.addDefault('enable_motor', 'true') self.params['enemy_offset'] = int( round((100 * self.params['scaling']) / 2)) self.params['beam_length'] = int(round(100 * self.params['scaling'])) self.params['rotor_size'] = int(round(128 * self.params['scaling'])) self.params['enemy_size'] = int(round(25 * self.params['scaling'])) self.params['__objID__'] = ID.next() self.params['__objID2__'] = ID.next()
def __init__(self, **kwargs): self.params = kwargs try: self.params['power'] = kwargs['power'] self.params['name'] = kwargs['name'] + kwargs['power'] except: self.params['power'] = '#1000' self.params['name'] = kwargs['name'] + '#1000' kwargs['piston_y'] = int(kwargs['y']) + 30 self.params['__objID__'] = ID.next() self.params['__objID2__'] = ID.next() self.params['__objID3__'] = ID.next()
def login(): global root1 root1 = tk.Tk() root1.wm_attributes('-topmost', 1) root1.title('Manager Login') root1.geometry('500x300') lable1 = tk.Label(root1, text='Account:', font=25).place(x=100, y=50) lable2 = tk.Label(root1, text='Password:', font=25).place(x=90, y=100) global entry_name, entry_key name = tk.StringVar() key = tk.StringVar() entry_name = tk.Entry(root1, textvariable=name, font=25) entry_name.place(x=180, y=50) entry_key = tk.Entry(root1, textvariable=key, font=25, show='*') entry_key.place(x=180, y=100) button1 = tk.Button(root1, text='Confirm', height=2, width=10, command=lambda: ID.id_check('1')) button1.place(x=210, y=180)
def p_UnaryExpressionOperatorAfter(t): '''Factor : NUMBER FACTORIAL | ID FACTORIAL | LPAREN Expression RPAREN FACTORIAL | NUMBER PERCENT | ID PERCENT | LPAREN Expression RPAREN PERCENT''' if t.slice[1].type == "ID": t[1] = Identifier(ID(t[1])) if len(t) > 3: if t.slice[4].type == "FACTORIAL": op = UnaryOperator.FACTORIAL else: op = UnaryOperator.PERCENT t[0] = ExpressionWithUnaryOperation(UnaryOperator(op), ExpressionBetweenParenthesis(t[2]), True) else: if t.slice[2].type == "FACTORIAL": op = UnaryOperator.FACTORIAL else: op = UnaryOperator.PERCENT t[0] = ExpressionWithUnaryOperation(UnaryOperator(op), t[1], True)
def register(): global root2 root2 = tk.Tk() root2.wm_attributes('-topmost', 1) root2.title('读者注册') root2.geometry('500x300') lable1 = tk.Label(root2, text='账号:', font=25).place(x=100, y=50) lable2 = tk.Label(root2, text='密码:', font=25).place(x=100, y=100) lable2 = tk.Label(root2, text='确认密码:', font=25).place(x=80, y=150) global entry_name, entry_key, entry_confirm name = tk.StringVar() key = tk.StringVar() confirm = tk.StringVar() entry_name = tk.Entry(root2, textvariable=name, font=25) entry_name.place(x=180, y=50) entry_key = tk.Entry(root2, textvariable=key, font=25, show='*') entry_key.place(x=180, y=100) entry_confirm = tk.Entry(root2, textvariable=confirm, font=25, show='*') entry_confirm.place(x=180, y=150) # 百度:tkinter要求由按钮(或者其它的插件)触发的控制器函数不能含有参数,若要给函数传递参数,需要在函数前添加lambda button1 = tk.Button(root2, text='确定', height=2, width=10, command=lambda: ID.id_write('0')) button1.place(x=210, y=200)
def drawZoi(style): if Events.showSensors == False: return """ bind vbo """ zoi.mesh.vertexPositions.bind() zoi.mesh.surfIndexPositions.bind() glVertexAttribPointer(Shaders.position, 3, GL_FLOAT, GL_FALSE, 0, None) for sensor in zoiSens: """ find sensor's template """ template = None for sensorData in sensorGraphics: if sensor.type == sensorData.type: template = sensorData break if template == None: print("WARNING : No template match !") continue """ choose color """ if style != Graphics.idBuffer: color = np.array([0.5, 0.5, 0.5, 1], dtype=np.float32) if sensor.id == overSensId: color = np.array( [0.5 * color[0], 0.5 * color[1], 0.5 * color[2], color[3]], dtype=np.float32) else: r, g, b = ID.id2color(sensor.id) color = np.array([r / 255., g / 255., b / 255., 1.], dtype=np.float32) """ send color to shader """ glUniform4fv(Shaders.setColor_loc, 1, color) """ load matrix in shader """ glUniformMatrix4fv(Shaders.model_loc, 1, GL_FALSE, sensor.modelMatrix) """ draw vbo """ glDrawElements(zoi.mesh.surfStyleIndex, zoi.mesh.surfNbIndex, GL_UNSIGNED_INT, None)
def register(): global root2 root2 = tk.Tk() root2.wm_attributes('-topmost', 1) root2.title('Borrower Register') root2.geometry('500x300') lable1 = tk.Label(root2, text='Account:', font=25).place(x=90, y=50) lable2 = tk.Label(root2, text='Password:', font=25).place(x=80, y=100) lable2 = tk.Label(root2, text='Confirm Password:', font=25).place(x=30, y=150) global entry_name, entry_key, entry_confirm name = tk.StringVar() name = tk.StringVar() key = tk.StringVar() confirm = tk.StringVar() entry_name = tk.Entry(root2, textvariable=name, font=25) entry_name.place(x=180, y=50) entry_key = tk.Entry(root2, textvariable=key, font=25, show='*') entry_key.place(x=180, y=100) entry_confirm = tk.Entry(root2, textvariable=confirm, font=25, show='*') entry_confirm.place(x=180, y=150) button1 = tk.Button(root2, text='Confirm', height=2, width=10, command=lambda: ID.id_write('0')) button1.place(x=210, y=200)
def drawLink(style): if Events.showSensors == False or style == Graphics.idBuffer: return link.mesh.edgeIndexPositions.bind() link.mesh.vertexPositions.bind() glVertexAttribPointer(Shaders.position, 3, GL_FLOAT, GL_FALSE, 0, None) for sensor in virtuSens + zoiSens: """ choose color """ for sensorData in sensorGraphics: if sensor.type == sensorData.type: if ID.idCategory(sensor.id) == ID.ZOI: color = np.array([0.5, 0.5, 0.5, 1], dtype=np.float32) else: color = np.array([ sensorData.color[0] / 255., sensorData.color[1] / 255., sensorData.color[2] / 255., sensorData.color[3] / 255. ], dtype=np.float32) break if sensor.id == selectedSens: color = np.array( [0.5 * color[0], 0.5 * color[1], 0.5 * color[2], color[3]], dtype=np.float32) """ send color to shader """ glUniform4fv(Shaders.setColor_loc, 1, color) """ load matrix in shader """ glUniformMatrix4fv(Shaders.model_loc, 1, GL_FALSE, sensor.linkModelMatrix) """ draw vbo """ glDrawElements(link.mesh.surfStyleIndex, link.mesh.surfNbIndex, GL_UNSIGNED_INT, None)
def login(): global root1 root1 = tk.Tk() root1.wm_attributes('-topmost', 1) root1.title('读者登录') root1.geometry('500x300') lable1 = tk.Label(root1, text='账号:', font=25).place(x=100, y=50) lable2 = tk.Label(root1, text='密码:', font=25).place(x=100, y=100) global entry_name, entry_key name = tk.StringVar() key = tk.StringVar() entry_name = tk.Entry(root1, textvariable=name, font=25) entry_name.place(x=180, y=50) entry_key = tk.Entry(root1, textvariable=key, font=25, show='*') entry_key.place(x=180, y=100) # 百度:tkinter要求由按钮(或者其它的插件)触发的控制器函数不能含有参数,若要给函数传递参数,需要在函数前添加lambda button1 = tk.Button(root1, text='确定', height=2, width=10, command=lambda: ID.id_check('0')) button1.place(x=210, y=180)
def __init__(self): Command.__init__(self, name = "show", footer = [ "INDENT_FILL and UNINDENT_FILL are applied " + \ "when indentation is needed", "LINE_FORMAT controls the output for each entry " + \ "dumped.", "Interpreted sequences are:", "", " %t text", " %s start time", " %e end time", " %p priority", " %I index (absolute)", " %i index (relative)", " %c comment", " %d depth", " %r root node name", "", "FILTER " + Filter.help_text(), "ID " + ID.help_text(), "WIDTH An integer >= 0, 0 means no formatting", "SORT_CRITERIA Sorting output by id, start, end or " + \ "priority (use '-' as suffix to reverse, eg. 'id-')" ])
def frame(): global window2 window2 = tk.Tk() window2.title('Borrower Operation') window2.configure(background='#7DC0F8') window2.geometry('700x600') lable = tk.Label(window2, text="Student ID: ", font=('Microsoft YaHei', 50)).place(x=20, y=10) lable0 = tk.Label(window2, text=ID.getid(), font=('Microsoft YaHei', 50)).place(x=280, y=10) lable1 = tk.Label(window2, text='Please select:', font=('Microsoft YaHei', 20)).place(x=80, y=200) lable2 = tk.Label(window2, text='General input borrow', font=('Microsoft YaHei', 20)).place(x=80, y=250) lable3 = tk.Label(window2, text='QR code borrow', font=('Microsoft YaHei', 20)).place(x=80, y=550) tk.Button(window2, text='Borrow', font=('Microsoft YaHei', 15), width=10, height=2, command=borrow).place(x=350, y=250) tk.Button(window2, text='Return', font=('Microsoft YaHei', 15), width=10, height=2, command=turnback).place(x=350, y=350) tk.Button(window2, text='Search', font=('Microsoft YaHei', 15), width=10, height=2, command=search.frame).place( x=350, y=450) tk.Button(window2, text='(1)QR code', font=('Microsoft YaHei', 15), width=10, height=2, command=scan).place(x=350, y=550) tk.Button(window2, text='(2)Borrow', font=('Microsoft YaHei', 15), width=10, height=2, command=qrcode_show).place( x=500, y=550) window2.mainloop()
def turnback(): global win win = tk.Tk() win.title('Borrower') win.geometry('550x600') db = pymysql.connect(host='127.0.0.1', port=3306, user='******', passwd='cla051063', db='abes', charset='utf8' ) cursor = db.cursor() sql0 = "SELECT COUNT(*) FROM borrow WHERE userid='%s'" % (ID.getid()) cursor.execute(sql0) result = cursor.fetchone() if result[0] == 0: msg.showinfo(title='Error', message='You have not borrowed an equipment yet!') else: lable1 = tk.Label(win, text='The following equipment on the unreturned:', bg='pink', font=('Microsoft YaHei', 20)).place(x=80, y=20) tree = ttk.Treeview(win, columns=('1', '2'), show="headings") tree.column('1', width=150, anchor='center') tree.column('2', width=150, anchor='center') tree.heading('1', text='Equipment') tree.heading('2', text='Date') tree.place(x=100, y=100) sql1 = "SELECT name,date FROM borrow WHERE userid='%s'" % (ID.getid()) cursor.execute(sql1) result1 = cursor.fetchall() for i in range(0, result[0]): tree.insert('', i, values=(result1[i])) lable2 = tk.Label(win, text='Please enter your equipment return information:', bg='pink', font=('Microsoft YaHei', 20)).place(x=80, y=360) lable22 = tk.Label(win, text='The equipment name should be filled in correctly!', bg='pink', font=('Microsoft YaHei', 20)).place(x=80, y=400) global e_name tk.Label(win, text='Equipment:', font=('Microsoft YaHei', 12)).place(x=80, y=480) e_name = tk.Entry(win, font=('Microsoft YaHei', 12), width=10) e_name.place(x=180, y=480) tk.Button(win, text='Confirm Turn back', font=('Microsoft YaHei', 12), width=10, command=confirm_turnback).place(x=395, y=480) db.close()
def __init__(self, **kwargs): self.params = kwargs self.params['name'] = "Nut" self.process(kwargs) self.addDefault('classname', 'NutSprite') self.addDefault('static', 'true') self.addDefault('eventName', 'onNutHit') self.params['__objID__'] = ID.next()
def itemSelect(self, text): text = "" if self.table.currentItem() != None: text = self.table.currentItem().text() Sensors.selectedSens = self.table.currentRow() + ID.offsetId(ID.SENSOR) else: print("TODO, not working yet.") Sensors.selectedSens = 0 self.edit.setText(text)
def __init__(self): Command.__init__(self, name="edit", footer=[ "ID " + ID.help_text(), "PRIORITY " + Priority.help_text(), "START " + Time.help_text(), "END " + Time.help_text() ])
def _addFolder( self, folder ): if folder.sourcePath in list(self._folders.keys()): return if folder.parent and folder.parent.name != '': self._addFolder(folder.parent) self._filters.addFilter( folder.sourcePath ).set( 'UniqueIdentifier', ID.generate() ) self._folders[folder.sourcePath] = folder
def __init__(self,**kwargs): self.params = kwargs self.params['__objID__'] = ID.next() self.bodies = "" self.joints = "" self.contacts = "" self.buildWalls() self.buildNuts() self.fillWithEnemiesAndStar()
def __init__(self,**kwargs): self.params = kwargs self.params['__objID__'] = ID.next() self.bodies = "" self.joints = "" self.contacts = "" self.buildBodies() self.buildJoints() self.buildContacts()
def preprocessMuscle(entity): for i in range(0,len(entity.muscles)): if entity.muscles[i].mesh == None: entity.muscles[i].mesh = Graphics.VBO_cylinder(6,2) Graphics.buildVBO(entity.muscles[i]) P1 = entity.muscles[i].Aworld P2 = entity.muscles[i].Bworld P3 = entity.muscles[i].Cworld if P1 == [] or P2 == [] or P3 == []: continue """ set muscle model matrix """ Ux = Definitions.vector4D((0, 1, 0, 0)) Vx = Definitions.vector4D((0, P1[0][0]-P2[0][0], P1[0][1]-P2[0][1], P1[0][2]-P2[0][2])) scale = math.sqrt(Vx.x*Vx.x + Vx.y*Vx.y + Vx.z*Vx.z) center = Definitions.vector4D((0, 0.5*(P1[0][0]+P2[0][0]), 0.5*(P1[0][1]+P2[0][1]), 0.5*(P1[0][2]+P2[0][2]))) Wx = Definitions.vector4D.AngleAxisBetween2Vec(Ux,Vx) Definitions.modelMatrix.push() Definitions.modelMatrix.set(Definitions.I) Definitions.modelMatrix.translate(center.x, center.y, center.z) Definitions.modelMatrix.rotate(Wx.o, Wx.x, Wx.y, Wx.z) """ readjust facing direction """ uy = np.dot(np.array([0, 1, 0, 0]), Definitions.modelMatrix.peek()) # Note : not same as Ux because here it's [x,y,z,o] and in vector4D it's [o,x,y,z] vy = np.array([0.5*(P1[0][0]+P2[0][0])-P3[0][0], 0.5*(P1[0][1]+P2[0][1])-P3[0][1], 0.5*(P1[0][2]+P2[0][2])-P3[0][2], 0]) Uy = Definitions.vector4D((0, uy[0], uy[1], uy[2])) Vy = Definitions.vector4D((0, vy[0], vy[1], vy[2])) Wy = Definitions.vector4D.AngleAxisBetween2Vec(Uy,Vy) if Definitions.vector4D.VecDot(Vx,Wy) < 0: Wy.o = -Wy.o Definitions.modelMatrix.rotate(Wy.o, 1, 0, 0) Definitions.modelMatrix.scale(scale,0.03,0.03) entity.muscles[i].modelMatrix = Definitions.modelMatrix.peek() if entity.muscles[i].id == Definitions.lookingAtID: Definitions.lookingAt = np.dot(np.array([[0, 0, 0, 1]]), entity.muscles[i].modelMatrix) for sensor in Sensors.virtuSens + Sensors.zoiSens: if sensor.attach == entity.muscles[i].tag: sensor.h = 0.6 if sensor.type == 'Eye': sensor.h = 0.4 if ID.idCategory(sensor.id) == ID.ZOI: sensor.h = 0.55 Sensors.preprocessSensor(sensor, scale, 0.03, 0.03) Definitions.modelMatrix.pop()
def drawMuscleSurface(entity, style, show): if Events.showMuscles == False: return for i in range(0,len(entity.muscles)): if entity.muscles[i].show == Events.HIDE\ or entity.muscles[i].show == Events.SHOW and show == Events.FADE: continue """ verify matrix validity """ if entity.muscles[i].modelMatrix == []: continue """ bind surfaces vbo """ entity.muscles[i].mesh.surfIndexPositions.bind() entity.muscles[i].mesh.vertexPositions.bind() glVertexAttribPointer(Shaders.position, 3, GL_FLOAT, GL_FALSE, 0, None) """ choose color """ if style == Graphics.idBuffer: r, g, b = ID.id2color(entity.muscles[i].id) color = np.array([r/255.,g/255.,b/255.,1.], dtype = np.float32) elif i+ID.offsetId(ID.MUSCLE) == SelectedMuscId: color = np.array([0.5,0,0.,0.3], dtype = np.float32) elif i+ID.offsetId(ID.MUSCLE) == OverMuscId: color = np.array([1,0,0,0.3], dtype = np.float32) else: color = np.array([1.,0.4,0.7,0.3], dtype = np.float32) """ send color to shader """ glUniform4fv(Shaders.setColor_loc, 1, color) """ send matrix to shader """ glUniformMatrix4fv(Shaders.model_loc, 1, GL_FALSE, entity.muscles[i].modelMatrix) """ draw vbo """ glDrawElements(entity.muscles[i].mesh.surfStyleIndex, entity.muscles[i].mesh.surfNbIndex, GL_UNSIGNED_INT, None)
def __init__( self, type, name, keyword, platform, toolset ): self._xml = Xml.Element( 'Project', attrib=dict( DefaultTargets = Project.DefaultTargets, ToolsVersion = Project.ToolsVersion, xmlns = Project.xmlns ) ) self._id = ID.generate() self._type = type self._toolset = toolset self._name = name self._keyword = keyword self._platform = platform self._dependencies = [] self._filters = Filters( Project ) self._configurations = [] self._sourceFiles = [] self._headerFiles = []
def __init__(self, **kwargs): self.params = kwargs try: self.params['width'] = kwargs['width'] self.params['height'] = kwargs['height'] except: self.params['width'] = '30' self.params['height'] = '30' self.params['name'] = "Hero" self.process(kwargs) self.addDefault('classname', 'HeroSprite') self.params['__objID__'] = ID.next()
def drawMuscleEdge(entity, style): if Events.showMuscles == False: return if style != Graphics.opaque and style != Graphics.blending: return for i in range(0,len(entity.muscles)): """ verify matrix validity """ if entity.muscles[i].modelMatrix == []: continue """ bind edges vbo """ entity.muscles[i].mesh.edgeIndexPositions.bind() entity.muscles[i].mesh.vertexPositions.bind() glVertexAttribPointer(Shaders.position, 3, GL_FLOAT, GL_FALSE, 0, None) """ choose color """ if style == Graphics.opaque: color = np.array([0.5,0.5,0.5,1.], dtype = np.float32) elif style == Graphics.blending: if i+ID.offsetId(ID.MUSCLE) == SelectedMuscId: color = np.array([0.5,0.,0.,0.3], dtype = np.float32) elif i+ID.offsetId(ID.MUSCLE) == OverMuscId: color = np.array([1.,0.,0.,0.3], dtype = np.float32) else: color = np.array([0.5,0.7,0.7,0.3], dtype = np.float32) """ send color to shader """ glUniform4fv(Shaders.setColor_loc, 1, color) """ send matrix to shader """ glUniformMatrix4fv(Shaders.model_loc, 1, GL_FALSE, entity.muscles[i].modelMatrix) """ draw vbo """ glDrawElements(entity.muscles[i].mesh.edgeStyleIndex, entity.muscles[i].mesh.edgeNbIndex, GL_UNSIGNED_INT, None)
def __init__(self, **kwargs): self.params = kwargs self.params['name'] = "Friend" self.process(kwargs) self.addDefault('classname', 'FriendSprite') #self.addDefault('firstframe','friend0001.png') try: self.params['classname'] if self.params['classname'] == "AccelFriendSprite": self.params['firstframe'] = "accel_friend.png" else: raise "default" except: self.params['firstframe'] = "friend0001.png" self.params['__objID__'] = ID.next()
def __init__(self, **kwargs): """ Create a new Entity. kwarg : description : default -------------------------------------------------------- x : center of the entity's x position : 0 y : center of the entity's y position : 0 visible : is the entity drawn/visible : True enabled : is the entity updating : True timescale : see update methods : 1.0 collider : collision object for the entity : None """ self._x, self._y = kwargs.get('x', 0), kwargs.get('y', 0) #pylint:disable-msg=C0103,C0301 self._visible = kwargs.get('visible', True) self._enabled = kwargs.get('enabled', True) self._timescale = kwargs.get('timescale', 1.0) self._collider = kwargs.get('collider', None) self._last_dmg_src = None self._id = ID.get_id(self) self._dirty = False self._dt = 0.0
def sign_in_handler(ip, info): is_virtual = info.get('virtual') virt_type = info.get('virt_type') if not is_virtual: id = ID.host_id_gen(ip) host_type = 'Host' global modeldb session = modeldb.openSession() host = session.getResource(host_type, id) if host is None: host = Host(ip) host.id = id else: logger.debug('retieve object %s from db' % host) host.is_virtual = is_virtual host.virt_type = virt_type components = info.get('components') cpuinfo = components.get('cpu') cpu = CPU(**cpuinfo) host.hasOne('cpu', cpu) disksinfo = components.get('filesystem')['local'] for dn, di in disksinfo.iteritems(): if di.has_key('disk'): diskname = di.get('disk') diskinfo= disksinfo.get(diskname) disk = Disk(**diskinfo) disk.update({'name': diskname}) partition = Partition(**di) partition.update({'name': dn}) disk.addOne('partitions', dn, partition) host.addOne('disks', diskname, disk) else: continue meminfo = components.get('memory') host.update(meminfo) ifsinfo = components.get('network') for ifn, ifi in ifsinfo.iteritems(): if ifn not in ('lo',): network_interface = NetworkInterface(**ifi) network_interface.update({'name': ifn}) host.addOne('network_interfaces', ifn, network_interface) #if virt_type is not None: #host.virt_type = virt_type host.metric_list = info['metric_groups'] session.setResource(host.__class__.__name__, host.id, host) session.setResource('active', host.ip, host) session.commit() session.close()
#Author: Yasha Pyshak #This script facilitates the parsing of the smac output, by opening each file and grabbing portion of each callstring used to set the parameters for the algorithm. #You will need to change to the directory that contains the smac console output files import glob import os import ID with open('configs-PSM.csv','w',1) as f_write: f_write.write('#PSM configurations found by first running 5 indepenedent runs of SMAC to configure parameters as constants for each problem instance size\n') f_write.write('#n = 500, 700, ..., 1300. Default PSM configurations were then fit using the gnuplot fit function and ranges were taken as the +/- standard\n') f_write.write('#errors reported. These were noted to be overly-optimistic in their documentation, but they may be sufficient for our purposes.\n') f_write.write('#Unique ID, configuration call string\n') for file in glob.glob("deploy-smac-PSM.pbs.o*"): with open(file,'r') as f_read: id = 'p' + ID.generateID() f_write.write(id + ', ') #print(file) #print(id) found = False for line in f_read: if ('Sample call for this final incumbent:' in line): found = True elif(found): #this line is the sample call for the best found PSM #print(id) #print(line) f_write.write(line[line.index(" -")+1:].strip()+'\n') break
def signIn(self, ip, info): is_virtual = info.get("virtual") virt_type = info.get("virt_type") if not is_virtual: id = ID.host_id_gen(ip) host_type = "Host" session = self.session #host = session.getResource(host_type, id) host = session.getResource("all", id) if host is None: host = Host(ip) host.id = id else: logger.debug("retrieve object %s from db" % host) host.is_virtual = is_virtual host.virt_type = virt_type host.ip = ip components = info.get("components") cpuinfo = components.get("cpu") cpu = CPU(**cpuinfo) host.hasOne("cpu", cpu) disksinfo = components.get("filesystem")["local"] for dn, di in disksinfo.iteritems(): if di.has_key("disk"): diskname = di.get("disk") diskinfo = disksinfo.get(diskname) disk = Disk(**diskinfo) disk.update({"name": diskname}) partition = Partition(**di) partition.update({"name": dn}) disk.addOne("partitions", dn, partition) host.addOne("disks", diskname, disk) else: continue meminfo = components.get("memory") host.update(meminfo) ifsinfo = components.get("network") for ifn, ifi in ifsinfo.iteritems(): if ifn not in ("lo",): network_interface = NetworkInterface(**ifi) network_interface.update({"name": ifn}) host.addOne("network_interfaces", ifn, network_interface) host.metric_list = info["metric_groups"] host.last_arrival = time.time() session.setResource("all", host.id, host) session.setResource(host.__class__.__name__, host.id, host) session.setResource("active", host.ip, host) #session.root._p_changed = 1 session.commit() logger.info("%s(%s) signed in" % (host.id, host.ip))
def __init__(self, custom_id = None): self.eid = ID.get_id(self, custom_id = custom_id)
def __init__(self, custom_id=None): self.id = ID.get_id(self, custom_id = custom_id) #pylint:disable-msg=C0103,C0301 self._listeners = []