예제 #1
0
        //
        //根据通道编号获取传感器信息
        public static IDataProcess GetDataProcess(string data, out string dataType)
        {
            try
            {
                string tdno   = common.GetTdno(data);
                Device device = common.GetDeviceByTdno(tdno);
                dataType = device.type;

                IDataProcess dataProcess = null;
                switch (device.type)
                {
                //震弦式
                case "轴力-单弦":
                case "土压":
                case "轴力-三弦":
                case "锚索-三弦":
                case "表面应变":
                case "钢筋":
                case "渗压":
                    dataProcess = new DataProcessZX(); break;

                    //485式
                }
                return(dataProcess);
            }
            catch (Exception ex)
            {
                FileOperation.WriteAppenFile("判断传感器类型失败," + ex.Message);
                throw ex;
            }
        }
예제 #2
0
        /// <summary>
        /// 处理接收到的数据
        /// </summary>
        /// <param name="data"></param>
        /// <param name="port"></param>
        public void ProcessData(string data, string port)
        {
            // string dataType;
            // int xmno;
            //根据端口判断收到的数据类型
            // IDataProcess process = FactoryObject.GetDataProcess(int.Parse(port), out dataType, out xmno);

            //根据通道号判断传感器类型
            //IDataProcess process = FactoryObject.GetDataProcess(data, out dataType);

            IDataProcess process = new DataProcessZX();

            process.AnalysisData(data, port, null);
        }
예제 #3
0
        //根据端口号确定传感器以及数据类型
        public static IDataProcess GetDataProcess(int port, out string dataType, out int xmno)
        {
            try
            {
                IDataProcess      dataProcess       = null;
                DataProcessCommon dataProcessCommon = new DataProcessCommon();

                //根据端口号获取项目编号
                //string xmno = dataProcessCommon.GetXmno(port);
                //根据端口号判断数据类型
                dataType = null;
                xmno     = 0;
                dataProcessCommon.GetDataType(port, out dataType, out xmno);
                Console.WriteLine("收到来自端口{0}的{1}数据", port.ToString(), dataType);

                string info = string.Format("收到来自端口{0}的{1}数据", port.ToString(), dataType);
                FileOperation.WriteAppenFile(info);

                switch (dataType)
                {
                //震弦式
                case "应变":
                case "土压":
                case "锚索":
                case "钢筋":
                case "轴力":
                case "水压":
                    dataProcess = new DataProcessZX(); break;

                    //485式

                    //    dataProcess = new DataProcess485(); break;
                }
                return(dataProcess);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }