CN105260177A - SiPESC platform based Python extension module development method - Google Patents
SiPESC platform based Python extension module development method Download PDFInfo
- Publication number
- CN105260177A CN105260177A CN201510602108.2A CN201510602108A CN105260177A CN 105260177 A CN105260177 A CN 105260177A CN 201510602108 A CN201510602108 A CN 201510602108A CN 105260177 A CN105260177 A CN 105260177A
- Authority
- CN
- China
- Prior art keywords
- python
- sipesc
- class
- platform
- function extension
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Stored Programmes (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses an SiPESC platform based Python extension module development method. The method is used for analyzing a global plug-in manager interface of an SiPESC platform and realizing the calling of an SiPESC platform plug-in by a Python script. The method particularly comprises the following steps of: step 1, initializing a global plug-in manager object, and obtaining a global function extension manager object; step 2, obtaining a function extension class name required to be loaded; step 3, determining whether a function extension class is registered, if the function extension class is registered, performing the step 4, and if the function extension class is not registered, dynamically registering the function extension class for Python, creating a function extension class Python object and returning; and step 4, calling a function object method, performing analysis and calculation, converting a calculation result into a PyObject type and returning.
Description
Technical field
The present invention relates to the field of computer digital animation Development of Module, a kind of Python expansion module development approach based on SiPESC platform particularly related to.
Background technology
The development of computer technology, make people no longer be confined to process numerical problem for the demand of scientific algorithm instrument, the problem such as to build of the computing systems such as the process of the large data collection of various form, the realization of new algorithm, database and internet all needs new tool to solve.
At present, although SiPESC platform has achieved the support to JavaScript script, we can by the most of functional modules on JavaScript language calling platform, but the Shortcomings in module is open of JavaScript language, i.e. the module of different tissues exploitation is difficult to realize easily integrated.Python, as the nowadays very powerful and exceedingly arrogant dynamic interpreted languages of object-oriented, becomes the preferred object of new script engine.
Traditional Python expansion module method for packing workload is large, lacks dirigibility development efficiency low, also cannot mate the opening of SiPESC platform, so the present invention adopts a kind of dynamic encapsulation method, realize the encapsulation of Python expansion module.
Therefore, prior art has yet to be improved and developed.
Summary of the invention
The object of the present invention is to provide a kind of Python expansion module development approach based on SiPESC platform, being intended to solve existing SiPESC platform uses the functional module of JavaScript language exploitation to be difficult to realize easily integrated, and Python expansion module method for packing workload is large, dirigibility development efficiency is low and cannot mate the technical matters of SiPESC platform opening.
Technical scheme of the present invention is as follows: a kind of Python expansion module development approach based on SiPESC platform, the method analyzes the overall plugin manager interface of SiPESC platform, realize Python script and call SiPESC platform plug-in, wherein, specifically comprise the following steps:.
Step 1, initialization overall situation plugin manager object, and obtain GF global functions extension manager to picture;
Step 2, obtains the Function Extension class title needing to load;
Step 3, whether arbitration functions extension class is registered, if this Function Extension class is registered, then performs step 4, if not registration, then to Python dynamic registration Function Extension class, creates Function Extension class Python object and returns;
Step 4, the method for calling function object, result of calculation is also changed into PyObject type and returns by analytical calculation.
The described Python expansion module development approach based on SiPESC platform, wherein, rreturn values all in described Python is all PyObject type.
The described Python expansion module development approach based on SiPESC platform, wherein, rreturn values all in SiPESC platform and parameter are QVariant type, be C type by PyObject type conversion, C type conversion is QVariant, thus realizes the conversion of PyObject type QVariant type.
The described Python expansion module development approach based on SiPESC platform, wherein, in described step 3, the mechanism to Python dynamic registration Function Extension class is that the Function Extension class of registration is only created when needs use.
The described Python expansion module development approach based on SiPESC platform, wherein, in described step 3, for realizing to Python dynamic registration Function Extension class, this dynamic registration mechanism needs the encapsulation first realizing MExtensionManager class.
The described Python expansion module development approach based on SiPESC platform, wherein, the method that the described encapsulation realizing MExtensionManager class uses is createExtension method; First inquire about this Function Extension class whether to register in Python engine, if unregistered, then first obtain the information object (MextensionInfo object) of Function Extension class, then according to the corresponding class of this information creating (if such parent is not registered in Python engine, then first can create parent), then register to Python by the class of establishment, the constructed fuction finally by class creates object and returns.
The described Python expansion module development approach based on SiPESC platform, wherein, described createExtension method have employed JIT technology, operationally bytecode is converted to machine code, by machine code storage function address.
The described Python expansion module development approach based on SiPESC platform, wherein, after the encapsulation completing MExtensionManager class, writes the initialization function of expansion module; The initialize method simultaneously calling MPluginManager class in SiPESC platform in initialization function completes platform initialization.
Beneficial effect of the present invention: the present invention, by carrying out initialization and acquisition to overall plugin manager object, then obtains the Function Extension class title of needs, then to Python dynamic registration Function Extension class, create Function Extension class Python object and return, the flow process can calling SiPESC platform plug-in function according to the step and Python expanding Python carrys out the main body frame of coding, solve the problem of the conversion between PyObject type and QVariant type, allow between PyObject type and QVariant type and can mutually change, SiPESC platform is made to use the functional module of Python exploitation can realize integrated easily, the encapsulation of MExtensionManager class is adopted to decrease the workload of Python expansion module method for packing, there is higher development efficiency and dirigibility, SiPESC platform can be mated open.
Accompanying drawing explanation
Fig. 1 is a kind of structural representation of the present invention.
Fig. 2 is another kind of structural representation of the present invention.
Fig. 3 is the programming of plugin manager class of the present invention.
Fig. 4 is the programming of Function Extension manager class of the present invention.
Embodiment
For making object of the present invention, technical scheme and advantage clearly, clearly, developing simultaneously referring to accompanying drawing, the present invention is described in more detail for embodiment.
As Figure 1-4, the invention discloses
Based on a Python expansion module development approach for SiPESC platform, the method analyzes the overall plugin manager interface of SiPESC platform, realizes Python script and call SiPESC platform plug-in, wherein, specifically comprise the following steps:.
Step 1, initialization overall situation plugin manager object, and obtain GF global functions extension manager to picture;
Step 2, obtains the Function Extension class title needing to load;
Step 3, whether arbitration functions extension class is registered, if this Function Extension class is registered, then performs step 4, if not registration, then to Python dynamic registration Function Extension class, creates Function Extension class Python object and returns;
Step 4, the method for calling function object, result of calculation is also changed into PyObject type and returns by analytical calculation.
Rreturn values all in Python of the present invention is all PyObject type.
In SiPESC platform of the present invention, all rreturn values and parameter are QVariant type, and be C type by PyObject type conversion, C type conversion is QVariant, thus realizes the conversion of PyObject type QVariant type.
Furtherly, in described step 3, the mechanism to Python dynamic registration Function Extension class is that the Function Extension class of registration is only created when needs use; Meanwhile, for realizing to Python dynamic registration Function Extension class, first this dynamic registration mechanism need the encapsulation realizing MExtensionManager class; After the encapsulation completing MExtensionManager class, write the initialization function of expansion module; The initialize method simultaneously calling MPluginManager class in SiPESC platform in initialization function completes platform initialization.
Furtherly, the method that the described encapsulation realizing MExtensionManager class uses is createExtension method; First inquire about this Function Extension class whether to register in Python engine, if unregistered, then first obtain the information object (MextensionInfo object) of Function Extension class, then according to the corresponding class of this information creating (if such parent is not registered in Python engine, then first can create parent), then register to Python by the class of establishment, the constructed fuction finally by class creates object and returns.
In real work, createExtension method of the present invention have employed JIT technology, operationally bytecode can be converted to machine code, by machine code storage function address.
Adopt technique scheme, the present invention needs to solve following technical matters:
1. the design of expansion module: due to Python expansion module more complicated, needs to realize much extra subsidiary function, and the flow process first calling SiPESC platform plug-in function according to the step of expansion Python and Python carrys out the main body frame of coding;
Conversion between 2.PyObject type and QVariant type: due in Python methodical rreturn value be all PyObject type, and its parameter also must be PyObject type, but on SiPESC platform, the methodical rreturn value of institute and parameter are QVariant type, therefore must realize the mutual conversion of PyObject type and QVariant type;
The encapsulation of 3.MExtensionManager class: in expansion module, ExtensionManager class is only had to be static defining, for realizing the loading of the Function Extension on SiPESC platform and calling, other Function Extension classes all by MExtensionManager class, register and call on Python engine, therefore, need to realize MExtensionManager class in expansion module;
4. the writing of initialization function: the initialization of overall plugin manager object completes with obtaining in the initialization function of expansion module, therefore, after the encapsulation completing MExtensionManager class, needs the initialization function writing expansion module.
Corresponding above-mentioned technical matters, the means of solution of the present invention correspond to:
1. adopt the method for dynamic encapsulation, make full use of the dynamic of SiPESC platform software system, realize the automatic packaging of any plug-in unit and source code need not be revised;
2.Python provides the API that PyObject type and C type are changed mutually, and the mutual transformation energy between QVariant and C type realizes easily, so just realizes the conversion of PyObject type and QVariant type by twice conversion;
The structure of 3.MExtensionManager class is consistent with SiPESC platform feature extension manager class, the method that what on expansion module, the method for class was finally called is also in fact on platform, to obtain Parameter Switch from script is Qt type, and pass to the correlation method of platform invoke Function Extension manager class, obtain rreturn value, then rreturn value is converted back PyObject type and export from script;
The API prototype creating a module in 4.Python is PyObject*Py_InitModule3 (char*name, PyMethodDef*methods, char*doc), because the dynamic perfromance of this expansion module, MExtensionManager class is only had to be just add in module when initialization, other classes are all dynamically added in use according to demand, so the module created must be an overall static variable, like this in each place of program, this variable can be used to add class; Meanwhile, in initialization function, the initialize method calling MPluginManager class in SiPESC platform is also needed to complete the initialization of platform.
Above-mentioned API is the abbreviation of English ApplicationProgrammingInterface, is meant to application programming interface; The English of CAE is computer-aided engineering, is also application simulation; The English of SiPESC is SoftwareIntegrationPlatformforEngineeringandScientificCo mputation, be meant to engineering and scientific algorithm Integrated Software platform, Python is a kind of object-oriented, explanation type computer programming language.
The flow process that the present invention can call SiPESC platform plug-in function according to the expansion step of Python and Python carrys out the main body frame of coding, allow between PyObject type and QVariant type can mutually change by Python, SiPESC platform is made to use the functional module of Python exploitation can realize integrated easily, the encapsulation of MExtensionManager class is adopted to decrease the workload of Python expansion module method for packing, there is higher development efficiency and dirigibility, SiPESC platform can be mated open.
Should be understood that, application of the present invention is not limited to above-mentioned citing, for those of ordinary skills, can be improved according to the above description or convert, and all these improve and convert the protection domain that all should belong to claims of the present invention.
Claims (8)
1., based on a Python expansion module development approach for SiPESC platform, the method analyzes the overall plugin manager interface of SiPESC platform, realizes Python script and call SiPESC platform plug-in, it is characterized in that, specifically comprise the following steps:
Step 1, initialization overall situation plugin manager object, and obtain GF global functions extension manager to picture;
Step 2, obtains the Function Extension class title needing to load;
Step 3, whether arbitration functions extension class is registered, if this Function Extension class is registered, then performs step 4, if not registration, then to Python dynamic registration Function Extension class, creates Function Extension class Python object and returns;
Step 4, the method for calling function object, result of calculation is also changed into PyObject type and returns by analytical calculation.
2. the Python expansion module development approach based on SiPESC platform according to claim 1, it is characterized in that, rreturn values all in described Python is all PyObject type.
3. the Python expansion module development approach based on SiPESC platform according to claim 1, it is characterized in that, rreturn values all in SiPESC platform and parameter are QVariant type, be C type by PyObject type conversion, C type conversion is QVariant, thus realizes the conversion of PyObject type QVariant type.
4. the Python expansion module development approach based on SiPESC platform according to claim 1, is characterized in that, in described step 3, the mechanism to Python dynamic registration Function Extension class is that the Function Extension class of registration is only created when needs use.
5. the Python expansion module development approach based on SiPESC platform according to claim 1 or 4, it is characterized in that, in described step 3, for realizing to Python dynamic registration Function Extension class, this dynamic registration mechanism needs the encapsulation first realizing MExtensionManager class.
6. the Python expansion module development approach based on SiPESC platform according to claim 5, is characterized in that, the method that the described encapsulation realizing MExtensionManager class uses is createExtension method; First inquire about this Function Extension class whether to register in Python engine, if unregistered, then first obtain the information object (MextensionInfo object) of Function Extension class, then according to the corresponding class of this information creating (if such parent is not registered in Python engine, then first can create parent), then register to Python by the class of establishment, the constructed fuction finally by class creates object and returns.
7. the Python expansion module development approach based on SiPESC platform according to claim 6, it is characterized in that, described createExtension method have employed JIT technology, operationally bytecode is converted to machine code, by machine code storage function address.
8. the Python expansion module development approach based on SiPESC platform according to claim 5, is characterized in that, after the encapsulation completing MExtensionManager class, write the initialization function of expansion module; The initialize method simultaneously calling MPluginManager class in SiPESC platform in initialization function completes platform initialization.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510602108.2A CN105260177A (en) | 2015-09-21 | 2015-09-21 | SiPESC platform based Python extension module development method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510602108.2A CN105260177A (en) | 2015-09-21 | 2015-09-21 | SiPESC platform based Python extension module development method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN105260177A true CN105260177A (en) | 2016-01-20 |
Family
ID=55099881
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510602108.2A Pending CN105260177A (en) | 2015-09-21 | 2015-09-21 | SiPESC platform based Python extension module development method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105260177A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106648932A (en) * | 2016-12-19 | 2017-05-10 | 四川长虹电器股份有限公司 | Python extended module-based multi-process share system and method |
CN107317722A (en) * | 2017-05-27 | 2017-11-03 | 北京奇艺世纪科技有限公司 | A kind of expansible system and method for data source |
CN107911401A (en) * | 2017-08-04 | 2018-04-13 | 上海壹账通金融科技有限公司 | Application plug-in expansion function methods and application server |
CN112882685A (en) * | 2019-11-29 | 2021-06-01 | 中国石油天然气股份有限公司 | Object extension method and device of object-oriented programming language |
CN112988279A (en) * | 2021-04-16 | 2021-06-18 | 广州南方卫星导航仪器有限公司 | Object processing method and device, electronic equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030149801A1 (en) * | 2001-12-12 | 2003-08-07 | Kushnirskiy Igor Davidovich | Scriptable plug-in application programming interface |
CN102929645A (en) * | 2012-11-23 | 2013-02-13 | 江苏现代造船技术有限公司 | Method utilizing embedded Python interpreter to realize secondary development of software system |
-
2015
- 2015-09-21 CN CN201510602108.2A patent/CN105260177A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030149801A1 (en) * | 2001-12-12 | 2003-08-07 | Kushnirskiy Igor Davidovich | Scriptable plug-in application programming interface |
CN102929645A (en) * | 2012-11-23 | 2013-02-13 | 江苏现代造船技术有限公司 | Method utilizing embedded Python interpreter to realize secondary development of software system |
Non-Patent Citations (3)
Title |
---|
TIMOTHY A.BUDD: "《面向对象编程导论(原书第3版)》", 30 September 2003, 北京:机械工业出版社 * |
刘志海等: "《C程序设计与案例分析》", 31 August 2014, 北京:清华大学出版社 * |
陈飙松等: ""基于SiPESC平台的Python扩展模块开发"", 《计算机辅助工程》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106648932A (en) * | 2016-12-19 | 2017-05-10 | 四川长虹电器股份有限公司 | Python extended module-based multi-process share system and method |
CN107317722A (en) * | 2017-05-27 | 2017-11-03 | 北京奇艺世纪科技有限公司 | A kind of expansible system and method for data source |
CN107317722B (en) * | 2017-05-27 | 2020-01-31 | 北京奇艺世纪科技有限公司 | data source extensible system and method |
CN107911401A (en) * | 2017-08-04 | 2018-04-13 | 上海壹账通金融科技有限公司 | Application plug-in expansion function methods and application server |
CN107911401B (en) * | 2017-08-04 | 2021-11-26 | 深圳壹账通智能科技有限公司 | Application plug-in extension function method and application server |
CN112882685A (en) * | 2019-11-29 | 2021-06-01 | 中国石油天然气股份有限公司 | Object extension method and device of object-oriented programming language |
CN112988279A (en) * | 2021-04-16 | 2021-06-18 | 广州南方卫星导航仪器有限公司 | Object processing method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Cotton | Obit: A development environment for astronomical algorithms | |
Daniel et al. | NeoEMF: A multi-database model persistence framework for very large models | |
CN105260177A (en) | SiPESC platform based Python extension module development method | |
Barrata et al. | DOLFINx: The next generation FEniCS problem solving environment | |
US9262158B2 (en) | Reverse engineering user interface mockups from working software | |
US10545739B2 (en) | LLVM-based system C compiler for architecture synthesis | |
Larsen et al. | Strawman: A batch in situ visualization and analysis infrastructure for multi-physics simulation codes | |
Ozik et al. | The ReLogo agent-based modeling language | |
CN113918195A (en) | Application interface updating method and device, electronic equipment and readable storage medium | |
CN111563253B (en) | Intelligent contract operation method, device, equipment and storage medium | |
Daniel et al. | Scalable queries and model transformations with the mogwai tool | |
Gong et al. | Geoprocessing in the Microsoft cloud computing platform-azure | |
Park et al. | A sharable format for multidisciplinary finite element analysis data | |
Jayaram et al. | Reorganizing CAD assembly models (as-designed) for manufacturing simulations and planning (as-built) | |
Kim et al. | Design of code template for automatic code generation of heterogeneous smartphone application | |
Markopoulos et al. | Massively parallel solution of elastoplasticity problems with tens of millions of unknowns using PermonCube and FLLOP packages | |
US11494463B2 (en) | Set operations using multi-core processing unit | |
Evans et al. | A scalable and adaptable solution framework within components of the community climate system model | |
Syschikov et al. | Visual development environment for OpenVX | |
CN110989995A (en) | Processing method and system for artificial intelligence application based on open source deep learning framework | |
Harrison et al. | Python's Role in VisIt. | |
Lichen | Model Integration and Model Transformation Approach for Multi-Paradigm Cyber Physical System Development | |
Hoshino et al. | Region-based reconstruction of an indoor scene using an integration of active and passive sensing techniques | |
CN103077284A (en) | Method and system for automatically generating auxiliary code file by using general text template | |
CN109542409B (en) | Storage method and device based on object-oriented design idea |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20160120 |
|
RJ01 | Rejection of invention patent application after publication |