Пример #1
0
    def initialize(self, point):
        if point == None:
            point = NetP('editor')
        self.m_self = point
        point.m_dev = self
        point.m_permission = 0

        pt_text = tools_basic.getPoint(point, 'm_plainText', 'text')
        pt_pool = tools_basic.getPoint(point, 'm_pool', 'pool')
        pt_motor = tools_basic.getPoint(point, 'm_motor', 'compiler')
        pt_debugger = tools_basic.getPoint(point, 'm_debugger', 'debugger')
        pt_screen = tools_basic.getPoint(point, 'm_screen', 'screen')

        self.modifyPtStruct(pt_debugger, pt_motor, pt_pool)

        self.m_plainText = pt_text
        self.setReadPtr(pt_text)
        self.m_pool = Pool(pt_pool)
        self.m_motor = Motor(pt_motor)
        self.m_debugger = Debugger(pt_debugger)
        self.m_screen = Brain(pt_screen)
        self.m_pool.register(self.m_screen.m_self)
        self.m_pool.register(self.m_debugger.m_self)

        self.updateByPts()
        self.setFont(QFont('宋体'))
        self.setStyleSheet('font: 20px;')
        self.show()
Пример #2
0
    def updateSysPts(self):
        pt_x = tools_basic.getPoint(self.m_self, 'm_x')
        pt_y = tools_basic.getPoint(self.m_self, 'm_y')
        pt_height = tools_basic.getPoint(self.m_self, 'm_height')
        pt_width = tools_basic.getPoint(self.m_self, 'm_width')

        pt_x.m_name = str(self.geometry().x())
        pt_y.m_name = str(self.geometry().y())
        pt_width.m_name = str(self.geometry().width())
        pt_height.m_name = str(self.geometry().height())
Пример #3
0
    def updateByPts(self):
        pt_x = tools_basic.getPoint(self.m_self, 'm_x', '300')
        pt_y = tools_basic.getPoint(self.m_self, 'm_y', '300')
        pt_height = tools_basic.getPoint(self.m_self, 'm_height', '600')
        pt_width = tools_basic.getPoint(self.m_self, 'm_width', '300')

        x = int(pt_x.m_name)
        y = int(pt_y.m_name)
        width = int(pt_width.m_name)
        height = int(pt_height.m_name)

        self.setGeometry(x, y, width, height)
Пример #4
0
    def initialize(self, point):
        if point == None:
            point = NetP('compiler')
        self.m_self = point
        point.m_dev = self
        point.m_permission = 0

        pt_source = tools_basic.getPoint(point, 'm_source', 'incomingPool')
        pt_terms = tools_basic.getPoint(point, 'm_terms', 'list')
        self.m_inputs = pt_source.m_dev.m_pool
        self.m_terms = tools_basic.getPointByFormat(pt_terms, 'list')
        for term in self.m_terms:
            term.m_permission = 0

        print(self.info())
Пример #5
0
    def initialize(self, point):
        if point == None:
            point = NetP('library')
        self.m_self = point
        point.m_dev = self
        point.m_permission = 0

        pt_motor = tools_basic.getPoint(point, 'm_motor', 'compiler')
        pt_terms = tools_basic.getPoint(point, 'm_terms', 'list')

        self.m_motor = pt_motor.m_dev
        self.m_terms = tools_basic.getPointByFormat(pt_terms, 'list')
        for term in self.m_terms:
            term.m_permission = 0

        print(self.info())
Пример #6
0
    def initialize(self,point):
        if point==None:
            point=NetP('pool')
        self.m_self=point
        point.m_dev=self
        point.m_permission=0

        pt_lib=tools_basic.getPoint(point,'m_lib','actions')
        pt_contain=tools_basic.getPoint(point,'m_contain','points')
        pt_pool=tools_basic.getPoint(point,'m_pool','list')

        pt_lib.m_permission=0
        pt_contain.m_permission=0
        pt_pool.m_permission=0

        self.m_lib=Library(pt_lib)
        self.m_contain=pt_contain
        self.m_pool=tools_basic.getPointByFormat(pt_pool,'list')
Пример #7
0
    def initialize(self, point):
        if point == None:
            point = NetP('screen')
        self.m_self = point
        point.m_permission = 0
        point.m_dev = self

        pt_select = tools_basic.getPoint(point, 'm_select', 'list')
        self.m_select = tools_basic.getPointByFormat(pt_select, 'list')
