def w_print(data): ret = xml_print() raw = ret["raw"] doc = ret["doc"] psn = data["psn"] detail = doc.createElement("Detail") raw.appendChild(detail) xml_node(doc, detail, "Key", "CID") xml_node(doc, detail, "Value", psn) return doc.toxml(encoding='gbk')
def w_ack(): ret = xml_ack() raw = ret["raw"] doc = ret["doc"] now = datetime.datetime.now() tim = datetime.datetime.strftime(now, '%Y%m%d%H%M%S') detail = doc.createElement("Detail") raw.appendChild(detail) xml_node(doc, detail, "STA", "X000") xml_node(doc, detail, "TIM", str(tim)) return doc.toxml(encoding='gbk')
def w_fin(data): ret = xml_fin() psn = data["psn"] bzd = get_bodyident(psn) bodyident = ret["bodyident"] kident = ret["kident"] raw = ret["raw"] doc = ret["doc"] bodyident.setAttribute("plant", get_item(bzd, "plant")) bodyident.setAttribute("checkdigit", get_item(bzd, "checkdigit")) bodyident.setAttribute("productionyear", get_item(bzd, "productionyear")) bodyident.setAttribute("id", get_item(bzd, "bodyidentid")) kid = get_kinident(psn) kident.setAttribute("plant", get_item(kid, "plant")) kident.setAttribute("componentnumber", get_item(kid, "componentnumber")) kident.setAttribute("productionyear", get_item(kid, "productionyear")) kident.setAttribute("id", get_item(kid, "bodyidentid")) kident.setAttribute("serial", " ") kident.setAttribute("checkdigit", get_item(kid, "checkdigit")) tin = get_item(data, u"in") tin = datetime.datetime.strptime( tin, "%Y-%m-%d %H:%M:%S").strftime("%Y%m%d%H%M%S") tout = get_item(data, u"out") tout = datetime.datetime.strptime( tout, "%Y-%m-%d %H:%M:%S").strftime("%Y%m%d%H%M%S") result = {"CID": psn, "IN": tin, "OUT": tout} for k, v in result.iteritems(): detail = doc.createElement("Detail") raw.appendChild(detail) xml_node(doc, detail, "Key", k) xml_node(doc, detail, "Value", v) return doc.toxml(encoding='gbk')
def w_eol(data): psn = data["psn"] wsn = data["wsn"] eol_data = data["data"] status = data["status"] ret = xml_eol() location = ret["location"] device = ret["device"] bodyident = ret["bodyident"] doc = ret["doc"] prc_sst_world = ret["prc_sst_world"] location.setAttribute("assembly_cycle", get_assemble(wsn)) device.setAttribute("hostname", get_hostname(wsn)) bid = get_bodyident(psn) bodyident.setAttribute("plant", get_item(bid, "plant")) bodyident.setAttribute("checkdigit", get_item(bid, "checkdigit")) bodyident.setAttribute("productionyear", get_item(bid, "productionyear")) bodyident.setAttribute("id", get_item(bid, "bodyidentid")) abz = doc.createElement("ABZ") prc_sst_world.appendChild(abz) wrk = doc.createElement("WRK") prc_sst_world.appendChild(wrk) fsg = doc.createElement("FSG") prc_sst_world.appendChild(fsg) fab = doc.createElement("FAB") prc_sst_world.appendChild(fab) fbr = doc.createElement("FBR") prc_sst_world.appendChild(fbr) ort = doc.createElement("ORT") prc_sst_world.appendChild(ort) abs = doc.createElement("ABS") prc_sst_world.appendChild(abs) pnr = doc.createElement("PNR") prc_sst_world.appendChild(pnr) par = doc.createElement("PAR") prc_sst_world.appendChild(par) prt = doc.createElement("PRT") par.appendChild(prt) xml_node(doc, par, "PI1", psn) pi2 = doc.createElement("PI2") par.appendChild(pi2) stc = doc.createElement("STC") par.appendChild(stc) result = get_item(status, "result") if result == "pass": xml_node(doc, par, "PSC", "IO") else: xml_node(doc, par, "PSC", "NIO") xml_node(doc, par, "TotalTestTime", status["totaltesttime"]) xml_node(doc, par, "Operator", status["Operator"]) xml_node(doc, par, "Tp-Name", status["Tp-Name"]) xml_node(doc, par, "gbcode", status["gbcode"]) xml_node(doc, par, "bustype", status["bustype"]) xml_node(doc, par, "bzdno", status["bzdno"]) for i in eol_data: fas = doc.createElement("FAS") par.appendChild(fas) xml_node(doc, fas, "FAP", get_item(i, "itemname")) xml_node(doc, fas, "FNR", get_item(i, "stepno")) wid = doc.createElement("WID") fas.appendChild(wid) s = get_item(i, "result") if s == "pass": xml_node(doc, fas, "FSC", "IO") else: xml_node(doc, fas, "FSC", "NIO") sio = doc.createElement("SIO") fas.appendChild(sio) iio = doc.createElement("IIO") fas.appendChild(iio) ino = doc.createElement("INO") fas.appendChild(ino) grp = doc.createElement("GRP") fas.appendChild(grp) PNR = doc.createElement("PNR") grp.appendChild(PNR) GNR = doc.createElement("GNR") grp.appendChild(GNR) PRG = doc.createElement("PRG") grp.appendChild(PRG) DAT = doc.createElement("DAT") grp.appendChild(DAT) TIM = doc.createElement("TIM") grp.appendChild(TIM) TAC = doc.createElement("TAC") grp.appendChild(TAC) objl = doc.createElement("OBJL") grp.appendChild(objl) i.pop("esn") i.pop("stepno") i.pop("line") i.pop("psn") i.pop("result") i.pop("time") i.pop("wsn") i.pop("extname") i.pop("itemname") for aaa in i: obj = doc.createElement("OBJ") objl.appendChild(obj) xml_node(doc, obj, "NAME", aaa) ist = doc.createElement("IST") obj.appendChild(ist) unt = doc.createElement("UNT") ist.appendChild(unt) val = doc.createElement("VAL") ist.appendChild(val) xml_node(doc, val, "VAD", get_item(i, aaa)) sta = doc.createElement("STA") ist.appendChild(sta) return doc.toxml(encoding='gbk')