private static void SaveToFile(string fileName, IldHeaderRaw startHeaderRaw, IldRecordRaw[] recordRawArray, IldRecordRaw finishRecordRaw, IldHeaderRaw finishHeaderRaw) { using (var fs = new FileStream(fileName, FileMode.Create)) { using (var bw = new BinaryWriter(fs)) { bw.Write(startHeaderRaw.Data); for (var i = 0; i < recordRawArray.Length; i++) { bw.Write(recordRawArray[i].Data); } bw.Write(finishRecordRaw.Data); bw.Write(finishHeaderRaw.Data); bw.Flush(); } } }
public IldHeader(IldHeaderRaw raw) { Raw = raw; _converter= new BytesConverter(raw.Data); }
public IldHeader(IldHeaderRaw raw) { Raw = raw; _converter = new BytesConverter(raw.Data); }
public void Save(string fileName, IFrameable frameable) { var startHeaderRaw = new IldHeaderRaw(); startHeaderRaw.Init(); var startHeader = new IldHeader(startHeaderRaw) { FileFormat = "ILDA", FormatCode = 0, FrameName = frameable.Name, CompanyName = "Peleton", TotalPoints = frameable.TracePoints.Length + 1, FrameNumber = 0, TotalFrames = 1, ScannerHead = 0, Future = 0 }; var finishHeaderRaw = new IldHeaderRaw(); finishHeaderRaw.Init(); var finishHeader = new IldHeader(finishHeaderRaw) { FileFormat = "ILDA", FormatCode = 0, FrameName = frameable.Name, CompanyName = "Peleton", TotalPoints = 0, FrameNumber = 1, TotalFrames = 1, ScannerHead = 0, Future = 0 }; var transformation = new CompositeTransformation( new ReverseTransformation(frameable.Transformation), Transformation); var recordRawArray = new IldRecordRaw[frameable.TracePoints.Length]; for (var i = 0; i < recordRawArray.Length; i++) { var tracePoint = frameable.TracePoints[i]; var recordRaw = new IldRecordRaw(); recordRaw.Init(); var point = transformation.Transform(tracePoint.Point); var record = new IldRecord(recordRaw) { X = (int)point.X, Y = (int)point.Y, Z = -16, Status = 56, IsMove = !tracePoint.Trace, IsLast = false }; recordRawArray[i] = recordRaw; } var finishRecordRaw = new IldRecordRaw(); finishRecordRaw.Init(); var finishRecord = new IldRecord(finishRecordRaw) { X = 0, Y = 0, Z = -16, Status = 56, IsMove = true, IsLast = true }; SaveToFile(fileName, startHeaderRaw, recordRawArray, finishRecordRaw, finishHeaderRaw); }