Skip to content

Commit

Permalink
Models for devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryba1986 committed Jul 4, 2022
1 parent 50f1cfb commit ebe42e6
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Zeus.Models/Devices/Commands/CreateDeviceCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Zeus.Enums.Devices;
using Zeus.Enums.SerialPorts;
using Zeus.Models.Base.Commands;

namespace Zeus.Models.Devices.Commands
{
public sealed class CreateDeviceCommand : BaseCreateCommand
{
public int LocationId { get; init; }
public string Name { get; init; }
public DeviceType Type { get; init; }
public byte ModbusId { get; init; }
public BoundRate RsBoundRate { get; init; }
public DataBits RsDataBits { get; init; }
public Parity RsParity { get; init; }
public StopBits RsStopBits { get; init; }
public bool IncludeReport { get; init; }

public CreateDeviceCommand()
{
Name = string.Empty;
}
}
}
24 changes: 24 additions & 0 deletions src/Zeus.Models/Devices/Commands/UpdateDeviceCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Zeus.Enums.Devices;
using Zeus.Enums.SerialPorts;
using Zeus.Models.Base.Commands;

namespace Zeus.Models.Devices.Commands
{
public sealed class UpdateDeviceCommand : BaseUpdateCommand
{
public int LocationId { get; init; }
public string Name { get; init; }
public DeviceType Type { get; init; }
public byte ModbusId { get; init; }
public BoundRate RsBoundRate { get; init; }
public DataBits RsDataBits { get; init; }
public Parity RsParity { get; init; }
public StopBits RsStopBits { get; init; }
public bool IncludeReport { get; init; }

public UpdateDeviceCommand()
{
Name = string.Empty;
}
}
}
26 changes: 26 additions & 0 deletions src/Zeus.Models/Devices/Dto/DeviceDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Zeus.Enums.Devices;
using Zeus.Enums.SerialPorts;
using Zeus.Models.Base.Dto;

namespace Zeus.Models.Devices.Dto
{
public sealed class DeviceDto : BaseDto
{
public int LocationId { get; init; }
public string Name { get; init; }
public string SerialNumber { get; init; }
public DeviceType Type { get; init; }
public byte ModbusId { get; init; }
public BoundRate RsBoundRate { get; init; }
public DataBits RsDataBits { get; init; }
public Parity RsParity { get; init; }
public StopBits RsStopBits { get; init; }
public bool IncludeReport { get; init; }

public DeviceDto()
{
Name = string.Empty;
SerialNumber = string.Empty;
}
}
}
29 changes: 29 additions & 0 deletions src/Zeus.Models/Devices/Dto/DeviceHistoryDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Zeus.Models.Base.Dto;

namespace Zeus.Models.Devices.Dto
{
public sealed class DeviceHistoryDto : BaseHistoryDto
{
public string Name { get; init; }
public string LocationName { get; init; }
public string Type { get; init; }
public string ModbusId { get; init; }
public string RsBoundRate { get; init; }
public string RsDataBits { get; init; }
public string RsParity { get; init; }
public string RsStopBits { get; init; }
public bool IncludeReport { get; init; }

public DeviceHistoryDto()
{
Name = string.Empty;
LocationName = string.Empty;
Type = string.Empty;
ModbusId = string.Empty;
RsBoundRate = string.Empty;
RsDataBits = string.Empty;
RsParity = string.Empty;
RsStopBits = string.Empty;
}
}
}
40 changes: 40 additions & 0 deletions src/Zeus.Models/Devices/Dto/DeviceReportDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Zeus.Enums.Devices;
using Zeus.Enums.Plcs;
using Zeus.Models.Base.Dto;

namespace Zeus.Models.Devices.Dto
{
public sealed class DeviceReportDto : BaseReportDto
{
public int LocationId { get; init; }
public string Name { get; init; }
public DeviceType Type { get; init; }

public PlcType PlcType =>
Type switch
{
DeviceType.Kamstrup or DeviceType.KamstrupRs500 => PlcType.Meter,
DeviceType.Rvd145Co or DeviceType.Rvd145CoCwu => PlcType.Rvd145,
_ => PlcType.None
};

public bool IsPlc =>
Type != DeviceType.Kamstrup &&
Type != DeviceType.KamstrupRs500;

public bool IsCo =>
Type == DeviceType.ClimatixCo ||
Type == DeviceType.ClimatixCoCwu ||
Type == DeviceType.Rvd145Co ||
Type == DeviceType.Rvd145CoCwu;

public bool IsCwu =>
Type == DeviceType.ClimatixCoCwu ||
Type == DeviceType.Rvd145CoCwu;

public DeviceReportDto()
{
Name = string.Empty;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using MediatR;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDeviceBoundRateDictionaryQuery : IRequest<IEnumerable<KeyValuePair<int, string>>>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using MediatR;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDeviceDataBitDictionaryQuery : IRequest<IEnumerable<KeyValuePair<int, string>>>
{
}
}
11 changes: 11 additions & 0 deletions src/Zeus.Models/Devices/Queries/GetDeviceHistoryQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using MediatR;
using Zeus.Models.Devices.Dto;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDeviceHistoryQuery : IRequest<IEnumerable<DeviceHistoryDto>>
{
public int DeviceId { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using MediatR;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDeviceParityDictionaryQuery : IRequest<IEnumerable<KeyValuePair<int, string>>>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using MediatR;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDeviceStopBitDictionaryQuery : IRequest<IEnumerable<KeyValuePair<int, string>>>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using MediatR;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDeviceTypeDictionaryQuery : IRequest<IEnumerable<KeyValuePair<int, string>>>
{
}
}
11 changes: 11 additions & 0 deletions src/Zeus.Models/Devices/Queries/GetDevicesFromLocationQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using MediatR;
using Zeus.Models.Devices.Dto;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDevicesFromLocationQuery : IRequest<IEnumerable<DeviceDto>>
{
public int LocationId { get; init; }
}
}
10 changes: 10 additions & 0 deletions src/Zeus.Models/Devices/Queries/GetDevicesQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using MediatR;
using Zeus.Models.Devices.Dto;

namespace Zeus.Models.Devices.Queries
{
public sealed class GetDevicesQuery : IRequest<IEnumerable<DeviceDto>>
{
}
}

0 comments on commit ebe42e6

Please sign in to comment.