A kind of function realizing method of programmable reusable control
Technical field
The present invention relates to field of computer technology, particularly relate to a kind of programmable reusable control function realizing method.
Background technology
Along with digital audio processing device and other various equipment function from strength to strength; for saving resource; reusable control (such as button) would generally be used, control control multiple control targets (as same switch key beats opening/closing in order to control desk lamp and curtain).As it is shown in figure 1, the function realizing method of traditional reusable control is: monitor trigger source;Often listen to control when being triggered, carry out conditional judgment, it is determined that after the control target that this control is current, perform corresponding operation.
This traditional implementation, for having the equipment of multiplexing control enormous amount, often listens to will carry out when control is triggered conditional judgment, not only takes considerable time, it is achieved complexity is high;And need when needing the attribute of control is modified to revise in whole software, considerably complicated so that user is difficult to amendment and meets different demand.Thus, it is necessary to the functional realiey scheme of this control is improved.
Summary of the invention
It is an object of the invention to provide the function realizing method of a kind of programmable reusable control, reduce implementation complexity, saving processes the time;
Another object of the present invention is to provide the function realizing method of a kind of programmable reusable control, it is achieved able to programme, the custom feature of user level, can arbitrarily revise configuration, meet the use demand of user.
It is an object of the invention to be achieved through the following technical solutions:
A kind of function realizing method of programmable reusable control, including:
Pre-defined control functional configuration table, each list item includes the control task of control title and correspondence, and this control task is made up of at least one control function;
According to control functional configuration table, generating control function mapping table, each list item includes control title and control function pointer, and each control function pointer points to the control task of corresponding control in control functional configuration table;
Monitor trigger source, when having listened to control and being triggered, perform corresponding control task according to corresponding control function pointer in control function mapping table, realize all control functions included by this control task simultaneously.
Wherein, the quantity of predefined control functional configuration table is a or many part and coexists.
Wherein, when described control functional configuration table has many parts to coexist, with whole control functional configuration tables for according to generating control function mapping table.
Wherein, also include the step that described control functional configuration table and control function mapping table are updated, including: when control kind, control function etc. have adjustment, first control functional configuration table is updated;Then, according to the control functional configuration table after updating, call current control function mapping table, it is updated.
Wherein, the method being updated control functional configuration table is: adds or deletes whole control functional configuration table, or add, the list item that control in functional configuration table is deleted or modified;Then, control functional configuration table is reloaded so that it comes into force.
Wherein, the method being updated described control function mapping table includes that update all and part update;During update all, the control functional configuration table currently come into force only portion;When part updates, the control functional configuration table currently come into force has many parts, according to the sequencing superposition loaded and covering.
Wherein, to the method for control function mapping table update all it is: the control function pointer of the whole list items in renewal control function mapping table so that it is be pointing directly at the control task of corresponding control in the control functional configuration table of new loading;If certain control does not exists in control functional configuration table, then the control function pointer in this control list item in control function mapping table is empty.
Wherein, the method updated control function mapping table part is: the control function pointer of the part list item in renewal control function mapping table;
If certain control in control function mapping table there is also in control functional configuration table, then update the control function pointer in this control list item in control function mapping table so that it is be pointing directly at the control task of corresponding control in the control functional configuration table of new loading;
If certain control in control function mapping table does not exists in control functional configuration table, then the control function pointer in this control list item in control function mapping table does not updates;
When part updates, if the function needing certain control is sky, then in functional configuration table, control task corresponding for this control is set to sky.
Wherein, the mode being updated described control function mapping table includes directly updating and trigger renewal;
Described direct update mode is particularly as follows: call control function mapping table and be updated after control functional configuration table updates;
Described triggering update mode is particularly as follows: add a control in control functional configuration table, and the control task of this control is set to the renewal of trigger control function mapping table;Listening to after this control is triggered, updating control functional configuration table and control function mapping table immediately.
Compared with prior art, the embodiment of the present invention has the advantages that
1) compared with the matrix mapping mode that prior art uses, the embodiment of the present invention have employed mapping mode one by one: pre-defined control functional configuration table and current control function mapping table, corresponding control task can be directly performed by current control function mapping table pointer when having listened to control and being triggered, when need not the most often listen to trigger source, all which kind of multiplexing function discriminatory analysis currently to perform, simplify the process of realization, greatly reduce the complexity of operation, save the operating time.
2) due in the embodiment of the present invention, control functional configuration table can multiple coexist, control functional configuration table and control function mapping table can update at any time, so when control kind and control task are varied from, only need to update the list item in two tables or directly switch, it is thus achieved that able to programme, the custom feature of user level, can arbitrarily revise configuration, facilitate, save time, laborsaving.
3) because control functional configuration table and control function mapping table can be relatively independent of execution program itself, execution program extensibility in different product is also made to be greatly improved.
Accompanying drawing explanation
Fig. 1 is the function realizing method flow chart of reusable control in prior art.
Fig. 2 is the function realizing method flow chart of reusable control in the embodiment of the present invention.
Detailed description of the invention
In order to make the purpose of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
Referring to shown in Fig. 2, in the present embodiment, the function realizing method of reusable control comprises the following steps:
201, definition control functional configuration table, each list item includes control title and control task, and control task is made up of function number and function array.Wherein, function array includes one or more control functions, and function number refers to the quantity of the control function included in function array.
In actual applications, control functional configuration table can only have portion, it is possibility to have many parts coexist.Can comprise different control kinds in different control functional configuration tables, it is possible to comprise the identical control kind of corresponding different control task, each allocation list is renewable, can use, also can switch over the most as required simultaneously.If there being control the most inoperative, control functional configuration table can arrange its control task for sky.
Shown in the following Tables 1 and 2 of structure of control functional configuration table, in the present embodiment, this two table coexists.
Table 1
Control title 1 |
Control task 1.1<function number, function array> |
Control title 2 |
Control task 2.1<function number, function array> |
Control title 3 |
Control task 3.1<function number, function array> |
Control title 4 |
Control task 4.1<function number, function array> |
… |
… |
Table 2
Control title 1 |
Control task 1.2<function number, function array> |
Control title 2 |
Control task 2.2<function number, function array> |
Control title 5 |
Control task 5.1<function number, function array> |
Control title 6 |
Control task 6.1<function number, function array> |
… |
… |
202, generating current control function mapping table according to control functional configuration table, each list item includes control title and control function pointer thereof.Control function pointer points to the control task that this control is corresponding in control functional configuration table, all control functions representing this control to be currently used in simultaneously to realize in the control task pointed by pointer.
With Tables 1 and 2 as reference, in the present embodiment, the structure of control function mapping table is as shown in table 3 below.
Table 3
Control title 1 |
* p-> control task 1.2 |
Control title 2 |
* p-> control task 2.1 |
Control title 3 |
* p-> control task 3.1 |
Control title 4 |
* p-> control task 4.1 |
Control title 5 |
* p-> control task 5.1 |
Control title 6 |
* p-> control task 6.1 |
… |
… |
203, monitor trigger source, when there being control to be triggered, perform corresponding control task according to pointer corresponding in current control function mapping table, realize all control functions included in control task simultaneously.As a example by table 1, table 2, table 3, when control 1 is triggered, perform the control task 1.2 in table 2;When control 2 is triggered, perform the control task 2.1 in table 1;When control 3 is triggered, perform the control task 3.1 in table 1;When control 5 is triggered, perform the control task 5.1 in table 2.
204, as required control functional configuration table and control function mapping table are updated.
Control set during control function maps necessarily is equal to control set in all control control functional configuration tables, thus concrete update method is: when control kind, control function etc. have adjustment, be first updated control functional configuration table;Then, according to the control functional configuration table after updating, call current control function mapping table, it is updated.
The method being updated control functional configuration table is particularly as follows: load control functional configuration table.Control functional configuration table to add, delete;List item in control functional configuration table also can add, deletes and revise.
The update method of control function mapping table also has update all and part to update;During update all, the control functional configuration table currently come into force only portion;When part updates, the control functional configuration table currently come into force has many parts, according to the sequencing superposition loaded and covering.
During to control function mapping table update all, the control function pointer of the whole list items in renewal control function mapping table.The control function pointer of the control list item in control function mapping table, is pointing directly at the control task of corresponding control in the control functional configuration table of new loading;If certain control does not exists in control functional configuration table, then the control function pointer in this control list item in control function mapping table is empty (NULL).
When control function mapping table part is updated, the control function pointer of the part list item in renewal control function mapping table.If certain control exists in control functional configuration table, then the control function pointer in this control list item in control function mapping table, it is pointing directly at the control task of corresponding control in the control functional configuration table of new loading;If certain control does not exists in control functional configuration table, then the control function pointer in this control list item in control function mapping table does not updates.If the control set in the new control functional configuration table loaded is equal to the control set in the mapping of control function, then effect is equivalent to update all.When part updates, if it is desired to the function of certain control is empty, then in functional configuration table, control task corresponding for this control is set to sky (actually the function number in control task being set to zero, control function array is empty).
The update mode of control function mapping table has direct update mode and triggers update mode.Directly update mode is particularly as follows: call control function mapping table and be updated after control functional configuration table updates.Triggering update mode is particularly as follows: add a control in control functional configuration table, and the control task of this control is the renewal of trigger control function mapping table;Listening to after this control is triggered, updating control functional configuration table and control function mapping table immediately.
Above-mentioned update method achieves the able to programme of user level and custom feature, and user can be adjusted the most as required, the most simple and convenient and also quick and precisely, be particularly suitable for the equipment that there is more control, control functional type is many.
As a example by 16 railway digital sound consoles, its control Mute is for the dumb sound of 16 passages of control simultaneously.In the prior art, after control Mute is triggered would generally first according to current conditional judgment, it now controls the dumb sound of which passage, then control to control accordingly function according to judged result.And after using the present invention, it is only used for controlling the dumb sound of dedicated tunnel owing to having been defined for control Mute in current control function mapping table, so listening to directly control after control Mute is triggered the dumb sound of dedicated tunnel, eliminate the conditional judgment link of centre.From the point of view of the digital sound console the most to control kind, control function is relatively more, it is greatly saved the intermediate treatment time, reduces the complexity of operation.
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all any amendment, equivalent and improvement etc. made within the spirit and principles in the present invention, should be included within the scope of the present invention.