def load_real_data():
    DataCommand = ice_con()
    pIDs = []
    ycdata = []
    for i in range(5):
        pIDs.append(i)
        structycdata = YCArea.DxDTYC(i, i + 1.1, i)
        ycdata.append(structycdata)

    print("........开始写入遥测数据.......")
    start = time.time()
    # 写入redis
    DataCommand.RPCSetRealtimeYCData(pIDs, ycdata)
    writeElapsed = time.time() - start
    print("write time use: %s " % writeElapsed)

    print("........开始读取遥测最新数据.......")
    start = time.time()
    ycstatus, ycdata = DataCommand.RPCGetRealtimeYCData(pIDs)
    readElapsed = time.time() - start
    print("read time use: %s " % readElapsed)
    # print(ycstatus)
    ycdatanum = len(ycdata)
    # print("总计读取遥测数据:%d " % ycdatanum)
    data0 = [writeElapsed, readElapsed, ycdatanum]
    data1 = []
    for i in range(len(ycdata)):
        data1.append({'status': ycdata[i].status,
                      'value': ycdata[i].value,
                      'timetag': ycdata[i].timetag})
    data = [data0, data1]
    return data
Beispiel #2
0
def set_soe_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newsoe = request.form.get("data")
    SoeProperty = json.loads(newsoe)
    soep = []
    for i in range(len(SoeProperty)):
        soep.append(json.loads(SoeProperty[i]))
    soeproperty = []
    for j in range(len(soep[1])):
        ID = soep[0][j]
        name = soep[1][j]
        describe = soep[2][j]
        level = soep[3][j]
        address = soep[4][j]
        if ID == "":
            ID = 1000
        if name == "":
            name = "请添加SOE名称"
        if describe == "":
            describe = "请描述SOE"
        if level == "":
            level = 1
        if address == "":
            address = "0"
        soepstruct = SOEArea.DxPropertySOE(int(ID), name.encode("utf-8"),
                                           describe.encode("utf-8"),
                                           int(level), address.encode("utf-8"))
        soeproperty.append(soepstruct)
    DataCommand.RPCSetSOEProperty(station, soeproperty)
    return '保存成功!'
def set_station_property():
    DataCommand = ice_con()
    newstation = request.form.get("data")
    new_station = json.loads(newstation)
    stations = json.loads(new_station[len(new_station) - 1])
    sta = []
    for i in range(len(stations)):
        sta.append(long(stations[i]))
    new_station.pop()
    StationProperty = new_station
    stationp = []
    for i in range(len(StationProperty)):
        stationp.append(json.loads(StationProperty[i]))
    stap = []
    for j in range(len(stations)):
        spstruct = StationArea.DxPropertyStation(
            stationp[0][j].encode("utf-8"), int(stationp[1][j]),
            int(stationp[2][j]), int(stationp[3][j]),
            stationp[4][j].encode("utf-8"), stationp[5][j].encode("utf-8"),
            stationp[6][j].encode("utf-8"), int(stationp[7][j]),
            int(stationp[8][j]), stationp[9][j].encode("utf-8"),
            int(stationp[10][j]), int(stationp[11][j]), int(stationp[12][j]),
            int(stationp[13][j]), int(stationp[14][j]), int(stationp[15][j]))
        stap.append(spstruct)
    # sta = [13L]
    # spstruct = StationArea.DxPropertyStation("station", 11, 12000, 100, "st_protocol", "192.168.100.111",
    #                                          "192.168.100.112", 200, 20000, "st_devName",
    #                                          20000, 31000, 32000, 100, 40000, 41000)
    # stap.append(spstruct)
    DataCommand.RPCSetStationProperty(sta, stap)
    return '保存成功!'
Beispiel #4
0
def delete_station_data():
    DataCommand = ice_con()
    stationIDs = request.form.get("ids")
    stations = json.loads(stationIDs)
    sta = []
    for i in range(len(stations)):
        sta.append(long(stations[i]))
    DataCommand.RPCDelStationProperty(sta)
    return '删除成功!'
def set_sys_property():
    DataCommand = ice_con()
    newstation = request.form.get("data")
    new_station = json.loads(newstation)
    syspstruct = SystemArea.DxPropertySystem(new_station[0].encode("utf-8"),
                                             int(new_station[1]))
    # syspstruct = SystemArea.DxPropertySystem("systemm", 10)
    DataCommand.RPCSetSystemProperty(syspstruct)
    return '保存成功!'
