Beispiel #1
0
 void RaiseRackScannedEvent(RackScanResult result)
 {
     if (this.RackScanned != null)
     {
         RaiseEventOnUIThread(this.RackScanned, new object[] { this, result });
     }
 }
Beispiel #2
0
 void RebuildRackScanResult(RackScanResult result)
 {
     result.BarcodeToAddressMap.Clear();
     foreach (var c in result.Cells)
     {
         result.BarcodeToAddressMap[c.Barcode] = c.Address;
     }
 }
Beispiel #3
0
        RackScanResult ScanInternal()
        {
            RackScanResult result = new RackScanResult();

            _result = null;
            List <string> options = new List <string>();

            options.Add("success");
            options.Add("fail");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            string response = _tc.ReadWaitForStrings("Intellicode.Instrument.Profile.scan", options, 60000);

            result.InterfaceMessage = response;
            if (response == null) //timeout
            {
                LogEvent("Time out awaiting scanner response");
                GenerateError("Time out waiting for scanner response");
                _ScanInProgress = false;
                return(result);
            }
            if (response.Contains("warning"))
            {
                LogEvent("Warning detected in scan result message");
                result.HasError    = true;
                result.ErrorDetail = "Bad scan: " + response;
            }

            if (response.Contains("fail"))
            {
                LogEvent("Failure detected in scan result message");
                result.HasError    = true;
                result.ErrorDetail = "Failure: " + response;
                GenerateError("Scan failure: " + response);
                _ScanInProgress = false;
                return(result);
            }

            LogEvent("Success detected in scan result message");
            while (_result == null && sw.Elapsed.Seconds < 20)
            {
                System.Threading.Thread.Sleep(300);
            }

            if (_result == null)
            {
                result.HasError    = true;
                result.ErrorDetail = "Timed out waiting for scan output file to appear";
                GenerateError("Timed out waiting for scan output file to appear");
                _ScanInProgress = false;
                return(result);
            }
            _ScanInProgress = false;
            return(_result);
        }
