Summary of the invention
The technical problem that the present invention solves is: make up a kind of multithread electric negative control system, the power load control system that overcomes prior art can not be to the technical problem of the control and management of magnanimity power load control system.
Technical scheme of the present invention is: a kind of multithread electric negative control system, comprise the power load control terminal, front end processor, the power load control system, described front end processor is used for communicating by letter of described power load control terminal and described power load control system, described power load control system is by described front end processor control and management power load control terminal, described power load control system 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 power load 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 for making up described front end processor and described power load control terminal.
Further technical scheme of the present invention is: the communication port of described front end processor and described power load 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 module is used for configuration and uses the consistent communication protocol of agreement with described power load control terminal.
Further technical scheme of the present invention is: described power load control system 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 the communication connection of described power load control system, described front end processor and power load control terminal;
The task configuration task thread that described thread configuration module is described power load 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: in the described communication connection step of setting up described power load control system, described front end processor and power load control terminal, comprising: the communication protocol that configures the communication port of described front end processor and described power load control system and the described front end processor of configuration and described power load control system.
Further technical scheme of the present invention is: the mission thread that automatically starts 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 power load control terminal, described thread pool makes up module with the mission thread structure thread pool of 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 power load control system 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 power load control terminals, can in time, intactly gather all kinds of power informations that a large amount of power load 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 power load control terminal 3, front end processor 2, power load control system 4, described front end processor 2 is used for communicating by letter of described power load control terminal 3 and described power load control system 4, described power load control system 4 is by the described power load control terminal 3 of described front end processor 2 control and managements, described power load control system 3 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 power load 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 processed.In multithread electric negative control of the present invention system, the task configuration task thread that described thread configuration module 11 is described power load control terminal 3, described thread pool makes up module 12 with the mission thread structure thread pool 13 of 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 processed.The present invention utilizes the technology of thread pool 3 that the power load control system is carried out control and management, when system moves, described task processing unit 1 reads the relevant configuration of power load control system database, connects front end processor 2, communicates by front end processor 2 and power load 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 power load control terminal 3 of some, a plurality of threads are executed the task in thread pool simultaneously, so that task processing unit 1 possesses the ability of being responsible for simultaneously magnanimity power load control terminal data.Thus, multithread electric negative control of the present invention system can in time, intactly gather all kinds of power informations that a large amount of power load control terminals 3 are preserved.
As shown in Figure 1, implementation process of the present invention is as follows: at first, described front end processor 2 connects with described power load 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 for making up described front end processor 2 and described power load control terminal 3.Described power load control system 4 is described front end processor 2 configuration communication passages according to the network application situation when configuration communication server archives, is power load 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 power load control terminal 3.After described power load control system 4 is the good communication port of front end processor 2 and power load control system configuration and communication protocol, namely send the message request of login power load control system 4 behind power load control terminal 3 electrifying startups to front end processor 2.Front end processor 2 is judged the communication protocol of power load control terminal 3 according to the message that receives, described front end processor comprises protocol configuration module 21, and described protocol configuration module 21 is used for configuration and uses the consistent communication protocol of agreement with described power load control terminal 3.Described front end processor 2 and the described electricity negative control system made of being engaged in is connected: described power load control system 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 for resolving the connection protocol of described power load control system and described front end processor 2.Described front end processor 2 and described power load control system by link block 41 be connected the passage of front end processor 2 and make up the Path Setup that module 22 makes up and be connected.Described front end processor 2 is set up the multi-protocols passage automatically according to the agreement of protocol configuration module 21 configuration, the power load control terminal data of different agreement is forwarded to different communication ports, for task processing unit 1.After starting, reads task processing unit 1 archive information of power load control terminal 3, the task configuration task thread that described thread configuration module 11 is described power load control terminal 3, simultaneously, according to what of power load control terminal 3 numbers, the suitable mission thread number of described thread configuration module 11 configurations.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 processed.
As shown in Figure 1 and Figure 2, preferred implementation of the present invention is: described power load control system 4 and described front end processor 2 adopt the proprietary protocol that is arranged on the client area to carry out exchanges data.Proprietary protocol is the agreement of in-house development, employing, and except 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 power load control terminal 3 can be placed on the client area, and the client area refers to 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 power load 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 power load control terminals 3 of extensive access, simultaneously do not need to set up the special communication server for the power load control terminal 3 of every kind of communication protocol, need to 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 the 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 according to the configuration of database dialing or other connected modes.
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 running that acquisition tasks generates thread 131 is: acquisition tasks generates the archive information that thread 131 reads the power load control terminal 3 in the power load control system database, it regularly is the acquisition tasks of power load 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 configure 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 generating acquisition tasks, and the generation task do not need communicate by letter with power load control terminal 3, therefore a task processing unit 1 configures 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 simultaneously the response message that front end processor 2 returns, 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 time tasks carrying 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 simultaneously and many power load control terminal communications, 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 power load control system.When the tasks carrying failure, newly-increased failed tasks information in the failed tasks formation.
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 the fault such as disconnecting, terminal is fallen point, terminal and ammeter communication failure when signal of communication appears in power load 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 the communication connection of described power load control system, described front end processor 2 and power load control terminal.At first connect between described front end processor 2 and described power load control system: described front end processor 2 and the described electricity negative control system made of being engaged in is connected: described power load control system 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 for resolving the connection protocol of described power load control system and described front end processor 2.Described front end processor 2 and described power load control system by link block 41 be connected the passage of front end processor 2 and make up the Path Setup that module 22 makes up and be connected.Described front end processor 2 is set up the multi-protocols passage automatically according to the agreement of protocol configuration module 21 configuration, the power load control terminal data of different agreement is forwarded to different communication ports, for task processing unit 1.Described power load control system 4 and described front end processor 2 adopt the proprietary protocol that is arranged on the client area to carry out exchanges data.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 power load 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 power load 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 power load control terminals 3 of extensive access, simultaneously do not need to set up the special communication server for the power load control terminal 3 of every kind of communication protocol, need to 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 the 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 according to the configuration of database dialing or other connected modes.Connect between described front end processor 2 and described power load 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 for making up described front end processor 2 and described power load control terminal 3.Described power load control system 4 is described front end processor 2 configuration communication passages according to the network application situation when configuration communication server archives, is power load 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 power load control terminal 3.After described power load control system 4 is the good communication port of front end processor 2 and power load control system configuration and communication protocol, namely send the message request of login power load control system 4 behind power load control terminal 3 electrifying startups to front end processor 2.Front end processor 2 is judged the communication protocol of power load control terminal 3 according to the message that receives, described front end processor comprises protocol configuration module 21, and described protocol configuration module 21 is used for configuration and uses the consistent communication protocol of agreement with described power load control terminal 3.Front end processor 2 is set up the multi-protocols passage automatically according to the agreement of protocol configuration module 21 configuration, the power load control terminal data of different agreement is forwarded to different communication ports, for task processing unit 1.
Step 200: configuration task thread, described thread configuration module 11 are described power load control terminal 3 configuration task threads.After starting, reads task processing unit 1 archive information of power load control terminal 3, the task configuration task thread that described thread configuration module 11 is described power load control terminal 3, simultaneously, according to what of power load control terminal 3 numbers, the suitable mission thread number of described thread configuration module 11 configurations.
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 processed.
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 power load control terminal 3 of some, a plurality of threads are executed the task in thread pool simultaneously, so that task processing unit 1 possesses the ability of being responsible for simultaneously magnanimity power load control terminal data.Thus, multithread electric negative control of the present invention system can in time, intactly gather and preserve all kinds of power informations of a large amount of power load control terminals 3.
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.
Such as Fig. 1, shown in Figure 3, preferred implementation of the present invention is: the running that acquisition tasks generates thread 131 is: acquisition tasks generates the archive information that thread 131 reads the power load control terminal 3 in the power load control system database, it regularly is the acquisition tasks of power load 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 configure 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 generating acquisition tasks, and the generation task do not need communicate by letter with power load control terminal 3, therefore a task processing unit 1 configures 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 simultaneously the response message that front end processor 2 returns, 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 time tasks carrying 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 simultaneously and many power load control terminal communications, 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 power load control system.When the tasks carrying failure, newly-increased failed tasks information in the failed tasks formation.
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 the fault such as disconnecting, terminal is fallen point, terminal and ammeter communication failure when signal of communication appears in power load 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 is in conjunction with concrete preferred implementation further description made for the present invention, can not assert that implementation 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.