update
This commit is contained in:
parent
73038de662
commit
99716cc414
|
|
@ -4,4 +4,4 @@
|
||||||
@rendermode InteractiveServer
|
@rendermode InteractiveServer
|
||||||
|
|
||||||
@attribute [Authorize]
|
@attribute [Authorize]
|
||||||
<h1>Welcome to RobotApp!</h1>
|
@* <h1>Welcome to RobotApp!</h1> *@
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"workingDirectory": "$(TargetDir)",
|
"workingDirectory": "$(TargetDir)",
|
||||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
||||||
"applicationUrl": "https://localhost:7150;http://localhost:5229",
|
"applicationUrl": "https://0.0.0.0:7150;http://localhost:5229",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,11 +191,11 @@ public class MQTTClient : IAsyncDisposable
|
||||||
|
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
Console.WriteLine("[BROKER] CLIENT CERTIFICATE VALID");
|
Console.WriteLine("Broker CERTIFICATE VALID");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("[BROKER] CLIENT CERTIFICATE INVALID");
|
Console.WriteLine("Broker CERTIFICATE INVALID");
|
||||||
foreach (var status in arg.Chain.ChainStatus)
|
foreach (var status in arg.Chain.ChainStatus)
|
||||||
Console.WriteLine($" -> Chain error: {status.Status} - {status.StatusInformation}");
|
Console.WriteLine($" -> Chain error: {status.Status} - {status.StatusInformation}");
|
||||||
}
|
}
|
||||||
|
|
@ -222,7 +222,7 @@ public class MQTTClient : IAsyncDisposable
|
||||||
{
|
{
|
||||||
var tlsOptions = new MqttClientTlsOptionsBuilder()
|
var tlsOptions = new MqttClientTlsOptionsBuilder()
|
||||||
.UseTls(true)
|
.UseTls(true)
|
||||||
.WithSslProtocols(System.Security.Authentication.SslProtocols.Tls12)
|
.WithSslProtocols(System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13)
|
||||||
.WithCertificateValidationHandler(ValidateCertificates)
|
.WithCertificateValidationHandler(ValidateCertificates)
|
||||||
.WithClientCertificatesProvider(new MQTTClientCertificatesProvider(VDA5050Setting.CerFile, VDA5050Setting.KeyFile))
|
.WithClientCertificatesProvider(new MQTTClientCertificatesProvider(VDA5050Setting.CerFile, VDA5050Setting.KeyFile))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
@ -304,11 +304,11 @@ public class MQTTClient : IAsyncDisposable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var applicationMessage = new MqttApplicationMessageBuilder()
|
var applicationMessage = MqttClientFactory.CreateApplicationMessageBuilder()
|
||||||
.WithTopic(topic)
|
.WithTopic(topic)
|
||||||
.WithPayload(data)
|
.WithPayload(data)
|
||||||
.WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtLeastOnce)
|
.WithQualityOfServiceLevel(MqttQualityOfServiceLevel.AtLeastOnce)
|
||||||
.Build();
|
.Build();
|
||||||
if (MqttClient is null || !IsConnected) return new(false, "Chưa có kết nối tới broker");
|
if (MqttClient is null || !IsConnected) return new(false, "Chưa có kết nối tới broker");
|
||||||
var publish = await MqttClient.PublishAsync(applicationMessage);
|
var publish = await MqttClient.PublishAsync(applicationMessage);
|
||||||
if (!publish.IsSuccess) continue;
|
if (!publish.IsSuccess) continue;
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ public abstract class RobotAction(IServiceProvider serviceProvider) : IDisposabl
|
||||||
{
|
{
|
||||||
HistoryStatus = Status;
|
HistoryStatus = Status;
|
||||||
Status = ActionStatus.PAUSED;
|
Status = ActionStatus.PAUSED;
|
||||||
|
IsPaused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Resume()
|
public void Resume()
|
||||||
|
|
@ -68,7 +69,8 @@ public abstract class RobotAction(IServiceProvider serviceProvider) : IDisposabl
|
||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
{
|
{
|
||||||
if(!IsCompleted) IsCancelAction = true;
|
if (!IsCompleted) IsCancelAction = true;
|
||||||
|
if (Status == ActionStatus.WAITING) StopAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WaitAsync(CancellationToken cancellationToken)
|
public async Task WaitAsync(CancellationToken cancellationToken)
|
||||||
|
|
@ -94,6 +96,7 @@ public abstract class RobotAction(IServiceProvider serviceProvider) : IDisposabl
|
||||||
|
|
||||||
protected virtual Task StopAction()
|
protected virtual Task StopAction()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"StopAction {Type}");
|
||||||
Status = ActionStatus.FAILED;
|
Status = ActionStatus.FAILED;
|
||||||
ResultDescription = "Action bị hủy bỏ.";
|
ResultDescription = "Action bị hủy bỏ.";
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public class RobotActionController(Logger<RobotActionController> Logger, RobotAc
|
||||||
ActionStatus = a.Status.ToString(),
|
ActionStatus = a.Status.ToString(),
|
||||||
ResultDescription = a.ResultDescription,
|
ResultDescription = a.ResultDescription,
|
||||||
})];
|
})];
|
||||||
public bool HasActionRunning => !ActionQueue.IsEmpty || Actions.Values.Any(a => !a.IsCompleted);
|
public bool HasActionRunning => !ActionQueue.IsEmpty || Actions.Values.Any(a => a.Type != ActionType.cancelOrder && !a.IsCompleted);
|
||||||
|
|
||||||
private readonly Dictionary<string, RobotAction> Actions = [];
|
private readonly Dictionary<string, RobotAction> Actions = [];
|
||||||
private readonly ConcurrentQueue<(ActionScopes scope, VDA5050.InstantAction.Action action)> ActionQueue = [];
|
private readonly ConcurrentQueue<(ActionScopes scope, VDA5050.InstantAction.Action action)> ActionQueue = [];
|
||||||
|
|
@ -62,7 +62,7 @@ public class RobotActionController(Logger<RobotActionController> Logger, RobotAc
|
||||||
{
|
{
|
||||||
foreach (var action in Actions.Values)
|
foreach (var action in Actions.Values)
|
||||||
{
|
{
|
||||||
if (!action.IsCompleted) action.Cancel();
|
if (!action.IsCompleted && action.Type != ActionType.cancelOrder) action.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Actions.TryGetValue(actionId, out RobotAction? robotAction) && robotAction is not null) robotAction.Cancel();
|
else if (Actions.TryGetValue(actionId, out RobotAction? robotAction) && robotAction is not null) robotAction.Cancel();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using RobotApp.VDA5050.InstantAction;
|
||||||
using RobotApp.VDA5050.Order;
|
using RobotApp.VDA5050.Order;
|
||||||
using RobotApp.VDA5050.State;
|
using RobotApp.VDA5050.State;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Data;
|
||||||
using Action = RobotApp.VDA5050.InstantAction.Action;
|
using Action = RobotApp.VDA5050.InstantAction.Action;
|
||||||
|
|
||||||
namespace RobotApp.Services.Robot;
|
namespace RobotApp.Services.Robot;
|
||||||
|
|
@ -111,6 +112,7 @@ public class RobotOrderController(INavigation NavigationManager,
|
||||||
CurrentBaseNode = null;
|
CurrentBaseNode = null;
|
||||||
Nodes = [];
|
Nodes = [];
|
||||||
Edges = [];
|
Edges = [];
|
||||||
|
UpdateState();
|
||||||
StateManager.TransitionTo(AutoStateType.Idle);
|
StateManager.TransitionTo(AutoStateType.Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ public class RobotStates(RobotConfiguration RobotConfiguration,
|
||||||
IDriver DriverManager) : BackgroundService
|
IDriver DriverManager) : BackgroundService
|
||||||
{
|
{
|
||||||
private uint HeaderId = 0;
|
private uint HeaderId = 0;
|
||||||
private readonly string SerialNumber = RobotConfiguration.SerialNumber;
|
|
||||||
|
|
||||||
private WatchTimerAsync<RobotStates>? UpdateStateTimer;
|
private WatchTimerAsync<RobotStates>? UpdateStateTimer;
|
||||||
private const int UpdateStateInterval = 1000;
|
private const int UpdateStateInterval = 1000;
|
||||||
|
|
@ -42,7 +41,7 @@ public class RobotStates(RobotConfiguration RobotConfiguration,
|
||||||
return new StateMsg
|
return new StateMsg
|
||||||
{
|
{
|
||||||
HeaderId = HeaderId++,
|
HeaderId = HeaderId++,
|
||||||
SerialNumber = SerialNumber,
|
SerialNumber = RobotConfiguration.SerialNumber,
|
||||||
Maps = [],
|
Maps = [],
|
||||||
OrderId = OrderManager.OrderId,
|
OrderId = OrderManager.OrderId,
|
||||||
OrderUpdateId = OrderManager.OrderUpdateId,
|
OrderUpdateId = OrderManager.OrderUpdateId,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ namespace RobotApp.Services.Robot;
|
||||||
|
|
||||||
public class RobotVisualization(ILocalization Localization, INavigation Navigation, RobotConfiguration RobotConfiguration, RobotConnection RobotConnection, Logger<RobotVisualization> Logger) : BackgroundService
|
public class RobotVisualization(ILocalization Localization, INavigation Navigation, RobotConfiguration RobotConfiguration, RobotConnection RobotConnection, Logger<RobotVisualization> Logger) : BackgroundService
|
||||||
{
|
{
|
||||||
public string SerialNumber = RobotConfiguration.SerialNumber;
|
|
||||||
private uint HeaderId;
|
private uint HeaderId;
|
||||||
|
|
||||||
private WatchTimerAsync<RobotVisualization>? UpdateTimer;
|
private WatchTimerAsync<RobotVisualization>? UpdateTimer;
|
||||||
|
|
@ -17,7 +16,7 @@ public class RobotVisualization(ILocalization Localization, INavigation Navigati
|
||||||
return new VisualizationMsg()
|
return new VisualizationMsg()
|
||||||
{
|
{
|
||||||
HeaderId = HeaderId++,
|
HeaderId = HeaderId++,
|
||||||
SerialNumber = SerialNumber,
|
SerialNumber = RobotConfiguration.SerialNumber,
|
||||||
MapId = Localization.CurrentActiveMap,
|
MapId = Localization.CurrentActiveMap,
|
||||||
MapDescription = string.Empty,
|
MapDescription = string.Empty,
|
||||||
AgvPosition = new AgvPosition()
|
AgvPosition = new AgvPosition()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user