first commit
This commit is contained in:
commit
b31e9a7261
38 files changed
+3822
No files matched your search
@@ -0,0 +1,7 @@
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
public sealed record AuditEntry(
|
||||
long Id,
|
||||
DateTimeOffset OccurredAtUtc,
|
||||
string Category,
|
||||
string Message);
|
||||
@@ -0,0 +1,86 @@
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
public sealed record GatewayConfiguration(
|
||||
int VendorId,
|
||||
int DeviceInstance,
|
||||
string DeviceName,
|
||||
BacnetConfiguration Bacnet,
|
||||
OpcUaConfiguration OpcUa,
|
||||
IReadOnlyList<ModbusServerConfiguration> ModbusServers,
|
||||
KnxConfiguration Knx,
|
||||
MqttConfiguration? Mqtt = null,
|
||||
InstallationIdentity? Installation = null)
|
||||
{
|
||||
public static GatewayConfiguration CreateDefault(int deviceInstance, int bacnetPort, int opcUaPort, string interfaceName) => new(
|
||||
VendorId: 815,
|
||||
DeviceInstance: deviceInstance,
|
||||
DeviceName: $"SEIU-Gateway-{deviceInstance}",
|
||||
Bacnet: new BacnetConfiguration(interfaceName, bacnetPort, BbmdMode.Disabled, null, null, false),
|
||||
OpcUa: new OpcUaConfiguration(opcUaPort, true, true, false),
|
||||
ModbusServers: [],
|
||||
Knx: new KnxConfiguration(false, false),
|
||||
Mqtt: MqttConfiguration.CreateDefault(),
|
||||
Installation: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Immutable identity assigned during the one-time commissioning workflow.
|
||||
/// The NixOS host helper consumes a deliberately small JSON request derived from
|
||||
/// this record; credentials are never part of the request.
|
||||
/// </summary>
|
||||
public sealed record InstallationIdentity(string ProjectNumber, int IspNumber)
|
||||
{
|
||||
public string HostName => $"SE-UGW-{ProjectNumber}-ISP{IspNumber:D2}";
|
||||
}
|
||||
|
||||
public sealed record BacnetConfiguration(
|
||||
string Interface,
|
||||
int IpPort,
|
||||
BbmdMode BbmdMode,
|
||||
string? BbmdAddress,
|
||||
int? ForeignDeviceTtlSeconds,
|
||||
bool SecureConnectEnabled);
|
||||
|
||||
public enum BbmdMode
|
||||
{
|
||||
Disabled,
|
||||
Bbmd,
|
||||
ForeignDevice
|
||||
}
|
||||
|
||||
public sealed record OpcUaConfiguration(
|
||||
int Port,
|
||||
bool ClientEnabled,
|
||||
bool ServerEnabled,
|
||||
bool AllowAnonymous);
|
||||
|
||||
public sealed record ModbusServerConfiguration(
|
||||
Guid Id,
|
||||
string Name,
|
||||
string BindAddress,
|
||||
int Port,
|
||||
int UnitId,
|
||||
int FirstHoldingRegister,
|
||||
int HoldingRegisterCount,
|
||||
IReadOnlyList<string> AllowedClientIps);
|
||||
|
||||
public sealed record KnxConfiguration(bool Enabled, bool Secure);
|
||||
|
||||
public sealed record MqttConfiguration(
|
||||
bool Enabled,
|
||||
string Host,
|
||||
int Port,
|
||||
bool UseTls,
|
||||
bool IgnoreCertificateErrors,
|
||||
string ClientId,
|
||||
string? Username)
|
||||
{
|
||||
public static MqttConfiguration CreateDefault() => new(
|
||||
Enabled: false,
|
||||
Host: "",
|
||||
Port: 1883,
|
||||
UseTls: false,
|
||||
IgnoreCertificateErrors: false,
|
||||
ClientId: "seiugw",
|
||||
Username: null);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
public enum MqttMappingFormat
|
||||
{
|
||||
SeMonitoring,
|
||||
Json
|
||||
}
|
||||
|
||||
public enum MqttDirection
|
||||
{
|
||||
Publish,
|
||||
Subscribe,
|
||||
Bidirectional
|
||||
}
|
||||
|
||||
public enum SeMonitoringCategory
|
||||
{
|
||||
Analog,
|
||||
Notify,
|
||||
Alarm,
|
||||
Setpoints
|
||||
}
|
||||
|
||||
public enum MqttQualityOfService
|
||||
{
|
||||
AtMostOnce,
|
||||
AtLeastOnce,
|
||||
ExactlyOnce
|
||||
}
|
||||
|
||||
public sealed record MqttMapping(
|
||||
Guid Id,
|
||||
Guid PointId,
|
||||
MqttMappingFormat Format,
|
||||
MqttDirection Direction,
|
||||
MqttQualityOfService QualityOfService,
|
||||
bool Retain,
|
||||
int? ProjectYear,
|
||||
string? ProjectNumber,
|
||||
string? IspNumber,
|
||||
SeMonitoringCategory? SeCategory,
|
||||
string? TopicName,
|
||||
string? JsonTopic,
|
||||
string? JsonProperty,
|
||||
DateTimeOffset CreatedAtUtc);
|
||||
|
||||
public sealed record CreateMqttMappingRequest(
|
||||
Guid PointId,
|
||||
MqttMappingFormat Format,
|
||||
MqttDirection Direction,
|
||||
MqttQualityOfService QualityOfService,
|
||||
bool Retain,
|
||||
int? ProjectYear,
|
||||
string? ProjectNumber,
|
||||
string? IspNumber,
|
||||
SeMonitoringCategory? SeCategory,
|
||||
string? TopicName,
|
||||
string? JsonTopic,
|
||||
string? JsonProperty);
|
||||
|
||||
public sealed record UpdateMqttConfigurationRequest(
|
||||
MqttConfiguration Configuration,
|
||||
string? Password,
|
||||
bool ClearPassword);
|
||||
|
||||
public sealed record MqttConfigurationView(MqttConfiguration Configuration, bool HasPassword);
|
||||
|
||||
public sealed record MqttInboundMessage(string Topic, JsonElement Payload, DateTimeOffset ReceivedAtUtc);
|
||||
|
||||
public sealed record MqttClientStatus(
|
||||
bool Enabled,
|
||||
bool Connected,
|
||||
string? Endpoint,
|
||||
string? LastError,
|
||||
DateTimeOffset? ConnectedAtUtc,
|
||||
DateTimeOffset? LastReceivedAtUtc,
|
||||
DateTimeOffset? LastPublishedAtUtc);
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
public enum PointProtocol
|
||||
{
|
||||
Bacnet,
|
||||
OpcUa,
|
||||
Modbus,
|
||||
Knx,
|
||||
Mqtt,
|
||||
Internal
|
||||
}
|
||||
|
||||
public enum PointScope
|
||||
{
|
||||
External,
|
||||
Gateway,
|
||||
Internal
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BACnet object types that the gateway can materialize. Event/Alarm behavior is
|
||||
/// represented by Event Enrollment plus Notification Class, not by a proprietary alarm object.
|
||||
/// </summary>
|
||||
public enum BacnetObjectKind
|
||||
{
|
||||
AnalogInput,
|
||||
AnalogOutput,
|
||||
AnalogValue,
|
||||
BinaryInput,
|
||||
BinaryOutput,
|
||||
BinaryValue,
|
||||
MultiStateInput,
|
||||
MultiStateOutput,
|
||||
MultiStateValue,
|
||||
Schedule,
|
||||
Calendar,
|
||||
EventEnrollment,
|
||||
NotificationClass,
|
||||
TrendLog
|
||||
}
|
||||
|
||||
public sealed record GatewayPoint(
|
||||
Guid Id,
|
||||
string DisplayName,
|
||||
PointProtocol Protocol,
|
||||
PointScope Scope,
|
||||
string ValueType,
|
||||
bool Readable,
|
||||
bool Writable,
|
||||
string? ExternalIdentity,
|
||||
JsonElement Address,
|
||||
DateTimeOffset CreatedAtUtc,
|
||||
BacnetObjectKind? BacnetObjectKind = null,
|
||||
uint? BacnetObjectInstance = null);
|
||||
|
||||
public sealed record CreatePointRequest(
|
||||
string DisplayName,
|
||||
PointProtocol Protocol,
|
||||
PointScope Scope,
|
||||
string ValueType,
|
||||
bool Readable,
|
||||
bool Writable,
|
||||
string? ExternalIdentity,
|
||||
JsonElement Address,
|
||||
BacnetObjectKind? BacnetObjectKind = null,
|
||||
uint? BacnetObjectInstance = null);
|
||||
|
||||
public sealed record PointValue(
|
||||
Guid PointId,
|
||||
JsonElement Value,
|
||||
PointProtocol SourceProtocol,
|
||||
DateTimeOffset UpdatedAtUtc,
|
||||
string? Status);
|
||||
|
||||
public enum MappingDirection
|
||||
{
|
||||
OneWay,
|
||||
Bidirectional
|
||||
}
|
||||
|
||||
public sealed record PointMapping(
|
||||
Guid Id,
|
||||
Guid SourcePointId,
|
||||
Guid TargetPointId,
|
||||
MappingDirection Direction,
|
||||
bool Enabled,
|
||||
int? BacnetPriority,
|
||||
bool AcknowledgeMultipleExternalWriters,
|
||||
JsonElement Transform,
|
||||
DateTimeOffset CreatedAtUtc);
|
||||
|
||||
public sealed record CreateMappingRequest(
|
||||
Guid SourcePointId,
|
||||
Guid TargetPointId,
|
||||
MappingDirection Direction,
|
||||
bool Enabled,
|
||||
int? BacnetPriority,
|
||||
bool AcknowledgeMultipleExternalWriters,
|
||||
JsonElement Transform);
|
||||
|
||||
public sealed record CreateMappingResponse(PointMapping Mapping, IReadOnlyList<string> Warnings);
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Gateway.Api.Domain;
|
||||
|
||||
/// <summary>A gateway-owned trend log can sample any mapped source point without writing to it.</summary>
|
||||
public sealed record GatewayTrendLog(
|
||||
Guid Id,
|
||||
Guid SourcePointId,
|
||||
string Name,
|
||||
uint BacnetObjectInstance,
|
||||
int IntervalSeconds,
|
||||
int MaxRecords,
|
||||
bool Enabled,
|
||||
DateTimeOffset CreatedAtUtc);
|
||||
|
||||
public sealed record CreateTrendLogRequest(
|
||||
Guid SourcePointId,
|
||||
string Name,
|
||||
uint BacnetObjectInstance,
|
||||
int IntervalSeconds,
|
||||
int MaxRecords,
|
||||
bool Enabled);
|
||||
|
||||
public sealed record TrendRecord(
|
||||
Guid TrendLogId,
|
||||
long SequenceNumber,
|
||||
DateTimeOffset TimestampUtc,
|
||||
JsonElement Value,
|
||||
PointProtocol SourceProtocol,
|
||||
string? Status);
|
||||
|
||||
public sealed record AppendTrendRecordRequest(
|
||||
JsonElement Value,
|
||||
PointProtocol SourceProtocol,
|
||||
string? Status,
|
||||
DateTimeOffset? TimestampUtc);
|
||||
Reference in new issue
Block a user