Create a sequence to write on different channels ethernet


Recommended Posts

Hello

I need to do a sequence to write on different channels ethernet. I can't use the "device.MyDevice.Write ()" because I can't change the value of "MyDevice."

I'm making in this way, but it is unsafe.

DIGOUT.strDevice = "MyDevice" + number

DIGOUT.Timing = 2

channel.Restart()

delay(0.3)

DIGOUT.Timing = 0

channel.Restart()

That way I can write in ...

MyDevice1

MyDevice2

...

Surely there is a better method

I hope I have explained my problem and that can help me. Thanks in advance

Link to comment
Share on other sites

There are a couple ways, if I'm understanding what you want to do:

1) change the IP or the port of MyDevice between each query:

device.mydevice.strAddress = "10.0.0.2"

device.mydevice.initcomm()

device.mydevice.write(...)

device.mydevice.strAddress = "10.0.0.3"

device.mydevice.initcomm()

device.mydevice.write(...)

You may need a delay between initcomm() and write().

2) Use the execute() function to build up your commands:

execute("device.mydevice" + doubletostr(number) + ".write(...)")

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.