A compilation method for fully distributed intelligent building system applications

By converting the source program of a fully distributed intelligent building system application into a standardized semantic module and mapping it to the code of the underlying hardware platform, the complexity and heterogeneity problems of the compilation process are solved, and an efficient compilation and development process is achieved.

CN116974573BActive Publication Date: 2024-09-20ARMY ENG UNIV OF PLA
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202310842110.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-10
Publication Date
2024-09-20
Estimated Expiration
2043-07-10

AI Technical Summary

Technical Problem

In the compilation process of fully distributed intelligent building system applications, there is complexity caused by the semantic gap between the source language and the target language, as well as the heterogeneity of the target hardware platform, resulting in a complex compilation process and difficulty in cross-platform transplantation, which increases development difficulty and maintenance costs. .

Method used

By obtaining the source program for preprocessing and structured analysis, an abstract syntax tree is generated, converted into a standardized semantic module, and mapped with the code of the underlying hardware platform to generate a target instruction program for a fully distributed intelligent building system, realizing a high-level Direct translation of abstractions to low-level instructions.

Benefits of technology

It simplifies the compilation process, reduces the difficulty of direct compilation, eliminates the need for programmers to consider underlying communication details, improves development efficiency, and realizes an integrated process from application development to execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116974573B
    Figure CN116974573B
Patent Text Reader

Abstract

The present invention discloses a compilation method for a fully distributed intelligent building system application, comprising: obtaining a source program of the fully distributed intelligent building system application; preprocessing and structurally parsing the obtained source program in sequence to generate an abstract syntax tree; querying and accessing nodes of the abstract syntax tree, converting the source program of each node into a standardized semantic module; splicing and combining the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program; mapping each standardized semantic module in the logic diagram with the code of the underlying hardware platform to obtain segmented underlying code, and linking the segmented underlying code into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system based on the execution order of each standardized semantic module in the logic diagram. The present invention can solve the problem that a fully distributed intelligent building system application with a high-level abstraction cannot be directly recognized and executed by a target hardware platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a compiling method for a fully distributed intelligent building system application program, belonging to the technical field of architecture and computer. Background Art

[0002] Traditional centralized building control systems have problems such as difficulty in on-site configuration of system configuration, difficulty in system upgrade and transformation, and difficulty in realizing cross-system functions. The fully distributed intelligent building system is a new type of flat, centerless building intelligent platform, which regards the building as a large computing network connected by building space units and electromechanical equipment units according to spatial position relationships. All basic units in the system are equal, and each basic unit is equipped with an intelligent computing node with information processing and communication functions, which realizes various building control tasks through interaction and parallel collaboration between nodes.

[0003] The fully distributed intelligent building system programming language is aimed at engineers and users who are familiar with the knowledge of building control. It can intuitively depict the parallel computing mode of building domain elements and building control tasks, shield the underlying complex node communication details, and support concise programming of fully distributed intelligent building system applications. The fully distributed intelligent building system application provides a high-level abstract description of the distributed building control algorithm, but it cannot be directly deployed on the fully distributed intelligent building system platform for execution. The fully distributed intelligent building system application needs to be compiled into an executable target instruction program that can be recognized by the intelligent node.

[0004] However, there are two key issues in the process of compiling the fully distributed intelligent building system application into an executable target instruction program:

[0005] (1) The complexity of the compilation process caused by the semantic gap between the source language and the target language. The programming language used to develop the fully distributed intelligent building system application is a language oriented to building users. The logical description method it provides is in line with people's thinking habits. It is designed based on commonly used computer languages ​​and consists of elements such as expressions, functions, and statements. However, the target language is a program instruction defined from the perspective of the underlying distributed computer system, which does not conform to the expression habits of general users. These instructions only include operations on variables, function definition operations, definition and triggering operations of computing tasks (sequences), and flowchart definitions of the above operations. The description of the logic of building application tasks is completed by the flowcharts of these instructions. Therefore, the fully distributed intelligent building system application and the instruction program of the target platform adopt two completely different architectures. There are huge differences between the two in terms of language elements and program structure, which makes the compilation conversion process from the application to the target instruction program very complicated.

[0006] (2) Heterogeneity of target hardware platforms. The underlying hardware controllers of building systems with swarm intelligence and node interaction features may come from different manufacturers, with many types and different instruction set architectures. Compiler software needs to generate different target instructions based on different target hardware platforms, which leads to a lengthy and complex development process and difficulty in porting code across platforms. In addition, the instructions of the upper-level application and the lower-level hardware platform may be continuously improved and perfected. Any changes in either of them require the adjustment of the entire compiler software, which increases the maintenance cost of the compiler software. Summary of the invention

[0007] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a compilation method for a fully distributed intelligent building system application, which can solve the problem that the fully distributed intelligent building system application with high-level abstraction cannot be directly recognized and executed by the target hardware platform. To achieve the above purpose, the present invention is implemented by adopting the following technical solutions:

[0008] In a first aspect, the present invention provides a compiling method for a fully distributed intelligent building system application, comprising:

[0009] Get the source code of the fully distributed intelligent building system application;

[0010] The acquired source program is preprocessed and structured parsed in turn to generate an abstract syntax tree;

[0011] Query and access the nodes of the abstract syntax tree, convert the source program of each node into a standardized semantic module; splice and combine the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program;

[0012] The standardized semantic modules in the logic diagram are mapped to the code of the underlying hardware platform to obtain segmented underlying codes. Based on the execution order of the standardized semantic modules in the logic diagram, the segmented underlying codes are linked into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

