Some shared classes and interfaces moved to project Common, re-factorization.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Common;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
{
|
||||
@@ -10,13 +11,13 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
public readonly int FrameLength; /// Frame length in characters/bytes, 0 = unknown
|
||||
public readonly double FrameFrequency; /// Number of frames per second (Hz)
|
||||
|
||||
public readonly Config.Unit VolumeUnits;
|
||||
public readonly Unit VolumeUnits;
|
||||
public readonly double VolumeScaleFactor; /// Volume in VolumeInits = volmeRaw / VolumeScaleFactor
|
||||
public readonly int VolumeFieldStart; /// Start of the volume field: 0-based index of the first character, -1 = no volume field in the frame
|
||||
public readonly int VolumeFieldEnd; /// End of the volume field: 0-based index of the last character
|
||||
public readonly FieldFormat VolumeFieldFormat; /// Hexadecimal or Decimal
|
||||
|
||||
public readonly Config.Unit TimeUnits;
|
||||
public readonly Unit TimeUnits;
|
||||
public readonly double TimeScaleFactor; /// Time in TimeUnits = timeRaw / TimeScaleFactor
|
||||
public readonly int TimeFieldStart; /// Start of the time field: 0-based index of the first character, -1 = no time field in the frame
|
||||
public readonly int TimeFieldEnd; /// End of the time field: 0-based index of the last character
|
||||
@@ -38,9 +39,9 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
public readonly long RawTimeIncrementPerFrame;
|
||||
|
||||
public FrameFormat(int frameLength, double frameFrequency,
|
||||
Config.Unit volumeUnits, double volumeScaleFactor,
|
||||
Unit volumeUnits, double volumeScaleFactor,
|
||||
int volumeFieldStart, int volumeFieldEnd, FieldFormat volumeFieldFormat,
|
||||
Config.Unit timeUnits, double timeScaleFactor,
|
||||
Unit timeUnits, double timeScaleFactor,
|
||||
int timeFieldStart, int timeFieldEnd, FieldFormat timeFieldFormat)
|
||||
{
|
||||
FrameLength = frameLength;
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
public int FrameLength; /// Frame length in characters/bytes, 0 = unknown
|
||||
public double FrameFrequency; /// Number of frames per second, 0 = unknown
|
||||
|
||||
public Config.Unit VolumeUnits;
|
||||
public Common.Unit VolumeUnits;
|
||||
public double VolumeScaleFactor; /// Volume =
|
||||
public int VolumeFieldStart; /// Start of the volume field: 0-based index of the first character, -1 = no volume field in the frame
|
||||
public int VolumeFieldEnd; /// End of the volume field: 0-based index of the last character
|
||||
public FieldFormat VolumeFieldFormat; /// Hexadecimal or Decimal
|
||||
|
||||
public Config.Unit TimeUnits;
|
||||
public Common.Unit TimeUnits;
|
||||
public double TimeScaleFactor; /// Time =
|
||||
public int TimeFieldStart; /// Start of the time field: 0-based index of the first character, -1 = no time field in the frame
|
||||
public int TimeFieldEnd; /// End of the time field: 0-based index of the last character
|
||||
@@ -40,13 +40,13 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
FrameLength = 42;
|
||||
FrameFrequency = 8;
|
||||
|
||||
VolumeUnits = Config.Unit.l;
|
||||
VolumeUnits = Common.Unit.l;
|
||||
VolumeScaleFactor = 16000;
|
||||
VolumeFieldStart = 17;
|
||||
VolumeFieldEnd = 22;
|
||||
VolumeFieldFormat = FieldFormat.HexadecimalWindow;
|
||||
|
||||
TimeUnits = Config.Unit.s;
|
||||
TimeUnits = Common.Unit.s;
|
||||
TimeScaleFactor = 8192;
|
||||
TimeFieldStart = 29;
|
||||
TimeFieldEnd = 36;
|
||||
@@ -112,9 +112,9 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
case 2: FrameFrequency = Utils.ParseUDouble(strValue); return CfgUpdateFlags.None;
|
||||
|
||||
case 3:
|
||||
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
||||
for (Unit u = 0; u < Unit.Count; u++)
|
||||
{
|
||||
if (Config.Units.IsQuantity(u, Config.Quantity.Volume) && u.ToDescription().Equals(strValue))
|
||||
if (Units.IsQuantity(u, Quantity.Volume) && u.ToDescription().Equals(strValue))
|
||||
{
|
||||
VolumeUnits = u;
|
||||
return CfgUpdateFlags.None;
|
||||
@@ -132,9 +132,9 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
break;
|
||||
|
||||
case 8:
|
||||
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
||||
for (Unit u = 0; u < Unit.Count; u++)
|
||||
{
|
||||
if (Config.Units.IsQuantity(u, Config.Quantity.Time) && u.ToDescription().Equals(strValue))
|
||||
if (Units.IsQuantity(u, Quantity.Time) && u.ToDescription().Equals(strValue))
|
||||
{
|
||||
TimeUnits = u;
|
||||
return CfgUpdateFlags.None;
|
||||
@@ -180,9 +180,9 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
||||
for (Unit u = 0; u < Unit.Count; u++)
|
||||
{
|
||||
if (Config.Units.IsQuantity(u, Config.Quantity.Volume) && u.ToDescription().Equals(strValue))
|
||||
if (Units.IsQuantity(u, Quantity.Volume) && u.ToDescription().Equals(strValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -199,9 +199,9 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
break;
|
||||
|
||||
case 8:
|
||||
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
||||
for (Unit u = 0; u < Unit.Count; u++)
|
||||
{
|
||||
if (Config.Units.IsQuantity(u, Config.Quantity.Time) && u.ToDescription().Equals(strValue))
|
||||
if (Units.IsQuantity(u, Quantity.Time) && u.ToDescription().Equals(strValue))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
public int FrameLength { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.FrameLength : 0; } }
|
||||
public double FrameFrequency { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.FrameFrequency : 0; } }
|
||||
|
||||
public Config.Unit VolumeUnits { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.VolumeUnits : Config.Unit.l; } }
|
||||
public Common.Unit VolumeUnits { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.VolumeUnits : Common.Unit.l; } }
|
||||
public double VolumeScaleFactor { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.VolumeScaleFactor : 1; } }
|
||||
public int VolumeFieldStart { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.VolumeFieldStart : 0; } }
|
||||
public int VolumeFieldEnd { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.VolumeFieldEnd : 0; } }
|
||||
public FieldFormat VolumeFieldFormat { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.VolumeFieldFormat : FieldFormat.None; } }
|
||||
|
||||
public Config.Unit TimeUnits { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.TimeUnits : Config.Unit.s; } }
|
||||
public Common.Unit TimeUnits { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.TimeUnits : Common.Unit.s; } }
|
||||
public double TimeScaleFactor { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.TimeScaleFactor : 1; } }
|
||||
public int TimeFieldStart { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.TimeFieldStart : 0; } }
|
||||
public int TimeFieldEnd { get { return (myCfg.ProcParams != null) ? myCfg.ProcParams.TimeFieldEnd : 0; } }
|
||||
@@ -633,11 +633,11 @@ namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
public event EventHandler<FrameReceivedEventArgs> FrameReceivedHandler;
|
||||
|
||||
|
||||
public static double UnitVolume(Config.Unit units, double scaleFactor)
|
||||
public static double UnitVolume(Common.Unit units, double scaleFactor)
|
||||
{
|
||||
if (Config.Units.IsQuantity(units, Config.Quantity.Volume))
|
||||
if (Common.Units.IsQuantity(units, Common.Quantity.Volume))
|
||||
{
|
||||
return Config.Units.ConvertFrom(units, 1.0) * scaleFactor;
|
||||
return Common.Units.ConvertFrom(units, 1.0) * scaleFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using Common;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.SerialStream
|
||||
|
||||
Reference in New Issue
Block a user