Summary of the invention
For solving above technical matters, the invention provides the temperature data acquisition method based on concentrating temperature control system, the method can be got up the data filling of the collection point of loss, makes the data integrity in database and draw real time temperature curve to make more complete, continuous and substantially realistic.
Technical scheme of the present invention is: based on the temperature data acquisition method of concentrating temperature control system, its difference is: it comprises the following steps:
Step 1), system host computer starts host computer serial ports and sends temperature control curve to logging;
Step 2), logging to temperature control base table by section send a temperature control curve;
Step 3), the host computer sample period according to the rules reads the real time temperature value of a certain base table in logging storer; Perform step 4 as do not collected temperature data in logging storer), as there being data further to judge whether this segment data sampling completes in logging storer, after the temperature data curve collecting being sent to database as completed, read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer as do not completed host computer sample period according to the rules;
Step 4), taking logging j and base table number i as search index, whole historical datas of traversal retrieval base table judge and in host computer database, have or not the temperature data mating with missing data, temperature curve is calculated and supplemented to the temperature data curve equation that is used as lacking time point or section as not having with design temperature curve values formula one, then judge whether this section of temperature data sampling completes, after complete temperature curve that collect and supplementary being sent to host computer database as completed, read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer by the sample period as do not completed host computer,
Y=(y2-y1)/(x2-x1) X+ (y1x2-y2x1)/(x2-x1) (formula one)
If x is the time, the temperature value that y is base table, wherein x1and x2for the initial sum termination time of temperature curve section, y1and y2for the temperature value of this curve initial sum termination;
As there being the data of mating with missing data in database, judge again data precision requirement, the value Y calculating according to design temperature curve values formula one with same base table as data accuracy requirement Gao Zejideduct historical data Vjithe value of obtaining carries out square obtaining variance yields afterwards, get all over n historical data obtain a corresponding n variance yields, get minimum value in n variance yields, the corresponding historical data V of this minimum variance valuejifor losing temperature data value Ujicalculate and supplement the temperature data curve of disappearance time point or section with the method, then judge whether this section of temperature data sampling completes, as complete by collect and supplement after complete temperature curve is sent to host computer database and read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer as do not completed host computer sample period according to the rules;
The temperature data curve equation that is used as lacking time point or section by formula two as low in data accuracy requirement is calculated and supplementary temperature curve, then judge whether this section of temperature data sampling completes, as complete by collect and supplement after complete temperature curve is sent to host computer database and read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer as do not completed host computer sample period according to the rules;
Uji=Σ Vji/ n (formula two)
Ujifor losing temperature data value, Vjifor the logging j of identical numbering in database and same base table number i are at the temperature value of same design temperature curve, same temperature control section, synchronization; Σ Vjifor n historical data sum; Yjithe value calculating according to design temperature curve values formula one for same base table.
The present invention gets up the data filling of the collection point of loss, this data filling is entered in database simultaneously, makes the data integrity in database and draw real time temperature change curve to make more complete, continuous and substantially realistic.
Embodiment
Referring to Fig. 1-Fig. 3, the temperature data acquisition method of the embodiment of the present invention based on concentrating temperature control system, its difference is: it comprises the following steps:
Step 1), system host computer starts host computer serial ports and sends temperature control curve to logging;
Step 2), logging to temperature control base table by section send a temperature control curve;
Step 3), the host computer sample period according to the rules reads the real time temperature value of a certain base table in logging storer; Perform step 4 as do not collected temperature data in logging storer), as there being data further to judge whether this segment data sampling completes in logging storer, after the temperature data curve collecting being sent to database as completed, read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer as do not completed host computer sample period according to the rules;
Step 4), taking logging j and base table number i as search index, whole historical datas of traversal retrieval base table judge and in host computer database, have or not the temperature data mating with missing data, temperature curve is calculated and supplemented to the temperature data curve equation that is used as lacking time point or section as not having with design temperature curve values formula one, then judge whether this section of temperature data sampling completes, after complete temperature curve that collect and supplementary being sent to host computer database as completed, read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer by the sample period as do not completed host computer,
Y=(y2-y1)/(x2-x1) X+ (y1x2-y2x1)/(x2-x1) (formula one)
If x is the time, the temperature value that y is base table, wherein x1and x2for the initial sum termination time of temperature curve section, y1and y2for the temperature value of this curve initial sum termination;
As there being the data of mating with missing data in database, judge again data precision requirement, the value Y calculating according to design temperature curve values formula one with same base table as data accuracy requirement Gao Zejideduct historical data Vjithe value of obtaining carries out square obtaining variance yields afterwards, get all over n historical data obtain a corresponding n variance yields, get minimum value in n variance yields, the corresponding historical data V of this minimum variance valuejifor losing temperature data value Ujicalculate and supplement the temperature data curve of disappearance time point or section with the method, then judge whether this section of temperature data sampling completes, as complete by collect and supplement after complete temperature curve is sent to host computer database and read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer as do not completed host computer sample period according to the rules;
The temperature data curve equation that is used as lacking time point or section by formula two as low in data accuracy requirement is calculated and supplementary temperature curve, then judge whether this section of temperature data sampling completes, as complete by collect and supplement after complete temperature curve is sent to host computer database and read again lower one piece of data, continue to read the real time temperature value of base table described in logging storer as do not completed host computer sample period according to the rules;
Uji=Σ Vji/ n (formula two)
Ujifor losing temperature data value, Vjifor the logging j of identical numbering in database and same base table number i are at the temperature value of same design temperature curve, same temperature control section, synchronization; Σ Vjifor n historical data sum; Yjithe value calculating according to design temperature curve values formula one for same base table.
Data precision is the diversity factor of collecting temperature curve and temperature control curve, and diversity factor belongs to high precision within positive and negative 3%,
Outside positive and negative 3%, belong to low precision, data precision size can arrange, and is not limited to positive and negative 3%.
Referring to Fig. 3, the temperature control base table in the embodiment of the present invention can adopt humidostat, and the temperature control line of this humidostat is connected to electric thermo-couple test furnace.
Algorithm design principle summary agreement will be understood the temperature variation of a base table every 1 minute, be 6.7 minutes so in collection period higher limit, and each base table has just been lost respectively 6.7 data.The following formula of the employing of these 6.7 data is calculated.For simplifying, in arthmetic statement, the number of base table is got [60,6400] the interval upper limit or lower limit, and 60 or 6400.The number of base table is less than 60 system acquisition and there will not be loss of data, and the number of base table is greater than 6400 systems and cannot processes. arthmetic statement (Statistics Temperature Data Fitting Algorithm)
(1) the pseudo-C language description of benefit reward temperature control data acquisition algorithm is as follows:
(2) data sampling algorithm
The host computer that data sampling algorithm the refers to system sample period is according to the rules read the real time temperature value of certain base table in logging storer, calls STEDAFA algorithm when wrong according to the data that send or send when logging is countless.Its pseudo-C language codes is as follows:
Below further describe logging communication protocol.
(1) instruction that, host computer may send is as follows:
Position: the real time clock of proofreading and correct logging.(date Hour Minute Second)
Read base table parameter: read and specify the parameter value of specifying in base table.(base table address, parameter sequence number)
Amendment base table parameter: the parameter value of specifying in base table is specified in amendment.(base table address, parameter sequence number, parameter value)
Issue curve data: issue the current temperature control curve data of each base table to logging.(base table number, curve data)
Suspend/start: control and specify base table to suspend or start.(base table address, order)
Acquisition and recording: gather temperature detector record from the data-carrier store of logging.
(2), host computer sends order to logging
Host computer sends order bag to logging, and form is as follows:
Address, address radix-minus-one complement, 07,00, C1, year, month, day, time, point, second, check code L, check code H
After logging fill order, return response packet format is as follows:
Address, 01,00, result code, check code L, check code H.
(3), read base table parameter
Host computer sends order bag to logging, and form is as follows:
Address, address radix-minus-one complement, 03,00, C2, base table address, parameter number, check code L, check code H
Logging receives orders, and from specifying base table to read relevant parameter data, return response packet format is as follows:
Address, 0B, 00, result code, base table address, parameter number, PV[2], SV[2] and, MV, B, parameter value [2], check code L, check code H.
(4), amendment base table parameter
Host computer sends order bag to logging, and form is as follows:
Address, address radix-minus-one complement, 05,00, C3, base table address, parameter number, parameter value [2], check code L, check code H
Logging receives orders, to specify base table be incorporated into relevant parameter data after return response packet format as follows:
Address, 0B, 00, result code, base table address, parameter number, PV[2], SV[2] and, MV, B, parameter value [2], check code L, check code H.
(5), issue curve data
Host computer sends order bag to logging, and form is as follows:
Address, address radix-minus-one complement, 53,00, C4, base table address, bag sequence number, curve data [80], check code L, check code H
Bag sequence number: 0~8. (if issue 90 sections of curves, be divided into 9 bag orders and issue)
Curve data: can send at most 10 sections of curve datas, every segment data accounts for 8 bytes at every turn, and structure is as follows:
Initial temperature [2], final temperature [2], working time [2], instruction character [1], mark [1]
After logging fill order, return response packet format is as follows:
Address, 01,00, result code, check code L, check code H.
(6), suspend/start and control
Host computer sends order bag to logging, and form is as follows:
Address, address radix-minus-one complement, 03,00, C5, base table address, control code, check code L, check code H
If base table address value FF, represents all base tables to control
Control code: 00=suspends, and 01=starts
After logging fill order, return response packet format is as follows:
Address, 01,00, result code, check code L, check code H.
(7), acquisition and recording
Host computer sends order bag to logging, and form is as follows:
Address, address radix-minus-one complement, 05,00, C6, bag sequence number [4], check code L, check code H
Bag sequence number: 0~xxxxxxx, (512 bytes/bag)
Logging return response packet format is as follows:
Address, 01,02, result code, data [512], check code L, check code H
Temperature detector records every and accounts for 16 bytes, and form is as follows:
Mark [1], base table address [1], temperature value [2], date Hour Minute Second [6], retains [6].
(8), logging " in real time " image data communication protocol:
Host computer sends querying command bag to logging, and form is as follows:
Address, address radix-minus-one complement, 02,00, C7,01, check code L, check code H
Logging return response packet format is as follows:
Address, 15,00, result code, data [20], check code L, check code H
Countless according to time, result code=00
While having data, result code=01
Data [20]: form is as follows:
In the time of result code=01, host computer must send data validation bag to logging again, notifies this record of logging to receive,
If not receiving to confirm to wrap, logging will reply same record always.Data validation packet format is as follows:
Address, address radix-minus-one complement, 02,00, C7,02, check code L, check code H
The nonreply of data validation bag.
Real-time Collection step is as follows: step 1), host computer are sent out querying command bag; Step 2), logging loopback should wrap; In step 3), response packet, countless certificates, get back to step 1); Step 4), host computer are sent out data validation bag, get back to step 1).