[0013] In combination with the first aspect, optionally, the preprocessing and structured parsing are performed in sequence to generate an abstract syntax tree, including:

[0014] Format the acquired source program, delete comments, line breaks and redundant spaces in the source program, and obtain a preprocessed source program;

[0015] According to the regular expression rules of the program language elements, the preprocessed source program is divided into a plurality of program blocks;

[0016] Each line in each program block is parsed, the source program is parsed into an abstract syntax tree, and each program block is stored in a StringBuilder data structure to provide input information for the subsequent compilation stage.

[0017] In combination with the first aspect, optionally, the standardized semantic module includes: a standardized semantic module format table and a standardized semantic module type library;

[0018] The standardized semantic module format table includes: semantic module name M Name , semantic module type M Type , input variable Var In and output variable Var Out ;

[0019] The standardized semantic module type library is a mapping relationship between source program elements and their corresponding standardized semantic module types, including: standardized semantic modules for variable fields, standardized semantic modules for global parameter expressions, and standardized semantic modules for parallel statements.

[0020] In combination with the first aspect, optionally, converting the source program of each node into a standardized semantic module includes:

[0021] Convert the variable field used to describe the building distribution physical field in the source program of each node into a variable field standardized semantic module;

[0022] Convert the global parameter expressions in the source programs of each node that describe the distributed computing logic from the system global perspective into standardized semantic modules of the global parameter expressions;

[0023] The parallel statements in the source program of each node that describe the distributed computing logic from the perspective of the node local and its neighborhood are converted into standardized semantic modules of parallel statements.

[0024] In conjunction with the first aspect, optionally, converting the parallel statements in the source program of each node that describe the distributed computing logic from the perspective of the node local and its neighborhood into a standardized semantic module of the parallel statements includes:

[0025] Generate corresponding C language variables in C language according to the local parameters in the parallel statement, wherein the C language variables include: local input variable Ar, local output variable Aw and interactive variable X;

[0026] According to the conversion of the local parameter representing the neighbor node data in the parallel statement into a C language array, the sub-statement code of the parallel statement containing the local parameter is converted into a C language code;

[0027] Generate attribute codes representing various calculation attributes of the distributed building system according to the calculation domain and read-write attributes of the local parameters in the parallel statement;

[0028] Based on the C language variables, C language arrays, C language codes and attribute codes, a complete C program is generated, and the complete C program is embedded into a standardized semantic module of a parallel statement.

[0029] In conjunction with the first aspect, optionally, the step of splicing and combining the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program includes:

[0030] Taking each standardized semantic module as the basic unit, generate the name M of each standardized semantic module in the logic graph Name ;

[0031] Based on logical conditions Logic Set a logical judgment variable Var for each standardized semantic module Logic , the logical judgment variable Var Logic The corresponding temporary variable that carries the result of the conditional expression operation:

[0032] When the program is executed sequentially, the logical judgment variable is none;

[0033] When the program is not executed sequentially and has branches or jumps, the logical judgment variable is 0 or 1, and the corresponding subsequent standardized semantic module name M is generated. NextNameList ; When the logical judgment variable is 1, the name of the subsequent module of the current standardized semantic module is the name of the standardized semantic module executed after the conditions are met; when the logical judgment variable is 0, the name of the subsequent standardized semantic module of the current standardized semantic module is the name of the standardized semantic module executed when the conditions are not met.

[0034] In a second aspect, the present invention provides a compiling device for a fully distributed intelligent building system application, comprising:

[0035] Acquisition module: used to obtain the source program of the fully distributed intelligent building system application program;

[0036] Preprocessing module: used to preprocess and structurally parse the acquired source program in sequence to generate an abstract syntax tree;

[0037] Parsing module: used to query and access the nodes of the abstract syntax tree, convert the source program of each node into a standardized semantic module; splice and combine the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program;

[0038] Lower-layer mapping module: used to map the standardized semantic modules in the logic diagram with the code of the underlying hardware platform to obtain segmented underlying codes, and based on the execution order of the standardized semantic modules in the logic diagram, link the segmented underlying codes into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

[0039] In combination with the second aspect, optionally, the method further includes:

[0040] The upper standard interface is used to connect with a user-oriented fully distributed intelligent building system application with building domain characteristics and high-level programming abstraction;

[0041] The lower layer standard interface is used to connect to the underlying hardware platform of the fully distributed intelligent building system.

[0042] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the compilation method for a fully distributed intelligent building system application as described in the first aspect.

[0043] In a fourth aspect, the present invention provides a device, comprising:

[0044] A memory for storing instructions;

[0045] The processor is used to execute the instructions so that the device performs operations to implement the compilation method for the fully distributed intelligent building system application as described in the first aspect.

[0046] Compared with the prior art, the beneficial effects achieved by the compiling method for a fully distributed intelligent building system application provided by the embodiment of the present invention include:

[0047] The present invention obtains the source program of the fully distributed intelligent building system application program; performs preprocessing and structured parsing on the obtained source program in sequence to generate an abstract syntax tree; the present invention provides a unified data structure for the storage of the parsed source program through the abstract syntax tree, which is convenient for operation;

[0048] The present invention queries and accesses the nodes of the abstract syntax tree, converts the source program of each node into a standardized semantic module; splices and combines the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program; the upper layer of the present invention faces the source program, realizes semantic analysis and solution of the source program, sorts out the standardized semantic modules corresponding to the source program blocks, converts the source program to an intermediate layer representation, describes the actual execution order of the standardized semantic modules, and splices and combines the standardized semantic module sequence into a logic diagram;

