Beispiel #1
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 #2
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 #4
0
status = 0
ic = None
try:
    ic = Ice.initialize(sys.argv)
    base = ic.stringToProxy("DataCommand:default -h 192.168.100.24 -p 10000")
    DataCommand = CommandArea.DataCommandPrx.checkedCast(base)
    if not DataCommand:
        raise RuntimeError("Invalid proxy")
        
    pIDs = []
    yxdata = []
    ycdata = []
    for i in range(10000):
        pIDs.append(i)
        structyxdata = YXArea.DxDTYX(i, i+1, i)
        structycdata = YCArea.DxDTYC(i, i+1.1, i)
        yxdata.append( structyxdata )
        ycdata.append( structycdata )
        #print(yxdata[0].value)
        
    print("........遥信数据写入start.......")
    start = time.time()
    DataCommand.RPCSaveYXData(pIDs,yxdata)
    elapsed = (time.time() - start)
    print("write yxdata time use: %s " % elapsed)
	
    print("........遥信数据读取start.......")
    start = time.time()
    yxdata = DataCommand.RPCGetRealtimeYXData(pIDs)
    elapsed = (time.time() - start)
#!/usr/bin/python
#-*-coding:utf-8-*-

import sys, traceback, Ice
Ice.loadSlice("./ice-redis.ice")
import CommandArea, YXArea

status = 0
ic = None

name = []
for i in range(41):
    name.append(i + 10)
    #print(name[i])
structyxproperty = YXArea.DxPropertyYX(name, True, False, 255, 12, 13, 14, 15)

try:
    ic = Ice.initialize(sys.argv)
    base = ic.stringToProxy("DataCommand:default -h 192.168.100.170 -p 10000")
    DataCommand = CommandArea.DataCommandPrx.checkedCast(base)
    if not DataCommand:
        raise RuntimeError("Invalid proxy")

    #DataCommand.RPCSetYXProperty(structyxproperty, 1)
    structycproperty = DataCommand.RPCGetYXProperty(1)
    print("读取的遥信属性name:%s " % name[40])
    print("读取的遥信属性fAlarm:%s " % structyxproperty.fAlarm)
    print("读取的遥信属性fAlarmCount:%s " % structyxproperty.fAlarmCount)
    print("读取的遥信属性unused:%s" % structyxproperty.unused)
    print("读取的遥信属性reserved:%s " % structyxproperty.reserved)
    print("读取的遥信属性ykno:%s " % structyxproperty.ykno)