Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AP-175] Add extended RS232 commands to RS232 test app #5

Merged
merged 20 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions .editorconfig

This file was deleted.

29 changes: 15 additions & 14 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ on:

jobs:
build:
name: Build check on ${{ matrix.os }} - ${{ matrix.configuration }} (SDK ${{ matrix.sdk }})
name: Build check on ${{ matrix.os }} - ${{ matrix.configuration }} (SDK ${{ matrix.sdk }})
strategy:
matrix:
os: [windows-latest]
sdk: [ 3.1.x ]
configuration: [Release, Debug]
os: [ windows-latest ]
sdk: [ 8.0 ]
configuration: [ Debug, Release ]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Setup dotnet
uses: actions/setup-dotnet@v1
- name: Checkout code
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.sdk }}
- name: Build Core
run: dotnet build --configuration ${{ matrix.configuration }} PTI.Rs232Validator/PTI.Rs232Validator.csproj

- name: Build Emulator
run: dotnet build --configuration ${{ matrix.configuration }} PTI.Rs232Validator.Emulator/PTI.Rs232Validator.Emulator.csproj

- name: Build
run: dotnet build --configuration ${{ matrix.configuration }} PTI.Rs232Validator/PTI.Rs232Validator.csproj
- name: Test
run: dotnet test --configuration ${{ matrix.configuration }} PTI.Rs232Validator.Test/PTI.Rs232Validator.Test.csproj
34 changes: 0 additions & 34 deletions PTI.Rs232Validator.CLI/BaseLogger.cs

This file was deleted.

61 changes: 61 additions & 0 deletions PTI.Rs232Validator.CLI/Commands/SendExtendedRequestCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using PTI.Rs232Validator.Cli.Utility;
using PTI.Rs232Validator.Messages.Commands;
using Spectre.Console.Cli;
using System.ComponentModel;

namespace PTI.Rs232Validator.Cli.Commands;

/// <summary>
/// A command to send an extended request to a bill acceptor.
/// </summary>
public class SendExtendedRequestCommand : Command<SendExtendedRequestCommand.Settings>
{
/// <summary>
/// The settings for <see cref="SendExtendedRequestCommand"/>.
/// </summary>
public class Settings : CommandSettings
{
[CommandArgument(0, "<port_name>")]
public string PortName { get; init; } = string.Empty;

[CommandArgument(1, "<extended_command>")]
[TypeConverter(typeof(ByteConverter))]
public ExtendedCommand ExtendedCommand { get; init; }

[CommandArgument(2, "[arguments]")]
public byte[] Arguments { get; init; } = [];
}

/// <inheritdoc />
public override int Execute(CommandContext context, Settings settings)
{
var commandLogger = Factory.CreateMultiLogger<SendTelemetryRequestCommand>();
using var billValidator = Factory.CreateBillValidator(settings.PortName);

switch (settings.ExtendedCommand)
{
case ExtendedCommand.BarcodeDetected:
var responseMessage = billValidator.GetDetectedBarcode().Result;
if (responseMessage is { IsValid: true, Barcode.Length: > 0 })
{
commandLogger.LogInfo($"The barcode is: {responseMessage.Barcode}");
}
else if (responseMessage is { IsValid: true, Barcode.Length: 0 })
{
commandLogger.LogInfo("No barcode was detected since the last power cycle.");
}
else
{
commandLogger.LogError("Failed to get the barcode.");
}

break;

default:
commandLogger.LogError("The specified command is not supported.");
return 1;
}

return 0;
}
}
37 changes: 0 additions & 37 deletions PTI.Rs232Validator.CLI/ConsoleInterrupt.cs

This file was deleted.

62 changes: 0 additions & 62 deletions PTI.Rs232Validator.CLI/ConsoleLogger.cs

This file was deleted.

Loading