Skip to content
Snippets Groups Projects
Commit 59e31a1f authored by Thomas Bock's avatar Thomas Bock :speech_balloon:
Browse files

dcc sens, clean up

parent 834d5674
No related branches found
No related tags found
No related merge requests found
{ {
"device_description":"item", "device_description": "item",
"error_and_cf":"used_method",
"result_error":"used_method", "error_and_cf": "used_method",
"temperature_correction":"used_method", "result_error": "used_method",
"uncertainty-cdg":"used_method", "result_sens": "used_method",
"calibration_procedure-se3-cdg":"used_method",
"calibration_procedure-se3-srg":"used_method", "temperature_correction": "used_method",
"calibration_procedure-ce3-ig":"used_method",
"sigma":"used_method", "calibration_procedure-se3-cdg": "used_method",
"uncertainty-srg":"used_method", "calibration_procedure-se3-srg": "used_method",
"uncertainty-ig":"used_method" "calibration_procedure-ce3-ig": "used_method",
"sigma": "used_method",
"sens": "used_method",
"uncertainty-srg": "used_method",
"uncertainty-fm1-tlv": "used_method",
"uncertainty-ig": "used_method",
"uncertainty-cdg": "used_method"
} }
...@@ -78,14 +78,8 @@ class Trans: ...@@ -78,14 +78,8 @@ class Trans:
"en": ", comparison with rotary piston gauge" "en": ", comparison with rotary piston gauge"
} }
} }
dcc_unit_trans = {
"1":"\\one",
"mbar": "\\hecto\\kilogram\\metre\\tothe{-1}\\second\\tothe{-2}",
"Pa":"\\kilogram\\metre\\tothe{-1}\\second\\tothe{-2}",
"1/Pa":"\\kilogram\\tothe{-1}\\metre\\second\\tothe{2}",
"K":"\\kelvin",
"A":"\\ampere"
}
def __init__(self, config, app, db): def __init__(self, config, app, db):
self.latex_path = config['templates']['latex'] self.latex_path = config['templates']['latex']
...@@ -131,9 +125,7 @@ class Trans: ...@@ -131,9 +125,7 @@ class Trans:
return cert return cert
def dcc(self, cal_docs): def dcc(self, cal_docs):
cal_docs = [doc for doc in cal_docs if not utils.should_skipped(doc)] cal_docs = [doc for doc in cal_docs if not utils.should_skipped(doc)]
maintainers = self.db.get_maintainers() maintainers = self.db.get_maintainers()
...@@ -141,13 +133,13 @@ class Trans: ...@@ -141,13 +133,13 @@ class Trans:
info_doc = cal_docs[-1] info_doc = cal_docs[-1]
lang = utils.get_lang(info_doc) lang = utils.get_lang(info_doc)
begin_meas_date, end_meas_date = utils.meas_date_begin_end(cal_docs) begin_meas_date, end_meas_date = utils.meas_date_begin_end(cal_docs)
cert = {
"RequestId": utils.get_request_id(cal_docs=cal_docs), cert = {"RequestId": utils.get_request_id(cal_docs=cal_docs),
"Meta": utils.get_meta(cal_docs=cal_docs), "Meta": utils.get_meta(cal_docs=cal_docs),
"Device": utils.get_device(cal_docs=cal_docs), "Device": utils.get_device(cal_docs=cal_docs),
"Helper":{"gas_trans":self.gas_trans, "meas_type_trans":self.meas_type_trans}, "Helper":{"gas_trans":self.gas_trans, "meas_type_trans":self.meas_type_trans},
"Table": utils.get_tables(cal_docs=cal_docs), "Table": utils.get_tables(cal_docs=cal_docs),
"MeasurementData": utils.get_measurement_data(cal_docs=cal_docs),} "MeasurementData": utils.get_measurement_data(cal_docs=cal_docs),}
secs = sections.get_all(cert) secs = sections.get_all(cert)
## needed for replacement of second order templates ## needed for replacement of second order templates
...@@ -162,75 +154,35 @@ class Trans: ...@@ -162,75 +154,35 @@ class Trans:
template = self.texenv.env.from_string(p) template = self.texenv.env.from_string(p)
para["Text"] = template.render(cert).strip() para["Text"] = template.render(cert).strip()
return {"administrativeData":{ return {"administrativeData":{"coreData":{"countryCodeISO3166_1":"DE",
"coreData":{ "usedLangCodeISO639_1":"de",
"countryCodeISO3166_1":"DE", "usedLangCodeISO639_1":"en",
"usedLangCodeISO639_1":"de", "mandatoryLangCodeISO639_1":lang,
"usedLangCodeISO639_1":"en", "uniqueIdentifier": utils.dcc_unique_identifier(info_doc),
"mandatoryLangCodeISO639_1":lang, "identifications": utils.dcc_identification_lab(info_doc),
"uniqueIdentifier":"{}PTB{}".format(utils.get_certificate(info_doc), #"receiptDate": utils.get_current_date(),
utils.get_current_year(short=True)), "beginPerformanceDate": begin_meas_date,
"identifications":{ "endPerformanceDate": end_meas_date,
"identification":[{"issuer":"calibrationLaboratory", "performanceLocation": "laboratory"},
"value": utils.get_reference_no(info_doc), "items":{"name":[{"lang":lang, "content":[utils.get_customerobject_type(info_doc)]}],
"name":[{"lang":"en", "item":[{"identifications": utils.dcc_identification_manufacturer(info_doc),
"content": ["Reference No."]}, "description":utils.dcc_calibration_object_description(cal_docs, secs),
{"lang":"de", "name":[{"lang": utils.get_lang(info_doc), "content": [utils.get_customerobject_device_type(info_doc)]}],
"content": ["Geschäftszeichen"]}]}]}, "manufacturer": utils.dcc_manufacturer(info_doc)}]},
#"receiptDate": utils.get_current_date(), "calibrationLaboratory": utils.dcc_calibration_laboratory(),
"beginPerformanceDate": begin_meas_date, "respPersons":{"respPerson":[utils.dcc_resp_person(cal_docs, maintainers),
"endPerformanceDate": end_meas_date, utils.dcc_meas_maintainer(cal_docs, maintainers)]},
"performanceLocation": "laboratory",}, "customer": utils.dcc_customer(cal_docs, countries),
"items":{ "dccSoftware":utils.dcc_software(cal_docs),
"name":[{"lang":lang, "statements": utils.dcc_statements(cal_docs)},
"content":[utils.get_customerobject_type(info_doc)]}], "measurementResults":{"name":[{"lang":"de", "content":["Ergebnis der Kalibrierung"]},
"item":[{ {"lang":"en", "content":["Result of the calibration"]}],
"identifications":{ "usedMethods":{"usedMethod": utils.dcc_used_methodes(cal_docs, secs)},
"identification":[{"issuer":"manufacturer", "influenceConditions": utils.dcc_influence_cond(cal_docs,
"value": utils.get_customerobject_device_serial(info_doc), self.gas_trans,
"name":[{"lang":"en", self.meas_type_trans,
"content":["Serial No."]}, utils.dcc_unit_trans()),
{"lang":"de", "results": {"result":utils.dcc_result(cal_docs,
"content":["Kennnummer"]}]}]}, self.gas_trans,
"description":utils.dcc_calibration_object_description(cal_docs, secs), self.meas_type_trans,
"name":[{"lang": utils.get_lang(info_doc), utils.dcc_unit_trans())}}}
"content": [utils.get_customerobject_device_type(info_doc)]}],
"manufacturer": {
"name":[{"lang": utils.get_lang(info_doc),
"content": [utils.get_customerobject_device_producer(info_doc)]}]}}]},
"calibrationLaboratory":{
"contact":{"name":[{"lang":"de",
"content":["Physikalisch-Technische Bundesanstalt (PTB)"]},
{"lang":"en",
"content":["Physikalisch-Technische Bundesanstalt (PTB)"]}],
"eMail":"vacuum.cal@ptb.de",
"location":{
"further":[{"lang":"en",
"content":["Working Group 7.54 Vacuum Metrology"]},
{"lang":"de",
"content":["Arbeitsgruppe 7.54 Vakuummetrologie"]}],
"street":"Abbestraße",
"streetNo": "2--12",
"postCode": "10587",
"city":"Berlin",
"countryCode":"DE"}}},
"respPersons":{
"respPerson":[utils.dcc_resp_person(cal_docs, maintainers),
utils.dcc_meas_maintainer(cal_docs, maintainers)]},
"customer": utils.dcc_customer(cal_docs, countries),
"dccSoftware":utils.dcc_software(cal_docs),
"statements": utils.dcc_statements(cal_docs)},
"measurementResults":{
"name":[{"lang":"de",
"content":["Ergebnis der Kalibrierung"]},
{"lang":"en",
"content":["Result of the calibration"]}],
"usedMethods":{"usedMethod": utils.dcc_used_methodes(cal_docs, secs)},
"influenceConditions": utils.dcc_influence_cond(cal_docs,
self.gas_trans,
self.meas_type_trans,
self.dcc_unit_trans),
"results": {"result":utils.dcc_result(cal_docs,
self.gas_trans,
self.meas_type_trans,
self.dcc_unit_trans)}}}
...@@ -3,9 +3,7 @@ import git ...@@ -3,9 +3,7 @@ import git
import requests import requests
import datetime import datetime
import re import re
from flask import jsonify, Response from flask import jsonify, Response
from pprint import pprint from pprint import pprint
def set_filename_header(res, no): def set_filename_header(res, no):
...@@ -14,7 +12,7 @@ def set_filename_header(res, no): ...@@ -14,7 +12,7 @@ def set_filename_header(res, no):
res.headers['Content-Type'] = 'application/x-latex;charset=utf-8' res.headers['Content-Type'] = 'application/x-latex;charset=utf-8'
res.headers['content-disposition'] = 'attachment' res.headers['content-disposition'] = 'attachment'
res.headers['Access-Control-Expose-Headers'] = 'filename, content-disposition, Server, Date, Content-Type' res.headers['Access-Control-Expose-Headers'] = 'filename, content-disposition, Server, Date, Content-Type'
res.headers['filename'] = '\"ks-{no}-{today}.tex\"'.format( no=no, today=today) res.headers['filename'] = '\"ks-{no}-{today}.tex\"'.format(no=no, today=today)
return res return res
...@@ -53,8 +51,8 @@ def get_meta(cal_docs): ...@@ -53,8 +51,8 @@ def get_meta(cal_docs):
"id":[], "id":[],
"kind":[], "kind":[],
"gas":[], "gas":[],
"lang":"" "lang":""}
}
for i, doc in enumerate(cal_docs): for i, doc in enumerate(cal_docs):
meta['skip'].append(should_skipped(doc)) meta['skip'].append(should_skipped(doc))
meta['std'].append(get_std(doc)) meta['std'].append(get_std(doc))
...@@ -74,7 +72,6 @@ def get_request_id(cal_docs): ...@@ -74,7 +72,6 @@ def get_request_id(cal_docs):
doc = cal_docs[-1] doc = cal_docs[-1]
return doc.get("Calibration", {}).get("Presettings", {}).get("RequestId") return doc.get("Calibration", {}).get("Presettings", {}).get("RequestId")
def get_last_cert(cal_docs): def get_last_cert(cal_docs):
"""Returns the last Cert sign or None. """Returns the last Cert sign or None.
""" """
...@@ -199,10 +196,9 @@ def get_calibration_data(cal_docs): ...@@ -199,10 +196,9 @@ def get_calibration_data(cal_docs):
return doc.get("Calibration", {}).get("Result", {}).get("CalibrationData") return doc.get("Calibration", {}).get("Result", {}).get("CalibrationData")
def get_titlepage(cal_docs, countries, maintainers): def get_titlepage(cal_docs, countries, maintainers):
title = { title = { "ShortYear":get_current_year(short=True),
"ShortYear":get_current_year(short=True), "FullYear": get_current_year(),
"FullYear": get_current_year(), "CertificateDate": get_current_date(),}
"CertificateDate": get_current_date(),}
fs_val = 0.0 fs_val = 0.0
fs_unit = "Pa" fs_unit = "Pa"
...@@ -239,10 +235,58 @@ def get_titlepage(cal_docs, countries, maintainers): ...@@ -239,10 +235,58 @@ def get_titlepage(cal_docs, countries, maintainers):
return title return title
def rm_leading_comma(s): def rm_leading_comma(s):
return re.sub("^,\s" , "", s) return re.sub("^,\s" , "", s)
def dcc_unit_trans():
return {"1":"\\one",
"mbar": "\\hecto\\kilogram\\metre\\tothe{-1}\\second\\tothe{-2}",
"Pa": "\\kilogram\\metre\\tothe{-1}\\second\\tothe{-2}",
"1/Pa": "\\kilogram\\tothe{-1}\\metre\\second\\tothe{2}",
"K": "\\kelvin",
"A": "\\ampere"}
def dcc_calibration_laboratory():
return {"contact":{"name":[{"lang":"de",
"content":["Physikalisch-Technische Bundesanstalt (PTB)"]},
{"lang":"en",
"content":["Physikalisch-Technische Bundesanstalt (PTB)"]}],
"eMail": "vacuum.cal@ptb.de",
"location":{
"further":[{"lang": "en",
"content":["Working Group 7.54 Vacuum Metrology"]},
{"lang": "de",
"content":["Arbeitsgruppe 7.54 Vakuummetrologie"]}],
"street": "Abbestraße",
"streetNo": "2--12",
"postCode": "10587",
"city": "Berlin",
"countryCode": "DE"}}}
def dcc_unique_identifier(info_doc):
return "{}PTB{}".format(get_certificate(info_doc), get_current_year(short=True))
def dcc_identification_lab(info_doc):
return {"identification":[{"issuer":"calibrationLaboratory",
"value": get_reference_no(info_doc),
"name":[{"lang":"en",
"content": ["Reference No."]},
{"lang":"de",
"content": ["Geschäftszeichen"]}]}]}
def dcc_manufacturer(info_doc):
return {"name":[{"lang": get_lang(info_doc),
"content": [get_customerobject_device_producer(info_doc)]}]}
def dcc_identification_manufacturer(info_doc):
return {"identification":[{"issuer":"manufacturer",
"value": get_customerobject_device_serial(info_doc),
"name":[{"lang":"en",
"content":["Serial No."]},
{"lang":"de",
"content":["Kennnummer"]}]}]}
def dcc_result(cal_docs, gas_trans, meas_type_trans, unit_trans): def dcc_result(cal_docs, gas_trans, meas_type_trans, unit_trans):
result = [] result = []
...@@ -328,15 +372,13 @@ def dcc_sigma_result(doc, dcc_unit_trans ): ...@@ -328,15 +372,13 @@ def dcc_sigma_result(doc, dcc_unit_trans ):
return res return res
def dcc_gen_real(val, unit, uncert, cover, prob): def dcc_gen_real(val, unit, uncert, cover, prob):
return {"value":val, return {"value": val,
"unit":unit, "unit": unit,
"expandedUnc":{ "expandedUnc":{"uncertainty": uncert,
"uncertainty":uncert, "coverageFactor": cover,
"coverageFactor": cover, "coverageProbability": prob}}
"coverageProbability": prob,}}
def dcc_influence_cond(cal_docs, gas_trans, meas_type_trans, unit_trans): def dcc_influence_cond(cal_docs, gas_trans, meas_type_trans, unit_trans):
influence_cond = {"name":[{"lang":"de", influence_cond = {"name":[{"lang":"de",
"content":["Die Kalibrierung wurde bei folgenden Umgebungsbedingungen ausgeführt"]}, "content":["Die Kalibrierung wurde bei folgenden Umgebungsbedingungen ausgeführt"]},
{"lang":"en", {"lang":"en",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment