RackScanResult GetRackScanResultFromData(string data) { RackScanResult result = new RackScanner.RackScanResult(); if (data.StartsWith("Date,")) { char[] div = new char[] { ',' }; foreach (var line in data.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { string[] items = line.Split(div); if (items != null && items.Length == 7) { string rack_barcode = (items[6] != "NOREAD") ? items[6] : ""; string row = items[3]; int colInt = Convert.ToInt32(items[4]); string col = colInt.ToString("D2"); string barcode = items[5]; result.RackBarcode = rack_barcode; if (barcode != "EMPTY") { RackScanResult.RackScanResultCell cell = new RackScanResult.RackScanResultCell(); cell.Address = row + col; cell.Barcode = barcode; result.Cells.Add(cell); result.BarcodeToAddressMap[barcode] = cell.Address; } } } } return(result); }
void fsw_Created(object sender, FileSystemEventArgs e) { //If we are not scanning actively, do not generate an event if (!_ScanInProgress) { return; } System.Diagnostics.Debug.WriteLine(e.FullPath); System.Diagnostics.Debug.WriteLine(this.Profile.Conversion.ToString()); LogEvent("File found in output directory: " + e.Name); _ScanInProgress = false; RackScanResult result = new RackScanResult(); int FIELD_COUNT = 2; string[] lines = null; int failure_count = 0; while (true) { try { lines = File.ReadAllLines(e.FullPath); break; } catch { failure_count++; System.Threading.Thread.Sleep(200); if (failure_count > 20) { GenerateError("Could not get access to locked file " + e.FullPath); } } } System.Diagnostics.Debug.WriteLine("Lines: " + lines.Length.ToString()); foreach (string line in lines) { string[] items = line.Split(new char[] { ',' }); if (items.Length != FIELD_COUNT) { result.HasError = true; result.ErrorDetail = "File failed parsing, expected " + FIELD_COUNT.ToString() + " fields, found " + items.Length.ToString(); RaiseRackScannedEvent(result); return; } string address = items[0].Trim(); string element_barcode = items[1].Trim(); if (this.Profile.Conversion != FluidXScannerProfile.FlipType.None) { address = Convert(this.Profile.Conversion, address); } if (this.PadColumnAddress) { string row_address = address.Substring(0, 1); string col_address = address.Substring(1); col_address = System.Convert.ToInt32(col_address).ToString("D2"); address = row_address + col_address; } if (element_barcode != "NO TUBE" && element_barcode != "NO READ") { RackScanResult.RackScanResultCell cell = new RackScanResult.RackScanResultCell(); cell.Address = address; cell.Barcode = element_barcode; result.Cells.Add(cell); result.BarcodeToAddressMap[element_barcode] = address; } if (element_barcode == "NO READ") { // result.HasError = true; // result.ErrorDetail = "At least one tube failed to read. Ensure tubes are flush and lighting is optimized."; } } _result = result; RaiseRackScannedEvent(result); }