/*
         * public void SerialCloseDisposeCollect()
         * {
         *  if (_SerialInstance != null)
         *  {
         *      _SerialInstance.ClosePort();
         *      _SerialInstance = null;
         *  }
         *  GC.Collect();
         * }
         */


        public void Dispose()
        {
            if (_SerialInstance != null)
            {
                _SerialInstance.Dispose();
                _SerialInstance = null;
            }

            if (timerClock != null)
            {
                timerClock = null;
            }

            if (_BaudRate != null)
            {
                _BaudRate = null;
            }

            if (_COMport != null)
            {
                _COMport = null;
            }
        }
        public void SEND_TEMPSENSOR_COMMAND(string Data)
        {
            _SerialInstance          = new SerialPortClass();
            _SerialInstance.Baudrate = _BaudRate;
            _SerialInstance.PortName = _COMport;

            try
            {
                if (_SerialInstance.OpenPortWithRetry())
                {
                    _SerialInstance.SerialDataReceived += new SerialPortClass.ReceivedSerialEventHandler(_SerialInstance_SerialDataReceived);

                    byte[] bytearr = Encoding.UTF8.GetBytes(Data);
                    _SerialInstance.WriteData(bytearr);

                    InitializeTimer();
                }
            }
            catch (Exception Ex)
            {
                System.Diagnostics.Debug.WriteLine(Ex);
                throw;
            }
        }
        public void SEND_TEMPSENSOR_COMMAND(string Data)
        {
            _SerialInstance = new SerialPortClass();
            _SerialInstance.Baudrate = _BaudRate;
            _SerialInstance.PortName = _COMport;

            try
            {
                if (_SerialInstance.OpenPortWithRetry())
                {
                    _SerialInstance.SerialDataReceived += new SerialPortClass.ReceivedSerialEventHandler(_SerialInstance_SerialDataReceived);

                    byte[] bytearr = Encoding.UTF8.GetBytes(Data);
                    _SerialInstance.WriteData(bytearr);

                    InitializeTimer();
                }
            }
            catch (Exception Ex)
            {
                System.Diagnostics.Debug.WriteLine(Ex);
                throw;
            }
        }
        /*
        public void SerialCloseDisposeCollect()
        {
            if (_SerialInstance != null)
            {
                _SerialInstance.ClosePort();
                _SerialInstance = null;
            }
            GC.Collect();
        }
         */
        public void Dispose()
        {
            if (_SerialInstance != null)
            {
                _SerialInstance.Dispose();
                _SerialInstance = null;
            }

            if (timerClock != null)
            {
                timerClock = null;
            }

            if (_BaudRate != null)
            {
                _BaudRate = null;
            }

            if (_COMport != null)
            {
                _COMport = null;
            }
        }