tbf/NfcC7_DLL/NfcHanler/Utils/SerialPortData.cs
Michal Buzik 95c5f09238 Working NfcC7_DLL, tests, clean up
"Remove unused NfcHanler classes and utilities"

This commit deletes several obsolete and unused files from the NfcHanler directory, including utility classes, enums, and a large command handling class. This cleanup improves code maintainability by eliminating unnecessary dependencies and clutter.
2025-10-14 13:15:31 +02:00

72 lines
2.4 KiB
C#

namespace NfcC7_DLL.NfcHanler.Utils
{
public class SerialPortData
{
private Boolean? _cliExists;
public bool CliExists { get {
if (_cliExists == null || !_cliExists.HasValue)
{
_cliExists = File.Exists(SerialPortCmdClientPath);
}
return _cliExists.Value;
} }
public string SerialPortCmdClientPath {
get {
#if DEBUG
return Path.Combine("C:","TBF","Cli", CmdClientName);
#else
return Path.Combine("..","Cli", CmdClientName);
#endif
}
}
public string CmdClientName { get; set; } = "HalCli.exe";
public string PortName { get; set; }
public int MeterType { get; set; }
public enum EMeterArg {
Calibration = 0,
AllParams = 2,
DeviceId = 3,
Optohead = 4,
}
EMeterArg _eMeterArg = EMeterArg.AllParams;
public string DefaultArgSettingsRead(EMeterArg eMeterArg)
{
switch (eMeterArg)
{
case EMeterArg.AllParams:
return $"-p {PortName} -m {MeterType} --operation readall";
case EMeterArg.DeviceId:
return $"-p {PortName} -m {MeterType} --operation read --parameter DeviceId";
case EMeterArg.Optohead:
return $"-p {PortName} -m {MeterType} --operation read --parameter \"OpticalDataMode\"";
default:
throw new Exception("Not implemented correct command!");
}
}
public string DefaultArgSettingsWrite(EMeterArg eMeterArg, string arg)
{
switch (eMeterArg)
{
case EMeterArg.Calibration:
return $"-p {PortName} -m {MeterType} --operation write --parameter Calibration --value {arg}";
case EMeterArg.Optohead:
return $"-p {PortName} -m {MeterType} --operation write --parameter \"OpticalDataMode\" --value {arg}";
default:
throw new Exception("Not implemented correct command!");
}
}
public SerialPortData(
string portName,
string cmdClientName,
int meterType)
{
PortName = portName;
CmdClientName = cmdClientName;
MeterType = meterType;
}
}
}