[0049] The present invention maps each standardized semantic module in the logic diagram with the code of the underlying hardware platform to obtain segmented underlying codes, and based on the execution order of each standardized semantic module in the logic diagram, links the segmented underlying codes into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system; the present invention maps and generates a target instruction sequence for the hardware platform based on the standardized semantic module information given by the upper-level program and the execution relationship contained in the logic diagram;

[0050] The present invention converts special language elements such as variable fields, global parameter expressions, parallel statements, etc. in the application program into target instruction programs one by one. Based on the compilation of the intermediate layer data structure, the complex compilation process containing huge semantic gaps is decomposed into conversion steps from source program to standardized semantic module, semantic module to logic diagram, and logic diagram to underlying target instruction sequence. Each step completes a relatively simple specific compilation work, reducing the difficulty of direct compilation.

[0051] The present invention converts a user-oriented fully distributed intelligent building system application program with architectural field characteristics and high-level programming abstraction into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system, so that programmers do not need to consider the complex underlying communication details and interaction mechanisms of the nodes, but focus on the logic of the distributed building control management algorithm itself, thereby improving development efficiency;

[0052] The present invention can solve the problem that a fully distributed intelligent building system application with high-level abstraction cannot be directly recognized and executed by the target hardware platform, realize an integrated process from application development to execution, and meet the development needs of this type of hardware platform for a fully distributed intelligent building system. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 A fully distributed intelligent building system application programming model in a compilation method for a fully distributed intelligent building system application provided in the first embodiment of the present invention;

[0054] Figure 2 It is the core part of the abstract syntax of the programming language of the fully distributed intelligent building system in the compilation method for the fully distributed intelligent building system application provided in the first embodiment of the present invention;

[0055] Figure 3 It is a flowchart of a compiling method for a fully distributed intelligent building system application provided by the first embodiment of the present invention;

[0056] Figure 4 It is a flowchart of a preprocessing and structured parsing method in a compilation method for a fully distributed intelligent building system application provided in the first embodiment of the present invention;

[0057] Figure 5 This is a flowchart of converting a variable field standardized semantic module in a compilation method for a fully distributed intelligent building system application provided by the first embodiment of the present invention.

[0058] Figure 6 It is a flowchart of a standardized semantic module converted into a global parameter expression in a compilation method for a fully distributed intelligent building system application provided by the first embodiment of the present invention;

[0059] Figure 7 It is a flow chart of a standardized semantic module converted into parallel statements in a compilation method for a fully distributed intelligent building system application provided by the first embodiment of the present invention;

[0060] Figure 8 It is a schematic diagram of converting a sub-statement in a parallel statement into a C language code in a compilation method for a fully distributed intelligent building system application provided in the first embodiment of the present invention;

[0061] Fig. 9 It is a flow chart of obtaining a logic diagram in a compilation method for a fully distributed intelligent building system application provided in the first embodiment of the present invention;

[0062] Fig.10 It is a flow chart of obtaining a target instruction program for a fully distributed intelligent building system underlying hardware platform in a compilation method for a fully distributed intelligent building system application provided by the first embodiment of the present invention. DETAILED DESCRIPTION

[0063] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.

[0064] Embodiment 1:

[0065] like Figure 1 The figure shows a fully distributed intelligent building system application programming model in a compilation method for a fully distributed intelligent building system application provided by the present invention. The programming model defines the main domain concepts in the fully distributed intelligent building system and the fully distributed intelligent building system programming language elements and the relationships between them.

[0066] Smart nodes are the basic components of a fully distributed intelligent building system. Each node has a built-in standard information model that stores all building information in the area managed by the node in a standardized manner. Smart nodes are interconnected and interact to realize various building functions.

[0067] A domain is a functional sub-network composed of multiple intelligent nodes in a fully distributed intelligent building system according to certain constraints, such as a variable air volume air conditioning system. A domain specifies a set of nodes that run a certain application. The domain name is the unique identifier of the domain in the entire fully distributed intelligent building system.

[0068] Physical field elements represent the environment or system parameters distributed in the building, the feedback value and set value of the equipment operation status, and other physical quantities such as temperature and humidity. The physical field elements of each building basic unit are stored in the standard information model of the intelligent node in a unified format.

[0069] The variable field is mapped from the physical field elements. The variable field is the distribution field of quantities with specific meanings in the fully distributed intelligent building system, that is, the distribution data set of the quantity on the nodes. The variable field contains data and distribution attributes. Among them, the node type and domain name describe the distribution attributes of the variable, that is, on which nodes the variable has valid values. The data and update time describe the data attributes of the variable field. Since the variable field is globally defined for the fully distributed intelligent building system network, it is not convenient to directly substitute the variable field into the program operation when describing the specific calculation process of the building control task.

[0070] Parameters are the projections of variable fields on computational domains. Computational domains represent sets of nodes with specific functional roles commonly used in building control tasks, such as the initiation point for triggering network computing tasks and the upstream and downstream nodes in the spanning tree network topology. A domain is a static network or node set defined in a fully distributed intelligent building system, while a computational domain supports dynamic specification of the node range covered by a certain calculation, and is a general description method for defining the projection relationship between variable fields and parameters.

