Summary of the invention
The technical matters that the present invention solves is: make up a kind of multithread electric negative control system, the negative control system of electric power that overcomes prior art can not be to the technical matters of the control and management of the negative control system of magnanimity electric power.
Technical scheme of the present invention is: a kind of multithread electric negative control system, comprise the electric power negative control terminal, front end processor, electric power is born the control system, described front end processor is used for communicating by letter of described electric power negative control terminal and the negative control system of described electric power, the negative control system of described electric power is by described front end processor control and management electric power negative control terminal, the negative control system of described electric power comprises task processing unit, described task processing unit comprises the thread configuration module, thread pool makes up module, described thread configuration module is used to the task configuration task thread of described electric power negative control terminal, described thread pool makes up module and is used for the mission thread of described thread configuration block configuration is made up thread pool, and the mission thread that described task processing unit starts in the thread pool automatically carries out the timed task processing.
Further technical scheme of the present invention is: described front end processor comprises that passage makes up module, and described passage makes up the communication port that module is used to make up described front end processor and described electric power negative control terminal.
Further technical scheme of the present invention is: the communication port of described front end processor and described electric power negative control terminal comprises GPRS and CDMA passage.
Further technical scheme of the present invention is: described front end processor comprises the protocol configuration module, and described protocol configuration unit is used to dispose and the consistent communication protocol of described electric power negative control terminal use agreement.
Further technical scheme of the present invention is: negative control system of described electric power and described front end processor adopt proprietary protocol to carry out exchanges data.
Further technical scheme of the present invention is: described thread configuration block configuration mission thread also comprises according to terminal quantity configuration task number of threads.
Further technical scheme of the present invention is: described mission thread comprises that acquisition tasks generates thread, acquisition tasks execution thread, task result processing threads, failed tasks processing threads.
Technical scheme of the present invention is: a kind of multithread electric negative control system control method is provided, comprises the steps:
Set up communicating to connect of described electric power negative control system, described front end processor and electric power negative control terminal;
The task configuration task thread that described thread configuration module is described electric power negative control terminal;
Described thread pool makes up module and makes up thread pool with described mission thread;
The mission thread that described task processing unit starts in the thread pool automatically carries out the timed task processing.
Further technical scheme of the present invention is: set up the communicating to connect in the step of described electric power negative control system, described front end processor and electric power negative control terminal described, comprising: dispose the communication port of the negative control system of described front end processor and described electric power and the communication protocol of described front end processor of configuration and the negative control system of described electric power.
Further technical scheme of the present invention is: the mission thread that starts automatically in the thread pool at described task processing unit carries out comprising in the timed task treatment step: acquisition tasks generates thread, acquisition tasks execution thread, task result processing threads, failed tasks processing threads.
Technique effect of the present invention is: make up a kind of multithread electric negative control system, in described multithread electric negative control system, the task configuration task thread that described thread configuration module is described electric power negative control terminal, described thread pool makes up the mission thread structure thread pool of module with described thread configuration block configuration, and the mission thread that described task processing unit starts in the thread pool automatically carries out the timed task processing.The present invention utilizes the technology of thread pool that the negative control system of electric power is carried out control and management, because thread pool is made of a plurality of mission threads, therefore, multithread electric negative control of the present invention system can realize the control and management to a large amount of electric power negative control terminals, can in time, intactly gather all kinds of power informations that a large amount of electric power negative control terminals are preserved.
Embodiment
Below in conjunction with specific embodiment, technical solution of the present invention is further specified.
As shown in Figure 1, the specific embodiment of the present invention is: make up a kind of multithread electric negative control system, comprise electric power negative control terminal 3, front end processor 2, electric power is born control system 4, described front end processor 2 is used for communicating by letter of described electric power negative control terminal 3 and the negative control system 4 of described electric power, the negative control system 4 of described electric power is by the described electric power negative control terminal 3 of described front end processor 2 control and managements, the negative control system 3 of described electric power comprises task processing unit 1, described task processing unit 1 comprises thread configuration module 11, thread pool makes up module 12, described thread configuration module 11 is used to the task configuration task thread of described electric power negative control terminal 3, described thread pool makes up module 12 and is used for the mission thread of described thread configuration module 11 configurations is made up thread pool 13, and the described task processing unit 1 automatic mission thread that starts in the thread pool carries out timed task to be handled.In multithread electric negative control of the present invention system, the task configuration task thread that described thread configuration module 11 is described electric power negative control terminal 3, described thread pool makes up the mission thread structure thread pool 13 of module 12 with described thread configuration module 11 configurations, and the described task processing unit 1 automatic mission thread that starts in the thread pool carries out timed task to be handled.The present invention utilizes the technology of thread pool 3 that the negative control system of electric power is carried out control and management, when system moves, described task processing unit 1 reads the relevant configuration of the negative control of electric power system database, connects front end processor 2, communicates by front end processor 2 and electric power negative control terminal 3.The thread pool technology of the Java that task processing unit 1 of the present invention is taked, each thread is responsible for the electric power negative control terminal 3 of some, a plurality of threads are executed the task in thread pool simultaneously, make task processing unit 1 possess the ability of being responsible for magnanimity electric power negative control terminal data simultaneously.Thus, all kinds of power informations that a large amount of electric power negative control terminals 3 are preserved can in time, intactly be gathered by multithread electric negative control of the present invention system.
As shown in Figure 1, implementation process of the present invention is as follows: at first, described front end processor 2 connects with described electric power negative control terminal 3: described front end processor 2 comprises that passage makes up module 22, and described passage makes up the communication port that module 22 is used to make up described front end processor 2 and described electric power negative control terminal 3.The negative control system 4 of described electric power is described front end processor 2 configuration communication passages according to the network application situation when configuration communication server archives, is electric power negative control terminal 3 configuration protocol simultaneously.In the present embodiment, described front end processor 2 comprises GPRS and CDMA passage with the communication port of described electric power negative control terminal 3.After the negative control system 4 of described electric power is front end processor 2 and electric power negative control good communication port of system configuration and communication protocol, promptly send the message request of the negative control system 4 of login electric power behind electric power negative control terminal 3 electrifying startups to front end processor 2.Front end processor 2 is according to the communication protocol of the message judgement electric power negative control terminal 3 that receives, and described front end processor comprises protocol configuration module 21, and described protocol configuration unit 21 is used to dispose and the consistent communication protocol of described electric power negative control terminal 3 use agreements.Described front end processor 2 is engaged in bearing the control system with described electricity and is connected: the negative control system of described electric power comprises link block 41, protocol analysis module 43 and memory module 42, the passage that described link block 41 is used for making up with the passage structure module 22 of described front end processor 2 is connected, and described protocol analysis module 43 is used to resolve the connection protocol of negative control system of described electric power and described front end processor 2.Described front end processor 2 connects by the passage of passage structure module 22 structures of link block 41 and described front end processor 2 with the negative control system of described electric power.Described front end processor 2 is set up the multi-protocols passage automatically according to the agreement of protocol configuration unit 21 configuration, with the electric power negative control terminal data forwarding of different agreement to different communication ports, for task processing unit 1 use.After starting, reads task processing unit 1 archive information of electric power negative control terminal 3, the task configuration task thread that described thread configuration module 11 is described electric power negative control terminal 3, simultaneously, according to what of electric power negative control terminal 3 numbers, described thread configuration module 11 configuration appropriate tasks number of threads.Described thread pool makes up module 12 and is used for the mission thread of mission thread configuration module 11 configurations is made up thread pool 13.After building thread pool 13, task processing unit 1 initiating task thread carries out timed task to be handled.
As shown in Figure 1 and Figure 2, preferred implementation of the present invention is: the negative control system 4 of described electric power adopts the proprietary protocol that is arranged on the client area to carry out exchanges data with described front end processor 2.Proprietary protocol is the agreement of in-house development, employing, and except that unauthorized, other manufacturers generally have no right to use this agreement.Adopt privately owned communication protocol to carry out exchanges data between task processing unit 1 and the front end processor 2, the data of different communication protocol electric power negative control terminal 3 can be placed on the client area, and the client area is meant the operable zone of web visitor.These data are mutual between task processing unit 1 and front end processor 2, do not need to change the privately owned communication protocol between prepositive communication computer and the timed task when needs increase new terminal communication protocol.Front end processor 2 built-in various protocols parsing modules 23, various protocols parsing module 23 can make front end processor 2 communicate by letter with the electric power negative control terminal 3 of different communication protocol simultaneously here.Therefore, multithread electric negative control of the present invention system possesses the ability of all kinds of electric power negative control terminals 3 of extensive access, simultaneously do not need to set up the special communication server for the electric power negative control terminal 3 of every kind of communication protocol, need be before the prepositive communication computer of each different manufacturers yet the development interface program, reduce the cost of setting up negative control system.Among the present invention, front end processor 2 is supported multiple connected modes such as TCP, UDP, dialing, optical fiber, serial ports, Modem pond, note, support the host-standby communication mode to switch, when the GPRS passage breaks down, can automatically switch to dialing or other connected modes according to the configuration of database.
As shown in Figure 1, preferred implementation of the present invention is: described mission thread comprises that acquisition tasks generates thread 131, acquisition tasks execution thread 132, task result processing threads 133, failed tasks processing threads 134.
As shown in Figure 1, preferred implementation of the present invention is: the operational process that acquisition tasks generates thread 131 is: acquisition tasks generates the archive information that thread 131 reads the electric power negative control terminal 3 in the negative control of the electric power system database, it regularly is the acquisition tasks of electric power negative control terminal 3 next time point of generation of each connecting system, be placed on public data area, acquisition tasks execution thread 132 obtains task from public data area, goes to carry out.The number that acquisition tasks generates thread 131 can dispose according to terminal quantity, and is placed in the thread pool of task processing unit 1 and moves.Do not need to take a lot of cpu resources owing to generate acquisition tasks, and the generation task do not need communicate by letter with electric power negative control terminal 3, therefore a task processing unit 1 disposes an acquisition tasks execution thread and can meet the demands mostly the time.
As shown in Figure 1, preferred implementation of the present invention is: acquisition tasks execution thread 132 reads newly-generated acquisition tasks, regularly carries out these tasks, and calls the stores service of application server, says that task result deposits database in.Acquisition tasks execution thread 132 regularly reads task, organize different communication messages according to the task classification, communication message is issued front end processor 2, in time-out time, wait for the response message that front end processor 2 returns simultaneously, then carry out protocol analysis if receive response message, according to resolving content message is converted to the Java object, calls stores service and carry out the insert library operation.If in time-out time, do not wait until response message, find that perhaps the message that returns is illegal, then this subtask is carried out failure, newly-increased failed tasks information in the failed tasks formation.Acquisition tasks execution thread 132 is placed in the thread pool of task processing unit 1 and carries out, its number of executions can be passed through database configuration, each acquisition tasks execution thread 132 can be communicated by letter with many electric power negative control terminals simultaneously, so timed task possesses the ability that communicates with the magnanimity terminal.
As shown in Figure 1, preferred implementation of the present invention is: task result processing threads 133 is put into the result of acquisition tasks execution thread 132 in the database of the negative control system of electric power.When task is carried out failure, in the failed tasks formation, increase a failed tasks information newly.
As shown in Figure 1, preferred implementation of the present invention is: failed tasks processing threads 134 regularly reads the failed tasks tabulation, and re-executes.By failed tasks processing threads 134, task processing unit 1 has possessed the ability of remedying to the communication failure situation, has well solved the data leak source problem that GPRS or CDMA go offline and bring.When fault such as disconnecting, terminal is fallen point, terminal and ammeter communication failure when signal of communication appears in electric power negative control terminal 3, task processing unit 1 can not be at the appointed time in real time with data acquisition in system, timed task is judged when fault recovery, the data that can automatically do not collected in the section fault-time again filling mining in system, to guarantee the integrality of system data.
Technical scheme of the present invention is: a kind of multithread electric negative control system control method is provided, comprises the steps:
Step 100: establish a communications link, set up communicating to connect of described electric power negative control system, described front end processor 2 and electric power negative control terminal.At first connect between described front end processor 2 and the negative control system of described electric power: described front end processor 2 is engaged in bearing the control system with described electricity and is connected: the negative control system of described electric power comprises link block 41, protocol analysis module 43 and memory module 42, the passage that described link block 41 is used for making up with the passage structure module 22 of described front end processor 2 is connected, and described protocol analysis module 43 is used to resolve the connection protocol of negative control system of described electric power and described front end processor 2.Described front end processor 2 connects by the passage of passage structure module 22 structures of link block 41 and described front end processor 2 with the negative control system of described electric power.Described front end processor 2 is set up the multi-protocols passage automatically according to the agreement of protocol configuration unit 21 configuration, with the electric power negative control terminal data forwarding of different agreement to different communication ports, for task processing unit 1 use.The negative control system 4 of described electric power adopts the proprietary protocol that is arranged on the client area to carry out exchanges data with described front end processor 2.Adopt privately owned communication protocol to carry out exchanges data between task processing unit 1 and the front end processor 2, the data of different communication protocol electric power negative control terminal 3 can be placed on the client area, these data are mutual between task processing unit 1 and front end processor 2, do not need to change the privately owned communication protocol between prepositive communication computer and the timed task when needs increase new terminal communication protocol.Front end processor 2 built-in various protocols parsing modules 23, various protocols parsing module 23 can make front end processor 2 communicate by letter with the electric power negative control terminal 3 of different communication protocol simultaneously here.Therefore, multithread electric negative control of the present invention system possesses the ability of all kinds of electric power negative control terminals 3 of extensive access, simultaneously do not need to set up the special communication server for the electric power negative control terminal 3 of every kind of communication protocol, need be before the prepositive communication computer of each different manufacturers yet the development interface program, reduce the cost of setting up negative control system.Among the present invention, front end processor 2 is supported multiple connected modes such as TCP, UDP, dialing, optical fiber, serial ports, Modem pond, note, support the host-standby communication mode to switch, when the GPRS passage breaks down, can automatically switch to dialing or other connected modes according to the configuration of database.Connect between described front end processor 2 and described electric power negative control terminal: described front end processor 2 comprises that passage makes up module 22, and described passage makes up the communication port that module 22 is used to make up described front end processor 2 and described electric power negative control terminal 3.The negative control system 4 of described electric power is described front end processor 2 configuration communication passages according to the network application situation when configuration communication server archives, is electric power negative control terminal 3 configuration protocol simultaneously.In the present embodiment, described front end processor 2 comprises GPRS and CDMA passage with the communication port of described electric power negative control terminal 3.After the negative control system 4 of described electric power is front end processor 2 and electric power negative control good communication port of system configuration and communication protocol, promptly send the message request of the negative control system 4 of login electric power behind electric power negative control terminal 3 electrifying startups to front end processor 2.Front end processor 2 is according to the communication protocol of the message judgement electric power negative control terminal 3 that receives, and described front end processor comprises protocol configuration module 21, and described protocol configuration unit 21 is used to dispose and the consistent communication protocol of described electric power negative control terminal 3 use agreements.Front end processor 2 is set up the multi-protocols passage automatically according to the agreement of protocol configuration unit 21 configuration, with the electric power negative control terminal data forwarding of different agreement to different communication ports, for task processing unit 1 use.
Step 200: configuration task thread, described thread configuration module 11 are described electric power negative control terminal 3 configuration task threads.After starting, reads task processing unit 1 archive information of electric power negative control terminal 3, the task configuration task thread that described thread configuration module 11 is described electric power negative control terminal 3, simultaneously, according to what of electric power negative control terminal 3 numbers, described thread configuration module 11 configuration appropriate tasks number of threads.
Step 300: make up thread pool, described thread pool makes up module and makes up thread pool with described mission thread.Described thread pool makes up module 12 and is used for the mission thread of mission thread configuration module 11 configurations is made up thread pool 13.
Step 400: the mission thread that Processing tasks thread, described task processing unit start in the thread pool automatically carries out the timed task processing.After building thread pool 13, task processing unit 1 initiating task thread carries out timed task to be handled.
The thread pool technology of the Java that task processing unit 1 of the present invention is taked, each mission thread is responsible for the electric power negative control terminal 3 of some, a plurality of threads are executed the task in thread pool simultaneously, make task processing unit 1 possess the ability of being responsible for magnanimity electric power negative control terminal data simultaneously.Thus, all kinds of power informations of a large amount of electric power negative control terminals 3 can in time, intactly be gathered and preserve in multithread electric negative control of the present invention system.
As shown in Figure 1, automatically the mission thread that starts in the thread pool at described task processing unit 1 carries out comprising in the timed task treatment step: acquisition tasks generates thread 131, acquisition tasks execution thread 132, task result processing threads 133, failed tasks processing threads 134.The course of work of described task processing unit 1 is as follows: at first communicate by letter with described front end processor 2, to resolving with the communication protocol of front end processor 2, set up communication port, the mission thread that described task processing unit 1 starts in the thread pool automatically carries out timed task.
As Fig. 1, shown in Figure 3, preferred implementation of the present invention is: the operational process that acquisition tasks generates thread 131 is: acquisition tasks generates the archive information that thread 131 reads the electric power negative control terminal 3 in the negative control of the electric power system database, it regularly is the acquisition tasks of electric power negative control terminal 3 next time point of generation of each connecting system, be placed on public data area, acquisition tasks execution thread 132 obtains task from public data area, goes to carry out.The number that acquisition tasks generates thread 131 can dispose according to terminal quantity, and is placed in the thread pool of task processing unit 1 and moves.Do not need to take a lot of cpu resources owing to generate acquisition tasks, and the generation task do not need communicate by letter with electric power negative control terminal 3, therefore a task processing unit 1 disposes an acquisition tasks execution thread and can meet the demands mostly the time.
As shown in Figure 1, preferred implementation of the present invention is: acquisition tasks execution thread 132 reads newly-generated acquisition tasks, regularly carries out these tasks, and calls the stores service of application server, says that task result deposits database in.Acquisition tasks execution thread 132 regularly reads task, organize different communication messages according to the task classification, communication message is issued front end processor 2, in time-out time, wait for the response message that front end processor 2 returns simultaneously, then carry out protocol analysis if receive response message, according to resolving content message is converted to the Java object, calls stores service and carry out the insert library operation.If in time-out time, do not wait until response message, find that perhaps the message that returns is illegal, then this subtask is carried out failure, newly-increased failed tasks information in the failed tasks formation.Acquisition tasks execution thread 132 is placed in the thread pool of task processing unit 1 and carries out, its number of executions can be passed through database configuration, each acquisition tasks execution thread 132 can be communicated by letter with many electric power negative control terminals simultaneously, so timed task possesses the ability that communicates with the magnanimity terminal.
As shown in Figure 1, preferred implementation of the present invention is: task result processing threads 133 is put into the result of acquisition tasks execution thread 132 in the database of the negative control system of electric power.When task is carried out failure, in the failed tasks formation, increase a failed tasks information newly.
As shown in Figure 1, preferred implementation of the present invention is: failed tasks processing threads 134 regularly reads the failed tasks tabulation, and re-executes.By failed tasks processing threads 134, task processing unit 1 has possessed the ability of remedying to the communication failure situation, has well solved the data leak source problem that GPRS or CDMA go offline and bring.When fault such as disconnecting, terminal is fallen point, terminal and ammeter communication failure when signal of communication appears in electric power negative control terminal 3, task processing unit 1 can not be at the appointed time in real time with data acquisition in system, timed task is judged when fault recovery, the data that can automatically do not collected in the section fault-time again filling mining in system, to guarantee the integrality of system data.
Above content be in conjunction with concrete preferred implementation to further describing that the present invention did, can not assert that concrete enforcement of the present invention is confined to these explanations.For the general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, can also make some simple deduction or replace, all should be considered as belonging to protection scope of the present invention.