Region Configuration
The region configuration must strictly follow the regulatory compliance. The class ReaderRegion contains all the relevant methods to configure the region. The following methods are exposed to set/get the region configuration:
| Method | Description |
|---|---|
| GetSupportedRegionList | Gets the list of supported regions |
| GetRegionStandardList | Gets Communication standard for given region |
| SetActiveRegion | Sets the given region as active region |
| GetActiveRegion | Gets the region information and frequency settings for the currently active region |
| GetActiveRegionStandardInfo | Gets the active communication standard |
| SetFrequencySetting | Sets Frequency hopping with list of supported channel indexes for the active region |
The Sample code given below illustrates all the methods for the region configuration:
Console.WriteLine("Region setting test on Fixed Reader\Pixie Module");
if (LoginToReader() == false)
{
LogTestResult("Failed to execute FixedReader_RegionSetting test", false);
return;
}
try
{
string[] regionList = rm.ReaderRegion.GetSupportedRegionList();
Console.WriteLine("Total number of Regions " + regionList.Length);
int index = 0;
foreach (string regionName in regionList)
{
Console.WriteLine("Region " + (++index) + " " + regionName);
}
foreach (string regionName in regionList)
{
ReaderRegion.CommunicationStandardInfo[] standardInfoList = rm.ReaderRegion.GetRegionStandardList(regionName);
Console.WriteLine("Region " + standardInfoList[0].RegionName);
Console.WriteLine("Number of standards " + standardInfoList.Length);
foreach (ReaderRegion.CommunicationStandardInfo standard in standardInfoList)
{
Console.WriteLine("Standard name " + standard.StandardName);
Console.WriteLine("Is Hopping Configurable " + standard.IsHoppingConfigurable);
if (standard.IsHoppingConfigurable)
{
int numberOfChannels = standard.ChannelIndexList.Length;
Console.WriteLine("Number of channels " + numberOfChannels);
for (int i = 0; i < numberOfChannels; i++)
{
Console.WriteLine("Channel index " + standard.ChannelIndexList[i] + " value " + standard.ChannelFrequencyValueList[i]);
}
}
//set active region
rm.ReaderRegion.SetActiveRegion(regionName, standard.StandardName);
Console.WriteLine("SetActiveRegion (" + regionName + ", " + standard.StandardName + ") successful");
//set active region freq-settings
if (standard.IsHoppingConfigurable)
{
int[] channleList1 = new int[standard.ChannelIndexList.Length - 1];
for (int i = 0; i < channleList1.Length; i++)
{
channleList1[i] = standard.ChannelIndexList[i];
}
int[] channleList2 = new int[1];
channleList2[0] = standard.ChannelIndexList[0];
//hopping on
rm.ReaderRegion.SetFrequencySetting(true, channleList1);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") channels: " + channleList1.Length + " Hopping: ON successful");
// Freq-setting hopping on - validation
channleList1[channleList1.Length - 1] = standard.ChannelIndexList[standard.ChannelIndexList.Length - 1] + 1;
try
{
rm.ReaderRegion.SetFrequencySetting(true, channleList1);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping on, wrong channel index validation: failed");
}
catch (System.Exception)
{
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping on, wrong channel index validation: successful");
}
try
{
rm.ReaderRegion.SetFrequencySetting(true, channleList2);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping on, single channel index validation: failed");
}
catch (System.Exception)
{
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping on, single channel index validation: successful");
}
//hopping off
rm.ReaderRegion.SetFrequencySetting(false, channleList2);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") channels: " + channleList2.Length + " Hopping: OFF successful");
// Freq-setting hopping off - validation
channleList2[0] = standard.ChannelIndexList[standard.ChannelIndexList.Length - 1] + 1;
try
{
rm.ReaderRegion.SetFrequencySetting(false, channleList2);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping off, wrong single channel index validation: failed");
}
catch (System.Exception)
{
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping off, wrong single channel index validation: successful");
}
channleList1[channleList1.Length - 1] = standard.ChannelIndexList[standard.ChannelIndexList.Length - 1];
try
{
rm.ReaderRegion.SetFrequencySetting(false, channleList1);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping off, multiple channel index validation: failed");
}
catch (System.Exception)
{
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") Hopping off, multiple channel index validation: successful");
}
}
else // Freq-setting validation
{
int[] channleList = new int[2];
channleList[0] = 1;
channleList[1] = 2;
try
{
rm.ReaderRegion.SetFrequencySetting(true, channleList);
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") IsHoppingConfigurable:false Validation: failed");
}
catch (System.Exception)
{
Console.WriteLine("SetFrequencySetting (" + regionName + ", " + standard.StandardName + ") IsHoppingConfigurable:false Validation: successful");
}
}
//GetActiveRegion
ReaderRegion.ActiveRegionInfo activeRegion = rm.ReaderRegion.GetActiveRegion();
if (activeRegion.RegionName == regionName && activeRegion.StandardName == standard.StandardName)
{
Console.WriteLine("GetActiveRegion (" + regionName + ", " + standard.StandardName + ") successful");
}
else
{
Console.WriteLine("GetActiveRegion (" + regionName + ", " + standard.StandardName + ") failed");
}
//GetActiveRegionStandardInfo
ReaderRegion.CommunicationStandardInfo activeStandard = rm.ReaderRegion.GetActiveRegionStandardInfo();
if (activeStandard.RegionName == standard.RegionName && activeStandard.StandardName == standard.StandardName)
{
Console.WriteLine("GetActiveRegionStandardInfo (" + regionName + ", " + standard.StandardName + ") successful");
}
else
{
Console.WriteLine("GetActiveRegionStandardInfo (" + regionName + ", " + standard.StandardName + ") failed");
}
} // foreach (ReaderRegion.CommunicationStandardInfo standard in standardInfoList)
}
//SetActiveRegion validation
try
{
rm.ReaderRegion.SetActiveRegion("region", "region");
Console.WriteLine("SetActiveRegion validation: failed");
}
catch (System.Exception)
{
Console.WriteLine("SetActiveRegion validation: successful");
}
}
catch (InvalidOperationException ioe)
{
Console.WriteLine("Region setting test failed: " + ioe.ToString());
}
catch (InvalidUsageException iue)
{
Console.WriteLine("Region setting test failed: " + iue.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Region setting test failed: " + ex.ToString());
}
rm.Logout();