106 lines
3.6 KiB
C#
106 lines
3.6 KiB
C#
using System;
|
|
using Config.Resources;
|
|
using log4net;
|
|
using Sensus.iPerl.RfidCom.Helper;
|
|
using TBF.Rig.RegisterReaders.CommonRR;
|
|
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
|
using TBF.Rig.RegisterReaders.iPerlASICReader.implementations;
|
|
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
|
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
|
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
|
|
|
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
|
|
{
|
|
/// <summary>
|
|
/// Manual commands for ASIC readers. They intentionally use the ASIC correction
|
|
/// transport path and never fall back to the old Sensus iPerl implementation.
|
|
/// </summary>
|
|
internal static class IPerlASICOpticalHeadTest
|
|
{
|
|
private static readonly ILog RfidDataLogger = LogManager.GetLogger("RfidData");
|
|
|
|
internal static string ReadPcb(SmartReader reader)
|
|
{
|
|
try
|
|
{
|
|
byte[] pcb;
|
|
int result = IPerlASICCorrections.ReadRequestPort(
|
|
SmartCommunicationForm.TestMethodCfg,
|
|
reader,
|
|
MessageID.Configuration,
|
|
StructName.Configuration,
|
|
16,
|
|
5,
|
|
out pcb);
|
|
|
|
if (result == 0 && pcb != null)
|
|
{
|
|
return RfidHelper.HexLiteral2Unsigned(
|
|
RfidHelper.SwapHexcode(BitConverter.ToString(pcb).Replace("-", string.Empty))).ToString();
|
|
}
|
|
|
|
RfidDataLogger.ErrorFormat("COM{0}: ASIC Read PCB failed ({1}).", reader.RfidComPortNr, result);
|
|
return "Error";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
}
|
|
}
|
|
|
|
internal static string SetActiveMode(SmartReader reader)
|
|
{
|
|
return WriteCommand(reader, Command.SetActiveMode, "Error Set Active Mode");
|
|
}
|
|
|
|
internal static string SetTestMode(SmartReader reader)
|
|
{
|
|
return WriteCommand(reader, Command.SetTestMode, "Error Set Test Mode");
|
|
}
|
|
|
|
internal static string TurnOffRadio(SmartReader reader)
|
|
{
|
|
return WriteRadioValue(reader, MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 3);
|
|
}
|
|
|
|
internal static string SetProductionMode(SmartReader reader)
|
|
{
|
|
return WriteRadioValue(reader, MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1);
|
|
}
|
|
|
|
private static string WriteCommand(SmartReader reader, Command command, string errorText)
|
|
{
|
|
int result = IPerlASICCorrections.WriteRequestPort(
|
|
SmartCommunicationForm.TestMethodCfg,
|
|
reader,
|
|
MessageID.Command,
|
|
StructName.Command,
|
|
0,
|
|
1,
|
|
new[] { (byte)command });
|
|
return result == 0 ? "OK" : errorText;
|
|
}
|
|
|
|
private static string WriteRadioValue(SmartReader reader, MessageID messageId,
|
|
StructName structName, int offset, byte value)
|
|
{
|
|
try
|
|
{
|
|
int result = IPerlASICCorrections.WriteRequestPort(
|
|
SmartCommunicationForm.TestMethodCfg,
|
|
reader,
|
|
messageId,
|
|
structName,
|
|
offset,
|
|
1,
|
|
new[] { value });
|
|
return result == 0 ? "OK" : "Error";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
}
|
|
}
|
|
}
|
|
}
|