def get_soe_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetSOEProperty(station)
    soeproperty = []
    for i in range(len(result)):
        soeproperty.append({"ID": result[i].ID, "name": result[i].name,
                           "describe": result[i].describe, "level": result[i].level, "address": result[i].address})
    return json.dumps(soeproperty)
def delete_yx_data():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    yxIDs = request.form.get("ids")
    yx_IDs = json.loads(yxIDs)
    pIDs = []
    for i in range(len(yx_IDs)):
        pIDs.append(long(yx_IDs[i]))
    DataCommand.RPCDelYXProperty(station, pIDs)
    return '删除成功!'
Beispiel #8
0
def get_soe_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetSOEProperty(station)
    soeproperty = []
    for i in range(len(result)):
        soeproperty.append({"num": result[i].num, "level": result[i].level,
                           "NowTime": result[i].NowTime, "time": result[i].time,
                           "StationName": result[i].StationName, "SOEName": result[i].SOEName,
                           "pointID": result[i].pointID, "status": result[i].status,
                           "Operater": result[i].Operater, "SOEOper": result[i].SOEOper})
    return json.dumps(soeproperty)
def get_yk_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetYKProperty(station)
    ykproperty = []
    for i in range(len(result)):
        ykproperty.append({"ID": result[i].ID, "name": result[i].name,
                           "describe": result[i].describe, "ASDU": result[i].ASDU,
                           "wordPos": result[i].wordPos, "bitPos": result[i].bitPos,
                           "bitLength": result[i].bitLength, "EnablePoint": result[i].EnablePoint,
                           "EnableValue": result[i].EnableValue, "address": result[i].address})
    return json.dumps(ykproperty)
Beispiel #10
0
def set_yk_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyk = request.form.get("data")
    YkProperty = json.loads(newyk)
    ykp = []
    for i in range(len(YkProperty)):
        ykp.append(json.loads(YkProperty[i]))
    ykproperty = []
    for j in range(len(ykp[1])):
        ID = ykp[0][j]
        name = ykp[1][j]
        describe = ykp[2][j]
        ASDU = ykp[3][j]
        wordPos = ykp[4][j]
        bitPos = ykp[5][j]
        bitLength = ykp[6][j]
        EnablePoint = ykp[7][j]
        EnableValue = ykp[8][j]
        address = ykp[9][j]
        if ID == "":
            ID = 1000
        if name == "":
            name = "请添加遥控名称"
        if describe == "":
            describe = "请描述遥控"
        if ASDU == "":
            ASDU = 0
        if wordPos == "":
            wordPos = 0
        if bitPos == "":
            bitPos = 0
        if bitLength == "":
            bitLength = 1
        if EnablePoint == "":
            EnablePoint = 0
        if EnableValue == "":
            EnableValue = 0
        if address == "":
            address = "0"
        ykpstruct = YKArea.DxPropertyYK(int(ID), name.encode("utf-8"),
                                        describe.encode("utf-8"), int(ASDU),
                                        int(wordPos), int(bitPos),
                                        int(bitLength), int(EnablePoint),
                                        int(EnableValue),
                                        address.encode("utf-8"))
        ykproperty.append(ykpstruct)
    DataCommand.RPCSetYKProperty(station, ykproperty)
    return '保存成功!'
def background_thread():
    # print("线程启动!")
    DataCommand = ice_con()
    # print(type(DataCommand))
    while True:
        socketio.sleep(1)
        pIDs = []
        pIDs.append(0)
        ycdata = []
        """
        print("........开始写入遥测当天数据.......")
        start = time.time()
        for i in range(1000):
            structycdata = YCArea.DxDTYC(i, i+1.1, i)
            ycdata.append(structycdata)
            
            # 写入redis
            # DataCommand.RPCSetRealtimeYCData(pIDs, ycdata)
            # 写入cassandra
            DataCommand.RPCSaveYCData(pIDs, ycdata)
            DataCommand.RPCGetRealtimeYCData(pIDs)
            ycdata.pop()
        elapsed = time.time() - start
        print("write time use: %s " % elapsed)
        """
        pID = 0
        datetime = "20190527"
        print("........开始获取遥测当天数据.......")
        start = time.time()
        ycstatus, ycdata = DataCommand.RPCGetDayYCData(datetime, pID)
        elapsed = time.time() - start
        print("read time use: %s " % elapsed)
        print(ycstatus)
        ycdatanum = len(ycdata)
        print("总计读取遥测数据:%d " % ycdatanum)
        """
        for i in range(len(ycdata)):
            print(ycdata[i].status, ycdata[i].value, ycdata[i].timetag)
        """
        # print(ycdata)
        data0 = [elapsed, ycdatanum]
        data1 = []
        for i in range(len(ycdata)):
            data1.append({
                'status': ycdata[i].status,
                'value': ycdata[i].value,
                'timetag': ycdata[i].timetag
            })
        data = [data0, data1]
        socketio.emit('server_response', data, namespace='/test')
