Example #1
0
        /// <summary>
        /// Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public override void ProcessRawData()
        {
            try
            {
                var allbyte = ByteData;
                _tempbuffer = string.Concat(_tempbuffer, Encoding.ASCII.GetString(allbyte));

                foreach (var onebyte in allbyte)
                {
                    if (onebyte.Equals((byte)DeviceHelper.ENQ))
                    {
                        Log.Debug(@"CobasE6000: <ENQ>");
                        _objAstm.CallGetENQ(_objDataEventArgs);
                        DumpStateMachine(_objWorkFlowRuntime, _instanceId);
                        //SendByte((byte)DeviceHelper.ACK);
                        //RaiseEventSendENQToWF(null, onebyte);
                        _bufferData = _tempbuffer = string.Empty;
                    }
                    else if (onebyte.Equals((byte)DeviceHelper.LF))
                    {
                        Log.Debug("CobasE6000: {0}", _tempbuffer);
                        var temp = DeviceHelper.GetStringAfterCheckSum(_tempbuffer);
                        _tempbuffer = string.Empty;
                        if (temp != string.Empty)
                        {
                            //SendStringData(DeviceHelper.ACK.ToString());
                            _objAstm.CallGetRightFrame(_objDataEventArgs);
                            _bufferData = string.Concat(_bufferData, temp);
                        }

                        else
                        {
                            //SendByte((byte)DeviceHelper.NAK);
                            _objAstm.CallGetWrongFrame(_objDataEventArgs);
                        }
                    }
                    else if (onebyte.Equals((byte)DeviceHelper.EOT))
                    {
                        Log.Debug(@"CobasE6000: <EOT>");
                        _objAstm.CallGetEOT(_objDataEventArgs);
                        ProcessData();
                        //Send((int)EventID.GetEOT,_newQuery);
                    }
                    else if (onebyte.Equals((byte)DeviceHelper.ACK))
                    {
                        //Send((int) EventID.GetACK);
                        Log.Debug(@"CobasE6000: <ACK>");
                        _objAstm.CallGetACK(_objDataEventArgs);
                        if ((_currentOrder != null) && (_currentOrder.Count != 0) &&
                            (_currentOrderIdx < _currentOrder.Count))
                        {
                            _prvLastStringRequest = _currentOrder[_currentOrderIdx];
                            _currentOrderIdx++;
                            SendStringData(_prvLastStringRequest);
                            Log.Debug("Host: {0}", _prvLastStringRequest);
                        }
                        else
                        {
                            //SendByte((byte)DeviceHelper.EOT);
                            Log.Debug(@"Session closing ...");
                            _objAstm.CallCloseSession(_objDataEventArgs);
                            if (_prvRequestArray != null && _prvRequestArray.Count != 0)
                            {
                                _objAstm.CallGetQuery(_objDataEventArgs);
                            }
                        }
                    }
                    else if (onebyte.Equals((byte)DeviceHelper.NAK))
                    {
                        Log.Debug(@"CobasE6000: <NAK>");
                        _objAstm.CallGetNAK(_objDataEventArgs);
                        SendStringData(_prvLastStringRequest);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.FatalException("Fatal Error: ", ex);
            }
            finally
            {
                ClearData();
            }
        }
Example #2
0
        /// <summary>
        ///     Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public void ProcessData()
        {
            try
            {
                var arrRecords  = new string[] {};
                var listRecords = new ArrayList();
                var listFields  = new ArrayList();

                if (BufferData != string.Empty)
                {
                    arrRecords = BufferData.Split(new[] { _clsRRecord.RecordDelimiter },
                                                  StringSplitOptions.RemoveEmptyEntries);
                }

                int i = 0;
                while (i < arrRecords.Length)
                {
                    string[] arrFields = arrRecords[i].Split(_clsPRecord.FieldDelimiter);

                    if (arrFields[0].Equals("H"))
                    {
                        while (!arrFields[0].Equals("L"))
                        {
                            if (++i > arrRecords.Length - 1)
                            {
                                break;
                            }
                            arrFields = arrRecords[i].Split(_clsPRecord.FieldDelimiter);
                            listFields.Add(arrFields);
                        }
                        listRecords.Add(listFields);
                    }

                    foreach (ArrayList l in listRecords)
                    {
                        foreach (string[] fields in l)
                        {
                            if (fields[0].StartsWith(_clsPRecord.RecordType))
                            {
                                _clsPRecord = new CentaurPatientRecord(fields);
                            }
                            else if (fields[0].StartsWith(_clsORecord.RecordType))
                            {
                                _clsORecord        = new CentaurOrderRecord(fields);
                                TestResult.Barcode = _clsORecord.Barcode;
                            }
                            else if (fields[0].StartsWith(_clsRRecord.RecordType))
                            {
                                _clsRRecord = new CentaurResultRecord(fields);

                                if (!string.IsNullOrEmpty(_clsRRecord.DataValue.PubFieldData))
                                {
                                    AddResult(new ResultItem(_clsRRecord.TestId,
                                                             _clsRRecord.DataValue.PubFieldData));
                                    TestResult.TestDate = _clsRRecord.TestDate;
                                    _newResult          = true;
                                    break;
                                }
                            }
                            else if (fields[0].StartsWith(_clsQRecord.RecordType))
                            {
                                _clsQRecord = new CentaurQueryRecord(fields);
                                _sQBarcode  = _clsQRecord.QueryBarcode;
                                _newQuery   = true;
                                List <string> regList = GetRegList(_clsQRecord.QueryBarcode);
                                PrvRequestArray.Enqueue(CreateOrderFrame(regList));
                            }
                        }
                    }
                    ++i;
                }
                if (_newResult)
                {
                    ImportResults();
                    _newResult = false;
                }
                if (_newQuery)
                {
                    //Send((int)EventID.OpenNewOutputSession, _sQBarcode);

                    objASTM.CallGetQuery(objDataEventArgs);
                    _timeoutManager.Start();
                    _timeoutManager.Stop();
                    _lastState = 0;
                    //SendByte((byte)DeviceHelper.ENQ);
                    _newQuery = false;
                }
            }
            catch (Exception ex)
            {
                Log.FatalException("Fatal Error: ", ex);
            }
        }
Example #3
0
        /// <summary>
        ///     Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        private void ProcessData()
        {
            try
            {
                var arrRecords = new string[] {};

                if (BufferData != string.Empty)
                {
                    arrRecords = BufferData.Split(new[] { _clsRRecord.RecordDelimiter },
                                                  StringSplitOptions.RemoveEmptyEntries);
                }

                int i = 0;
                while (i < arrRecords.Length)
                {
                    if (arrRecords[i].StartsWith("R"))
                    {
                        Log.Trace(arrRecords[i]);
                        _clsRRecord         = new ADVIA1650ResultRecord(arrRecords[i]);
                        TestResult.TestDate = string.Concat(_clsRRecord.DateTestCompleted.Substring(6, 2), "/",
                                                            _clsRRecord.DateTestCompleted.Substring(4, 2), "/",
                                                            _clsRRecord.DateTestCompleted.Substring(0, 4));
                        TestResult.Barcode = _clsRRecord.Barcode;
                        foreach (DictionaryEntry entry in _clsRRecord.htResult)
                        {
                            AddResult(new ResultItem(entry.Key.ToString(), entry.Value.ToString()));
                        }
                        Log.Debug(ImportResults() ? "Import Result Success" : "Import Result Error");
                    }
                    if (arrRecords[i].StartsWith("q") || arrRecords[i].StartsWith("Q"))
                    {
                        Log.Trace(arrRecords[i]);
                        _clsQRecord = new ADVIA1650QueryRecord(arrRecords[i]);
                        _clsORecord = new ADVIA1650OrderRecord();
                        Log.Debug("Request for barcode: {0}", _clsQRecord.QueryBarcode);

                        for (int index = 0; index < _clsQRecord.QueryBarcode.Count; index++)
                        {
                            string        barcode = _clsQRecord.QueryBarcode[index];
                            List <string> reglist = GetRegList(barcode);
                            Log.Debug("Reglist for barcode: {0}", string.Join(",", reglist.ToArray()));
                            _newQuery = true;
                            if ((reglist == null) || (reglist.Count == 0))
                            {
                                continue;
                            }
                            string data = _clsORecord.CreateData(index, barcode, reglist);
                            PrvRequestArray.Add(data);
                            Log.Trace(data);
                        }
                    }
                    ++i;
                }

                if (_newQuery)
                {
                    objASTM.CallGetQuery(objDataEventArgs);

                    _newQuery = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error While Process Data: {0}", ex));
            }
        }