예제 #1
0
async def writeY(data):
    client = Client(data['opcUrl'])
    client.name = "TOTO"
    client.application_uri = "urn:freeopcua:clientasync"
    async with client:
        struct = client.get_node(
            "ns=4;s=|var|CODESYS Control Win V3 x64.Application.GVL.intYPos")
        await struct.write_value(data['yPos'], ua.VariantType.Int16)
예제 #2
0
async def read(data):
    client = Client(data['opcUrl'])
    client.name = "TOTO"
    client.application_uri = "urn:freeopcua:clientasync"
    async with client:
        struct = client.get_node(
            "ns=4;s=|var|CODESYS Control Win V3 x64.Application.GVL.stringStatus"
        )
        readVal = await struct.read_value()
        return readVal
예제 #3
0
async def connectUa(data):
    client = Client(data['opcUrl'])
    client.name = "TOTO"
    client.application_uri = "urn:freeopcua:clientasync"
    try:
        async with client:
            struct = client.get_node(
                ua.ObjectIds.Server_ServerStatus_CurrentTime)
            time = await struct.read_value()
            return time
    except:
        return 'failed'
예제 #4
0
async def readSubscribed(data):
    oldVals = data['oldVals']
    oldData = []
    for val in oldVals:
        dataOld = {'NodeID': val['NodeID'], 'Value': val['Value']}
        oldData.append(dataOld)
    client = Client(data['opcUrl'])

    client.name = "TOTO"
    client.application_uri = "urn:freeopcua:clientasync"

    async with client:
        for i in range(290):
            returnVal = []
            for nodeID in oldData:
                struct = client.get_node(nodeID['NodeID'])
                readVal = await struct.read_value()
                data = {'NodeID': nodeID['NodeID'], 'Value': str(readVal)}
                returnVal.append(data)
            for i in returnVal:
                if i not in oldData:
                    return returnVal
            asyncio.sleep(0.1)
        return