Beispiel #12
0
def set_yc_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyc = request.form.get("data")
    YcProperty = json.loads(newyc)
    ycp = []
    for i in range(len(YcProperty)):
        ycp.append(json.loads(YcProperty[i]))
    ycproperty = []
    for j in range(len(ycp[1])):
        ID = ycp[0][j]
        name = ycp[1][j]
        describe = ycp[2][j]
        unit = ycp[3][j]
        kval = ycp[4][j]
        bval = ycp[5][j]
        address = ycp[6][j]
        uplimt = ycp[7][j]
        downlimt = ycp[8][j]
        if ID == "":
            ID = 1000
        if name == "":
            name = "请添加遥测名称"
        if describe == "":
            describe = "请描述遥测"
        if unit == "":
            unit = "请添加单位"
        if kval == "":
            kval = 1.0
        if bval == "":
            bval = 0.0
        if address == "":
            address = "0"
        if uplimt == "":
            uplimt = 2000.0
        if downlimt == "":
            downlimt = 0.0
        ycpstruct = YCArea.DxPropertyYC(int(ID), name.encode("utf-8"),
                                        describe.encode("utf-8"),
                                        unit.encode("utf-8"),
                                        round(float(kval), 7),
                                        round(float(bval), 7),
                                        address.encode("utf-8"),
                                        round(float(uplimt), 7),
                                        round(float(downlimt), 7))
        ycproperty.append(ycpstruct)
    DataCommand.RPCSetYCProperty(station, ycproperty)
    return '保存成功!'
Beispiel #13
0
def get_soe_property_send():
    stationId = request.args.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetSOEProperty(station)
    soeproperty = []
    for i in range(len(result)):
        soeproperty.append({
            "ID": result[i].ID,
            "name": result[i].name,
            "describe": result[i].describe,
            "level": result[i].level
        })
    response = {
        'soeproperty': soeproperty,
        'lensoep': len(result),
    }
    return jsonify(response)
Beispiel #14
0
def get_yc_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetYCProperty(station)
    ycproperty = []
    for i in range(len(result)):
        ycproperty.append({
            "id": result[i].ID,
            "name": result[i].name,
            "describe": result[i].describe,
            "unit": result[i].unit,
            "kval": round(result[i].kval, 7),
            "bval": round(result[i].bval, 7),
            "address": result[i].address,
            "uplimt": round(result[i].uplimt, 7),
            "downlimt": round(result[i].downlimt, 7)
        })
    return json.dumps(ycproperty)
Beispiel #15
0
def set_soe_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newsoe = request.form.get("data")
    SoeProperty = json.loads(newsoe)
    soep = []
    for i in range(len(SoeProperty)):
        soep.append(json.loads(SoeProperty[i]))
    soeproperty = []
    for j in range(len(soep[1])):
        soepstruct = SOEArea.DxPropertySOE(int(soep[0][j]), int(soep[1][j]),
                                           soep[2][j].encode("utf-8"), soep[3][j].encode("utf-8"),
                                           soep[4][j].encode("utf-8"), soep[5][j].encode("utf-8"),
                                           int(soep[6][j]), soep[7][j].encode("utf-8"),
                                           soep[8][j].encode("utf-8"), soep[9][j].encode("utf-8"))
        soeproperty.append(soepstruct)
    DataCommand.RPCSetSOEProperty(station, soeproperty)
    return '保存成功!'
