Exemple #1
0
 public AdminShellViewModel(MainWidowViewModel containingVm, Admin user)
 {
     this.containingVm        = containingVm;
     this.Admin               = user;
     SignOutCommand           = new BackCommand(this);
     ScreenReplacementCommand = new ScreenReplacementCommand(this);
     Message                = "";
     DecisionMessage        = "";
     IsDecisionMessageShown = false;
     DecisionCommand        = new DecisionCommand(this);
     CurrentVM              = null;
 }
Exemple #2
0
        public async Task <DecisionCommandProcessResult> ProcessDecisionCommand(DecisionCommand decisionCommand)
        {
            if (decisionCommand.ParameterCommands.GroupBy(c => c.Parameter)
                .Any(x => x.Count() > 1))
            {
                throw new InvalidOperationException($"Can't process command with duplicated parameter commands: {decisionCommand.ToJson()}");
            }

            var commandTasks            = decisionCommand.ParameterCommands.Select(ProcessParameterCommand).ToArray();
            var parameterCommandResults = await Task.WhenAll(commandTasks).ConfigureAwait(false);

            return(new DecisionCommandProcessResult
            {
                ParameterCommandProcessResults = parameterCommandResults
            });
        }
 public PhysicianShellViewModel(MainWidowViewModel containingVm, Physician physicianUser)
 {
     Message = "";
     IsBusy  = false;
     IsDecisionMessageShown   = false;
     DecisionMessage          = "";
     DecisionCommand          = new DecisionCommand(this);
     this.containingVm        = containingVm;
     ScreenReplacementCommand = new ScreenReplacementCommand(this);
     SearchCommand            = new SearchItemCommand(this);
     SignOutCommand           = new BackCommand(this);
     physicianShellModel      = new PhysicianShellModel();
     //patientSearchVM = new PatientSearchViewModel(containingVm, physicianUser);
     this.PhysicianUser   = physicianUser;
     IsEnabledActionsMenu = false;
     CurrentVM            = null;
     //PersonalDetailsTab = patientDetailsVM;
     //AddReceptTab = addReceptVM;
     //AddMedicalRecordTab = addMedicalRecordVM;
     //MedicalFileTab = medicalFileVM;
 }
Exemple #4
0
        public async Task <ActionResult <DecisionCommandProcessResult> > ProcessDecisionCommand([FromBody] DecisionCommand decisionCommand)
        {
            var commandProcessResult = await _commandProcessingService.ProcessDecisionCommand(decisionCommand).ConfigureAwait(false);

            return(commandProcessResult);
        }
Exemple #5
0
    public static GameCommand GenerateGameCommand(GameCommandTypes commandType, Type subPhase, string parameters = null, bool isRpc = false)
    {
        GameCommand command = null;

        switch (commandType)
        {
        case GameCommandTypes.DamageDecksSync:
            command = new DamageDeckSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SquadsSync:
            command = new SquadsSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.Decision:
            command = new DecisionCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ObstaclePlacement:
            command = new ObstaclePlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ShipPlacement:
            command = new ShipPlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.AssignManeuver:
            command = new AssignManeuverCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressNext:
            command = new PressNextCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ActivateAndMove:
            command = new ActIvateAndMoveCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DeclareAttack:
            command = new DeclareAttackCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DiceModification:
            command = new DiceModificationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectShip:
            command = new SelectShipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceResults:
            command = new SyncDiceResultsCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceRerollSelected:
            command = new SyncDiceRerollSelectedCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmCrit:
            command = new ConfirmCritCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmDiceCheck:
            command = new ConfirmDiceCheckCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressSkip:
            command = new PressSkipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.HotacSwerve:
            command = new HotacSwerveCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.HotacFreeTargetLock:
            command = new HotacFreeTargetLockCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncPlayerWithInitiative:
            command = new SyncPlayerWithInitiativeCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SystemActivation:
            command = new SystemActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.CombatActivation:
            command = new CombatActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectObstacle:
            command = new SelectObstacleCommand(commandType, subPhase, parameters);
            break;

        default:
            Console.Write("Constructor for GameCommand is not found", LogTypes.Errors, true, "red");
            break;
        }

        string receivedString = (isRpc) ? " (rpc)": "";

        Console.Write("Command is generated" + receivedString + ": " + command.Type, LogTypes.GameCommands, false, "aqua");

        return(command);
    }