[0071] Therefore, parameters have attributes such as data, update time and calculation domain. When programming, you can flexibly select the calculation range according to the task requirements, substitute parameters of different node ranges into the expression calculation, and realize the corresponding network calculation task. The variable field, parameters and calculation domain in the fully distributed intelligent building system application are the basis for realizing the concise description of parallel computing tasks and the universal development of applications.

[0072] like Figure 2 Shown is the core part of the abstract syntax of the fully distributed intelligent building system programming language in a compilation method for fully distributed intelligent building system applications.

[0073] The domain definition statement DomainDef defines the name of the domain and specifies the constraints that make up the domain, including node type, node name, etc.

[0074] The variable field definition statement VarDef defines the variable field name corresponding to the building physical field, specifies the node type and domain name corresponding to the variable, and describes the distribution range of the variable's valid values.

[0075] Parameters represent the values ​​of a variable field projected onto one or more nodes. The parameter definition statement ParaDef defines the parameter name and specifies the name of the source variable field to which the parameter points, as well as the update time and calculation domain of the parameter.

[0076] The process definition statement PeriodicTrigger describes the start time, end time and trigger period of a certain building application task, where the trigger period is the interval period for executing sub-statements within this process.

[0077] The parallel statement SwarmParallelStmt constrains which nodes participate in the execution of the statement by specifying the node type and domain name. When a node in the building function system triggers the calculation as the starting point, all nodes that meet the constraint conditions process the statement in parallel.

[0078] The syntax of the fully distributed intelligent building system programming language is a mixture of imperative and functional constructs, some of which are similar to general programming languages, such as loops, branches, and partial expressions, which ensures that the learning curve for novice programmers is short, and the fully distributed intelligent building system programming language is easy to read and familiar.

[0079] like Figure 3 The flowchart of a compilation method for a fully distributed intelligent building system application is shown, comprising:

[0080] Get the source code of the fully distributed intelligent building system application;

[0081] The acquired source program is preprocessed and structured parsed in turn to generate an abstract syntax tree;

[0082] Query and access the nodes of the abstract syntax tree, convert the source program of each node into a standardized semantic module; splice and combine the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program;

[0083] The standardized semantic modules in the logic diagram are mapped to the code of the underlying hardware platform to obtain segmented underlying codes. Based on the execution order of the standardized semantic modules in the logic diagram, the segmented underlying codes are linked into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

[0084] The flow chart consists of three layers. The upper layer is oriented to the fully distributed intelligent building system application software, and the lower layer is oriented to the heterogeneous target hardware platform. Standardized semantic modules and logic diagrams constitute a universal middle-layer data structure.

[0085] At the upper layer, the acquired source program is preprocessed and structured parsed in turn to generate an abstract syntax tree and store it in the StringBuilder data structure. The nodes of the abstract syntax tree are queried and accessed, and the source program of each node is converted into a standardized semantic module according to the pre-established format library and type library of standardized semantic modules, as well as compilation algorithms such as variable field definition conversion algorithm, global parameter expression conversion algorithm, and parallel statement conversion algorithm. At the middle layer, according to the actual semantic execution order of the source program, the standardized semantic modules are spliced ​​and combined to obtain a logic diagram consistent with the actual execution order of the source program. At the lower layer, according to the mapping relationship between the semantic module and the underlying instruction sequence in the logic diagram, the logic diagram is converted into a target instruction sequence executable by the hardware platform.

[0086] The specific steps include:

[0087] Step 1: Get the source code of the fully distributed intelligent building system application.

[0088] Step 2: Preprocess and structure the obtained source program in turn to generate an abstract syntax tree.

[0089] This step performs structural analysis on the source program and stores it in categories to provide input for the subsequent compilation stage.

[0090] like Figure 4 As shown, the step includes:

[0091] Step 2.1: Format the acquired source program, delete comments, line breaks, and redundant spaces in the source program, and obtain a preprocessed source program to avoid ambiguity during compilation.

[0092] Step 2.2: According to the regular expression rules of program language elements, the preprocessed source program is divided into multiple program blocks.

[0093] Programming language elements include variable definitions, statements, and expressions.

[0094] Step 2.3: Parse each line in each program block, parse the source program into an abstract syntax tree, store each program block in a StringBuilder data structure, and provide input information for the subsequent compilation stage.

[0095] After lexical analysis, each type of programming language element is split into a string set consisting of several attribute information (such as keywords, variable names, operators and other terminal symbols). The StringBuilder data structure containing the TreeNode class is defined to provide a unified data structure and operation for the storage of the abstract syntax tree. The TreeNode class is mainly composed of attribute parameters such as name, type, and status, and is responsible for the structured storage of the abstract syntax tree information.

[0096] In addition, class methods such as getName, getType, and getExpr are provided to access and operate abstract syntax tree nodes.

[0097] Step 3: query and access the nodes of the abstract syntax tree, convert the source program of each node into a standardized semantic module; splice and combine the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program.

[0098] The standardized semantic module includes: a standardized semantic module format table and a standardized semantic module type library.

[0099] The standardized semantic module format table includes: semantic module name M Name , semantic module type M Type , input variable Var In and output variable Var Out .

[0100] The following table shows the standardized semantic module format:

[0101]

[0102] Semantic module name M Name It is the unique identifier of the semantic module in the entire logic graph, and is given by the upper-level compiler software when generating each standardized semantic module.

[0103] For semantic module type M Type ,Different types of language elements such as variable definitions, expressions, statements in the source program are ,classified into several types of semantic modules.

