MATES / Modular Automatic Test Equipment System API  2.5.0.0
Public Member Functions | Data Fields | Protected Member Functions | Properties
UccNode Class Reference

Represents single MATES-UCC-MK1 node. More...

Public Member Functions

void AlcdWrite (int row, int col, string text)
 Write text onto the alphanumeric LCD display. More...
 
double GetAdc (int channel)
 Get the value of the ADC. More...
 
int GetAdcRaw (int channel)
 Get the raw value of the ADC. More...
 
int GetNumChannels ()
 Get number of channels of the ADC. More...
 
PhysicalValue GetRangeMax (int channel)
 Get the maximum value of a channel. More...
 
void SetDout (int channel, bool value)
 Set value of an individual digital output. More...
 
void SetDoutAll (int value)
 Set value of all digital outputs. More...
 
bool GetDout (int channel)
 Get value of an individual digital output. More...
 
int GetDoutAll ()
 Get value of all digital outputs. More...
 
bool GetDin (int channel)
 Get value of an individual digital input. More...
 
int GetDinAll ()
 Get value of all digital inputs. More...
 
bool IsCanBridge ()
 Check if this node acts as a CAN bridge (it is connected directly to PC). More...
 
int GetStatusRegister ()
 Get the value of the status register. More...
 
int GetRegisterI (RegisterNumber reg)
 Get regular (integral) MATES register. More...
 
float GetRegisterF (RegisterNumber reg)
 Get floating point MATES register. More...
 
void SetRegisterI (RegisterNumber reg, int val)
 Set regular (integral) MATES register. More...
 
void SetRegisterF (RegisterNumber reg, float val)
 Set floating point MATES register. More...
 
void RegisterEquals (RegisterNumber register, int value)
 Asserts that the specified integral register has the specified value. More...
 
void RegisterEquals (RegisterNumber register, float value)
 Asserts that the specified floating point register has the specified value. More...
 
void LampTest ()
 Execute lamp test. More...
 
string NodeInfo ()
 Get node information as string. More...
 

Data Fields

RegList Registers
 The registers that are associated with this node. Populated by the node constructor. More...
 

Protected Member Functions

void InputSet (int channel)
 Asserts that the specified input channel is in high state. More...
 
void OutputSet (int channel)
 Asserts that the specified output channel is in high state. More...
 
void InputEquals (int channel, bool state)
 Asserts that the specified input channel is in the given state. More...
 

Properties

IDioAsserts Assert [get]
 Represents collection of UnitTestFramework - compatible asserts defined for this type of node. More...
 
int SerialNumber [get]
 Holds the device serial number. More...
 
string NodeIdName [get]
 Get string representation of this node Id (NodeId). More...
 
string NodeName [get]
 Get node name of this node. More...
 

Detailed Description

Represents single MATES-UCC-MK1 node.

The UccNode constructor is not intended to be called directly. Use Mates.NewUccNode instead.

Member Function Documentation

void AlcdWrite ( int  row,
int  col,
string  text 
)

Write text onto the alphanumeric LCD display.

Parameters
rowThe LCD row number (0 - based).
colThe LCD column number (0 - based).
textThe text to write at the given position.

Example usage (mates_test_14.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_14
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
UccNode ucc = mates.NewUccNode(NodeId.mates_ucc_mk1_1);
ucc.AlcdWrite(0, 0, "CS test!");
}
catch (Exception ex)
{
Console.Write("Cannot discover node: " + ex + "\n");
}
}
}
}
}
double GetAdc ( int  channel)

Get the value of the ADC.

Parameters
channelThe ADC channel number [0,39].
Returns
ADC voltage value in Volts.

Example usage (mates_test_01.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_01
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Adc5Node node = mates.NewAdc5Node(NodeId.mates_adc5_mk1_1);
Console.Write("Voltage at channel IN01: {0} V\n", node.GetAdc(0));
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}

Implements IAdcNode.

int GetAdcRaw ( int  channel)

Get the raw value of the ADC.

Parameters
channelThe ADC channel number [0,39]
Returns
The raw ADC value.

Example usage (mates_test_02.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_02
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Adc5Node node = mates.NewAdc5Node(NodeId.mates_adc5_mk1_1);
int val = node.GetAdcRaw(0);
Console.Write("Raw value at channel IN01: {0} V\n", val);
Assert.IsTrue(val >= 0 && val <= 65535);
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}

Implements IAdcNode.

int GetNumChannels ( )

Get number of channels of the ADC.

Returns
The number of channels.

Implements IAdcNode.

PhysicalValue GetRangeMax ( int  channel)

Get the maximum value of a channel.

Parameters
channel
Returns
The maximum value in Volts, Amperes or Degrees Centigrade.

Implements IAdcNode.

void SetDout ( int  channel,
bool  value 
)
inherited

Set value of an individual digital output.

Parameters
channelThe DOUT channel number [0,19].
valueThe output value.