Exemple #6
0
        public async Task TestDecisionCommandProcessing()
        {
            var rpcRequestTopic      = "command/request";
            var rpcResponseTopic     = "command/response";
            var apiClient            = _factory.CreateClient();
            var mqttClientRepository = _factory.Services.GetService <MqttClientRepository>();
            var decisionCommand      = new DecisionCommand()
            {
                ParameterCommands = new []
                {
                    new ParameterCommand()
                    {
                        CommandImpact = CommandImpact.Decrease,
                        Parameter     = ParameterType.TemperatureInside
                    }
                }
            };
            var clientReceivedCommands = new List <RpcCommandRequest>();
            var devicePushClient       = await mqttClientRepository.Subscribe("_", ((s, bytes) => Task.CompletedTask));

            var deviceClient = await mqttClientRepository.Subscribe(rpcRequestTopic, (s, bytes) =>
            {
                var receivedCommand = bytes.DeserializeJsonBytes <RpcCommandRequest>();
                clientReceivedCommands.Add(receivedCommand);
                return(devicePushClient.PublishAsync(rpcResponseTopic, new RpcCommandResponse()
                {
                    CommandId = receivedCommand.CommandId,
                    FailedMessage = null,
                    IsFailed = false
                }));
            });

            var tempDecreaseDeviceInfo = new ActuatorDeviceInfo()
            {
                DeviceCode       = "Custom",
                Id               = Guid.NewGuid(),
                IsConstantImpact = false,
                Impacts          = new[] { CommandImpact.Decrease, CommandImpact.StrongDecrease },
                Parameter        = ParameterType.TemperatureInside,
            };

            await deviceClient.PublishAsync("data/device", tempDecreaseDeviceInfo);

            await Task.Delay(1000);

            var request = new StringContent(decisionCommand.ToJson());

            request.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
            var decisionCommandHttpResult = await apiClient.PostAsync("commands/decision", request);

            await Task.Delay(1000);

            decisionCommandHttpResult.EnsureSuccessStatusCode();
            var decisionCommandResult = (await decisionCommandHttpResult.Content.ReadAsStringAsync())
                                        .DeserializeJson <DecisionCommandProcessResult>();
            var executedParameterCommand = decisionCommandResult.ParameterCommandProcessResults.Single();
            var executedImpact           = executedParameterCommand.Impacts.Single();
            var receivedDeviceCommand    = clientReceivedCommands.Single();

            Assert.Null(executedParameterCommand.Error);
            Assert.False(executedParameterCommand.Failed);
            Assert.Equal(CommandImpact.Decrease, executedImpact);
            Assert.Equal(CommandImpact.Decrease, receivedDeviceCommand.Impact);
            Assert.Equal(ParameterType.TemperatureInside, receivedDeviceCommand.Parameter);
            Assert.Equal(tempDecreaseDeviceInfo.Id, receivedDeviceCommand.DeviceId);
        }
    public static GameCommand GenerateGameCommand(GameCommandTypes commandType, Type subPhase, string parameters = null, bool isRpc = false)
    {
        GameCommand command = null;

        switch (commandType)
        {
        case GameCommandTypes.DamageDecksSync:
            command = new DamageDeckSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SquadsSync:
            command = new SquadsSyncCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.Decision:
            command = new DecisionCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ObstaclePlacement:
            command = new ObstaclePlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ShipPlacement:
            command = new ShipPlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.AssignManeuver:
            command = new AssignManeuverCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressNext:
            command = new PressNextCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ActivateAndMove:
            command = new ActivateAndMoveCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectShipToAssignManeuver:
            command = new SelectShipToAssignManeuverCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DeclareAttack:
            command = new DeclareAttackCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.DiceModification:
            command = new DiceModificationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectShip:
            command = new SelectShipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceResults:
            command = new SyncDiceResultsCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncDiceRerollSelected:
            command = new SyncDiceRerollSelectedCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmCrit:
            command = new ConfirmCritCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.ConfirmDiceCheck:
            command = new ConfirmDiceCheckCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.PressSkip:
            command = new PressSkipCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SyncPlayerWithInitiative:
            command = new SyncPlayerWithInitiativeCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SystemActivation:
            command = new SystemActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.CombatActivation:
            command = new CombatActivationCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.SelectObstacle:
            command = new SelectObstacleCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.BombPlacement:
            command = new BombPlacementCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.MoveObstacle:
            command = new MoveObstacleCommand(commandType, subPhase, parameters);
            break;

        case GameCommandTypes.CancelShipSelection:
            command = new CancelShipSelectionCommand(commandType, subPhase, parameters);
            break;

        default:
            break;
        }

        return(command);
    }