Пример #1
0
        public SENSOR_OBJECT(EBaudRate BaudRate, string COM_port)
        {
            try
            {
                _BaudRate = ReturnStringBaudrate(BaudRate);
                _COMport = COM_port.Replace(" ", "").ToUpper();

                string[] ports = SerialPort.GetPortNames();

                if (!ports.Contains(_COMport))
                    throw new Exception("Com Port Not Available");
            }
            catch (Exception Ex)
            {
                Function_CallError_Received(Ex.Message);
            }
        }
Пример #2
0
        private string ReturnStringBaudrate(EBaudRate Baud)
        {
            switch (Baud)
            {
            case EBaudRate.Baud250000:
            {
                return("250000");
            }

            case EBaudRate.Baud115200:
            {
                return("115200");
            }

            case EBaudRate.Baud57600:
            {
                return("57600");
            }

            case EBaudRate.Baud38400:
            {
                return("38400");
            }

            case EBaudRate.Baud19200:
            {
                return("19200");
            }

            case EBaudRate.Baud9600:
            {
                return("9600");
            }

            case EBaudRate.Baud4800:
            {
                return("4800");
            }

            default:
            {
                throw new Exception("Incorrect Baudrate");
            }
            }
        }
Пример #3
0
        public SENSOR_OBJECT(EBaudRate BaudRate, string COM_port)
        {
            try
            {
                _BaudRate = ReturnStringBaudrate(BaudRate);
                _COMport  = COM_port.Replace(" ", "").ToUpper();

                string[] ports = SerialPort.GetPortNames();


                if (!ports.Contains(_COMport))
                {
                    throw new Exception("Com Port Not Available");
                }
            }
            catch (Exception Ex)
            {
                Function_CallError_Received(Ex.Message);
            }
        }
Пример #4
0
 private string ReturnStringBaudrate(EBaudRate Baud)
 {
     switch (Baud)
     {
         case EBaudRate.Baud250000:
         {
             return "250000";
         }
         case EBaudRate.Baud115200:
         {
             return "115200";
         }
         case EBaudRate.Baud57600:
         {
             return "57600";
         }
         case EBaudRate.Baud38400:
         {
             return "38400";
         }
         case EBaudRate.Baud19200:
         {
             return "19200";
         }
         case EBaudRate.Baud9600:
         {
             return "9600";
         }
         case EBaudRate.Baud4800:
         {
             return "4800";
         }
         default:
         {
             throw new Exception("Incorrect Baudrate");
         }
     }
 }