Beispiel #16
0
def get_yx_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, pIDs, result = DataCommand.RPCGetYXProperty(station)
    yxproperty = []
    for i in range(len(pIDs)):
        yxproperty.append({
            "id": pIDs[i],
            "name": result[i].name,
            "fAlarm": result[i].fAlarm,
            "fAlarmCount": result[i].fAlarmCount,
            "unused": result[i].unused,
            "reserved": result[i].reserved,
            "ykno": result[i].ykno,
            "alarmtype": result[i].alarmtype,
            "alevel": result[i].alevel
        })
    return json.dumps(yxproperty)
Beispiel #17
0
def get_yc_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, pIDs, result = DataCommand.RPCGetYCProperty(station)
    ycproperty = []
    for i in range(len(pIDs)):
        ycproperty.append({
            "id": pIDs[i],
            "name": result[i].name,
            "unit": result[i].unit,
            "k": result[i].k,
            "b": result[i].b,
            "precision": result[i].precision,
            "fullvalue": result[i].fullvalue,
            "mindelta": result[i].mindelta,
            "zerovalue": result[i].zerovalue,
            "flog": result[i].flog,
            "fplan": result[i].fplan,
            "fcache": result[i].fcache,
            "fTrans": result[i].fTrans,
            "fMin": result[i].fMin,
            "fMax": result[i].fMax,
            "fAvrg": result[i].fAvrg,
            "fRatio": result[i].fRatio,
            "fUpper": result[i].fUpper,
            "fLower": result[i].fLower,
            "fUpper2": result[i].fUpper2,
            "fLower2": result[i].fLower2,
            "fMinTime": result[i].fMinTime,
            "fMaxTime": result[i].fMaxTime,
            "padding": result[i].padding,
            "fMax2": result[i].fMax2,
            "fMaxTime2": result[i].fMaxTime2,
            "yxno": result[i].yxno,
            "alevel": result[i].alevel,
            "uppervalue": result[i].uppervalue,
            "lowervalue": result[i].lowervalue,
            "uppervalue2": result[i].uppervalue2,
            "lowervalue2": result[i].lowervalue2
        })
    return json.dumps(ycproperty)
Beispiel #18
0
def set_station_property():
    DataCommand = ice_con()
    new_station = request.form.get("data")
    StationProperty = json.loads(new_station)
    stationp = []
    for i in range(len(StationProperty)):
        stationp.append(json.loads(StationProperty[i]))
    stap = []
    for j in range(len(stationp[6])):
        spstruct = StationArea.DxPropertyStation(
            int(stationp[0][j]),
            stationp[1][j].encode("utf-8"), stationp[2][j].encode("utf-8"),
            int(stationp[3][j]), stationp[4][j].encode("utf-8"),
            int(stationp[5][j]), int(stationp[6][j]))
        stap.append(spstruct)
    # spstruct = StationArea.DxPropertyStation(99, "station", "station111", 19,
    #                                          "192.168.100.124", 29, 39)
    # stap.append(spstruct)
    DataCommand.RPCSetStationProperty(stap)
    return '保存成功!'
def set_station_property():
    DataCommand = ice_con()
    new_station = request.form.get("data")
    StationProperty = json.loads(new_station)
    stationp = []
    for i in range(len(StationProperty)):
        stationp.append(json.loads(StationProperty[i]))
    stap = []
    for j in range(len(stationp[6])):
        ID = stationp[0][j]
        name = stationp[1][j]
        describe = stationp[2][j]
        ruleID = stationp[3][j]
        address = stationp[4][j]
        PORT = stationp[5][j]
        role = stationp[6][j]
        if ID == "":
            ID = 100
        if name == "":
            name = "请填写厂站名"
        if describe == "":
            describe = "请描述厂站"
        if ruleID == "":
            ruleID = 1
        if address == "":
            address = "请添加地址信息"
        if PORT == "":
            PORT = 60000
        if role == "":
            role = 1
        spstruct = StationArea.DxPropertyStation(int(ID), name.encode("utf-8"),
                                                 describe.encode("utf-8"),
                                                 int(ruleID),
                                                 address.encode("utf-8"),
                                                 int(PORT), int(role))
        stap.append(spstruct)
    # spstruct = StationArea.DxPropertyStation(99, "station", "station111", 19,
    #                                          "192.168.100.124", 29, 39)
    # stap.append(spstruct)
    DataCommand.RPCSetStationProperty(stap)
    return '保存成功!'