[0104] Input variable Var In Indicates that each type of semantic module corresponds to the corresponding input variables involved in the calculation and the output variable Var Out It means that each type of semantic module corresponds to the corresponding calculation result output variable.

[0105] Different types of semantic modules may have different numbers of input and output variables and description methods due to their different computing functions.

[0106] The standardized semantic module type library describes the expression form of the program language elements corresponding to each semantic module and the description method of related parameters. It is a mapping relationship between source program elements and their corresponding standardized semantic module types, and provides template information for generating semantic module sequences in the compilation phase, including: standardized semantic modules for variable fields, standardized semantic modules for global parameter expressions, and standardized semantic modules for parallel statements.

[0107] Step 3.1: query and access the nodes of the abstract syntax tree, and convert the source program of each node into a standardized semantic module.

[0108] Step 3.1.1: Convert the variable field used to describe the building distributed physical field in the source program of each node into a standardized semantic module of the variable field.

[0109] like Figure 5 The flowchart shown is a compilation method for converting the variable field used to characterize the building distribution physical field in the source program of each node into the variable field of the variable field standardized semantic module. First, the variable field definition statement is parsed and identified, and the name of the standardized semantic module is generated, which is automatically incremented based on the name of the last generated semantic module. The standardized semantic module type table is queried, and the type name of the generated semantic module is Var_Define, and the type code is 0x00000001. Then, the data attributes of the variable field definition statement are extracted in the abstract syntax tree, and the output information of the semantic module is generated by mapping, and the variable field name in the variable field definition statement, the set of node types with valid values ​​of the variable field, the functional system name corresponding to the variable field, and the data type of the variable field are sequentially mapped to the output information of the semantic module.

[0110] Step 3.1.2: Convert the global parameter expressions used to describe logical relationships and calculation contents in the source programs of each node into standardized semantic modules of the global parameter expressions.

[0111] like Figure 6 The flowchart of the global parameter expression compilation method for converting the global parameter expression that describes the distributed computing logic from the global perspective of the system in the source program of each node into a standardized semantic module of the global parameter expression is shown. The global parameter expression compilation method compiles the global parameter expression programmed from a global perspective in the source program into a corresponding standardized semantic module, which combines the general expression with the parallel operator. The fully distributed intelligent building system programming language allows programming users to describe the distributed computing logic of building control tasks from a global perspective. When describing the logic from a global perspective, the expressions used to describe the logical relationship or calculation content must be global expressions, that is, the relevant parameters in the expression are all global parameters.

[0112] The steps are as follows: Identify the global parameter expression statement and generate the name of the standardized semantic module, which is 1 plus the name of the previously generated semantic module. Extract the expression operator and the calculation domain properties of the left and right parameters, query the standardized semantic module type library and select to generate the semantic module type name and semantic module type code. For example, for the expression "temp1+5", if the calculation domain of the global parameter temp1 is global, that is, All, 5 is a constant and does not contain a calculation domain, the generated semantic module type name is "All_+_Value" and the semantic module type code is 0x00000024. Based on the operator and parameter information on both sides extracted from the abstract syntax tree, the output information of the global parameter expression semantic module is mapped and generated, and the left variable name and the right variable name are generated according to the parameter names on the left and right sides of the operator, that is, the input variables of the semantic module. And establish the semantic module output variable that carries the result of the expression operation, and finally generate the expression operator, thereby generating a complete global parameter expression semantic module.

[0113] Step 3.1.3: Convert the parallel statements containing local parameters in the source program of each node into standardized semantic modules of the parallel statements.

[0114] like Figure 7 The flowchart of the compiling method for converting parallel statements containing local parameters in the source program of each node into parallel statements of standardized semantic modules is shown.

[0115] Different from the global perspective adopted by global parameter expressions, parallel statements in fully distributed intelligent building system applications use information of the node local and its neighboring nodes to describe the computational logic, so all the parameters appearing in the statements are local parameters. The parallel statement compilation method converts parallel statements containing local parameters into corresponding standardized semantic module sequences. When describing the computational logic of the neighborhood scope, the syntax of the fully distributed intelligent building system programming language is similar to that of the general C language. Therefore, in order to utilize existing resources and reduce the difficulty of compilation, parallel statements are converted into standardized semantic modules with a portion of the C language program, so that the C language compiler can be directly called to compile the C program into target code and link it to the target instruction program.

[0116] The steps are as follows: identify parallel statements in the fully distributed intelligent building system application, generate the name of the standardized semantic module, query the standardized semantic module type library and select to generate the semantic module type name and semantic module type code. The subsequent compilation method mainly includes three key steps.

[0117] Step a: Generate corresponding C language variables in C language according to the local parameters in the parallel statement, and the C language variables include: local input variable Ar, local output variable Aw and interactive variable X.

[0118] Traverse the parallel statements and determine whether each parameter corresponds to a local input variable Ar, a local output variable Aw, or an interactive variable X according to the computational domain and read / write properties of the local parameters. Generate a sequence of Ara, Awb, and Xc variables (where a~1-n, b~1-m, c~1-k, n, m, and k are the number of variables of this type). Generate a mapping table between local parameter names and Ara, Awb, and Xc variable sequences.

[0119] Step b: converting the local parameters representing the neighbor node data in the parallel statement into a C language array, and converting the sub-statement code of the parallel statement containing the local parameters into a C language code.

