plugins/svgui/svgui.py
changeset 73 5e1e3d46c0c9
parent 65 e55d6faee9d1
child 82 d7b4dd1f543f
equal deleted inserted replaced
72:dc107daa2135 73:5e1e3d46c0c9
   775         self.GenerateProgram(buildpath, progname)
   775         self.GenerateProgram(buildpath, progname)
   776         Gen_C_file = os.path.join(buildpath, progname+".cpp" )
   776         Gen_C_file = os.path.join(buildpath, progname+".cpp" )
   777         return [(Gen_C_file,"")],"",True
   777         return [(Gen_C_file,"")],"",True
   778     
   778     
   779     def BlockTypesFactory(self):
   779     def BlockTypesFactory(self):
   780         def generate_svgui_block(generator, block, body, link):
   780         def generate_svgui_block(generator, block, body, link, order=False):
   781             name = block.getInstanceName()
   781             name = block.getInstanceName()
   782             block_id = self.GetElementIdFromName(name)
   782             block_id = self.GetElementIdFromName(name)
   783             if block_id == None:
   783             if block_id == None:
   784                 raise ValueError, "No corresponding block found"
   784                 raise ValueError, "No corresponding block found"
   785             type = block.getTypeName()
   785             type = block.getTypeName()
   786             block_infos = self.GetBlockType(type)
   786             block_infos = self.GetBlockType(type)
   787             current_location = ".".join(map(str, self.GetCurrentLocation()))
   787             current_location = ".".join(map(str, self.GetCurrentLocation()))
   788             if not generator.ComputedBlocks.get(name, False):
   788             if not generator.ComputedBlocks.get(name, False) and not order:
   789                 for num, variable in enumerate(block.inputVariables.getVariable()):
   789                 for num, variable in enumerate(block.inputVariables.getVariable()):
   790                     connections = variable.connectionPointIn.getConnections()
   790                     connections = variable.connectionPointIn.getConnections()
   791                     if connections and len(connections) == 1:
   791                     if connections and len(connections) == 1:
   792                         parameter = "%sQ%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["inputs"][num][1]], current_location, block_id, num+1)
   792                         parameter = "%sQ%s%s.%d.%d"%("%", TYPECONVERSION[block_infos["inputs"][num][1]], current_location, block_id, num+1)
   793                         value = generator.ComputeFBDExpression(body, connections[0])
   793                         value = generator.ComputeFBDExpression(body, connections[0])
   794                         generator.Program += ("  %s := %s;\n"%(parameter, generator.ExtractModifier(variable, value)))
   794                         generator.Program += ("  %s := %s;\n"%(parameter, generator.ExtractModifier(variable, value)))
   795                 generator.ComputedBlocks[name] = True
   795                 generator.ComputedBlocks[block] = True
   796             if link:
   796             if link:
   797                 connectionPoint = link.getPosition()[-1]
   797                 connectionPoint = link.getPosition()[-1]
   798                 for num, variable in enumerate(block.outputVariables.getVariable()):
   798                 for num, variable in enumerate(block.outputVariables.getVariable()):
   799                     blockPointx, blockPointy = variable.connectionPointOut.getRelPosition()
   799                     blockPointx, blockPointy = variable.connectionPointOut.getRelPosition()
   800                     if block.getX() + blockPointx == connectionPoint.getX() and block.getY() + blockPointy == connectionPoint.getY():
   800                     if block.getX() + blockPointx == connectionPoint.getX() and block.getY() + blockPointy == connectionPoint.getY():