Synchronize deployed gateway features and documentation

This commit is contained in:
jhartworks committed 2026-11-24 13:38:27 +01:00
1 parent 98c48d9d78
commit 198b1d7b78
20 files changed
+1235 -45

No files matched your search

+30
View File
@@ -126,6 +126,36 @@ Assert(mqttDefaults.Site == new MqttMonitoringSite(2026, "P260123", "ISP3") &&
var monitoringBatch = store.CreateBulkMappings(new([csvSource.Id, statePoint.Id, alarmPoint.Id], BulkMappingTarget.Mqtt));
Assert(monitoringBatch.Created == 3 && monitoringBatch.Assignments.Any(item => item.Contains("/Alarms/", StringComparison.Ordinal)) &&
monitoringBatch.Assignments.Any(item => item.Contains("/Notify/", StringComparison.Ordinal)), "Bulk MQTT should use SE-Monitoring by default.");
var oldTopics = store.ListMqttMappings().ToDictionary(mapping => mapping.Id, GatewayStore.GetMqttTopic);
var templateView = store.UpdateMqttTopicTemplate("Anlagen/{Rechnername}/{Kategorie}/{Datenpunkt}");
Assert(templateView.PreviewValues["{Rechnername}"] == "SE-UGW-P260123-ISP03", "The preview must show the configured installation identity.");
var templatedRequest = new CreateMqttMappingRequest(csvSource.Id, MqttMappingFormat.SeMonitoring, MqttDirection.Publish,
MqttQualityOfService.AtLeastOnce, false, null, "P260123", "ISP3", SeMonitoringCategory.Analog, "Vorlauf", null, null);
var customMapping = store.CreateMqttMapping(templatedRequest);
const string customTopic = "Anlagen/SE-UGW-P260123-ISP03/Analog/Vorlauf";
Assert(GatewayStore.GetMqttTopic(customMapping) == customTopic &&
store.ListMqttMappings().Where(mapping => oldTopics.ContainsKey(mapping.Id)).All(mapping => GatewayStore.GetMqttTopic(mapping) == oldTopics[mapping.Id]),
"A new template must affect new mappings and preserve every previously resolved topic.");
var bulkTemplate = store.UpdateMqttTopicTemplate("Messwerte/{Projekt}/{Datenpunkt}");
var batchWithTemplate = store.CreateBulkMappings(new([statePoint.Id], BulkMappingTarget.Mqtt));
Assert(batchWithTemplate.Created == 1 && batchWithTemplate.Assignments.Single().EndsWith("Messwerte/P260123/Pumpe_läuft", StringComparison.Ordinal) &&
GatewayStore.GetMqttTopic(store.UpdateMqttMapping(customMapping.Id, templatedRequest with { Retain = true })!) == customTopic,
"Bulk mappings must use the active template while an existing mapping edit keeps its saved path.");
try
{
store.UpdateMqttTopicTemplate("Messwerte/{Unbekannt}/{Datenpunkt}");
throw new InvalidOperationException("An unknown MQTT placeholder must be rejected.");
}
catch (DomainValidationException)
{
Assert(store.GetMqttMappingDefaults().TopicTemplate.Template == bulkTemplate.Template, "Rejected templates must not overwrite the saved template.");
}
var legacyMqttCsv = "Id;PointId;Format;Direction;QualityOfService;Retain;ProjectYear;ProjectNumber;IspNumber;SeCategory;TopicName;JsonTopic;JsonProperty\r\n" +
$";{csvSource.Id};SeMonitoring;Publish;AtLeastOnce;False;2026;P260123;ISP3;Analog;CsvLegacy;;\r\n";
Assert(store.ImportConfigurationCsv(ConfigurationCsvKind.MqttMappings, legacyMqttCsv).Created == 1 &&
store.ListMqttMappings().Any(mapping => GatewayStore.GetMqttTopic(mapping) == "Projekte2026/P260123/ISP3/Analog/CsvLegacy_Wert"),
"MQTT CSVs exported before the template field must continue to resolve legacy paths.");
store.UpdateMqttTopicTemplate(templateView.DefaultTemplate);
var rawMqtt = store.CreateMqttMapping(new(csvSource.Id, MqttMappingFormat.SingleTopic, MqttDirection.Publish, MqttQualityOfService.AtLeastOnce,
false, null, null, null, null, null, "plant/temperature", null));
Assert(GatewayStore.GetMqttTopic(rawMqtt) == "plant/temperature", "A numeric single-topic mapping must use the specified topic exactly.");