You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
using Kean.Application.Command.Interfaces;
|
|
using Kean.Application.Command.ViewModels;
|
|
using Kean.Domain;
|
|
using Kean.Domain.Wcs.Commands;
|
|
using Orleans;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kean.Application.Command.Implements
|
|
{
|
|
/// <summary>
|
|
/// 控制交互颗粒
|
|
/// </summary>
|
|
internal class WcsGrain : Grain, IWcsGrain
|
|
{
|
|
private readonly ICommandBus _bus; // 命令总线
|
|
private readonly INotification _notifications; // 总线通知
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
public WcsGrain(
|
|
ICommandBus bus,
|
|
INotification notifications)
|
|
{
|
|
_bus = bus;
|
|
_notifications = notifications;
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IWcsService.AcceptInput 方法
|
|
*/
|
|
public async Task<(AcceptInputCommand Fallback, Failure Failure)> AcceptInput(AcceptInputCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return (command.Fallback, _notifications.FirstOrDefault());
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IWcsService.SyncOutput 方法
|
|
*/
|
|
public async Task<Failure> SyncOutput(SyncOutputCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
/*
|
|
* 实现 Kean.Application.Command.Interfaces.IWcsService.SyncStation 方法
|
|
*/
|
|
public async Task<Failure> SyncStation(SyncStationCommand command)
|
|
{
|
|
DeactivateOnIdle();
|
|
await _bus.Execute(command);
|
|
return _notifications.FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
}
|