Stichproben regeln

This commit is contained in:
Stoyan Zlatev
2025-01-31 11:21:23 +01:00
parent 6a310dc141
commit c3d5ea172d
20 changed files with 957 additions and 196 deletions
+17 -130
View File
@@ -1,148 +1,35 @@
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;
using Stichproben.Cordonel;
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>>>();
var assemblyLocation = typeof(Program).Assembly.Location;
var stichproben = new Stichproben(assemblyLocation);
void ParseType(Type type)
for (var pono = 1; pono <= 10; pono++)
{
foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
for (var sn = 1; sn <= 10; sn++)
{
var propertyType = property.PropertyType;
if (!typeof(Pam).IsAssignableFrom(propertyType))
for (var pcb = 1; pcb <= 10; pcb++)
{
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;
}
stichproben.ShouldBePressureTested(pono, sn, pcb);
}
}
}
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
//IF OBJECT_ID(N'Stichproben') IS NOT NULL BEGIN DROP TABLE Stichproben END
//CREATE TABLE Stichproben
// (Id INT PRIMARY KEY IDENTITY(1, 1) NOT NULL
// , FertigungsauftragNr INT NOT NULL
// , SerienNr INT NOT NULL
// , PcbId INT NOT NULL
// , Nummer INT NOT NULL
// , Prozentsatz INT NOT NULL
// , IstStichprobe BIT DEFAULT(0))