Metratec devices library 3.1.1.0
Metratec Device SDK

Metratec Devices SDK for .net 6.0 (core)

Install the library

This library also requires for the serial connection the System.IO.Ports package.

To add the required libraries, you can do this via the Visual Studio UI: Right-click on Dependencies->Add Project Reference->Browse and select the external MetratecDevices.dll. For the serial connection add the required package System.IO.Ports via the Visual Studio UI. Right-click on Dependencies->Manage NuGet Packages and locate and install the System.IO.Ports package.

This library uses the Microsoft Logging System, for which at least the Microsoft.Extensions.Logging.Abstraction package is necessary. Add this package as well.

Or you can alternatively edit your .csproj file:

<ItemGroup>
<Reference Include="MetratecDevices, Version=3.1.1.0">
<HintPath>path\to\MetratecDevices.dll</HintPath>
</Reference>
<!-- For serial connection -->
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
<!-- For logging -->
<PackageReference Include="Microsoft.Extensions.Logging.Abstraction" Version="7.0.0" />
</ItemGroup>

Usage

namespace Tests
{
class Program
{
static void Main(string[] args)
{
try
{
// Create a DeskID iso device object
DeskID_ISO deskid = new DeskID_ISO("COM6");
// add a reader status listener
reader.StatusChanged += (s, e) => Console.WriteLine($"Reader status changed to {e.Message} ({e.Status})");
// add an inventory listener
reader.NewInventory += (s, e) =>
{
Console.WriteLine($"New inventory event! {e.Tags.Count} Tag(s) found");
foreach (HfTag tag in e.Tags)
{
Console.WriteLine($" {tag.TID}");
}
};
// connect the reader with timeout
try
{
reader.Connect(2000);
}
catch (TimeoutException)
{
Console.WriteLine($"Can not connect to reader. Program exits");
return;
}
// fetches the current inventory - if an inventory listener exists, this method also triggers the listener
List<HfTag> tags = reader.GetInventory();
Console.WriteLine($"Current inventory: {tags.Count} Tag(s) found");
foreach (HfTag tag in tags)
{
Console.WriteLine($" {tag.TID}");
}
reader.StartInventory();
Console.WriteLine("Continuous inventory scan started - Press any key to stop");
Console.ReadKey();
reader.StopInventory();
// Disconnect reader
reader.Disconnect();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
The DeskID ISO is a compact HF RFID Reader/Writer for RFID applications in the office or factory....
Definition: DeskID_ISO.cs:12
Hf transponder.
Definition: Transponder.cs:85
Definition: DeskID_ISO.cs:5

License

MIT License