148 lines
4.5 KiB
C#
148 lines
4.5 KiB
C#
namespace CommonConsole
|
|
{
|
|
using Common.Hardware.WaterMeter.eRegister;
|
|
using Common.Hardware.WaterMeter.eRegister.Features;
|
|
using Common.Hardware.WaterMeter.eRegister.Models;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
public static class Program
|
|
{
|
|
public class FeatureDictionary : SortedDictionary<string, PropertyInfo>
|
|
{
|
|
public PropertyInfo FeatureInfo { get; set; }
|
|
}
|
|
|
|
public static void Main()
|
|
{
|
|
var features = new SortedDictionary<bool, SortedDictionary<string, SortedDictionary<string, FeatureDictionary>>>();
|
|
|
|
void ParseType(Type type)
|
|
{
|
|
foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
|
{
|
|
var propertyType = property.PropertyType;
|
|
|
|
if (!typeof(Pam).IsAssignableFrom(propertyType))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var pamAttribute = property.GetCustomAttribute<PamAttribute>();
|
|
|
|
if (pamAttribute is null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var isSingleCmd = pamAttribute.IsSingleCmd;
|
|
|
|
if (!features.ContainsKey(isSingleCmd))
|
|
{
|
|
features[isSingleCmd] = new SortedDictionary<string, SortedDictionary<string, FeatureDictionary>>();
|
|
}
|
|
|
|
var _features = features[isSingleCmd];
|
|
var authBytes = pamAttribute.AuthLevel.AuthBytes();
|
|
var authLevel = $"{authBytes.LastOrDefault():X2}";
|
|
|
|
if (authBytes.Length > 0)
|
|
{
|
|
authLevel = $"{authBytes[1]:X2}";
|
|
}
|
|
|
|
if (!_features.ContainsKey(authLevel))
|
|
{
|
|
_features[authLevel] = new SortedDictionary<string, FeatureDictionary>();
|
|
}
|
|
|
|
var __features = _features[authLevel];
|
|
var pam = Activator.CreateInstance(property.PropertyType) as Pam;
|
|
var cmdHex = pam.CmdHex;
|
|
|
|
if (cmdHex.Length == 2)
|
|
{
|
|
cmdHex = $"00-{cmdHex}";
|
|
}
|
|
|
|
if (!__features.ContainsKey(cmdHex))
|
|
{
|
|
__features[cmdHex] = new FeatureDictionary();
|
|
}
|
|
|
|
var ___features = __features[cmdHex];
|
|
___features.FeatureInfo = property;
|
|
|
|
foreach (var _property in propertyType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
|
{
|
|
if (_property.CanWrite && _property.PropertyType != typeof(byte[]))
|
|
{
|
|
___features[_property.Name] = _property;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ParseType(typeof(EregisterFeatures));
|
|
ParseType(typeof(EregisterDebugFeatures));
|
|
|
|
var types = new HashSet<string>();
|
|
|
|
foreach (var kvp in features)
|
|
{
|
|
Console.WriteLine(kvp.Key ? "Single PAM:" : "Combined PAM:");
|
|
|
|
foreach (var _kvp in kvp.Value)
|
|
{
|
|
Console.WriteLine($" Auth level {_kvp.Key}:");
|
|
|
|
foreach (var __kvp in _kvp.Value)
|
|
{
|
|
Console.WriteLine($" {__kvp.Key} {__kvp.Value.FeatureInfo.Name}");
|
|
|
|
foreach (var ___kvp in __kvp.Value)
|
|
{
|
|
Console.WriteLine($"\t\t{___kvp.Key} - {___kvp.Value.PropertyType.Name}");
|
|
|
|
types.Add(___kvp.Value.PropertyType.Name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Console.WriteLine();
|
|
|
|
var _types = types.ToList();
|
|
_types.Sort();
|
|
|
|
foreach (var type in _types)
|
|
{
|
|
Console.WriteLine(type);
|
|
}
|
|
|
|
Console.WriteLine();
|
|
}
|
|
}
|
|
}
|
|
|
|
//AuthLevel
|
|
//Boolean
|
|
//Byte
|
|
//DecimalPointLocations
|
|
//FactoryState
|
|
//Int32
|
|
//MBusModes
|
|
//MessurementUnits
|
|
//MeterTypes
|
|
//Options
|
|
//OTAMode
|
|
//RegisterMode
|
|
//ResetMode
|
|
//String
|
|
//Types
|
|
//UInt16
|
|
//UInt32
|
|
//WakeUpMode |