Do sprawdzania obecności nody MATES służą specjalne funkcje. Poniżej przykłady ich użycia w C, Python i CSharp.
#include <stdio.h>
#include "mates.h"
int main(void)
{
MATES_HANDLE h = mates_open("proxy.mon", 1);
if (mates_discover_single_node(h, 20) == UOS_STATUS_OK)
{
printf("Found node #20\n");
}
mates_close(h);
}
import mates
with mates.Mates("proxy.mon", 1) as m:
for node in (20, 21, 40, 41):
if m.discover_node(node):
print("Discovered node #{0}".format(node))
else:
print("Node #{0} not found".format(node))
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using Viresco.Mates;
using Viresco.Mates.Registers;
using System.Threading;
namespace unit_tests
{
[TestClass]
public class UnitTest1
{
private static Mates mates;
/// <summary>
/// Default configuration file name.
/// </summary>
private const string configFile = "mates_REMOTE.mon";
private const int channel = 1;
private static NodeId[] allTestedNodes = new NodeId[]
{
NodeId.mates_diox_mk1_1,
NodeId.mates_dio3_mk1_1
};
private static List<NodeId> allDio3Nodes = new List<NodeId> { };
private static List<NodeId> allDioxNodes = new List<NodeId> { };
[ClassInitialize]
public static void Initialize(TestContext context)
{
using (mates = new Mates(configFile, channel))
{
foreach (Node n in mates.DiscoverNodes(allTestedNodes))
{
Console.WriteLine("Found node {0}", n.NodeName);
if (n is Dio3Node)
{
allDio3Nodes.Add(n.NodeId);
}
else if (n is DioxNode)
{
allDioxNodes.Add(n.NodeId);
}
}
}
}
}
}