Beispiel #4
0
 bool RackScanResultIsComplete(RackScanResult r)
 {
     foreach (var c in r.Cells)
     {
         if (c.Barcode == "TRIAL")
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #5
0
 RackScanResult MergeRackScanResults(RackScanResult r1, RackScanResult r2)
 {
     for (int i = 0; i < r1.Cells.Count; i++)
     {
         if (r1.Cells[i].Barcode == "TRIAL")
         {
             r1.Cells[i].Barcode = r2.Cells[i].Barcode;
         }
     }
     return(r1);
 }
Beispiel #6
0
        public RackScanResult Scan()
        {
            RackScanResult result = new RackScanResult();
            var            conn   = GetConnection();

            LogEvent("Sending scan command");
            string data = conn.ReadWaitForStrings("SCAN " + this.Profile.ProfileName + " TEXT", new List <string>()
            {
                "OK", "ERR"
            }, 1000);

            if (data.Contains("ERR"))
            {
                data               = data.Replace("OK\r\n", "");
                result.HasError    = true;
                result.ErrorDetail = data;
                GenerateError(data);
                LogEvent("Scanner error: " + data);
                return(result);
            }

            LogEvent("Scan command acknowledged.  Acquiring ...");
            data = conn.ReadWaitForStrings("", new List <string>()
            {
                "OK", "ERR"
            }, 5000);
            if (data == null)
            {
                LogEvent("No data. Scan must be repeated ...");
                data = "";
            }

            if (data.Contains("ERR"))
            {
                data               = data.Replace("OK\r\n", "");
                result.HasError    = true;
                result.ErrorDetail = data;
                GenerateError(data);
                LogEvent("Scanner error: " + data);
                return(result);
            }

            LogEvent("Processing scan data");
            if (data.StartsWith("Date,"))
            {
                result = GetRackScanResultFromData(data);
            }
            conn.WriteLine("CLOSE");
            conn.Close();
            RaiseRackScannedEvent(result);
            return(result);
        }
        private void _RackScanner_RackScanned(object sender, RackScanResult e)
        {
            Invoke((MethodInvoker) delegate
            {
                this.rackScanLogViewer1.ShowProgress = false;
            });


            if (this.RackScanned != null)
            {
                RaiseEventOnUIThread(this.RackScanned, new object[] { this, e });
            }
        }
Beispiel #8
0
        public RackScanResult Scan()
        {
            if (!IsProcessRunning())
            {
                LogEvent("Intellicodel process not running, starting up");
                InitializeScanner();
            }

            if (!TryConnect())
            {
                LogEvent("Connection failure, attempting to reinitialize");
                InitializeScanner();
            }

            if (!TryConnect())
            {
                LogEvent("Could not connect/start scanner profile");
                GenerateError("Could not connect/start scanner profile"); return(null);
            }

            RackScanResult result = null;

            _ScanInProgress = true;
            result          = ScanInternal();


            ///
            ///
            /// for (int i = 0; i <= this.Profile.FailedScanRetryCount; i++)
            //  {
            //      LogEvent("Initiating scan attempt " + (i + 1).ToString());
            //       result = ScanInternal();
            //      result.RetryCount = i;
            //      if (!result.HasError) return result;
            // }
            //

            RaiseRackScannedEvent(result);
            return(result);
        }
Beispiel #9
0
        public RackScanResult AdvancedScan()
        {
            RackScanResult result = new RackScanResult();
            var            conn   = GetConnection();

            if (conn == null)
            {
                result.HasError    = true;
                result.ErrorDetail = "Could not get a connection to Ziath device.  Is DataPaq installed and device attached?";
                RaiseRackScannedEvent(result);
                return(result);
            }

            int tries = 1;

            LogEvent("Sending scan command " + tries.ToString());
            string data = conn.ReadWaitForStrings("SCAN " + this.Profile.ProfileName + " TEXT", new List <string>()
            {
                "OK", "ERR"
            }, 1000);

            if (data.Contains("ERR"))
            {
                data               = data.Replace("OK\r\n", "");
                result.HasError    = true;
                result.ErrorDetail = data;
                GenerateError(data);
                LogEvent("Scanner error: " + data);
                RaiseRackScannedEvent(result);
                return(result);
            }

            LogEvent("Scan command acknowledged.  Acquiring ...");

            data = conn.ReadWaitForStrings("", new List <string>()
            {
                "OK", "ERR"
            }, 5000);

            if (data.Contains("ERR"))
            {
                data               = data.Replace("OK\r\n", "");
                result.HasError    = true;
                result.ErrorDetail = data;
                GenerateError(data);
                LogEvent("Scanner error: " + data);
                RaiseRackScannedEvent(result);
                return(result);
            }

            LogEvent("Processing scan data");

            result = GetRackScanResultFromData(data);

            while (!RackScanResultIsComplete(result))
            {
                tries++;
                LogEvent("Sending scan command " + tries.ToString());
                data = conn.ReadWaitForStrings("SCAN " + this.Profile.ProfileName + " TEXT", new List <string>()
                {
                    "OK", "ERR"
                }, 1000);

                if (data.Contains("ERR"))
                {
                    data               = data.Replace("OK\r\n", "");
                    result.HasError    = true;
                    result.ErrorDetail = data;
                    GenerateError(data);
                    LogEvent("Scanner error: " + data);
                    return(result);
                }

                LogEvent("Scan command acknowledged.  Acquiring ...");
                data = conn.ReadWaitForStrings("", new List <string>()
                {
                    "OK", "ERR"
                }, 5000);
                if (data.Contains("ERR"))
                {
                    data               = data.Replace("OK\r\n", "");
                    result.HasError    = true;
                    result.ErrorDetail = data;
                    GenerateError(data);
                    LogEvent("Scanner error: " + data);
                    return(result);
                }
                LogEvent("Processing scan data " + tries.ToString());
                RackScanResult result2 = GetRackScanResultFromData(data);
                result = MergeRackScanResults(result, result2);
            }
            conn.WriteLine("CLOSE");
            conn.Close();
            RaiseRackScannedEvent(result);
            return(result);
        }
Beispiel #10
0
        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);
        }