66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
|
{
|
|
public class SerialPortData
|
|
{
|
|
public const string CliDirectory = @"C:\TBF\Cli";
|
|
|
|
private Boolean? _cliExists;
|
|
public bool CliExists { get {
|
|
if (_cliExists == null || !_cliExists.HasValue)
|
|
{
|
|
_cliExists = File.Exists(SerialPortCmdClientPath);
|
|
}
|
|
return _cliExists.Value;
|
|
} }
|
|
public string SerialPortCmdClientPath
|
|
{
|
|
get
|
|
{
|
|
string cliFileName = Path.GetFileName(CmdClientName);
|
|
if (String.IsNullOrWhiteSpace(cliFileName))
|
|
cliFileName = "HalCli.exe";
|
|
|
|
return Path.Combine(CliDirectory, cliFileName);
|
|
}
|
|
}
|
|
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,
|
|
}
|
|
EMeterArg _eMeterArg = EMeterArg.AllParams;
|
|
|
|
public string DefaultArgSettings(EMeterArg eMeterArg)
|
|
{
|
|
switch (eMeterArg)
|
|
{
|
|
case EMeterArg.Calibration:
|
|
return $"-p {PortName} -m {MeterType} --operation write --parameter Calibration --value 1";
|
|
case EMeterArg.AllParams:
|
|
return $"-p {PortName} -m {MeterType} --operation readall";
|
|
case EMeterArg.DeviceId:
|
|
return $"-p {PortName} -m {MeterType} --operation read --parameter DeviceId";
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public SerialPortData(
|
|
string portName,
|
|
string cmdClientName,
|
|
int meterType)
|
|
{
|
|
PortName = portName;
|
|
CmdClientName = cmdClientName;
|
|
MeterType = meterType;
|
|
}
|
|
}
|
|
}
|