Exemple #1
0
        /// <summary>
        /// 获取与当前机器连接的天平秤的串口对象。
        /// </summary>
        /// <returns>串口对象</returns>
        private static SerialPort GetSerialPort()
        {
            //W_PORT_NAME  天平秤端口号
            //W_BAUD_RATE  天平秤串行波特率
            SerialPort     obj           = new SerialPort();
            ComputerEntity entity        = new ComputerEntity();
            DataTable      dtComputerUDA = entity.GetComputerInfo();
            string         portName      = entity.GetComputerUDAAttributeValue(dtComputerUDA, "W_PORT_NAME");
            string         baudRate      = entity.GetComputerUDAAttributeValue(dtComputerUDA, "W_BAUD_RATE");
            int            nBaudRate;

            obj.BaudRate = int.TryParse(baudRate, out nBaudRate) ? nBaudRate : 1200;
            obj.PortName = string.IsNullOrEmpty(portName) ? "COM1" : portName;
            obj.StopBits = System.IO.Ports.StopBits.One;
            obj.Parity   = System.IO.Ports.Parity.None;
            obj.DataBits = 8;
            return(obj);
        }
Exemple #2
0
        /// <summary>
        /// 获取方阻的配置数据。
        /// </summary>
        /// <returns></returns>
        public static DataFileReadConfig GetResistanceConfig(DateTime startTime)
        {
            //1 R_STARTROW	    方租数据在文件中的起始行
            //2	R_FILEPATH	    方租读取的文件存放路径
            //3	R_DATACOLUMN	方租数据行中列号
            //4 R_SearchPattern 方租文件扩展名
            //5	R_IdentityName	方租数据在行中标识符
            //6 R_Separator     方租数据在行中分隔符
            //7 R_Direction     方租数据的搜索方向
            ComputerEntity entity        = new ComputerEntity();
            DataTable      dtComputerUDA = entity.GetComputerInfo();
            string         startRow      = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_STARTROW");
            string         filePath      = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_FILEPATH");
            string         dataColumn    = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_DATACOLUMN");
            string         identifyName  = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_IdentityName");
            string         pattern       = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_SearchPattern");
            string         separator     = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_Separator");
            string         direction     = entity.GetComputerUDAAttributeValue(dtComputerUDA, "R_Direction");
            string         fileName      = string.Empty;

            pattern = pattern == string.Empty ? "*.*" : pattern;
            if (!string.IsNullOrEmpty(filePath) && System.IO.Directory.Exists(filePath))
            {
                fileName = GetFileNameByLastTime(filePath, pattern, startTime);
            }
            DataFileReadConfig config = new DataFileReadConfig();

            config.Column        = string.IsNullOrEmpty(dataColumn) ? 9 : Convert.ToInt32(dataColumn);
            config.StartRow      = string.IsNullOrEmpty(startRow) ? 0 : Convert.ToInt32(startRow);
            config.FileName      = fileName;
            config.IdentityName  = string.IsNullOrEmpty(identifyName) ? "POINT" : identifyName;
            config.Separator     = string.IsNullOrEmpty(separator) ? ',' : separator.ToCharArray()[0];
            config.SearchPattern = pattern;
            config.Direction     = string.IsNullOrEmpty(direction) ? "F" : direction;
            if (System.IO.File.Exists(fileName))
            {
                config.FileLastWriteTime = System.IO.File.GetLastWriteTime(fileName);
            }
            return(config);
        }
Exemple #3
0
        /// <summary>
        /// 获取折射率的配置数据。
        /// </summary>
        /// <returns></returns>
        public static DataFileReadConfig GetRefractionConfig()
        {
            //1 A_STARTROW	    折射率数据在文件中的起始行
            //2	A_FILEPATH	    折射率读取的文件存放路径
            //3	A_DATACOLUMN	折射率数据行中列号
            //4 A_SearchPattern 折射率文件扩展名
            //5	A_IdentityName	折射率数据在行中标识符
            //6 A_Separator     折射率数据在行中分隔符
            //7 A_Direction     折射率数据的搜索方向
            ComputerEntity entity        = new ComputerEntity();
            DataTable      dtComputerUDA = entity.GetComputerInfo();
            string         startRow      = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_STARTROW");
            string         filePath      = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_FILEPATH");
            string         dataColumn    = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_DATACOLUMN");
            string         identifyName  = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_IdentityName");
            string         pattern       = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_SearchPattern");
            string         separator     = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_Separator");
            string         direction     = entity.GetComputerUDAAttributeValue(dtComputerUDA, "A_Direction");
            string         fileName      = string.Empty;

            pattern = pattern == string.Empty ? "*.*" : pattern;
            if (!string.IsNullOrEmpty(filePath) && System.IO.Directory.Exists(filePath))
            {
                fileName = GetFileNameByLastTime(filePath, pattern);
            }
            DataFileReadConfig config = new DataFileReadConfig();

            config.Column        = string.IsNullOrEmpty(dataColumn) ? 2 : Convert.ToInt32(dataColumn);
            config.StartRow      = string.IsNullOrEmpty(startRow) ? 0 : Convert.ToInt32(startRow);
            config.FileName      = fileName;
            config.IdentityName  = string.IsNullOrEmpty(identifyName) ? "n:" : identifyName;
            config.Separator     = string.IsNullOrEmpty(separator) ? ' ' : separator.ToCharArray()[0];
            config.SearchPattern = pattern;
            config.Direction     = string.IsNullOrEmpty(direction) ? "F" : direction;
            return(config);
        }