private async Task <bool> SendCommands(IsolationAlgorithm algorithm, Dictionary <long, DiscreteCommandingType> commands, Dictionary <long, CommandedElement> commandedElements) { var algorithmBaseLogString = $"{baseLogString} [HeadBreakerGid: 0x{algorithm.HeadBreakerGid:X16}]"; if (!await lifecycleHelper.SendMultipleScadaCommandAsync(commands, commandedElements, CommandOriginType.ISOLATING_ALGORITHM_COMMAND)) { string message = $"{algorithmBaseLogString} StartIndividualAlgorithmCycle => Sending multiple command failed."; Logger.LogError(message); return(false); } commands.Keys.ToList().ForEach(async commandedElementGid => { var commandedElement = new CommandedElement() { ElementGid = commandedElementGid, CorrespondingHeadElementGid = algorithm.HeadBreakerGid, CommandingType = commands[commandedElementGid], }; await CommandedElements.SetAsync(commandedElementGid, commandedElement); await ElementsToBeIgnoredInReportPotentialOutage.SetAsync(commandedElementGid, DateTime.UtcNow); Logger.LogDebug($"{algorithmBaseLogString} SendCommands => Element 0x{commandedElementGid:X16} set to collection '{ReliableDictionaryNames.ElementsToBeIgnoredInReportPotentialOutage}' at {DateTime.UtcNow}."); }); await StartedIsolationAlgorithms.SetAsync(algorithm.HeadBreakerGid, algorithm); return(true); }
private async Task <bool> SendCommands(IsolationAlgorithm algorithm, Dictionary <long, DiscreteCommandingType> commands, Dictionary <long, CommandedElement> commandedElements) { var algorithmBaseLogString = $"{baseLogString} [HeadBreakerGid: 0x{algorithm.HeadBreakerGid:X16}]"; if (!await lifecycleHelper.SendMultipleScadaCommandAsync(commands, commandedElements, CommandOriginType.ISOLATING_ALGORITHM_COMMAND)) { string message = $"{algorithmBaseLogString} StartIndividualAlgorithmCycle => Sending multiple command failed."; Logger.LogError(message); return(false); } commands.Keys.ToList().ForEach(async commandedElementGid => { var commandedElement = new CommandedElement() { ElementGid = commandedElementGid, CorrespondingHeadElementGid = algorithm.HeadBreakerGid, CommandingType = commands[commandedElementGid], }; await CommandedElements.SetAsync(commandedElementGid, commandedElement); algorithm.ElementsCommandedInCurrentCycle.Add(commandedElementGid); }); await StartedIsolationAlgorithms.SetAsync(algorithm.HeadBreakerGid, algorithm); return(true); }