[0120] Conversion of substatements in parallel statements to C language code. Local parameters with neighborhood computation domain attributes in parallel statements represent the data set of the parameter on certain nodes in the neighborhood. For example, the parameter Temp_N with the computation domain of AllNeighbors represents the numerical set of Temp_N on all neighbors observed from the perspective of this node. Although this description method is concise and intuitive, it is not allowed in the generalized C language, so it is necessary to convert the substatements involving local parameters into corresponding C language codes.

[0121] Figure 8 The following is a schematic diagram of the conversion of substatements in parallel statements to C language codes, which converts substatements in which the local parameter Parameter with the computational domain AllNeighbors participates into C language codes. First, create a corresponding C language array for each X variable converted in step (a). Take the array X_j[i] corresponding to the parameter Parameter in the parallel statement as an example. Construct a for loop statement, where i is a newly defined C language temporary variable used to record the number of for loops. The number of neighbor nodes contained in the computational domain AllNeighbors of the parameter Parameter is set to the incremental upper limit NeighborAmount. X_j[i] is used to replace the position of the parameter Parameter in the parallel statement for each loop, where X_j[i] represents the value of the Parameter parameter corresponding to the i-th neighbor, and then the C language code corresponding to the substatement is converted and generated.

[0122] Step c: Generate attribute codes representing various calculation attributes of the distributed building system according to the calculation domain and read-write attributes of the local parameters in the parallel statement.

[0123] The calculation properties such as how to trigger node calculation and the object of calculation result publication involve the complex details of the underlying calculation of the distributed system, which are difficult to display in parallel statements. During the compilation phase, it is necessary to convert the attribute values ​​corresponding to each calculation attribute according to the calculation domain of the parameter in the source program. Taking the calculation result publication object attribute as an example, it describes which neighbor nodes the result of a single calculation of a single node needs to be sent to.

[0124] On the premise that the X, Aw, and Ar variable sequences are obtained by conversion in step (a), the algorithm for generating the properties of the calculation result publishing object is as follows: When the parallel statement does not contain the local parameter corresponding to the X variable, it means that the calculation result will not be told to any neighbor node in this calculation, and the generated calculation result publishing object property is 050x00. When the last assignment of all X variables in the statement, the parameter calculation domain corresponding to the X variable on the left side of the equation is Downstreams, it means that the calculation result will be published to all downstream neighbors, and the generated calculation result publishing object property is 050x0F. Other situations are similar. In addition, other calculation properties such as how the node calculation logic is triggered and how to judge the completion of the calculation can also be obtained according to a similar algorithm. In summary, according to steps (a), (b), and (c), the parallel statement can be compiled into a standardized semantic module sequence.

[0125] Based on the C language variables, C language arrays, C language codes and attribute codes, a complete C program is generated, and the complete C program is embedded into a standardized semantic module of a parallel statement.

[0126] Step 3.2: The standardized semantic modules are spliced ​​and combined to obtain a logic diagram that is consistent with the actual execution order of the source program.

[0127] In the logic diagram, each semantic module consists of two parts, the semantic module name and the subsequent semantic module part.

[0128] The following table 2 shows the logical diagram structure:

[0129]

[0130] Considering the semantic module as the basic unit, the entire logic diagram can be fully described according to the name of the subsequent modules of each semantic module and the logical conditions for executing these subsequent modules, which reflects the actual execution order of the source program and the overall logic of the building operation task.

[0131] From the perspective of a certain semantic module in the logic graph, the logic graph can be represented as a four-tuple. Name It is the name of the semantic module concerned by the local logic diagram corresponding to this description, and is the unique identifier of the module in the entire logic diagram. NextNameListIndicates the names of the semantic modules that follow this semantic module, and is the unique identifier of each module in the entire logic diagram. Each semantic module can have multiple subsequent semantic modules, or no subsequent semantic module. The logical judgment variable name of the subsequent semantic module 1 to n is Var Logic Indicates the name of the logical judgment variable from this module to the subsequent 1 to n semantic modules, and is also the basis for synchronous and parallel execution between modules. Each module following this semantic module can be executed conditionally or unconditionally. In the logic diagram, the value of a variable is allowed to be used as a judgment condition to determine whether to execute. Logical condition Cond Logic Indicates that when the execution of the subsequent semantic module is conditional, this field describes the execution of the subsequent module, whether it is executed when the logic value of the corresponding judgment variable is 1 or when the logic value is 0. For example, when the value of the logic judgment variable is 0, the subsequent module M0 is executed, and when the value of the variable is 1, the subsequent module M1 is executed.

[0132] The logic diagram is composed of semantic modules arranged in the actual execution order of the source program, and can be described in the form of a flow chart. Based on these standardized logical relationship descriptions, the compiler lower-level software can accurately understand the meaning of the logic diagram and convert it into target instruction programs for different platforms. Although the logic diagram structure is flexible and corresponds to various possible logics, the description method of the execution sequence relationship between semantic modules is standardized. Based on these standardized logical relationship descriptions, the lower-level program can accurately understand the meaning of the upper-level program logic diagram, and then combine these segmented instruction sequences of the corresponding semantic modules according to the editing rules of the target instruction sequence, and finally obtain an instruction sequence that can be recognized and executed by the hardware platform.

[0133] like Fig. 9 As shown, specifically including:

[0134] Step 3.2.1: Taking each standardized semantic module as the basic unit, generate the name M of each standardized semantic module in the logic graph Name .

[0135] Traverse the semantic module sequence and transform the semantic modules one by one. Take each semantic module as the basic unit and first map the name of the semantic module in the generated logic graph.

