Summary of the invention
The technical problem to be solved in the present invention is, at the defective that the above-mentioned processing time is long, system effectiveness is lower of prior art, provides in distributed principal and subordinate's machine communication that a kind of processing time is short, system effectiveness is higher processing method and device to the slave parameter.
The technical solution adopted for the present invention to solve the technical problems is: construct in a kind of distributed principal and subordinate's machine communication the processing method of slave parameter, comprise the steps:
A) setting is numbered corresponding slave device numbering table with slave;
B) the slave parameter type is set, and, every type slave parameter length and initial address is set according to above-mentioned slave device numbering table and slave parameter type;
C) according to main frame current receive orders or ask in included slave addresses, parameter type, action type, obtain the parameter address that it will be operated, thereby obtain or upgrade the value of this parameter, and immediately or behind the traversal slave this parameter value is transmitted or operates according to order or request.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, described steps A) table of slave device numbering described in comprises a plurality of first modules with equal length, the corresponding slave of each first module, each first module comprises a bank bit at least, and the value of storing in the described first module is its corresponding slave addresses.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, described a plurality of first modules join end to end according to the slave numbering.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, described step B) further comprise:
B1) the slave parameter type is set, every type comprises a parameter, sets the storage mode of each parameter, comprises array;
B2) establish described slave device numbering table and comprise N first module, parameter then is set comprises N+1 Unit second, described Unit second comprises a bank bit at least; The type parameter of first storage host in described Unit second, all the other store slave the type parameter respectively, are arranged in after described first Unit second and corresponding one by one with slave by slave numbering;
B3) initial address and the length of each parameter are set, form slave configuration chained list.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, described step C) further comprise the steps:
C10) judge that whether the current command is inquired about from machine information, carries out next step in this way;
C11) resolve above-mentioned querying command and obtain corresponding slave device address and parameter type;
C12) according to above-mentioned slave device address, inquire about described device numbering table, obtain its corresponding slave numbering;
C13) according to the above-mentioned parameter type, inquire about described slave configuration chained list, obtain the initial address of the type parameter;
C14) according to step C12) and result C13), take out and be stored in the slave supplemental characteristic of main frame and the relevant position of depositing the packet that is ready for sending away.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, also comprise being provided for sending the control chained list that parameter is provided with order the corresponding control chained list of each slave to slave; Described step C) further comprises the steps:
C20) judge that whether the current command is provided with the slave parameter command, carries out next step in this way;
C21) resolve above-mentioned querying command and obtain corresponding slave numbering, parameter type and this parameter value;
C22) according to the above-mentioned slave numbering that obtains, inquire about described slave device numbering table, obtain this slave addresses of its correspondence;
C23) according to the above-mentioned parameter type that obtains, inquire about described slave configuration chained list, obtain the initial address of the type parameter;
C24) according to step C22) and result C23), with step C21) parameter value that obtains deposits its relevant position in;
C25) with step C21) parameter value that obtains put into be ready for sending from the pairing control chained list of corresponding slave and send or the traversal parameter type after send to this slave.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, described step C) further comprise the steps:
C30) judge that whether current request is slave reporting types packet, carries out next step in this way;
C31) resolve this packet and obtain reporting the address of slave and the parameter type that reports, and refresh the corresponding data in the main frame;
C32) will be somebody's turn to do the relevant position of depositing the packet that is ready for sending upper level equipment from machine data.
In the processing method to the slave parameter in a kind of distributed principal and subordinate's machine communication of the present invention, described step C) further comprise the steps:
C40) main frame sends the order of poll from machine information;
C41) whether receive the echo message of above-mentioned polling order, carry out next step in this way;
C42) resolve this information, obtain slave addresses and alarm parameters value;
C43) this slave alarm parameter of storing in this slave alarm parameter in the information of relatively receiving and the main frame as inconsistent, squeezed into this slave alarm parameter the alarm status formation and is deposited the alarm parameter of receiving in the main frame this slave alarm parameter position;
The invention also discloses a kind of device that is used to realize the above-mentioned parameter processing method, comprising:
Slave numbering recognition device: be used for order of receiving or the slave addresses of asking and obtain the slave numbering or obtain slave addresses by the slave numbering according to main frame;
Slave argument address recognition device: be used for discerning order that main frame receives or request the slave parameter classification and in main frame the initial address of memory location;
Communication and control device: be used for order that receives according to main frame or the indication of asking, relevant parameter operated or inserted packet and be sent to slave or upper level equipment.
In method of the present invention, described communication and control device also comprise one first storage device, when this storage device was used for the parameter that transmits or handle at needs more than one, temporary transient storage needed the parameter value and slave addresses or the slave numbering that transmit or handle.
Implement in a kind of distributed principal and subordinate's machine communication of the present invention processing method and device to the slave parameter, has following beneficial effect: owing to dispose the parameter storage relative position that chained list provides the storage initial address of this type of slave supplemental characteristic and draws corresponding slave from slave device numbering table based on the slave slave, the handling process of having unified all slaves is so the processing time is short, system effectiveness is higher.
Embodiment
Fig. 1 is to the flow chart of processing method first embodiment of slave parameter in distributed principal and subordinate's machine communication of the present invention, its step comprises S11-S13, wherein, S11 and S12 are initial setting up, only work on power or carry out during system reset in system, when system's operate as normal, because above-mentioned S11-S12 has finished setting, so as long as it is according to the order of receiving S13 processing set by step.Being described in detail as follows of above steps:
S11 is provided with initial address, length and the content thereof of slave device numbering table: be provided with slave on the host stores device and number the initial address and the length of corresponding slave device numbering table, and described slave device numbering table is set; This slave device numbering table has been set up the contact between slave numbering and the slave addresses, thereby makes and can be obtained the address of slave or be obtained the numbering of slave by the address of slave by the slave numbering, referring to Fig. 2;
S12 is provided with the slave parameter type, and the length and the initial address of every type slave parameter is set: what at first will be provided with is that the parameter type of slave has how many kinds of, for example, and alarm parameter, operating state, temperature etc.; The parameter of each type is generally one, has comprised the parameter value of this type of all slaves in this parameter; Next is provided with the length and the initial address of these parameters, is convenient to can find these parameters when needed;
S13 is according to order or request, obtain or upgrade the value of this parameter, and transmit or operation: according to main frame current receive orders or ask in included slave addresses, parameter type, action type, obtain the parameter address that it will be operated, thereby obtain or upgrade the value of this parameter, and immediately or behind the traversal slave this parameter value is transmitted or operates according to order or request; In the present embodiment, this step is that main frame receives that the slave parameter that will be stored in the main frame after the order of inquiry slave parameter sends, and its concrete operating process has more detailed explanation after a while.
In the present embodiment, slave device numbering table comprises a plurality of first modules with equal length, the corresponding slave of each first module, each first module comprises a bank bit at least, the value of storing in the described first module is its corresponding slave addresses, and a plurality of first modules join end to end according to the slave numbering, referring to Fig. 2; What store in above-mentioned first module is the address of numbering corresponding slave with its slave, normally physical address; Because first module quantity is identical with slave quantity, and putting in order of above-mentioned first module is to join end to end according to the slave numbering, so first module is corresponding one by one with slave, known the slave numbering, can find the address of slave, know slave addresses equally, also can find the numbering of slave.
As shown in Figure 3, in the present embodiment, step S12 further comprises the steps:
S31 is provided with parameter type, number of parameters and storage mode:
S32 is provided with the Unit second in the parameter, sets the type parameter of first storage host, and all the other store slave the type parameter respectively, and corresponding one by one with slave:
S33 sets the original position and the length of each parameter, forms slave configuration chained list:
Fig. 4 is the flow chart of first embodiment of the invention step S13, and in the present embodiment, step S13 specifically comprises the steps:
S401 begins: step S13 originates in S401.
Whether S402 the current command is inquiry slave message command: main frame is resolved current order of receiving, confirms whether be inquiry slave message command, in this way, and execution in step S403; As not being execution in step S413.
The S403 resolve command obtains its corresponding slave numbering: comprised the slave numbering in the order, this step extracts this slave numbering.
S404 inquiry slave device numbering table obtains corresponding slave addresses: the slave that said extracted goes out is numbered as index, look into slave device numbering table, obtain its corresponding slave addresses.
The S405 resolve command obtains its corresponding parameters type: also comprised the slave parameter type that will inquire about in the order, this step extracts this slave parameter type.
S406 obtains the initial address of the type parameter storage for search index slave configuration chained list by type: the slave parameter type that said extracted is gone out is as index, look into slave configuration chained list, obtain the initial address that its corresponding slave type parameter is stored in main frame.
S407 takes out the relevant position that the slave supplemental characteristic that is stored in main frame is deposited packet in order by the initial address of slave addresses and parameter storage: because the initial address of known slave parameter storage and the numbering of slave, the type parameter that main frame can utilize a simple add operation to obtain this slave is stored in specific address in the main frame, and then read this data, and be stored in the relevant position of corresponding data bag; If the parameter of inquiring about in the mentioned order comprises parameter or a plurality of dissimilar parameter of same slave or a plurality of dissimilar parameter of a plurality of slaves of the same type of a plurality of slaves, also all be the relevant position of obtaining and deposit in the corresponding data bag by above-mentioned steps one by one; Said method has been realized disposing the parameter storage relative position that chained list provides the storage initial address of this type of slave supplemental characteristic and draws corresponding slave from the device numbering table of slave based on slave parameter type and slave slave.The characteristics of this processing method are the handling processes of having unified all slaves; So because that data are stored in the main frame group speed packet fully is also fast, the method for searching target component is simple, has realized the fully isolation related with the programming of slave of tension management equipment, the realization of the tissue that helps encoding helps maintenance.
S408 puts the flag bit that sends query response information: when the parameter of order request inquiry has obtained, will send the flag bit set of query response information, main frame enters answers the querying command flow process.
Other flow processs of S413: judge that in step S402 order is not when inquiring about from machine information, to carry out other operations.
Fig. 5 is the flow chart of the step that step S13 is further comprised in the second embodiment of the invention, in second embodiment and described in the back the 3rd embodiment and the 4th embodiment, each embodiment compares with first embodiment, step S11 among each embodiment, S12 are identical, difference only is that the particular content of its step S13 is different and different according to the order of being received, before execution in step S13, also set up in a second embodiment and be used for sending the control chained list that parameter is provided with order the corresponding control chained list of each slave to slave.
In a second embodiment, step S13 realizes by following flow process:
S501 begins: step S13 originates in S501.
Whether S502 the current command is that the slave parameter command is set: main frame is resolved current order of receiving, whether confirm for the slave parameter command is set, in this way, execution in step S503; As not being execution in step S513.
S503 resolves this order is set, and obtain corresponding slave addresses: in this step, what the order that the main frame parse upper layers is sent obtained is the numbering of slave, obtains slave addresses by inquiry slave device numbering table.
S504 resolves this order is set, and obtains the parameter type that will be provided with: the parameter type that be provided with may be one, also may be a plurality of; Equally, the related slave among the step S503 also can be for one or more.
S505 take this type as search index slave configuration chained list, obtain the initial address of this type of parameter storage: the slave parameter type that step S503 is extracted is as index, look into slave configuration chained list, obtain the initial address that its corresponding slave type parameter is stored in main frame.
S506 takes out from order is set parameter is set, be stored in the data storage location of the corresponding slave of such parameter in the main frame: because the initial address of known slave parameter storage and the numbering of slave, the type parameter that main frame can utilize a simple add operation to obtain this slave is stored in specific address in the main frame, and then will be stored in this particular location by the parameter value that obtains in the order, this parameter value that is about to be stored in this slave in the main frame refreshes.
S507 puts the controlled flag position of corresponding slave, and the parameter that will be provided with is squeezed into the dynamic control chained list of the slave that will be provided with: this step will be joined by the parameter value that order obtains in should the dynamic control chained list of slave, prepare to send configuration order to slave.Above-mentioned steps (S503-S507) has been described the setting of single parameter in the single slave, if the parameter that is provided with in the mentioned order comprises parameter or a plurality of dissimilar parameter of same slave or a plurality of dissimilar parameter of a plurality of slaves of the same type of a plurality of slaves, also all be obtain one by one, deposit the relevant position of main frame in and add the pairing dynamic control chained list of corresponding slave by above-mentioned steps.
S508 traversal slave controlled flag position, invalid as flag bit, then continue next flag bit; Effectively then put into as flag bit and to send buffer area and to finish traversal back execution in step S509 according to the dynamic Quality Initiative table organization control data order bag of corresponding slave;
S509 puts serial ports and sends sign: require main frame to carry out the program that sends data to slave.
S510 responds to being provided with successfully of slave: wait for the slave response, as all responding, execution in step S511 as responding, continues to carry out this step, waits for the slave response.
The S511 tissue is provided with the information response of success and sends the equipment of this order: inform that its order of this equipment is performed.
Other flow processs of S513: judge that in step S502 order is not when the slave parameter is set, to carry out other operations.
Fig. 6 is the flow chart of the step that step S13 is further comprised in the third embodiment of the invention, and in the 3rd embodiment, step S13 further comprises the steps:
S601 begins: step S13 originates in S601.
Whether what S602 received is the type data packets that reports from machine information: main frame is resolved the current information of receiving, confirms whether be the type data packets that reports, in this way, and execution in step S503; As not being execution in step S513.
S603 sends to slave and successfully receives the reporting information confirmation: send confirmation to this slave immediately after main frame is received packet.
S604 analytical information bag obtains the slave numbering of this packets of information: slave addresses by extracting in this packets of information, is obtained the slave numbering by searching slave device numbering table.
S605 analytical information bag obtains the parameter type that this slave reports: the parameter type that slave is reported is by extracting in this packets of information, and refreshes the corresponding data in the main frame.
S606 group slave reported data bag: main frame makes up the reported data bag that sends to tension management equipment according to slave numbering and the parameter type that above-mentioned analysis obtains.
S607 puts and sends data to the upper layer device flag bit: main frame is responsible for sending above-mentioned reported data bag to tension management equipment.
Other flow processs of S613: judgement information is not the type data packets that reports in step S602, carries out other operations.
Fig. 7 is the flow chart of the step that step S13 is further comprised in the fourth embodiment of the invention, and in the 4th embodiment, step S13 further comprises the steps:
S701 begins: step S13 originates in S701.
S702 sends poll slave message command: main frame sends poll slave message command to slave.
Whether S703 receives the polling order echo message: whether the main frame interpretation receives the echo message of this polling order that slave is beamed back, as receives, execution in step S704; Otherwise, execution in step S713.
Alarm parameters value and the alarm parameters value that is stored in the main frame in S704 storage and the comparison echo message, as inconsistent this parameter value is squeezed into alarm parameter counter-rotating formation: each poll, can upgrade the alarm parameter state of this slave during the slave echo message simultaneously, if found the alarm parameter state upset having taken place, just the initial address of this parameter is inserted in the state turnover chained list of this slave correspondence products for further together with the present condition value and handle.
S705 traversal slave alarm parameter counter-rotating formation, the time of carrying out mechanism is handled, shielding mechanism is handled and squeezed into corresponding slave and alarm formation satisfactory: main frame travels through the flip queue of all slaves, via shielding processing, delay process, after enabling to handle, finally in the first address of the slave parameter of needs alarm and the alarm formation that state is squeezed into corresponding slave.
S706 traversal slave alarm formation, as then organizing alarm packet at non-phase and the non-NULL of awaiting a response: finish the alarm formation of traversal slave and finish await a response after, as be empty in the alarm formation, main frame structure alarm packet.
S707 puts and finds the warning information sign: main frame is responsible for sending above-mentioned alarm packet.,
S708 receives to respond and empties the alarm formation: after the affirmation of receiving tension management equipment, empty the content of alarm formation.
Other flow processs of S713: in step S703, judge when not receiving echo message, carry out the operation that other need.
The invention also discloses a kind of processing unit of distributed principal and subordinate's machine communication that be used for being implemented in to the slave parameter, comprise slave numbering recognition device 82, slave argument address recognition device 83 and communicate by letter and control device 81, in communication and control device 81, also comprise first storage device 811; Wherein slave numbering recognition device 81 and slave argument address recognition device 83 be connected to communicate by letter and control device 81 on, communication control unit 81 links to each other with a plurality of slaves 84 with upper management equipment 85 respectively, as shown in Figure 5, Fig. 5 has schematically shown the above-mentioned annexation among this device embodiment; In the embodiment of this device, slave numbering recognition device 82 is used for the order of receiving according to communication and control device 81 or the slave addresses of request obtains the slave numbering; Slave argument address recognition device 83 be used for order that identification communication and control device 81 receive or request the slave parameter classification and in communication and control device 81 initial address of memory location; Communication and control device 81 are used to receive the information that order that upper level management equipment 85 sends or slave 84 are sent, and, relevant parameter is operated or inserted packet and be sent to slave 84 or upper level management equipment 85 according to the indication in order that receives or the request.When more than one of the parameter that will handle or send in order of receiving or the information, communication and control device 81 need to handle one by one, the slave addresses or the slave numbering of the parameter that obtained and this parameter are stored in above-mentioned first storage device 811, handle and to send or to squeeze into the packet transmission more together after the parameter of processing Deng communication and control device 81, and after the affirmation information of receiving upper management equipment 85 or slave 84, empty above-mentioned first storage device.Use the device in the present embodiment to realize numbering the parameter storage relative position that recognition device 82 draws corresponding slave by slave, obtain the storage initial address of slave supplemental characteristic by slave argument address recognition device 83, thereby, be convenient to subsequent action or processing for communication and control device 81 provide the particular location of the parameter value that will handle or transmit.Be characterized in unifying the handling process of all slaves; So because that data are stored in the main frame group speed packet fully is also fast, the method for searching target component is simple, has realized the fully isolation related with the programming of slave of tension management equipment
Though more than described the specific embodiment of the present invention, those of ordinary skills should be understood that these only for illustrating, and can make numerous variations or modification to these real-time modes and do not deviate from principle of the present invention and essence.