Multiple AT1000 devices
In some situations, you'll have to deal with multiple AT1000 devices. Since AT1000 devices communicate over TCP/IP, the number of devices is virtually unlimited. However, when using multiple devices, it's important to be able to address the right device.
Also, in some cases, you may want to connect several AT1000 devices together in a daisy-chained configuration. This allows you to build a larger test system, in while you can significantly increase the number of I/O channels available, while keeping the output signals perfectly synchronized using the SYNC IN and SYNC OUT signals.
This section will describe the best practices when it comes to using multiple AT1000 devices.
Independent devices​
The simplest multi-device use case is when you have several AT1000 devices, each one used independently. In this case, you can simply use the find_device
function to search among all devices on the network for the one having the right serial number.
- NodeJS
- Python
import at1000 from "at1000";
let tester = at1000.find_device("12345"); // Find the device with serial number 12345
if (tester === undefined) {
console.log("Device not found");
} else {
console.log("Device found: ", tester.get_capabilities().serialnumber);
}
import at1000
tester = at1000.find_device("12345") # Find the device with serial number 12345
if tester is None:
print("Device not found")
else:
print("Device found:", tester.serialnumber)
In this example, the find_device
function will return the first device found with the serial number 12345
. If no device is found, it will return None
(Python) or undefined
(JavaScript).
You can also use the find_devices
function to list all devices on the network and then filter them by serial number. This is useful if you want to see all available devices before selecting one.
Daisy-chained devices​
Compared to independent devices, daisy chained devices are interconnected using SYNC IN and SYNC OUT signals (which allows to synchronize the outputs of the devices). Conveniently, you can also daisy chain the RJ45 connections of the devices, but this is not mandatory for the daisy chain to work. The daisy chained devices can be connected using any network topology as long as they are all in the same network.
In essence, you can use the find_devices
function to find the devices in the daisy chain, or you could use the find_device
function to find each single device using its serial number.
The only difference in the API comes when you need to synchronize the outputs of the devices. In that case, one device should be the master device, and the other devices should be the slave devices. The master device will control the synchronization of the outputs, while the slave devices will follow the master device's commands.
Some important notes about daisy-chained devices:
- Any device can be the master device at any given time.
- The master device can change at any time.
- The master device is the one to which the
hold_output
andsync_output
functions are applied. (More on this in the output synchronization section).
Here is a full functional example showing a typical usage of two daisy-chained devices. The example shows how to find the daisy chain, and how to use the hold_output
and sync_output
functions to synchronize the outputs of the devices. In this example, the device "A" playes the roles of the master device, but it could be as well the device "B". This choice totally arbitrary in this example.
- NodeJS
- Python
import at1000 from "at1000";
let tester_a = at1000.find_device("10001"); // Find the device with serial number 10001
let tester_b = at1000.find_device("10002"); // Find the device with serial number 10002
if (tester_a === undefined || tester_b === undefined) {
console.log("Device not found");
} else {
console.log("Devices found: ", tester_a.get_capabilities().serialnumber,
tester_b.get_capabilities().serialnumber);
}
let output_a = tester_a.digital_io(5); // GPIO 5 on device A
let output_b = tester_b.digital_io(12); // GPIO 12 on device B
tester_a.hold_outputs(); // Hold all outputs on all devices
output_a.write(1); // Set GPIO 5 on device A to high
output_b.write(0); // Set GPIO 12 on device B to low
tester_a.sync_outputs(); // Synchronize all outputs on all devices
// ... some other code ...
tester_a.hold_outputs(); // Hold all outputs on all devices
output_a.write(0); // Set GPIO 5 on device A to low
output_b.write(1); // Set GPIO 12 on device B to high
tester_a.sync_outputs(); // Synchronize all outputs on all devices
import at1000
tester_a = at1000.find_device("10001") # Find the device with serial number 10001
tester_b = at1000.find_device("10002") # Find the device with serial number 10002
if tester_a is None or tester_b is None:
print("Device not found")
else:
print("Devices found: ", tester_a.get_capabilities().serialnumber,
tester_b.get_capabilities().serialnumber)
output_a = tester_a.digital_io(5) # GPIO 5 on device A
output_b = tester_b.digital_io(12) # GPIO 12 on device B
tester_a.hold_outputs() # Hold all outputs on all devices
output_a.write(1) # Set GPIO 5 on device A to high
output_b.write(0) # Set GPIO 12 on device B to low
tester_a.sync_outputs() # Synchronize all outputs on all devices
# ... some other code ...
tester_a.hold_outputs() # Hold all outputs on all devices
output_a.write(0) # Set GPIO 5 on device A to low
output_b.write(1) # Set GPIO 12 on device B to high
tester_a.sync_outputs() # Synchronize all outputs on all devices
If you don't need to synchronize the outputs between several physical AT1000 devices, you can simply treat them as independent devices. You don't even need to connect them together using the SYNC IN and SYNC OUT signals.
Portability and duplicability​
When you have several AT1000 devices, you'll probably want to use the same code for all of them.
A slight disadvantage of the simple approaches described above, is that the serial numbers of the devices are hard-coded in the script. This means that if you change the serial number of one of the devices, you'll have to update the code. Similarly, if you need to duplicate your test setup, you'll end up having several copies of the same code, each one with different serial numbers.
This is why, a better approach - slightly more sophisticated - is to save and load-back the serial number from a separate file. This way, you can easily change the serial numbers in the file, and the code will remain unchanged.
The implementation of serial-numbers save/load feature is left to the user to implement. This can either be done using a simple text file, or using a more sophisticated approach like JSON, YAML or even a full featured database. The choice is up to you, and depends on your project.