Beispiel #20
0
def set_yc_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyc = request.form.get("data")
    YcProperty = json.loads(newyc)
    ycp = []
    for i in range(len(YcProperty)):
        ycp.append(json.loads(YcProperty[i]))
    ycproperty = []
    for j in range(len(ycp[1])):
        ycpstruct = YCArea.DxPropertyYC(int(ycp[0][j]),
                                        ycp[1][j].encode("utf-8"),
                                        ycp[2][j].encode("utf-8"),
                                        ycp[3][j].encode("utf-8"),
                                        float(ycp[4][j]), float(ycp[5][j]),
                                        ycp[6][j].encode("utf-8"),
                                        float(ycp[7][j]), float(ycp[8][j]))
        ycproperty.append(ycpstruct)
    DataCommand.RPCSetYCProperty(station, ycproperty)
    return '保存成功!'
Beispiel #21
0
def set_yt_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyt = request.form.get("data")
    YtProperty = json.loads(newyt)
    ytp = []
    for i in range(len(YtProperty)):
        ytp.append(json.loads(YtProperty[i]))
    ytproperty = []
    for j in range(len(ytp[1])):
        ytpstruct = YTArea.DxPropertyYT(int(ytp[0][j]),
                                        ytp[1][j].encode("utf-8"),
                                        ytp[2][j].encode("utf-8"),
                                        ytp[3][j].encode("utf-8"),
                                        float(ytp[4][j]), float(ytp[5][j]),
                                        ytp[6][j].encode("utf-8"),
                                        float(ytp[7][j]), float(ytp[8][j]))
        ytproperty.append(ytpstruct)
    DataCommand.RPCSetYTProperty(station, ytproperty)
    return '保存成功!'
def get_yx_property_send():
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetYXProperty(station)
    yxproperty = []
    for i in range(len(result)):
        yxproperty.append({
            "ID": result[i].ID,
            "name": result[i].name,
            "describe": result[i].describe,
            "ASDU": result[i].ASDU,
            "wordPos": result[i].wordPos,
            "bitPos": result[i].bitPos,
            "bitLength": result[i].bitLength,
            "LinkPoint1": result[i].LinkPoint1,
            "LinkPoint2": result[i].LinkPoint2,
            "OneToZero": result[i].OneToZero,
            "ZeroToOne": result[i].ZeroToOne,
            "address": result[i].address
        })
    return json.dumps(yxproperty)
Beispiel #23
0
def set_yx_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyx = request.form.get("data")
    YxProperty = json.loads(newyx)
    yxp = []
    for i in range(len(YxProperty)):
        yxp.append(json.loads(YxProperty[i]))
    yxproperty = []
    for j in range(len(yxp[1])):
        yxpstruct = YXArea.DxPropertyYX(int(yxp[0][j]),
                                        yxp[1][j].encode("utf-8"),
                                        yxp[2][j].encode("utf-8"),
                                        int(yxp[3][j]), int(yxp[4][j]),
                                        int(yxp[5][j]), int(yxp[6][j]),
                                        int(yxp[7][j]), int(yxp[8][j]),
                                        yxp[9][j].encode("utf-8"),
                                        yxp[10][j].encode("utf-8"),
                                        yxp[11][j].encode("utf-8"))
        yxproperty.append(yxpstruct)
    DataCommand.RPCSetYXProperty(station, yxproperty)
    return '保存成功!'
Beispiel #24
0
def get_yc_property_send():
    stationId = request.args.get("stationId")
    station = json.loads(stationId)
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetYCProperty(station)
    ycproperty = []
    for i in range(len(result)):
        ycproperty.append({
            "ID": result[i].ID,
            "name": result[i].name,
            "describe": result[i].describe,
            "unit": result[i].unit,
            "kval": round(result[i].kval, 7),
            "bval": round(result[i].bval, 7),
            "address": result[i].address,
            "uplimt": result[i].uplimt,
            "downlimt": result[i].downlimt
        })
    response = {
        'ycproperty': ycproperty,
        'lenycp': len(result),
    }
    return jsonify(response)
