public void ShowCurrentPartitionWithSettings() { var commandAndData = new CommandAndData { CommandType = CommandType.ShowCurrentPartitionWithSettings, RenderingSettings = _renderingSettings }; SendToClient(commandAndData); }
public void CreateScreenshot() { var commandAndData = new CommandAndData { CommandType = CommandType.SavePartitionImage, ImageSavePath = _manualScreenshotPath ? Encoding.UTF8.GetBytes(_screenshotPath) : null }; SendToClient(commandAndData); }
public void ShowPartitionAtIteration() { var commandAndData = new CommandAndData { CommandType = CommandType.ShowPartitionAtIterationIndex, RenderingSettings = _renderingSettings }; SendToClient(commandAndData); }
public void CreateFuzzyPartition() { var commandAndData = new CommandAndData { CommandType = CommandType.CreateFuzzyPartition, PartitionSettings = _partitionSettingsHolder.GetPartitionSettings(), RenderingSettings = _renderingSettings }; SendToClient(commandAndData); }
private void ProcessReceivedCommands() { if (!_commandsAndDatas.Any()) { return; } if (_currentData != null) { return; } _currentData = _commandsAndDatas.Dequeue(); Logger.Info($"Start to process command. CommandType = {_currentData.CommandType}"); switch (_currentData.CommandType) { case CommandType.CreateFuzzyPartition: { if (_currentData.PartitionSettings.IsCenterPlacingTask) { var result = _partitionRunner.CreateFuzzyPartitionWithCentersPlacing(_currentData.PartitionSettings, _currentData.RenderingSettings); _client.Write(result.ToBytes()); } else { var result = _partitionRunner.CreateFuzzyPartitionWithFixedCenters(_currentData.PartitionSettings, _currentData.RenderingSettings); _client.Write(result.ToBytes()); } _currentData = null; } break; case CommandType.ShowPartitionAtIterationIndex: { //if (_currentData.IterationNumber >= _partitionImageByIterations.Count) //{ // Logger.Error($"Error: iteration number {_currentData.IterationNumber} bigger then existing {_partitionImageByIterations.Count} partition images count."); // return; //} //_partitionRunner.show _partitionRunner.DrawPartitionAtIteration(_currentData.RenderingSettings.IterationNumber); } break; case CommandType.SavePartitionImage: { if (_currentData.ImageSavePath == null) { _partitionRunner.SavePartitionImage(null); } else { var path = Encoding.UTF8.GetString(_currentData.ImageSavePath); _partitionRunner.SavePartitionImage(path); } _currentData = null; } break; case CommandType.ShowCurrentPartitionWithSettings: { _partitionRunner.RedrawPartitionWithSettings(_currentData.RenderingSettings); _currentData = null; } break; } }
private void SendToClient(CommandAndData commandAndData) { _server.Broadcast(commandAndData.ToBytes()); }