コード例 #1
0
 public void Save()
 {
     Basic.SetRegistryKey("UseScale", UseScale.ToString());
     Basic.SetRegistryKey("Commend", Commend.ToString());
     Basic.SetRegistryKey("PortName", PortName.ToString());
     Basic.SetRegistryKey("BaudRate", BaudRate.ToString());
     Basic.SetRegistryKey("Parity", Parity.ToString());
     Basic.SetRegistryKey("DataBit", DataBit.ToString());
     Basic.SetRegistryKey("StopBit", StopBit.ToString());
     Basic.SetRegistryKey("ScaleType", ScaleType.ToString());
     Basic.SetRegistryKey("DefaultWeight", DefaultWeight.ToString());
     Basic.SetRegistryKey("BarcodeSize", BarcodeSize.ToString());
 }
コード例 #2
0
        /// <summary>
        /// set the amount of the stopbits for the serial communication
        /// </summary>
        /// <param name="stopbits">stopbit which set for the communication</param>
        private void setStopbit(StopBit stopbits)
        {
            try
            {
                if (_sPort.IsOpen)
                {
                    _sPort.Close();
                }

                switch (stopbits)
                {
                case StopBit.One:
                    this._sPort.StopBits = System.IO.Ports.StopBits.One;
                    break;

                case StopBit.OnePointFive:
                    this._sPort.StopBits = System.IO.Ports.StopBits.OnePointFive;
                    break;

                case StopBit.Two:
                    this._sPort.StopBits = System.IO.Ports.StopBits.Two;
                    break;
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                throw new ArgumentOutOfRangeException(e.Message);
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    throw new Exception(e.InnerException.Message);
                }
                else
                {
                    throw new Exception(e.Message);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Constructor for initialisation of this class
 /// </summary>
 /// <param name="portName">Name of the networkPort, where connected the device</param>
 /// <param name="baudRate">baudrate for the device-communicaton</param>
 /// <param name="databits">count of the databits for the device communication</param>
 /// <param name="parity">kind of parity for the device communication</param>
 /// <param name="stopBit">kind of stopbits for the device communication</param>
 public SerialCom(string portName, BaudRate baudRate, int databits, Parities parity, StopBit stopBit)
 {
     initSerial();
     setPortName(portName);
     setBaudRate(baudRate);
     setDatabits(databits);
     setParity(parity);
     setStopbit(stopBit);
 }