Example usage (mates_test_06.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_06
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node node = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
foreach (var val in new bool[]{false, true, false})
{
// Assume loopback is pressent.
node.SetDout(0, val);
node.Assert.InputEquals(0, val);
}
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
void SetDoutAll ( int  value)
inherited

Set value of all digital outputs.

Parameters
valueThe output value, LSB is OUT01.

Example usage (mates_test_05.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_05
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node dio = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
// Assume there is loopback present between outputs and inputs.
dio.SetDoutAll(0xCAFE);
Assert.AreEqual(dio.GetDinAll(), 0xCAFE);
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
bool GetDout ( int  channel)
inherited

Get value of an individual digital output.

Parameters
channelThe DOUT channel number [0,19].
Returns
The result.

Example usage (mates_test_07.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_07
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node dio = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
// Set and verify.
dio.SetDout(10, true);
Assert.AreEqual(dio.GetDout(10), true);
dio.SetDout(10, false);
Assert.AreEqual(dio.GetDout(10), false);
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
int GetDoutAll ( )
inherited

Get value of all digital outputs.

Returns
The result, LSB is OUT01.

Example usage (mates_test_08.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_08
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node dio = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
// No more than 20 outputs can be high.
Assert.IsTrue(dio.GetDoutAll() <= 0xFFFFF);
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
bool GetDin ( int  channel)
inherited

Get value of an individual digital input.

Parameters
channelThe DIN channel number [0,19].
Returns
The result.

Example usage (mates_test_09.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_09
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node dio = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
// Enumerate all inputs.
for (Mates.MatesInput input = Mates.MatesInput.IN01;
input <= Mates.MatesInput.IN20;
input++)
{
Console.Write("Input {0}: {1}\n", input, dio.GetDin((int)input));
}
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
int GetDinAll ( )
inherited

Get value of all digital inputs.

Returns
The result, LSB is IN01.

Example usage (mates_test_10.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_10
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node dio = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
// Send 8 of inputs to the outputs.
int output = dio.GetDoutAll();
int input = dio.GetDinAll();
dio.SetDoutAll((output & 0xFFF00) | (input & 0xFF));
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
void InputSet ( int  channel)
protectedinherited

Asserts that the specified input channel is in high state.

Parameters
channelThe input channel number [0, 19].

Implements IDioAsserts.

void OutputSet ( int  channel)
protectedinherited

Asserts that the specified output channel is in high state.

Parameters
channelThe output channel number [0, 19].

Implements IDioAsserts.

void InputEquals ( int  channel,
bool  state 
)
protectedinherited

Asserts that the specified input channel is in the given state.

Parameters
channelThe input channel number [0, 19].
stateThe expected state.

Implements IDioAsserts.

bool IsCanBridge ( )
inherited

Check if this node acts as a CAN bridge (it is connected directly to PC).

Returns
True if CAN bridge, otherwise false.
int GetStatusRegister ( )
inherited

Get the value of the status register.

Returns
The REG_COMMON_SR register value.
int GetRegisterI ( RegisterNumber  reg)
inherited

Get regular (integral) MATES register.

Parameters
regThe register number to access (see Viresco.Mates.Registers.RegisterNumber).
Returns
The register value.
float GetRegisterF ( RegisterNumber  reg)
inherited

Get floating point MATES register.

Parameters
regThe register number to access (see Viresco.Mates.Registers.RegisterNumber).
Returns
The register value.
void SetRegisterI ( RegisterNumber  reg,
int  val 
)
inherited

Set regular (integral) MATES register.

Parameters
regThe register number to access (see Viresco.Mates.Registers.RegisterNumber).
valThe register value.
void SetRegisterF ( RegisterNumber  reg,
float  val 
)
inherited

Set floating point MATES register.

Parameters
regThe register number to access (see Viresco.Mates.Registers.RegisterNumber).
valThe register value.
void RegisterEquals ( RegisterNumber  register,
int  value 
)
inherited

Asserts that the specified integral register has the specified value.

Parameters
registerThe register number.
valueThe expected value.

Implements INodeAsserts.

void RegisterEquals ( RegisterNumber  register,
float  value 
)
inherited

Asserts that the specified floating point register has the specified value.

Parameters
registerThe register number.
valueThe expected value.

Implements INodeAsserts.

void LampTest ( )
inherited

Execute lamp test.

Example usage (mates_test_11.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_11
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
Dio3Node dio = mates.NewDio3Node(NodeId.mates_dio3_mk1_1);
// Locate node by blinking its LEDs.
dio.LampTest();
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}
string NodeInfo ( )
inherited

Get node information as string.

Returns
The node information.

Example usage (mates_test_13.cs):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Viresco.Mates;
namespace unit_tests
{
[TestClass]
public class mates_test_13
{
[TestMethod]
public void TestMethod()
{
using (Mates mates = new Mates("mates_REMOTE.mon", 1))
{
try
{
UccNode dio = mates.NewUccNode(NodeId.mates_ucc_mk1_1);
// Get node info and print to console.
string info = dio.NodeInfo();
Console.Write(info);
}
catch
{
Console.Write("Cannot discover node.\n");
}
}
}
}
}

Field Documentation

RegList Registers
inherited

The registers that are associated with this node. Populated by the node constructor.

Property Documentation

IDioAsserts Assert
getinherited

Represents collection of UnitTestFramework - compatible asserts defined for this type of node.

int SerialNumber
getinherited

Holds the device serial number.

string NodeIdName
getinherited

Get string representation of this node Id (NodeId).

string NodeName
getinherited

Get node name of this node.


The documentation for this class was generated from the following files: