private async Task DbgShowTransferRateAsync() { while (State == EState.ACTIVE) { Log.s(TAG, "ScreenCap TransferRate: " + TransferRate.ToXByteSize(2) + "(" + TransferRate.ToMbitSpeed() + ")"); await Task.Delay(500); } }
public bool Open(IFilter imageFilter) { Stream stream = imageFilter.GetDataForkStream(); stream.Seek(0, SeekOrigin.Begin); var cmt = new MemoryStream(); stream.Seek(0x1F, SeekOrigin.Begin); for (uint i = 0; i < stream.Length; i++) { byte b = (byte)stream.ReadByte(); if (b == 0x1A) { break; } cmt.WriteByte(b); } imageInfo.Comments = StringHandlers.CToString(cmt.ToArray()); sectorsData = new List <byte[]>(); byte currentCylinder = 0; imageInfo.Cylinders = 1; imageInfo.Heads = 1; ulong currentLba = 0; TransferRate mode = TransferRate.TwoHundred; while (stream.Position + 5 < stream.Length) { mode = (TransferRate)stream.ReadByte(); byte cylinder = (byte)stream.ReadByte(); byte head = (byte)stream.ReadByte(); byte spt = (byte)stream.ReadByte(); byte n = (byte)stream.ReadByte(); byte[] idmap = new byte[spt]; byte[] cylmap = new byte[spt]; byte[] headmap = new byte[spt]; ushort[] bps = new ushort[spt]; if (cylinder != currentCylinder) { currentCylinder = cylinder; imageInfo.Cylinders++; } if ((head & 1) == 1) { imageInfo.Heads = 2; } stream.Read(idmap, 0, idmap.Length); if ((head & SECTOR_CYLINDER_MAP_MASK) == SECTOR_CYLINDER_MAP_MASK) { stream.Read(cylmap, 0, cylmap.Length); } if ((head & SECTOR_HEAD_MAP_MASK) == SECTOR_HEAD_MAP_MASK) { stream.Read(headmap, 0, headmap.Length); } if (n == 0xFF) { byte[] bpsbytes = new byte[spt * 2]; stream.Read(bpsbytes, 0, bpsbytes.Length); for (int i = 0; i < spt; i++) { bps[i] = BitConverter.ToUInt16(bpsbytes, i * 2); } } else { for (int i = 0; i < spt; i++) { bps[i] = (ushort)(128 << n); } } if (spt > imageInfo.SectorsPerTrack) { imageInfo.SectorsPerTrack = spt; } SortedDictionary <byte, byte[]> track = new SortedDictionary <byte, byte[]>(); for (int i = 0; i < spt; i++) { var type = (SectorType)stream.ReadByte(); byte[] data = new byte[bps[i]]; // TODO; Handle disks with different bps in track 0 if (bps[i] > imageInfo.SectorSize) { imageInfo.SectorSize = bps[i]; } switch (type) { case SectorType.Unavailable: if (!track.ContainsKey(idmap[i])) { track.Add(idmap[i], data); } break; case SectorType.Normal: case SectorType.Deleted: case SectorType.Error: case SectorType.DeletedError: stream.Read(data, 0, data.Length); if (!track.ContainsKey(idmap[i])) { track.Add(idmap[i], data); } imageInfo.ImageSize += (ulong)data.Length; break; case SectorType.Compressed: case SectorType.CompressedDeleted: case SectorType.CompressedError: case SectorType.CompressedDeletedError: byte filling = (byte)stream.ReadByte(); ArrayHelpers.ArrayFill(data, filling); if (!track.ContainsKey(idmap[i])) { track.Add(idmap[i], data); } break; default: throw new ImageNotSupportedException($"Invalid sector type {(byte)type}"); } } foreach (KeyValuePair <byte, byte[]> kvp in track) { sectorsData.Add(kvp.Value); currentLba++; } } imageInfo.Application = "IMD"; // TODO: The header is the date of dump or the date of the application compilation? imageInfo.CreationTime = imageFilter.GetCreationTime(); imageInfo.LastModificationTime = imageFilter.GetLastWriteTime(); imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename()); imageInfo.Comments = StringHandlers.CToString(cmt.ToArray()); imageInfo.Sectors = currentLba; imageInfo.MediaType = MediaType.Unknown; MediaEncoding mediaEncoding = MediaEncoding.MFM; if (mode == TransferRate.TwoHundred || mode == TransferRate.ThreeHundred || mode == TransferRate.FiveHundred) { mediaEncoding = MediaEncoding.FM; } imageInfo.MediaType = Geometry.GetMediaType(((ushort)imageInfo.Cylinders, (byte)imageInfo.Heads, (ushort)imageInfo.SectorsPerTrack, imageInfo.SectorSize, mediaEncoding, false)); switch (imageInfo.MediaType) { case MediaType.NEC_525_HD when mode == TransferRate.FiveHundredMfm: imageInfo.MediaType = MediaType.NEC_35_HD_8; break; case MediaType.DOS_525_HD when mode == TransferRate.FiveHundredMfm: imageInfo.MediaType = MediaType.NEC_35_HD_15; break; case MediaType.RX50 when mode == TransferRate.FiveHundredMfm: imageInfo.MediaType = MediaType.ATARI_35_SS_DD; break; } imageInfo.XmlMediaType = XmlMediaType.BlockMedia; AaruConsole.VerboseWriteLine("IMD image contains a disk of type {0}", imageInfo.MediaType); if (!string.IsNullOrEmpty(imageInfo.Comments)) { AaruConsole.VerboseWriteLine("IMD comments: {0}", imageInfo.Comments); } return(true); }
public PointCloudTileSource Process(ProgressManager progressManager) { progressManager.Log("<= {0}", m_inputHandler.FilePath); PerformanceManager.Start(m_inputHandler.FilePath); // check for existing tile source LoadFromCache(progressManager); if (m_tileSource == null) { using (var process = progressManager.StartProcess("ProcessSet")) { m_binarySource = m_inputHandler.GenerateBinarySource(progressManager); m_tiledHandler = LASFile.Create(m_tiledHandler.FilePath, m_binarySource); using (var segmentBuffer = BufferManager.AcquireBuffer(m_id, (int)PROPERTY_SEGMENT_SIZE.Value, true)) { var tileManager = new PointCloudTileManager(m_binarySource); m_tileSource = tileManager.TilePointFileIndex(m_tiledHandler, segmentBuffer, progressManager); } #warning this was for xyz, but I have not yet re-implemented that anyway //if (m_binarySource.FilePath != m_inputHandler.FilePath) // File.Delete(m_binarySource.FilePath); if (m_tileSource.IsDirty) { m_tileSource.Close(); File.Delete(m_tileSource.FilePath); m_tileSource = null; process.LogTime("=> Processing Cancelled"); } else { process.LogTime("=> Processing Completed"); } } GC.Collect(); } TransferRate averageReadSpeed = PerformanceManager.GetReadSpeed(); TransferRate averageWriteSpeed = PerformanceManager.GetWriteSpeed(); Context.WriteLine("IO Read Speed: {0}", averageReadSpeed); Context.WriteLine("IO Write Speed: {0}", averageWriteSpeed); //{ // // test // Stopwatch stopwatch = new Stopwatch(); // stopwatch.Start(); // PointCloudTile tempTile = m_tileSource.TileSet[0, 0]; // Grid<float> grid = new Grid<float>(tempTile.Extent, 540, (float)m_tileSource.Extent.MinZ - 1.0f, true); // Grid<uint> quantizedGrid = new Grid<uint>(grid.SizeX, grid.SizeY, m_tileSource.Extent, true); // using (GridTileSource<float> gridSource = new GridTileSource<float>(m_tiledPath + ".grid", grid.SizeX, grid.SizeY, m_tileSource.TileSet.Cols, m_tileSource.TileSet.Rows)) // { // int tempBufferSize = (int)(m_tileSource.TileSet.Max(t => t.PointCount)); // byte[] tempBuffer = new byte[tempBufferSize * m_tileSource.PointSizeBytes]; // foreach (PointCloudTile tile in m_tileSource) // { // m_tileSource.LoadTileGrid(tile, tempBuffer, grid, quantizedGrid); // gridSource.WriteTile(tile.Col, tile.Row, grid.Data); // if (!progressManager.Update((float)tile.Index / m_tileSource.TileSet.TileCount)) // break; // } // //gridSource.ReadTile(tempTile.Col, tempTile.Row, grid.Data); // } // m_tileSource.Close(); // progressManager.Log(stopwatch, "Generated GRID"); //} return(m_tileSource); }
public ChargeableComponent(Blob config, long maxCharge = 300000, long transferIn = 128, long transferOut = 128) { _blob = config; MaxCharge = config.GetLong("maxCharge", maxCharge); ChargeModels = new Dictionary <int, string>(); TransferRate = new TransferRate(); DescriptionCode = config.GetString("descriptionCode", null); OutputToTiles = config.GetBool("outputToTiles", false); InputFromTiles = config.GetBool("inputFromTiles", true); PowerVerb = config.GetString("powerVerb", "nimbusfox.powerapi.verb.power"); try { CompatiblePower = config.GetStringList("compatiblePower").ToList(); } catch { CompatiblePower = new List <string> { PowerVerb }; } if (!config.Contains("transferRate")) { TransferRate.In = transferIn; TransferRate.Out = transferOut; } else { if (config.KeyValueIteratable["transferRate"].Kind == BlobEntryKind.Int) { var rate = config.GetLong("transferRate", transferIn); TransferRate.In = rate; TransferRate.Out = rate; } else if (config.KeyValueIteratable["transferRate"].Kind == BlobEntryKind.Blob) { var rates = config.GetBlob("transferRate"); TransferRate.In = rates.GetLong("in", transferIn); TransferRate.Out = rates.GetLong("out", transferOut); } else { TransferRate.In = transferIn; TransferRate.Out = transferOut; } } var blob = config.FetchBlob("chargeModels"); foreach (var charge in blob.KeyValueIteratable) { if (charge.Value.Kind == BlobEntryKind.String) { var text = charge.Key; if (text.Contains("%")) { text = text.Replace("%", ""); } if (byte.TryParse(text, out var chargePercent)) { if (!ChargeModels.ContainsKey(chargePercent)) { ChargeModels.Add(chargePercent, charge.Value.GetString()); } } } } }
// Use this for initialization void Start() { _Inst = this; DontDestroyOnLoad(this); }