[0136] Step 3.2.1: Based on logical condition Cond Logic Set a logical judgment variable Var for each standardized semantic module Logic , the logical judgment variable Var Logic A temporary variable that carries the result of the conditional expression operation.

[0137] In this embodiment, it is determined whether this module is a conditional expression semantic module. If it is not a conditional expression semantic module, it means that the semantic module is executed sequentially. When the program is executed smoothly, the logical judgment variable is none, the logical condition is also none, and the subsequent semantic module name is the semantic module plus 1.

[0138] When the conditional expression of this module is a semantic module, the program is not executed smoothly, the logical judgment variable is 0 or 1, and the corresponding subsequent standardized semantic module name M is generated. NextNameList .

[0139] The generated logic judgment variable is the output variable V of the conditional expression semantic module. The generated logic condition is 1. The name N1 of the subsequent semantic module generated is the name of the semantic module executed when the judgment condition (ie V==1) is met.

[0140] The logical judgment variable is then generated as the output variable V of the conditional expression semantic module, the generated logical condition is 0, and the name N2 of the subsequent semantic module is generated as the name of the semantic module executed when the judgment condition (i.e. V == 0) is not met. In this way, the corresponding description of the semantic module in the logic diagram is generated, and the next semantic module is converted until all modules in the standardized semantic module sequence are completely compiled and converted into logic diagrams.

[0141] Step 4: Map each standardized semantic module in the logic diagram with the code of the underlying hardware platform to obtain segmented underlying code, and based on the execution order of each standardized semantic module in the logic diagram, link the segmented underlying code into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

[0142] The compilation method from logic diagram to target instruction program converts the logic diagram corresponding to the application program of the fully distributed intelligent building system into the target instruction program that can be run by the building hardware platform. The Insect Intelligent Building (I2B) platform with flat and decentralized characteristics is used as a typical case of the fully distributed building system to illustrate the conversion from logic diagram to target instruction program. The Insect Intelligent Building platform regards the building as a distributed computing network connected by computing process nodes, and provides a low-level instruction sequence for the computing process node (CPN) operating system to support the runtime of the APP. As the target code, the CPN low-level instruction sequence contains basic operations such as variable definition, assignment, query, and function definition. The building operation control task is regarded as a low-level instruction sequence executed in a certain order. Since the generated semantic modules are standardized, a mapping relationship can be established between the logic diagram and the low-level instruction sequence. The corresponding low-level instruction can be configured for each semantic module in the logic diagram, which may be a certain instruction or a standardized combination of a series of instructions.

[0143] like Fig.10 As shown, it specifically includes: first, traverse each semantic module in the logic diagram, and generate the type code of the corresponding underlying instruction according to the type code of the semantic module. Then, for different types of semantic modules such as variable definition, global parameter expression, parallel statement, etc., map the data information therein to the information in the underlying instruction one by one. For example, for the global parameter expression semantic module, first generate the number of parameters contained in the expression, generate the calculation type of the underlying instruction according to the operator mapping, generate the name, data type and byte length of the Ar variable according to the information of the parameter on the right side of the operator, obtain the name, data type and byte length of the Aw variable according to the information of the parameter on the left side of the operator, and generate the scope and number of hops of the expression in the distributed computing network according to the function system VPN attribute and node type set attribute of the parameter. The conversion algorithm of the semantic module corresponding to other types of language elements is similar to this. Finally, according to the execution order relationship of the semantic modules in the logic diagram, these segmented underlying instruction sequences are linked to form a complete underlying instruction sequence, that is, the APP executable by the target hardware platform. So far, the compilation method gradually compiles the source program into an executable underlying instruction sequence for the fully distributed intelligent building system platform.

[0144] Embodiment 2:

[0145] The embodiment of the present invention provides a compiling device for a fully distributed intelligent building system application, comprising:

[0146] Acquisition module: used to obtain the source program of the fully distributed intelligent building system application program;

[0147] Preprocessing module: used to preprocess and structurally parse the acquired source program in sequence to generate an abstract syntax tree;

[0148] Parsing module: used to query and access the nodes of the abstract syntax tree, convert the source program of each node into a standardized semantic module; splice and combine the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program;

[0149] Lower-layer mapping module: used to map the standardized semantic modules in the logic diagram with the code of the underlying hardware platform to obtain segmented underlying codes, and based on the execution order of the standardized semantic modules in the logic diagram, link the segmented underlying codes into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

[0150] Specifically, it also includes:

[0151] The upper standard interface is used to connect with a user-oriented fully distributed intelligent building system application with building domain characteristics and high-level programming abstraction;

[0152] The lower layer standard interface is used to connect to the underlying hardware platform of the fully distributed intelligent building system.

[0153] Embodiment three:

[0154] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the compiling method for a fully distributed intelligent building system application as described in the first embodiment is implemented.

[0155] Embodiment 4:

[0156] An embodiment of the present invention provides a device, characterized by comprising:

[0157] A memory for storing instructions;

[0158] The processor is used to execute the instructions so that the device performs operations to implement the compilation method for the fully distributed intelligent building system application as described in the first embodiment.

