public async static Task Main(string[] args) { ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); CancellationTokenSource cts = new CancellationTokenSource(); fLog.Info("Started to process the data..."); IoFactory factory = new IoFactory(); IIoService ioService = factory.GetIoService(true); string input = await ioService.ReadFromSourceAsync(); fLog.Info($"Input file : {input}"); ITransformationService transformationService = new TransformFileService(); string output = transformationService.Transform(ioService.GetSourceDocumentType(), ioService.GetDestinationDocumentType(), input); ioService = factory.GetIoService(false); await ioService.SaveToDestinationAsync(output, cts.Token); //TODO make write async also - not such usable in this case fLog.Info($"Finished the processing with: {output}..."); }
public RelativePaths(PathFlags flags, string directorySeparator, IIoService ioService, RelativePaths <string> paths) { Flags = flags; DirectorySeparator = directorySeparator; IoService = ioService; Paths = paths; }
public AbsolutePathDescendantsOrChildren(AbsolutePath path, string pattern, bool includeSubdirectories, IIoService ioService) { _path = path; _pattern = pattern; IncludeSubdirectories = includeSubdirectories; IoService = ioService; }
public TxFramesTreeNode(IIoService ioService) { _ioService = ioService; _watch = new Stopwatch(); if (ioService.GetRxFrames.HasValue) { Text = "Tx" + @": " + ioService.GetTxFrames; } else { Text = "Tx" + @": " + AppConstants.ValueNotAvailable2; } SelectedImageKey = ImageKey = @"counter16"; TimerService.Instance.Tick += new EventHandler(Timer_Tick); EventAggregator.Instance.Subscribe <StopAppEvent>(e => { _watch.Stop(); Timer_Tick(this, EventArgs.Empty); /*Leállás után még rá frissít, ez KELL!*/ }); EventAggregator.Instance.Subscribe <PlayAppEvent>(e => { Timer_Tick(null, EventArgs.Empty); /*Ajánlott!*/ }); }
public WaitForParseTreeNode(IIoService ioService) { _ioService = ioService; Text = "Wait For Parse" + @": " + AppConstants.ValueNotAvailable2; TimerService.Instance.Tick += new EventHandler(Timer_Tick); EventAggregator.Instance.Subscribe <Events.StopAppEvent>(e => { Timer_Tick(this, EventArgs.Empty); /*Leállás után még rá frissít, ez KELL!*/ }); EventAggregator.Instance.Subscribe <PlayAppEvent>(e => { Timer_Tick(null, EventArgs.Empty); /*Ajánlott!*/ }); EventAggregator.Instance.Subscribe <ResetAppEvent>(e => { Timer_Tick(null, EventArgs.Empty); }); void Timer_Tick(object sender, EventArgs e) { if (_ioService.GetWaitForParseFrames.HasValue) { Text = "Wait For Parse" + @": " + _ioService.GetWaitForParseFrames; } else { Text = "Wait For Parse" + @": " + AppConstants.ValueNotAvailable2; } } }
public SortedGroupWriterFactory( IIoService ioService, IConfig config) { _ioService = ioService; _config = config; }
public ShowController(ILogger <ShowController> logger, IIoService ioService, IMapper mapper, IShowService showService) { _logger = logger; _ioService = ioService; _mapper = mapper; _showService = showService; }
public SortedGroupWriter( IIoService ioService, IConfig config) { _writers = new ConcurrentBag <IFileWriter>(); _ioService = ioService; _config = config; }
internal CalculatedAbsolutePathTranslation(AbsolutePath absolutePath, AbsolutePath ancestorSource, AbsolutePath ancestorDestination, IIoService ioService) { AbsoluteAbsolutePath = absolutePath; AncestorSource = ancestorSource; AncestorDestination = ancestorDestination; IoService = ioService; _actualValues = Calculate(); }
public LaserViewModel([Inject] LaserService laser, [Inject] IIoService ioService) { timer.Interval = TimeSpan.FromMilliseconds(100); timer.Tick += Timer_Tick; timer.Start(); _laser = laser; _ioService = ioService; _laser.LaserHandler += _laser_LaserHandler; }
public GroupsLoaderFactory( IBuffersPool buffersPool, IIoService ioService, IConfig config) { _buffersPool = buffersPool; _ioService = ioService; _config = config; }
public GroupsLinesOutputFactory( IIoService ioService, ITasksQueue tasksQueue, IBuffersPool buffersPool, IConfig config) { _ioService = ioService; _tasksQueue = tasksQueue; _buffersPool = buffersPool; _config = config; }
public InputReaderFactory( IIoService ioService, ITasksQueue tasksQueue, IBuffersPool buffersPool, IConfig config) { _ioService = ioService; _tasksQueue = tasksQueue; _buffersPool = buffersPool; _config = config; }
public AbsolutePath(PathFlags flags, string directorySeparator, IIoService ioService, IEnumerable <string> path) { Flags = flags; DirectorySeparator = directorySeparator; IoService = ioService; Path = new AbsolutePath <string>(path); if (!ioService.ComponentsAreAbsolute(Path.Components)) { throw new ArgumentException($"The path {Path} is not absolute"); } }
public GrouperIOs( IInputReaderFactory inputReaderFactory, IGroupsLinesOutputFactory groupsLinesOutputFactory, IIoService ioService, IConfig config) { _implementation = new Lazy <IReadOnlyList <IGrouperIO> >(() => { var inputFileLength = ioService.SizeOfFile(config.InputFilePath); if (config.GrouperEnginesCount == 1) { return new[] { new IO(inputReaderFactory.Create(inputFileLength), groupsLinesOutputFactory.Create()) } } ; var implementation = new List <IGrouperIO>(); var blockLength = inputFileLength / config.GrouperEnginesCount; long offset = 0; using (var inputStream = ioService.OpenRead(config.InputFilePath)) for (int i = 0; i < config.GrouperEnginesCount; i++) { inputStream.Position = Math.Min( offset + blockLength, inputFileLength - 1); while (inputStream.ReadByte() != Consts.EndLineByte2) { ; } var readingLength = inputStream.Position - offset; implementation.Add(new IO( inputReaderFactory.Create(offset, readingLength), groupsLinesOutputFactory.Create(offset))); if (inputStream.Position == inputFileLength) { break; } offset = inputStream.Position; } return(implementation); }); }
public PlayCommand(IIoService ioService) { _ioService = ioService; Image = Resources.Play_48x48; Text = "Run"; ShortcutKeys = Keys.F5; Enabled = true; DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; ToolTipText = @"F5"; EventAggregator.Instance.Subscribe <StopAppEvent>(e => Enabled = true); EventAggregator.Instance.Subscribe <PlayAppEvent>(e => Enabled = false); }
public StopCommand(IIoService service) { _service = service; Image = Resources.Stop_48x48; Text = "Stop"; Enabled = false; DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; ToolTipText = @"F6"; ShortcutKeys = Keys.F6; EventAggregator.Instance.Subscribe <PlayAppEvent>(n => Enabled = true); EventAggregator.Instance.Subscribe <StopAppEvent>(n => Enabled = false); }
public Sorter( IIoService ioService, IGrouper grouper, IGroupsLoaderFactory groupsLoaderFactory, IGroupSorter groupSorter, ISortedGroupWriterFactory groupWriterFactory, IConfig config) { _ioService = ioService; _grouper = grouper; _groupsLoaderFactory = groupsLoaderFactory; _groupSorter = groupSorter; _groupWriterFactory = groupWriterFactory; _config = config; }
public LinesWriter( long fileOffset, IBuffersPool buffersPool, ITasksQueue tasksQueue, IIoService ioService, IConfig config) { _buffersPool = buffersPool; _tasksQueue = tasksQueue; _ioService = ioService; _writingPosition = fileOffset; _usingBufferLength = config.UsingBufferLength; _groupsFilePath = config.GroupsFilePath; _groupsStorage = new Group[Consts.MaxGroupsCount]; _writers = new ConcurrentBag <IFileWriter>(); }
public DroppedFramesStatus(IIoService ioService) { _ioService = ioService; BorderSides = ToolStripStatusLabelBorderSides.Left; BorderStyle = Border3DStyle.Etched; Size = new System.Drawing.Size(58, 19); Text = AppConstants.ValueNotAvailable2; TimerService.Instance.Tick += (s, e) => { if (_ioService.GetDroppedFrames.HasValue) { Text = "Dropped Frames" + @": " + _ioService.GetDroppedFrames; } else { Text = "Dropped Frames" + @": " + AppConstants.ValueNotAvailable2; } }; }
public GroupsLoader( GroupInfo[] groupsInfo, IGroup[] output, IBuffersPool buffersPool, IIoService ioService, IConfig config) { _groupsInfo = groupsInfo; _output = output; _ioService = ioService; _buffersPool = buffersPool; int maxGroupBytesCount = 0, maxGroupLinesCount = 0; for (int i = 0; i < Consts.MaxGroupsCount; i++) { var info = groupsInfo[i]; if (!GroupInfo.IsZero(info)) { maxGroupBytesCount = Math.Max(maxGroupBytesCount, info.BytesCount); maxGroupLinesCount = Math.Max(maxGroupLinesCount, info.LinesCount); } } var memoryUsedForBuffers = (long) _buffersPool.Count * config.PhysicalBufferLength; var maxGroupBuffersCount = (int)Math.Ceiling((double) maxGroupBytesCount / config.UsingBufferLength); var maxGroupSize = maxGroupBuffersCount * config.PhysicalBufferLength; var lineSize = Marshal.SizeOf <LineIndexes>() + sizeof(ulong); var maxSizeForGroupLines = lineSize * maxGroupLinesCount; var maxLoadedGroupsCount = memoryUsedForBuffers / (maxGroupSize + maxSizeForGroupLines); var memoryForLines = (int) maxLoadedGroupsCount * maxSizeForGroupLines; _reservedLinesCount = memoryForLines / lineSize; var buffersCountForFree = (int)Math.Ceiling((double) memoryForLines / config.PhysicalBufferLength); var buffersCount = _buffersPool.Count - buffersCountForFree; var allBuffers = _buffersPool.ExtractAll(); Array.Resize(ref allBuffers, buffersCount); _buffers = allBuffers; _linesIndexes = new LineIndexes[_reservedLinesCount]; _sortingSegments = new ulong[_reservedLinesCount]; _groupsFilePath = config.GroupsFilePath; _usingBufferLength = config.UsingBufferLength; _readers = Enumerable .Range(0, Consts.MaxRunningTasksCount) .Select(_ => _ioService.OpenRead(_groupsFilePath)) .ToArray(); var tempBuffersHandles = Enumerable .Range(0, Consts.MaxRunningTasksCount) .Select(_ => _buffersPool.Get()) .ToArray(); _tempBuffers = tempBuffersHandles .Select(o => o.Value) .ToArray(); _dispose = Enumerable .Concat <IDisposable>(_readers, tempBuffersHandles) .Select(o => new Action(o.Dispose)) .Aggregate((a, b) => a + b); }
internal AbsolutePathTranslation(AbsolutePath source, AbsolutePath destination, IIoService ioService) { Source = source; Destination = destination; IoService = ioService; }
public BrowseController(ILogger <BrowseController> logger, IIoService ioService) { _logger = logger; _ioService = ioService; }
public AbsolutePathChildren(AbsolutePath path, string pattern, IIoService ioService) : base(path, pattern, false, ioService) { }
public PlayAppEvent(IIoService ioService) { IoService = ioService; }
public StopAppEvent(IIoService service) { IoService = service; }
public AbsolutePathDescendants(AbsolutePath path, string pattern, IIoService ioService) : base(path, pattern, true, ioService) { }
public App() { /*** Application Settings Upgrade ***/ if (Settings.Default.ApplictionSettingsSaveCounter == 0) { Settings.Default.Upgrade(); Settings.Default.ApplictionSettingsUpgradeCounter++; } Settings.Default.ApplictionSettingsSaveCounter++; Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Settings_PropertyChanged); /*** Main Form ***/ _mainForm = new MainForm(); _mainForm.Text = AppConstants.SoftwareTitle + " - " + Application.ProductVersion; _mainForm.Shown += MainForm_Shown; _mainForm.FormClosing += MainForm_FormClosing; _mainForm.FormClosed += new FormClosedEventHandler(MainForm_FormClosed); /*** Explorer ***/ _explorer = new Explorer(); /*** IoService ***/ _ioService = new IoService(_explorer); _ioService.Started += IoService_Started; _ioService.Stopped += IoService_Stopped; /*** TimerService ***/ TimerService.Instance.Interval = Settings.Default.GuiRefreshRateMs; /*** TcpService ***/ _tcpService = new TcpService(); _tcpService.ParserCallback = TcpServiceParser; _tcpService.Begin(null); _tcpService.Completed += TcpService_Completed; /*** Menu Bar ***/ #region MenuBar var configMenu = new ToolStripMenuItem("Config"); configMenu.DropDown.Items.AddRange( new ToolStripItem[] { new Commands.OptionsCommand(this) }); var helpMenu = new ToolStripMenuItem("Help"); helpMenu.DropDown.Items.AddRange( new ToolStripItem[] { new Commands.HowIsWorkingCommand(), // new Commands.UpdatesCommands(), }); var runMenu = new ToolStripMenuItem("Run"); runMenu.DropDown.Items.AddRange( new ToolStripItem[] { new Commands.PlayCommand(_ioService), new Commands.StopCommand(_ioService), new Commands.ResetCommand() }); _mainForm.MenuBar = new ToolStripItem[] { // configMenu, runMenu, //viewMenu, helpMenu, }; #endregion /*** SendView ***/ #region SendView var sendView = _mainForm.SendView; sendView.Signals = CanDb.Instance.Signals.Where(n => n.Message.NodeType.Name == NodeCollection.NODE_PC).Select(n => n.Name).ToArray(); sendView.SelectedSignalChanged += (o, s) => { sendView.Value = CanDb.Instance.Signals.FirstOrDefault(n => n.Name == sendView.SelectedSignal).DefaultValue; }; sendView.Send += (o, s) => { var msg = CanDb.MakeMessage ( nodeTypeId: CanDb.Instance.Nodes.FirstOrDefault(n => n.Name == NodeCollection.NODE_PC).NodeTypeId, nodeAddress: sendView.Address, broadcast: sendView.Broadcast, signal: CanDb.Instance.Signals.FirstOrDefault(n => n.Name == sendView.SelectedSignal), value: sendView.Value ); _ioService.TxQueue.Enqueue(msg); }; #endregion /*** Tree ***/ #region Tree _mainForm.Tree.AfterSelect += Tree_AfterSelect; _mainForm.Tree.Nodes.AddRange( new TreeNode[] { new View.TreeNodes.RacksTreeNode(_explorer), new View.TreeNodes.ModulsTree(_explorer), new View.TreeNodes.WaitForParseTreeNode(_ioService), new View.TreeNodes.DropFrameTreeNode(_ioService), new View.TreeNodes.ParsedFrameTreeNode(_ioService), new View.TreeNodes.RxFramesTreeNode(_ioService), new View.TreeNodes.TxFramesTreeNode(_ioService), new View.TreeNodes.WaitForTxTreeNode(_ioService), new View.TreeNodes.IoLogTreeNode() }); _mainForm.Tree.ContextMenuStrip = new ContextMenuStrip(); _mainForm.Tree.ContextMenuStrip.Items.AddRange( new ToolStripItem[] { new View.Commands.OpenCanIOLogFileCommand(), new View.Commands.DeleteCanIOLogFileCommand(), new View.Commands.OpenExplorerCanIOLogFileCommand(), }); #endregion /*** DataGrid ***/ var grid = _mainForm.DataGrid; grid.DataSource = _explorer.Devices; /*** StatusBar ***/ #region StatusBar _mainForm.StatusBar = new ToolStripItem[] { new StatusBar.AppLogStatus(), new StatusBar.WaitForParseFramesStatus(_ioService), new StatusBar.ParsedFramesStatus(_ioService), new StatusBar.DroppedFramesStatus(_ioService), new StatusBar.EmptyStatus(), new StatusBar.VersionStatus(), new StatusBar.LogoStatus(), }; #endregion /*** Run ***/ Application.Run((MainForm)_mainForm); }
public PongBehavior(IIoService ioService) { _ioService = ioService; }
public Exporter(IIoService ioService) { this.ioService = ioService; }
public InputReader( long readingOffset, long readingLength, IBuffersPool buffersPool, ITasksQueue tasksQueue, IIoService ioService, IConfig config) { _buffersPool = buffersPool; _tasksQueue = tasksQueue; _readingOut = readingOffset + readingLength; // -1 - for set "Buffer End" Symbol to last cell of buffer without data lose var readingBufferLength = config.UsingBufferLength - 1; using (var reader = ioService.OpenRead(config.InputFilePath)) { var firstBufferHandle = _buffersPool.Get(); var length = (int)Math.Min( readingBufferLength - Consts.EndLineBytesCount, readingLength); reader.Position = readingOffset; length = reader.Read(firstBufferHandle.Value, Consts.EndLineBytesCount, length); _firstBufferItem = new Item( length + Consts.EndLineBytesCount, firstBufferHandle); readingOffset += length; readingLength -= length; } _capacity = (int)Math.Min( Math.Ceiling((double)readingLength / readingBufferLength), InitCapacity); _readed = new ConcurrentDictionary <int, Item>( concurrencyLevel: config.MaxRunningTasksCount, capacity: Math.Max(1, _capacity)); if (_capacity == 0) { _readed.TryAdd(0, new Item(0, Handle <byte[]> .Zero)); _readNext = new Action[] { () => _readed.TryAdd(0, new Item(0, Handle <byte[]> .Zero)) }; _readingIndex = Enumerable.Repeat(0, int.MaxValue).GetEnumerator(); return; } var readerStep = (_capacity - 1) * readingBufferLength; _readingIndex = ReadingIndexes.GetEnumerator(); _readingIndex.MoveNext(); _readNext = new Action[_capacity]; for (int i = 0; i < _capacity; i++) { var reader = ioService.OpenRead(config.InputFilePath, position: readingOffset + i * readingBufferLength); int buffIndex = i; Action read = delegate { var pooledBuff = _buffersPool.Get(); var length = (int)Math.Min(_readingOut - reader.Position, readingBufferLength); length = reader.Read(pooledBuff.Value, 0, length); _readed.TryAdd(buffIndex, new Item(length, pooledBuff)); }; _readNext[i] = delegate { read(); _readNext[buffIndex] = delegate { var position = reader.Position + readerStep; if (position < _readingOut) { reader.Position = position; read(); } else { _readed.TryAdd(buffIndex, new Item(0, Handle <byte[]> .Zero)); reader.Dispose(); } }; }; } for (int i = 0; i < _readNext.Length; i++) { _tasksQueue.Enqueue(_readNext[i]); } }