def load_real_data():
    DataCommand = ice_con()
    """
    pIDs = []
    pIDs.append(0)
    ycdata = []
    for i in range(1000):
        structycdata = YCArea.DxDTYC(i, i + 1.1, i)
        ycdata.append(structycdata)

        # 写入redis
        DataCommand.RPCSetRealtimeYCData(pIDs, ycdata)
        # 写入cassandra
        DataCommand.RPCSaveYCData(pIDs, ycdata)
        DataCommand.RPCGetRealtimeYCData(pIDs)
        ycdata.pop()
    """

    pID = 0
    datetime = "20190527"
    print("........开始获取遥测当天数据.......")
    start = time.time()
    ycstatus, ycdata = DataCommand.RPCGetDayYCData(datetime, pID)
    elapsed = time.time() - start
    print("read time use: %s " % elapsed)
    ycdatanum = len(ycdata)
    # print(ycstatus)
    # print("总计读取遥测数据:%d " % ycdatanum)
    data0 = [elapsed, ycdatanum]
    data1 = []
    for i in range(len(ycdata)):
        data1.append({'status': ycdata[i].status,
                      'value': ycdata[i].value,
                      'timetag': ycdata[i].timetag})
    data = [data0, data1]
    return data
Beispiel #26
0
def set_yc_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyc = request.form.get("data")
    new_yc = json.loads(newyc)
    p_IDs = json.loads(new_yc[len(new_yc) - 1])
    pIDs = []
    for i in range(len(p_IDs)):
        pIDs.append(long(p_IDs[i]))
    new_yc.pop()
    YcProperty = new_yc
    ycp = []
    for i in range(len(YcProperty)):
        ycp.append(json.loads(YcProperty[i]))
    ycproperty = []
    for j in range(len(p_IDs)):
        ycpstruct = YCArea.DxPropertyYC(ycp[0][j].encode("utf-8"),
                                        ycp[1][j].encode("utf-8"),
                                        float(ycp[2][j]), float(ycp[3][j]),
                                        int(ycp[4][j]), float(ycp[5][j]),
                                        float(ycp[6][j]), float(ycp[7][j]),
                                        int(ycp[8][j]), int(ycp[9][j]),
                                        int(ycp[10][j]), ycp[11][j],
                                        ycp[12][j], ycp[13][j], ycp[14][j],
                                        ycp[15][j], ycp[16][j], ycp[17][j],
                                        ycp[18][j],
                                        ycp[19][j], ycp[20][j], ycp[21][j],
                                        int(ycp[22][j]), ycp[23][j],
                                        ycp[24][j], int(ycp[25][j]),
                                        int(ycp[26][j]), float(ycp[27][j]),
                                        float(ycp[28][j]), float(ycp[29][j]),
                                        float(ycp[30][j]))
        ycproperty.append(ycpstruct)
    DataCommand.RPCSetYCProperty(station, pIDs, ycproperty)
    return '保存成功!'
Beispiel #27
0
def set_yx_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyx = request.form.get("data")
    new_yx = json.loads(newyx)
    p_IDs = json.loads(new_yx[len(new_yx) - 1])
    pIDs = []
    for i in range(len(p_IDs)):
        pIDs.append(long(p_IDs[i]))
    new_yx.pop()
    YxProperty = new_yx
    yxp = []
    for i in range(len(YxProperty)):
        yxp.append(json.loads(YxProperty[i]))
    yxproperty = []
    for j in range(len(p_IDs)):
        yxpstruct = YXArea.DxPropertyYX(yxp[0][j].encode("utf-8"), yxp[1][j],
                                        yxp[2][j], int(yxp[3][j]),
                                        int(yxp[4][j]), int(yxp[5][j]),
                                        int(yxp[6][j]), int(yxp[7][j]))
        yxproperty.append(yxpstruct)
    DataCommand.RPCSetYXProperty(station, pIDs, yxproperty)
    return '保存成功!'