[0159] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0160] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0161] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0162] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0163] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A compilation method for fully distributed intelligent building system applications, It is characterized in that include: Get the source code of the fully distributed intelligent building system application; The acquired source program is preprocessed and structured parsed in turn to generate an abstract syntax tree; Query and access the nodes of the abstract syntax tree, and convert the source program of each node into a standardized semantic module; The standardized semantic modules are combined and spliced ​​to obtain a logic diagram consistent with the actual execution order of the source program; Wherein, the standardized semantic module includes: a standardized semantic module format table and a standardized semantic module type library; The standardized semantic module format table includes: semantic module name M Name , semantic module type M Type , input variable Var In and output variable Var Out ; The standardized semantic module type library is a mapping relationship between source program elements and their corresponding standardized semantic module types, including: standardized semantic modules for variable fields, standardized semantic modules for global parameter expressions, and standardized semantic modules for parallel statements; The step of converting the source program of each node into a standardized semantic module includes: Convert the variable field used to describe the building distribution physical field in the source program of each node into a variable field standardized semantic module; Convert the global parameter expressions in the source programs of each node that describe the distributed computing logic from the system global perspective into standardized semantic modules of the global parameter expressions; Convert the parallel statements in the source program of each node that describe the distributed computing logic from the perspective of the node and its neighborhood into standardized semantic modules of parallel statements; The step of combining the standardized semantic modules to obtain a logic diagram consistent with the actual execution order of the source program includes: Taking each standardized semantic module as the basic unit, generate the name M of each standardized semantic module in the logic graph Name ; Based on logical conditions Logic Set a logical judgment variable Var for each standardized semantic module Logic , the logical judgment variable Var Logic The corresponding temporary variable that carries the result of the conditional expression operation: When the program is executed sequentially, the logical judgment variable is none; When the program is not executed sequentially and has branches or jumps, the logical judgment variable is 0 or 1, and the corresponding subsequent standardized semantic module name M is generated. NextNameList ; When the logic judgment variable is 1, the name of the subsequent module of the current standardized semantic module is the name of the standardized semantic module executed after the condition is met; when the logic judgment variable is 0, the name of the subsequent standardized semantic module of the current standardized semantic module is the name of the standardized semantic module executed when the condition is not met; The standardized semantic modules in the logic diagram are mapped to the code of the underlying hardware platform to obtain segmented underlying codes. Based on the execution order of the standardized semantic modules in the logic diagram, the segmented underlying codes are linked into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

2. The compiling method for a fully distributed intelligent building system application according to claim 1, It is characterized in that The preprocessing and structured parsing are performed in sequence to generate an abstract syntax tree, including: Format the acquired source program, delete comments, line breaks and redundant spaces in the source program, and obtain a preprocessed source program; According to the regular expression rules of the program language elements, the preprocessed source program is divided into a plurality of program blocks; Each line in each program block is parsed, the source program is parsed into an abstract syntax tree, and each program block is stored in a StringBuilder data structure to provide input information for the subsequent compilation stage.

3. The compiling method for a fully distributed intelligent building system application according to claim 1, It is characterized in that The method of converting the parallel statements in the source program of each node that describe the distributed computing logic from the perspective of the node and its neighborhood into a standardized semantic module of parallel statements includes: Generate corresponding C language variables in C language according to the local parameters in the parallel statement, wherein the C language variables include: local input variable Ar, local output variable Aw and interactive variable X; According to the conversion of the local parameter representing the neighbor node data in the parallel statement into a C language array, the sub-statement code of the parallel statement containing the local parameter is converted into a C language code; Generate attribute codes representing various calculation attributes of the distributed building system according to the calculation domain and read-write attributes of the local parameters in the parallel statement; Based on the C language variables, C language arrays, C language codes and attribute codes, a complete C program is generated, and the complete C program is embedded into a standardized semantic module of a parallel statement.

4. A compiling device for a fully distributed intelligent building system application based on the compiling method for a fully distributed intelligent building system application according to claim 1, It is characterized in that include: Acquisition module: used to obtain the source program of the fully distributed intelligent building system application program; Preprocessing module: used to preprocess and structurally parse the acquired source program in sequence to generate an abstract syntax tree; Parsing module: used to query and access the nodes of the abstract syntax tree, and convert the source program of each node into a standardized semantic module; The standardized semantic modules are combined and spliced ​​to obtain a logic diagram consistent with the actual execution order of the source program; Lower layer mapping module: used to map the standardized semantic modules in the logic diagram with the code of the underlying hardware platform to obtain segmented underlying codes, and based on the execution order of the standardized semantic modules in the logic diagram, link the segmented underlying codes into a target instruction program for the underlying hardware platform of the fully distributed intelligent building system.

5. The compiling device for a fully distributed intelligent building system application according to claim 4, It is characterized in that Also includes: Upper-level standard interface: used to connect with user-oriented fully distributed intelligent building system applications with building domain characteristics and high-level programming abstraction; Lower-layer standard interface: used to connect to the underlying hardware platform of the fully distributed intelligent building system.

6. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the compiling method for a fully distributed intelligent building system application program as described in any one of claims 1 to 3 is implemented.

7. A device, It is characterized in that include: A memory for storing instructions; A processor is used to execute the instructions so that the device performs operations to implement the compilation method for a fully distributed intelligent building system application as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • LLVM-based ST language compiling method and system and compiler

    CN110825384A

  • Blockchain intelligent contract security detection system based on static analysis

    CN112256271A

  • A distributed Internet of Things (IoT) system modeling language and its compilation method

    CN114936028A

  • System and method for creating a parser generator and associated computer program

    US20120191446A1

  • An apparatus for processing an abstract syntax tree being associated with a source code of a source program

    WO2016163901A1