Пример #8
0
 def loadTerm(self, code):
     sents = []
     try:
         sents = tools_basic.divideSents_tokener(code)
         pt_terms = tools_basic.getPoint(self.m_self, 'm_terms', 'list')
         for sent in sents:
             tools_basic.setPointByFormat(pt_terms, 'list.append', sent)
             sent.m_permission = 0
     except Exception as e:
         logging.exception(e)
     self.m_terms += sents
Пример #9
0
    def initialize(self, point):
        if point == None:
            point = NetP('debugger')
        self.m_self = point
        point.m_dev = self
        point.m_permission = 0

        pt_motor = tools_basic.getPoint(point, 'm_motor', 'compiler')
        if pt_motor.m_dev == None:
            self.m_motor = Motor(pt_motor)
        else:
            self.m_motor = pt_motor.m_dev
Пример #10
0
 def restoreContain(self,action):
     pt_pool=tools_basic.getPoint(self.m_self,'m_pool','list')
     list_pt=[]
     for pt in self.m_pool:
         if pt.m_permission!=0 and pt!=action:
             if pt.m_db[0]!=None and pt.m_db[0].m_permission==0:
                 continue
             if pt.m_db[1]!=None and pt.m_db[1].m_permission==0:
                 continue
             list_pt.append(pt)
     for pt in list_pt:
         tools_basic.setPointByFormat(pt_pool,'list.remove',pt)
         self.m_pool.remove(pt)
         pt.delete()
     del list_pt[:]
     list_pt=tools_basic.buildPoints_tokener(self.m_contain.m_text)
     tools_basic.setPointByFormat(pt_pool,'list.+=',list_pt)
     self.m_pool+=list_pt
Пример #11
0
 def input(self,points,mode=1):
     if points==[]:
         return
     pt_pool=tools_basic.getPoint(self.m_self,'m_pool','list')
     points_new=[]
     origin=None
     for pt in self.m_pool:
         if pt.m_name=='诞生地':
             origin=pt
             break
     for point in points:
         if point not in self.m_pool:
             points_new.append(point)
             if origin!=None:
                 point.m_pos=origin.m_pos.copy()
     self.m_pool+=points_new
     tools_basic.setPointByFormat(pt_pool,'list.+=',points_new)
     if points_new!=[]:
         if mode==1:
             self.operate(points_new)
         self.update()
Пример #12
0
 def removeSel(self, point):
     if point not in self.m_select:
         return
     self.m_select.remove(point)
     pt_select = tools_basic.getPoint(self.m_self, 'm_select', 'list')
     tools_basic.setPointByFormat(pt_select, 'list.remove', point)
Пример #13
0
 def clear(self):
     pt_pool=tools_basic.getPoint(self.m_self,'m_pool','list')
     tools_basic.setPointByFormat(pt_pool,'list.clear')
     self.m_pool.clear()
     self.update()
Пример #14
0
 def clearTerm(self):
     self.m_terms.clear()
     pt_terms = tools_basic.getPoint(self.m_self, 'm_terms', 'list')
     tools_basic.setPointByFormat(pt_terms, 'list.clear')
Пример #15
0
 def modifyPtStruct(self, pt_debugger, pt_motor, pt_pool):
     tools_basic.setPoint(pt_debugger, 'm_motor', pt_motor)
     tools_basic.setPoint(pt_motor, 'm_source', pt_pool)
     pt_lib = tools_basic.getPoint(pt_pool, 'm_lib')
     tools_basic.setPoint(pt_lib, 'm_motor', pt_motor)
