/// <summary>
        /// Connect to ITHCA 850 Printer
        /// </summary>
        /// <param name="ErrorMsg"></param>
        /// <returns></returns>
        public bool Connect(ref string ErrorMsg)
        {
            bool retVal = false;

            try
            {
                ////  Read from the Initialization file
                Pinfo = new PrinterStatus();
                if (oPrt.IsOpen)
                {
                    oPrt.ClosePort();
                    //oPrt.Dispose();
                }

                oPrt.PortName     = _PortNO;
                oPrt.BaudRate     = 9600;
                oPrt.DataBits     = 8;
                oPrt.StopBits     = System.IO.Ports.StopBits.One;
                oPrt.WriteTimeout = 500;  /*in Milli Seconds */
                oPrt.ReadTimeout  = 4000; /*in Milli Seconds*/
                oPrt.Handshake    = System.IO.Ports.Handshake.None;

                try
                {
                    _CurrentVersion = BMC.Common.ConfigurationManagement.ConfigManager.Read("ITHACAFRIMWAREVERSION");
                    oPrt.OpenPort();
                    retVal = true;
                }
                catch (Exception ex)
                {
                    Pinfo.StatusInt = -1;
                    Pinfo.Valid     = false;
                    ErrorMsg        = "OpenPort failed to open " + _PortNO + ", make sure no other devices are using this port.";
                    LogManager.WriteLog("ITHACA850 --> Error Occured:" + ErrorMsg, LogManager.enumLogLevel.Info);
                    LogManager.WriteLog("ITHACA850 --> Error Occured:" + ex.Message, LogManager.enumLogLevel.Info);
                }
                if (oPrt.IsOpen)
                {
                    byte[] Data = null;

                    switch (_CurrentVersion)
                    {
                    case "PP8522":
                        Data = new byte[] { 29, 83 };
                        break;

                    case "PP8576":     //New Version
                        Data = new byte[] { 29, 122 };
                        break;

                    default:
                        Data = new byte[] { 29, 122 };
                        break;
                    }

                    LogManager.WriteLog("<1>", LogManager.enumLogLevel.Info);
                    oPrt.Write(Data, 0, Data.Length);
                    LogManager.WriteLog("<2>", LogManager.enumLogLevel.Info);
                    int result = oPrt.ReadByte();

                    //GS S – Return Printer Status [ref pageno:141 in Itchaca 950]
                    if ((Convert.ToByte(result & 0xFF) & (Byte)(1 << 0)) == (Byte)(1 << 0) || (_CurrentVersion == "PP8576" && result == 62)) /*Is printer ready*/
                    {
                        Pinfo.StatusInt    = 0;
                        Pinfo.StatusString = "Printer Ready";
                        Pinfo.Valid        = true;
                        LogManager.WriteLog("ITHACA850 Printer Ready Version No: " + _CurrentVersion, LogManager.enumLogLevel.Info);
                    }
                    else
                    {
                        if ((Convert.ToByte(result & 0xFF) & (Byte)(1 << 5)) == (Byte)(1 << 5))
                        {
                            /*Out of ticket*/
                            Pinfo.StatusInt    = -1;
                            Pinfo.StatusString = "Out Of Paper";
                            Pinfo.Valid        = false;
                            LogManager.WriteLog("ITHACA850 Version No:" + _CurrentVersion + " --> Out Of Paper", LogManager.enumLogLevel.Info);
                        }
                        if (oPrt.IsOpen)
                        {
                            oPrt.ClosePort();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMsg = "Unable to Connect";
                LogManager.WriteLog("<3>", LogManager.enumLogLevel.Info);
                LogManager.WriteLog("ITHACA850 --> Error Occured:" + ex.Message, LogManager.enumLogLevel.Info);
                Pinfo.StatusInt = -1;
                Pinfo.Valid     = false;
                if (oPrt.IsOpen)
                {
                    oPrt.ClosePort();
                }
            }
            return(retVal);
        }
        /// <summary>
        /// Connect to ITHCA 850 Printer
        /// </summary>
        /// <param name="ErrorMsg"></param>
        /// <returns></returns>
        public bool Connect(ref string ErrorMsg)
        {
            bool retVal = false;
            try
            {
                ////  Read from the Initialization file
                Pinfo = new PrinterStatus();
                if (oPrt.IsOpen)
                {
                    oPrt.ClosePort();
                    //oPrt.Dispose();
                }

                oPrt.PortName = _PortNO;
                oPrt.BaudRate = 9600;
                oPrt.DataBits = 8;
                oPrt.StopBits = System.IO.Ports.StopBits.One;
                oPrt.WriteTimeout = 500;  /*in Milli Seconds */
                oPrt.ReadTimeout = 4000;  /*in Milli Seconds*/
                oPrt.Handshake = System.IO.Ports.Handshake.None;

                try
                {
                    _CurrentVersion = BMC.Common.ConfigurationManagement.ConfigManager.Read("ITHACAFRIMWAREVERSION");
                    oPrt.OpenPort();
                    retVal = true;

                }
                catch (Exception ex)
                {
                    Pinfo.StatusInt = -1;
                    Pinfo.Valid = false;
                    ErrorMsg = "OpenPort failed to open " + _PortNO + ", make sure no other devices are using this port.";
                    LogManager.WriteLog("ITHACA850 --> Error Occured:" + ErrorMsg, LogManager.enumLogLevel.Info);
                    LogManager.WriteLog("ITHACA850 --> Error Occured:" + ex.Message, LogManager.enumLogLevel.Info);
                }
                if (oPrt.IsOpen)
                {
                    byte[] Data = null;

                    switch (_CurrentVersion)
                    {
                        case "PP8522":
                            Data = new byte[] { 29, 83 };
                            break;
                        case "PP8576": //New Version
                            Data = new byte[] { 29, 122 };
                            break;
                        default:
                            Data = new byte[] { 29, 122 };
                            break;

                    }

                    LogManager.WriteLog("<1>", LogManager.enumLogLevel.Info);
                    oPrt.Write(Data, 0, Data.Length);
                    LogManager.WriteLog("<2>", LogManager.enumLogLevel.Info);
                    int result = oPrt.ReadByte();
                   
                    //GS S – Return Printer Status [ref pageno:141 in Itchaca 950]
                    if ((Convert.ToByte(result & 0xFF) & (Byte)(1 << 0)) == (Byte)(1 << 0) || (_CurrentVersion == "PP8576" && result == 62)) /*Is printer ready*/
                    {

                        Pinfo.StatusInt = 0;
                        Pinfo.StatusString = "Printer Ready";
                        Pinfo.Valid = true;
                        LogManager.WriteLog("ITHACA850 Printer Ready Version No: " + _CurrentVersion, LogManager.enumLogLevel.Info);
                    }
                    else
                    {
                        
                         if ((Convert.ToByte(result & 0xFF) & (Byte)(1 << 5)) == (Byte)(1 << 5))
                        {
                            /*Out of ticket*/
                            Pinfo.StatusInt = -1;
                            Pinfo.StatusString = "Out Of Paper";
                            Pinfo.Valid = false;
                            LogManager.WriteLog("ITHACA850 Version No:" + _CurrentVersion + " --> Out Of Paper", LogManager.enumLogLevel.Info);
                        }
                        if (oPrt.IsOpen)
                        {
                            oPrt.ClosePort();
                        }
                    }
                }


            }
            catch (Exception ex)
            {
                ErrorMsg = "Unable to Connect";
                LogManager.WriteLog("<3>", LogManager.enumLogLevel.Info);
                LogManager.WriteLog("ITHACA850 --> Error Occured:" + ex.Message, LogManager.enumLogLevel.Info);
                Pinfo.StatusInt = -1;
                Pinfo.Valid = false;
                if (oPrt.IsOpen)
                {
                    oPrt.ClosePort();
                }

            }
            return retVal;
        }