A kind of function realizing method of programmable reusable control
Technical field
The present invention relates to field of computer technology, relate in particular to a kind of programmable reusable control functionality implementation method.
Background technology
Along with the function of digital audio processing device and other various devices from strength to strength; be saving resource; usually can adopt reusable control (such as button), control a plurality of control targets (such as same switch key in order to control the opening/closing of desk lamp and curtain) by a control.As shown in Figure 1, the function realizing method of traditional reusable control is: monitor trigger source; When whenever listening to control and being triggered, carry out condition judgment, carry out corresponding operation after judging the current control target of this control.
This traditional implementation is for the equipment with multiplexing control enormous amount, all will carry out condition judgment when whenever listening to control and being triggered, and not only expends the plenty of time, and implementation complexity is high; And in the time need to making amendment to the attribute of control, need in whole software, revise, very complex satisfies different demands so that the user is difficult to revise.Thereby, be necessary the function implementation of this control is improved.
Summary of the invention
The object of the present invention is to provide a kind of function realizing method of programmable reusable control, reduce implementation complexity, save the processing time;
Another object of the present invention is to provide a kind of function realizing method of programmable reusable control, realize able to programme, the custom feature of user level, can revise arbitrarily configuration, satisfy user's user demand.
The objective of the invention is to be achieved through the following technical solutions:
A kind of function realizing method of programmable reusable control comprises:
Pre-defined control functionality allocation list, each list item comprise control title and corresponding control task, and this control task is comprised of at least a control functionality;
According to the control functionality allocation list, generate the control functionality mapping table, each list item comprises control title and control functionality pointer, the control task of corresponding control in each control functionality pointed control functionality allocation list;
Monitor trigger source, when having listened to control and be triggered, carry out corresponding control task according to corresponding control functionality pointer in the control functionality mapping table, realize simultaneously all control functionality that this control task is included.
Wherein, the quantity of predefined control functionality allocation list is a or many parts of coexistences.
Wherein, when described control functionality allocation list has many parts of coexistences, generate the control functionality mapping table take whole control functionality allocation lists as foundation.
Wherein, also comprise the step that described control functionality allocation list and control functionality mapping table are upgraded, comprising: when control kind, control functionality etc. have adjustment, at first the control functionality allocation list is upgraded; Then, the control functionality allocation list according to after upgrading calls current control functionality mapping table, and it is upgraded.
Wherein, the method that the control functionality allocation list is upgraded is: add or delete whole control functional configuration table, perhaps add, the list item in deletion or the change control functional configuration table; Then, reload the control functionality allocation list so that it comes into force.
Wherein, the method for described control functionality mapping table being upgraded comprises update all and part renewal; During update all, the current control functionality allocation list that comes into force only has portion; When part was upgraded, the current control functionality allocation list that comes into force had many parts, according to the sequencing stack and the covering that load.
Wherein, to the method for control functionality mapping table update all be: upgrade the control functionality pointer of the whole list items in the control functionality mapping table, make it directly point to the control task of corresponding control in the new control functionality allocation list that loads; If certain control does not exist in the control functionality allocation list, then the control functionality pointer in this control list item in the control functionality mapping table is empty.
Wherein, the method for the control functionality mapping table partly being upgraded is: the control functionality pointer that upgrades the part list item in the control functionality mapping table;
If certain control in the control functionality mapping table also exists in the control functionality allocation list, then upgrade the control functionality pointer in this control list item in the control functionality mapping table, make it directly point to the control task of corresponding control in the new control functionality allocation list that loads;
If certain control in the control functionality mapping table does not exist in the control functionality allocation list, then the control functionality pointer in this control list item in the control functionality mapping table does not upgrade;
When part was upgraded, if need the function of certain control to be sky, the control task that then this control is corresponding in the functional configuration table was set to sky.
Wherein, the mode of described control functionality mapping table being upgraded comprises direct renewal and triggers and upgrade;
Described direct update mode is specially: call the control functionality mapping table and upgrade after the control functionality allocation list upgrades;
Described triggering update mode is specially: add a control in the control functionality allocation list, the control task of this control is made as the renewal that triggers the control functionality mapping table; After listening to this control and being triggered, upgrade immediately control functionality allocation list and control functionality mapping table.
Compared with prior art, the embodiment of the invention has following beneficial effect:
1) compares with the matrix mapping mode that prior art adopts, adopted one by one mapping mode in the embodiment of the invention: pre-defined control functionality allocation list and current control functionality mapping table, when having listened to control and be triggered, can directly carry out corresponding control task by current control functionality mapping table pointer, all discriminatory analysis is current in the time of need not whenever listening to trigger source again will carry out for which kind of multiplexing function, simplified implementation procedure, greatly reduce the complexity of operation, saved the running time.
2) because in the embodiment of the invention, the control functionality allocation list can a plurality ofly coexist, control functionality allocation list and control functionality mapping table can upgrade at any time, like this when control kind and control task change to some extent, only need to upgrade the list item in two tables or directly switch and get final product, thereby realized able to programme, the custom feature of user level, and can revise arbitrarily configuration, make things convenient for, save time, laborsaving.
3) because control functionality allocation list and control functionality mapping table can be relatively independent of executive routine itself, also so that the extensibility of executive routine in different product greatly improve.
Description of drawings
Fig. 1 is the function realizing method process flow diagram of reusable control in the prior art.
Fig. 2 is the function realizing method process flow diagram of reusable control in the embodiment of the invention.
Embodiment
In order to make 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.
See also shown in Figure 2ly, in the present embodiment, the function realizing method of reusable control may further comprise the steps:
201, definition control functionality allocation list, each list item comprises control title and control task, the control task is comprised of function number and function array.Wherein, the function array has comprised one or more control functionality, and the function number refers to the quantity of the control functionality that comprises in the function array.
In actual applications, the control functionality allocation list can only have portion, also many parts of coexistences can be arranged.Can comprise different control kinds in the different control functionality allocation lists, also can comprise the identical control kind of corresponding different control tasks, each allocation list is renewable, can use simultaneously, also can switch as required at any time.If there is control temporarily inoperative, its control task can be set for empty in the control functionality allocation list.
The structure of control functionality allocation list is shown in following table 1 and table 2, and this two table coexists in the present embodiment.
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, generate current control functionality mapping table according to the control functionality allocation list, each list item comprises control title and control functionality pointer thereof.Control task corresponding to this control in the control functionality pointed control functionality allocation list represents current all control functionality for realizing simultaneously the control task that pointer is pointed of this control.
Take table 1 and table 2 as reference, the structure of control functionality mapping table is as shown in table 3 below in the present embodiment.
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 having control to be triggered, carry out corresponding control task according to pointer corresponding in the current control functionality mapping table, realize simultaneously all control functionality that comprise in the control task.Take table 1, table 2, table 3 as example, when control 1 is triggered, the control task 1.2 in the execution list 2; When control 2 is triggered, the control task 2.1 in the execution list 1; When control 3 is triggered, the control task 3.1 in the execution list 1; When control 5 is triggered, the control task 5.1 in the execution list 2.
204, as required control functionality allocation list and control functionality mapping table are upgraded.
Control set in the control functionality mapping must equal control set in all control control functionality allocation lists, thereby concrete update method is: when control kind, control functionality etc. have adjustment, at first the control functionality allocation list is upgraded; Then, the control functionality allocation list according to after upgrading calls current control functionality mapping table, and it is upgraded.
The method that the control functionality allocation list is upgraded is specially: load the control functionality allocation list.Control functional configuration table can add, delete; List item in the control functionality allocation list also can add, deletes and revise.
The update method of control functionality mapping table also has update all and part to upgrade; During update all, the current control functionality allocation list that comes into force only has portion; When part was upgraded, the current control functionality allocation list that comes into force had many parts, according to the sequencing stack and the covering that load.
During to control functionality mapping table update all, upgrade the control functionality pointer of the whole list items in the control functionality mapping table.The control functionality pointer of the control list item in the control functionality mapping table, directly the control task of corresponding control in the new control functionality allocation list that loads of sensing; If certain control does not exist in the control functionality allocation list, then the control functionality pointer in this control list item in the control functionality mapping table is empty (NULL).
When the control functionality mapping table is partly upgraded, upgrade the control functionality pointer of the part list item in the control functionality mapping table.If certain control exists in the control functionality allocation list, the control functionality pointer in this control list item in the control functionality mapping table then directly points to the control task of corresponding control in the new control functionality allocation list that loads; If certain control does not exist in the control functionality allocation list, then the control functionality pointer in this control list item in the control functionality mapping table does not upgrade.If the control set in the new control functionality allocation list that loads equals the control set in the control functionality mapping, then effect is equivalent to update all.When part was upgraded, if want the function of certain control to be sky, the control task that then this control is corresponding in the functional configuration table was set to sky (the function number that is actually in the control task is set to zero, and the control functionality array is empty).
The update mode of control functionality mapping table has direct update mode and triggers update mode.Directly update mode is specially: call the control functionality mapping table and upgrade after the control functionality allocation list upgrades.The triggering update mode is specially: add a control in the control functionality allocation list, the control task of this control is for triggering the renewal of control functionality mapping table; After listening to this control and being triggered, upgrade immediately control functionality allocation list and control functionality mapping table.
Above-mentioned update method has realized the able to programme and custom feature of user level, and the user can adjust at any time as required, and is not only simple and convenient but also quick and precisely, be particularly suitable for have more control, equipment that the control functionality kind is many.
Take 16 railway digital sound consoles as example, its control Mute is used for controlling simultaneously the dumb sound of 16 passages.In the prior art, it controls the dumb sound of which passage at this moment according to current condition judgment first in common meeting after control Mute is triggered, and then controls corresponding control function according to judged result.And behind employing the present invention, owing in current control functionality mapping table, having defined control Mute only for the dumb sound of controlling dedicated tunnel, so the direct dumb sound of control dedicated tunnel after listening to control Mute and being triggered, the condition judgment link in the middle of having omitted.The digital sound console especially many to the control kind, that control functionality is many has been saved the intermediate treatment time greatly, has reduced the complexity of operation.
The above only is preferred embodiment of the present invention, not in order to limiting the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.