Пример #16
0
    def operate(self,points):
        actions,outputs=self.divPts(points)
        self.input(outputs,0)
        pt_pool=tools_basic.getPoint(self.m_self,'m_pool','list')

        while len(actions)>0:
            action=actions.pop()
            # self.printActionStack(actions,action)
            if action.m_name=='[删除]' or action.m_name=='[del]':
                obj=None
                if action.m_db[1]!=None and action.m_db[1].m_permission!=0:
                    obj=action.m_db[1]
                    print('删除\"'+obj.info(1)+'\"')
                action.con(None,None)
                if obj in self.m_pool:
                    tools_basic.setPointByFormat(pt_pool,'list.remove',obj)
                    obj.delete()
                    self.m_pool.remove(obj)
                if obj in outputs:
                    obj.delete()
                    outputs.remove(obj)
            elif action.m_name=='[左连]' or action.m_name=='[lt_connect]':
                sbj=action.m_db[0]
                obj=action.m_db[1]
                action.con(None,None)
                if sbj!=None and sbj.m_permission!=0:
                    sbj.disconnect_i(0)
                    if obj!=None:
                        sbj.connect(obj,0)
            elif action.m_name=='[右连]' or action.m_name=='[rt_connect]':
                sbj=action.m_db[0]
                obj=action.m_db[1]
                action.con(None,None)
                if sbj!=None and sbj.m_permission!=0:
                    sbj.disconnect_i(1)
                    if obj!=None:
                        sbj.connect(obj,1)
            elif action.m_name=='[写入]' or action.m_name=='[write]':
                sbj=action.m_db[0]
                obj=action.m_db[1]
                action.con(None,None)
                if sbj!=None and obj!=None:
                    obj.m_name=sbj.m_name
                    obj.m_text=sbj.m_text
            elif action.m_name=='[检查连接节点]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None:
                    list_pt=[]
                    for con in obj.m_con:
                        if con.m_permission!=0:
                            list_pt.append(con)
                    if list_pt!=[]:
                        print(obj.info()+'的连接节点:')
                        tools_basic.printPtList(list_pt)
                        self.input(list_pt,0)
            elif action.m_name=='[推入]' or action.m_name=='[push]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None and obj not in self.m_pool:
                    tools_basic.setPointByFormat(pt_pool,'list.append',obj)
                    self.m_pool.append(obj)
            elif action.m_name=='[弹出]' or action.m_name=='[pop]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None and obj in self.m_pool:
                    tools_basic.setPointByFormat(pt_pool,'list.remove',obj)
                    self.m_pool.remove(obj)
            elif action.m_name=='[移动到]' or action.m_name=='[moveTo]':
                sbj=action.m_db[0]
                obj=action.m_db[1]
                action.con(None,None)
                if sbj!=None and obj!=None:
                    sbj.m_pos[0]=obj.m_pos[0]
                    sbj.m_pos[1]=obj.m_pos[1]
            elif action.m_name=='[载入]' or action.m_name=='[load]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None:
                    self.m_lib.loadLib(obj.m_name)
                    obj.delete()
                    if obj in self.m_pool:
                        tools_basic.setPointByFormat(pt_pool,'list.remove',obj)
                        self.m_pool.remove(obj)
                    if obj in outputs:
                        outputs.remove(obj)
                elif action.m_text!='':
                    self.m_lib.loadLib(action.m_text)
            elif action.m_name=='[打开]' or action.m_name=='[open]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None:
                    tools_acts.openFile(obj.m_name)
            elif action.m_name=='[显示函数库]':
                self.m_lib.print()
                action.con(None,None)
            elif action.m_name=='[显示节点]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None:
                    print(obj.info(1))
            elif action.m_name=='[上点]' or action.m_name=='[up]':
                sbj=action.m_db[0]
                action.con(None,None)
                if sbj!=None:
                    action.m_pos[0]=sbj.m_pos[0]
                    action.m_pos[1]=sbj.m_pos[1]-1
            elif action.m_name=='[下点]' or action.m_name=='[down]':
                sbj=action.m_db[0]
                action.con(None,None)
                if sbj!=None:
                    action.m_pos[0]=sbj.m_pos[0]
                    action.m_pos[1]=sbj.m_pos[1]+1
            elif action.m_name=='[左点]' or action.m_name=='[left]':
                sbj=action.m_db[0]
                action.con(None,None)
                if sbj!=None:
                    action.m_pos[0]=sbj.m_pos[0]-1
                    action.m_pos[1]=sbj.m_pos[1]
            elif action.m_name=='[右点]' or action.m_name=='[right]':
                sbj=action.m_db[0]
                action.con(None,None)
                if sbj!=None:
                    action.m_pos[0]=sbj.m_pos[0]+1
                    action.m_pos[1]=sbj.m_pos[1]
            elif action.m_name=='[显示器]' or action.m_name=='[命令行]' or action.m_name=='[调试器]' \
                or action.m_name=='[Brain]' or action.m_name=='[Mouth]' or action.m_name=='[Hand]':
                tools_acts.createDev(action)
                action.m_name=action.m_name[1:-1]
                action.m_creator='System'
            elif action.m_name=='[更新设备]' or action.m_name=='[updateDev]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None:
                    tools_acts.updateDev(obj)
            elif action.m_name=='[输入端接入]':
                if action.m_db[0]==self.m_self:
                    self.register(action.m_db[1],1)
                action.con(None,None)
            elif action.m_name=='[输出端接入]':
                if action.m_db[0]==self.m_self:
                    self.register(action.m_db[1],0)
                action.con(None,None)
            elif action.m_name=='[输入端拔出]':
                if action.m_db[0]==self.m_self:
                    self.signout(action.m_db[1],1)
                action.con(None,None)
            elif action.m_name=='[输出端拔出]':
                if action.m_db[0]==self.m_self:
                    self.signout(action.m_db[1],0)
                action.con(None,None)
            elif action.m_name=='[清空词条]' or action.m_name=='[clearTerm]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None and obj.m_dev!=None:
                    obj.m_dev.clearTerm()
                    print(obj.m_dev.info())
            elif action.m_name=='[导入词条]' or action.m_name=='[loadTerm]':
                obj=action.m_db[1]
                code=action.m_text
                action.con(None,None)
                if obj!=None and code!='':
                    obj.m_dev.loadTerm(code)
                    print(obj.m_dev.info())
            elif action.m_name=='[编辑文本]':
                sbj=action.m_db[0]
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None and sbj!=None and sbj.m_dev!=None:
                    sbj.m_dev.setReadPtr(obj)
            elif action.m_name=='[保存内景节点]' or action.m_name=='[savePool]':
                self.saveContain(action)
            elif action.m_name=='[恢复内景节点]' or action.m_name=='[loadPool]':
                self.restoreContain(action)
            elif action.m_name=='[生成算式]':
                obj=action.m_db[1]
                if obj!=None and obj.m_text!=None:
                    points_new=tools_parsers.eqn2struct(obj.m_text)
                    if points_new!=[]:
                        outputs+=points_new
                        self.input(points_new,0)
                        obj.connect(points_new[0],1)
                action.con(None,None)
            elif action.m_name=='[显示算式]':
                obj=action.m_db[1]
                action.con(None,None)
                if obj!=None:
                    str_eqn=tools_parsers.struct2Eqn(obj)
                    print(str_eqn)
            elif action.m_name=='[打开smilei]':
                points_new=tools_parsers.Smilei2struct(action.m_text)
                if points_new!=[]:
                    outputs+=points_new
                    self.input(points_new,0)
                action.con(None,None)
            else:
                points_new=self.m_lib.transfer(action)
                actions_new,outputs_new=self.divPts(points_new)
                actions+=actions_new
                outputs+=outputs_new
                self.input(outputs_new,0)
            if action in self.m_pool:
                action.con(None,None)
                tools_basic.setPointByFormat(pt_pool,'list.remove',action)
                self.m_pool.remove(action)

        return outputs
Пример #17
0
 def updateMotor(self):
     pt_motor = tools_basic.getPoint(self.m_self, 'm_motor', 'compiler')
     self.m_motor = pt_motor.m_dev
Пример #18
0
 def addSel(self, point):
     self.m_select.append(point)
     pt_select = tools_basic.getPoint(self.m_self, 'm_select', 'list')
     tools_basic.setPointByFormat(pt_select, 'list.append', point)
Пример #19
0
 def clearSel(self):
     self.m_select.clear()
     pt_select = tools_basic.getPoint(self.m_self, 'm_select', 'list')
     tools_basic.setPointByFormat(pt_select, 'list.clear')
Пример #20
0
 def popSel(self):
     self.m_select.pop()
     pt_select = tools_basic.getPoint(self.m_self, 'm_select', 'list')
     tools_basic.setPointByFormat(pt_select, 'list.pop')
Пример #21
0
 def renew(self,points):
     pt_pool=tools_basic.getPoint(self.m_self,'m_pool','list')
     tools_basic.setPointByFormat(pt_pool,'list.clear')
     self.m_pool.clear()
     self.input(points)