def set_yx_property():
    DataCommand = ice_con()
    stationId = request.form.get("stationId")
    station = json.loads(stationId)
    newyx = request.form.get("data")
    YxProperty = json.loads(newyx)
    yxp = []
    for i in range(len(YxProperty)):
        yxp.append(json.loads(YxProperty[i]))
    yxproperty = []
    num = len(yxp[1]) / 8000
    print num
    j = 0
    if j < num:
        for i in range(8000 * j, 8000 * j + 8000):
            ID = yxp[0][i]
            name = yxp[1][i]
            describe = yxp[2][i]
            ASDU = yxp[3][i]
            wordPos = yxp[4][i]
            bitPos = yxp[5][i]
            bitLength = yxp[6][i]
            LinkPoint1 = yxp[7][i]
            LinkPoint2 = yxp[8][i]
            OneToZero = yxp[9][i]
            ZeroToOne = yxp[10][i]
            address = yxp[11][i]
            if ID == "":
                ID = 1000
            if name == "":
                name = "请添加遥信名称"
            if describe == "":
                describe = "请描述遥信"
            if ASDU == "":
                ASDU = 0
            if wordPos == "":
                wordPos = 0
            if bitPos == "":
                bitPos = 0
            if bitLength == "":
                bitLength = 1
            if LinkPoint1 == "":
                LinkPoint1 = 0
            if LinkPoint2 == "":
                LinkPoint2 = 0
            if OneToZero == "":
                OneToZero = "由分到合"
            if ZeroToOne == "":
                ZeroToOne = "由合到分"
            if address == "":
                address = "0"
            yxpstruct = YXArea.DxPropertyYX(int(ID), name.encode("utf-8"),
                                            describe.encode("utf-8"),
                                            int(ASDU), int(wordPos),
                                            int(bitPos), int(bitLength),
                                            int(LinkPoint1), int(LinkPoint2),
                                            OneToZero.encode("utf-8"),
                                            ZeroToOne.encode("utf-8"),
                                            address.encode("utf-8"))
            yxproperty.append(yxpstruct)
        DataCommand.RPCSetYXProperty(station, yxproperty)
        print len(yxproperty)
        yxproperty[:] = []
        j = j + 1
    for i in range(8000 * j, len(yxp[1])):
        ID = yxp[0][i]
        name = yxp[1][i]
        describe = yxp[2][i]
        ASDU = yxp[3][i]
        wordPos = yxp[4][i]
        bitPos = yxp[5][i]
        bitLength = yxp[6][i]
        LinkPoint1 = yxp[7][i]
        LinkPoint2 = yxp[8][i]
        OneToZero = yxp[9][i]
        ZeroToOne = yxp[10][i]
        address = yxp[11][i]
        if ID == "":
            ID = 1000
        if name == "":
            name = "请添加遥信名称"
        if describe == "":
            describe = "请描述遥信"
        if ASDU == "":
            ASDU = 0
        if wordPos == "":
            wordPos = 0
        if bitPos == "":
            bitPos = 0
        if bitLength == "":
            bitLength = 1
        if LinkPoint1 == "":
            LinkPoint1 = 0
        if LinkPoint2 == "":
            LinkPoint2 = 0
        if OneToZero == "":
            OneToZero = "由分到合"
        if ZeroToOne == "":
            ZeroToOne = "由合到分"
        if address == "":
            address = "0"
        yxpstruct = YXArea.DxPropertyYX(int(ID), name.encode("utf-8"),
                                        describe.encode("utf-8"), int(ASDU),
                                        int(wordPos), int(bitPos),
                                        int(bitLength), int(LinkPoint1),
                                        int(LinkPoint2),
                                        OneToZero.encode("utf-8"),
                                        ZeroToOne.encode("utf-8"),
                                        address.encode("utf-8"))
        yxproperty.append(yxpstruct)
    print len(yxproperty)
    # 测试写函数,不能超过约10000条数据
    # for i in range(10000):
    #     ID = i
    #     name = "AU桥臂故障模块过多故障(=18)"
    #     describe = "station1_YX_1"
    #     ASDU = 1
    #     wordPos = 0
    #     bitPos = 0
    #     bitLength = 1
    #     LinkPoint1 = 0
    #     LinkPoint2 = 0
    #     OneToZero = "由合到分"
    #     ZeroToOne = "由分到合"
    #     address = "0"
    #     yxpstruct = YXArea.DxPropertyYX(int(ID), name.encode("utf-8"),
    #                                     describe.encode("utf-8"), int(ASDU),
    #                                     int(wordPos), int(bitPos),
    #                                     int(bitLength), int(LinkPoint1),
    #                                     int(LinkPoint2), OneToZero.encode("utf-8"),
    #                                     ZeroToOne.encode("utf-8"), address.encode("utf-8"))
    #     yxproperty.append(yxpstruct)
    DataCommand.RPCSetYXProperty(station, yxproperty)
    return '保存成功!'
Beispiel #29
0
def get_station_property():
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetStationProperty()
    return result
def get_sys_property():
    DataCommand = ice_con()
    status, result = DataCommand.RPCGetSystemProperty()
    return result