Embodiment
Specify the specific embodiment of the present invention below in conjunction with Figure of description.
As shown in Figure 1, a kind ofly be used for the driver module that multithreading calls, it comprises application software 1 and corresponding driving module 2, and driver module comprises that driving method repository 4, product Driver Library 6 and product drive case library 8.Wherein the driving method repository is mainly upper application software the driving method interface is provided, and product Driver Library loading stocks drives example, and product drives the driving code that case library provides product.Wherein driving method repository, product Driver Library, product driving case library all are * .dll files, i.e. dynamic link database D ynamic Link Library file.
As shown in Figure 2, be used for the functional block diagram of the driver module that multithreading calls, driver module 2 comprises judge module 10, separation module 12, enquiry module 14, opens module 16, creation module 18 and update module 20.
Described judge module 10 receives the product connection string that driving method repository 4 transmits, product Driver Library 6 judges whether the product connection string is correct, the form of product connection string is: business men:: model:: interface:: address parameter:: fixed value, if judge that the product connection string is correct, then send to separation module 12 and separate; If judge that the product connection string is incorrect, then return error code, EOP (end of program).
After described separation module 12 receives judicious character string, isolate product type and title according to the form of character string, in the product Driver Library, inquire about whether there is corresponding product driving example by enquiry module 14, exist corresponding product to drive example if judge, then drive corresponding product and drive example by product Driver Library 6, module 16 is opened in execution, be used for driving example according to the product that finds, in product Driver Library container, increase product Driver Library memory source information record, load the deployment method of current production Driver Library, function is opened in execution, sets up the communication relation with product, and described product drives example and can a plurality of concurrent product drive.
Preferably, in the product Driver Library, inquiring about whether there is corresponding product driving example by enquiry module 14, Query Result is not when finding, creation module 18 is created corresponding product driving example according to separation module 12 isolated product types and title, carry out again and open module 16, load the deployment method of current production Driver Library, carry out and open function, set up the communication relation with product.
Preferably, after creation module 18 is finished establishment product driving example, update module 20 is created the product driving example of finishing with creation module 18 and is joined the product Driver Library, in product Driver Library container, increase product Driver Library memory source information record, when needing same product to drive example, directly from the product Driver Library, seek next time and use.
The process flow diagram that shown in Fig. 3, is used for the driver module preferred embodiment that multithreading calls, at first judge module 10 receives driving method repository 4 and transmits the product connection string among the step S10, whether the form of judging the product connection string is correct, if judge that the product connection string is correct, then send to separation module 12 and separate; If judge that the product connection string is incorrect, then return error code, EOP (end of program).
After separation module described in the step S12 12 receives judicious character string, isolate product type and title according to the form of character string, in the product Driver Library, inquire about the product that whether has isolated product type of separation module and title correspondence by enquiry module 14 among the step S14 and drive example, check whether corresponding product Driver Library loads, exist corresponding product to drive example if judge, then drive corresponding product and drive example by product Driver Library 6, carry out among the step S16 and open module 16, increase a product Driver Library memory source information record at the driver module container, load the deployment method of current production Driver Library, function is opened in execution, set up the communication relation with product, described product drives example and can a plurality of concurrent product drive.
Preferably, in the product Driver Library, inquiring about whether there is corresponding product driving example by enquiry module 14, Query Result is not when finding, creation module 18 is created corresponding product driving example according to separation module 12 isolated product types and title among the step S18, load the product Driver Library, carry out again and open module 16, increase a product Driver Library memory source information record at the driver module container, load the deployment method of current production Driver Library, function is opened in execution, sets up the communication relation with product.
Preferably, after creation module 18 is finished establishment product driving example, update module 20 is created the product driving example of finishing with creation module 18 and is joined the product Driver Library among the step S20, increase a product Driver Library memory source information record at the driver module container, when needing same product to drive example, directly from the product Driver Library, find the back to use next time.
Drive in the example procedure at above establishment product, can finish initialization, in driving method repository 4, generate a product container, be used for the product handle product; Generate a product and drive container and a product driving example container in the product Driver Library, the memory source and the product that are respectively applied for the product Driver Library drive example, its driving method entry address.
The driving method repository is for unified driving method interface, adopt the mentality of designing of object factory, mainly comprise: definition driving method base class, definition are from the interface function of the derived class of the derivative driving method of base class, method factory, method generator, external reference driving method.
1. wherein defining the driving method base class mainly comprises;
A) function parameter is provided with structure
{
Parameter name;
Parameter type;
Number of parameters;
Parameter value;
Parameter unit;
}
B) input parameter container<function parameter is provided with structure 〉
C) output parameter container<function parameter is provided with structure 〉
D) input parameter (input parameter container) is set
E) obtain input parameter (input parameter container)
F) output parameter (output parameter container) is set
G) obtain output parameter (output parameter container)
H) operation
I) initialization
2. the external interface function of visit driving method mainly comprises;
A) open (
The instrument module style number,
The instrument module connection string,
The instrument module handle
)
B) close (instrument module style number, instrument module connection string)
C) obtain all driving method titles (method name, method number)
D) obtain a quasi-instrument module drive method title (instrument module style number, method name, method number)
E) create a method (method name, method handle)
F) discharge a method (method handle)
G) the functional description language (method handle, functional description language) of a method is set
H) obtain the functional description language (method handle, functional description language) of a method
I) obtain the input parameter number (method handle, input parameter number) of a method
J) obtain input parameter details (
The method handle,
The input parameter call number,
The input parameter title,
The input parameter type,
The input parameter number,
The input parameter value,
Input parameter unit
)
K) input parameter value (method handle, input parameter call number, input parameter value) is set
L) obtain output parameter number (method handle, output parameter number)
M) obtain output parameter details (
The method handle,
The output parameter call number,
The output parameter title,
The output parameter type,
The output parameter number,
Output parameter value,
Output parameter unit
)
N) an operation method (method handle).
3. method factory adopts the basic design of " scalable factory ", when adding new " an instrument module driving method derived class " at every turn, needn't revise it code.The function division of instrument module driving method factory is clear, and each new " instrument module driving method " all must be registered factory, and " driving method sign " and " pointer of generating function " passed to it.Usually generating function has only delegation
BaseClass*?CreateDeviceMethod()
{
return?new?DeviceMethod
}。
4, driving method repository (ATML method base) is in order to reach the purpose that the instrument module driving method is visible, select configuration: adopt general type design, state that a Map container is used for preserving the instrument module driving method title that all were registered.
5, driver module adopts Object-Oriented Design, connection string according to the input of driving method repository, load libraries LoadLibrary function by the Microsoft of Microsoft comes loading stocks to drive case library, and Registering product driving Map, " product Driver Library title ", " product Driver Library handle " and " product Driver Library call number " are passed to product drive Map.The driving method entry address that utilizes the load libraries GetProcAddress function of the Microsoft of Microsoft to obtain product driven object example.And Registering product driven object example Map.
In driver module, also comprise several public data structure body and methods:
A) dynamic base structure
{
The dynamic base handle
The dynamic base coding
};
B) product driven object exemplary construction body
{
The dynamic base handle
The dynamic base coding
The equipment handle
The driver module title
};
C) driver module Map container key: driver module title
Typedef std::map<std::string, the dynamic base structure〉DllManagerMap;
D) product driven object example Map container key: product driven object instance handle
Typedef std::map<int, the device structure body〉DeviceManagerMap;
E) in product driven object example Map, increase a record function
Newly-increased (product driven object instance handle, product driven object exemplary construction body);
F) in product driven object example Map, revise a record function
Revise (product driven object instance handle, product driven object exemplary construction body);
G) record of deletion function from product driven object example Map
Deletion (product driven object instance handle);
H) from product driven object example Map, find a record function
Search (product driven object instance handle).
The present invention passes through according to product type and title, create corresponding product and drive example, drive product, a plurality of products drive the operation of example, revise and delete and do not disturb mutually, reach the technique effect that multithreading calls, solved the not high problem of testing tool utilization factor in the test products process at present, by the definition unified interface, automatically seek or generate corresponding product according to product and drive example, shielding product drives the method divergence of example, reaching increases the technique effect that product driving example does not disturb other products driving examples, realizes that multithreading calls, and improves the service efficiency of testing tool.
The present invention is not limited to aforesaid embodiment.The present invention expands to any new feature or any new combination that discloses in this manual, and the arbitrary new method that discloses or step or any new combination of process.