Skip to content

Commit

Permalink
Added missing DataItem types for DataItem.GetPascalCaseType()
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed May 30, 2023
1 parent 02dbbc4 commit d0d9547
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions src/MTConnect.NET-Common/Devices/DataItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class DataItem : IDataItem
private static readonly object _lock = new object();

private static Dictionary<string, Type> _types;
private static IEnumerable<string> _conditionTypes;
private static IEnumerable<string> _eventTypes;
private static IEnumerable<string> _sampleTypes;
private static Dictionary<string, string> _typeDescriptions;
private static Dictionary<string, IEnumerable<string>> _subtypes;
private static Dictionary<string, string> _subtypeDescriptions;
Expand Down Expand Up @@ -528,6 +531,10 @@ public static string GetPascalCaseType(string type)
{
case DataItems.Events.AdapterUriDataItem.TypeId: return "AdapterURI";
case DataItems.Events.MTConnectVersionDataItem.TypeId: return "MTConnectVersion";
case DataItems.Samples.AmperageACDataItem.TypeId: return "AmperageAC";
case DataItems.Samples.AmperageDCDataItem.TypeId: return "AmperageDC";
case DataItems.Samples.VoltageACDataItem.TypeId: return "VoltageAC";
case DataItems.Samples.VoltageDCDataItem.TypeId: return "VoltageDC";
}

lock (_lock)
Expand Down Expand Up @@ -613,6 +620,84 @@ public static IEnumerable<string> GetTypes()
return _types.Keys;
}

public static IEnumerable<string> GetConditionTypes()
{
if (_conditionTypes == null)
{
if (_types == null) _types = GetAllTypes();

if (!_types.IsNullOrEmpty())
{
var x = new List<string>();

foreach (var type in _types)
{
var instance = Create(type.Value);
if (instance != null)
{
x.Add(instance.Type);
}
}

_conditionTypes = x.OrderBy(o => o);
}
}

return _conditionTypes;
}

public static IEnumerable<string> GetEventTypes()
{
if (_eventTypes == null)
{
if (_types == null) _types = GetAllTypes();

if (!_types.IsNullOrEmpty())
{
var x = new List<string>();

foreach (var type in _types)
{
var instance = Create(type.Value);
if (instance != null && instance.Category == DataItemCategory.EVENT)
{
x.Add(instance.Type);
}
}

_eventTypes = x.OrderBy(o => o);
}
}

return _eventTypes;
}

public static IEnumerable<string> GetSampleTypes()
{
if (_sampleTypes == null)
{
if (_types == null) _types = GetAllTypes();

if (!_types.IsNullOrEmpty())
{
var x = new List<string>();

foreach (var type in _types)
{
var instance = Create(type.Value);
if (instance != null && instance.Category == DataItemCategory.SAMPLE)
{
x.Add(instance.Type);
}
}

_sampleTypes = x.OrderBy(o => o);
}
}

return _sampleTypes;
}

public static IEnumerable<KeyValuePair<string, string>> GetTypeDescriptions()
{
if (_typeDescriptions == null)
Expand Down

0 comments on commit d0d9547

Please sign in to comment.