Exemple #1
0
def upgradeDataProc(recv, self):
    if isinstance(recv, dict):
        data = recv
        if 'ip' in data and 'port' in data:
            self.uplist["ip"] = data["ip"]
            self.uplist["port"] = data["port"]
        if 'recvData' in data:
            data = data["recvData"]
    elif isinstance(recv, str):
        ret, data = jsonframe.subStrToJson(recv)
        if ret and "ip" and "port" in data:
            self.uplist["ip"] = data["ip"]
            self.uplist["port"] = data["port"]
            if "DataTime" not in data["recvData"]:
                return
        data = data["recvData"]
    else:
        return

    if isinstance(data, str):
        ret, data = jsonframe.subStrToJson(data)

    if ret and "04A00503" in data["DataValue"]:
        if data["DataValue"]["04A00503"][13:17] == "0001":
            bstr = data["DataValue"]["04A00503"][18:]
            upgradeRecvDataToMap(0, bstr, self)
        elif data["DataValue"]["04A00503"][13:17] == "0002":
            bstr = data["DataValue"]["04A00503"][18:]
            upgradeRecvDataToMap(1, bstr, self)
Exemple #2
0
def RecvProcess(self):
    if not self.qRecv.empty():
        data = self.qRecv.get()

        if "linkNum" in data:
            SocketLinkManage(self, data['linkNum'])
            return

        linkNum = socketServer.GetLinkNum()
        if linkNum > 0:
            SocketLinkManage(self, linkNum)

        if isinstance(data, dict):
            if 'recvData' in data:
                data = data["recvData"]
        elif isinstance(data, str):
            data = jsonframe.subStrToJson(data)
            if "DataTime" not in data["recvData"]:
                return
            data = data["recvData"]
        else:
            return

        if isinstance(data, str):
            data = jsonframe.subStrToJson(data)

        plan = self.uim.planComboBox.currentText()
        type = judgePrtl(plan)

        # 是否有报文, 解析成标准报文, 供收发界面显示
        senddata = self.test["SendFrame"]
        senddata = jsonframe.subStrToJson(senddata)
        answer = self.test["Answer"]
        answer = jsonframe.subStrToJson(answer)

        # 界面显示
        # data = jsonframe.subStrToJson(data)
        mainlog = showinfo.addTimelog(str(data))
        self.uim.RxTextEdit.append(mainlog)

        ret, value = prtlDealFrame(type, data, senddata, answer)
        if ret > 0 and value is not None and len(value) > 0:
            self.test["timeout"] = 0.5
            if self.test["Index"] < self.test["Num"]:
                self.uim.AnaTableWidget.setItem(self.test["Index"] - 1, 4,
                                                QTableWidgetItem(value))
                self.uim.AnaTableWidget.setItem(self.test["Index"] - 1, 5,
                                                QTableWidgetItem("合格"))
Exemple #3
0
def contjson(content):
    jsondata = bytes.decode(content)

    # 将json对象转换成python对象
    data = json.loads(jsondata)

    count = data["data"]["count"]
    recvtimelist = []
    valuelist = []
    for i in range(count):
        dic = data["data"]["datastreams"][0]["datapoints"][i]

        recvtime = dic["at"]
        value = dic["value"]
        ret, jsonvalue = subStrToJson(value)
        recvtimelist += [recvtime]
        valuelist += [jsonvalue]
    return count, recvtimelist, valuelist