Exemple #1
0
        // 从相同业务地址点集合取出最大值的那个点,如果为字符串点返回第一点
        private void GetSamePointMaxValue(PointValueBase[] points, out string sColnumAndVal, out string sValHis)
        {
            sColnumAndVal = "";
            sValHis       = "";
            if (points == null || points.Length == 0)
            {
                return;
            }
            if (points.Length == 1)
            {
                GetPointColAndValueStr(points[0], out sColnumAndVal, out sValHis);
                return;
            }
            double         valueCache = 0;
            PointValueBase pointCache = points[0];// 防止第一个就是最大值

            foreach (PointValueBase point in points)
            {
                if (point.dbSAddress == "TEMPTIME")
                {
                    GetPointColAndValueStr(point, out sColnumAndVal, out sValHis);
                    return;
                }
                else
                {
                    // 其余都是数字类型
                    if (valueCache < DataUtil.ToDouble(point.Value))
                    {
                        valueCache = DataUtil.ToDouble(point.Value);
                        pointCache = point;// 最大值的点记下来
                    }
                }
            }
            GetPointColAndValueStr(pointCache, out sColnumAndVal, out sValHis);
        }
Exemple #2
0
        // 根据值拼接merge的部分SQL
        private void GetPointColAndValueStr(PointValueBase point, out string sColnumAndVal, out string sValHis)
        {
            sColnumAndVal = "";                           //,1 'F40001',2 'F40002'
            sValHis       = "";                           //,1,2

            if (point.dbSAddress.ToUpper() == "TEMPTIME") // 转日期型
            {
                if (point.Value != null)
                {
                    sColnumAndVal = string.Format(@",'{0}' {1}", DataUtil.ToDateString(point.Value), point.dbSAddress);
                    sValHis       = string.Format(@",'{0}'", DataUtil.ToDateString(point.Value));
                }
                else
                {
                    sColnumAndVal = string.Format(@",null {0}", point.dbSAddress);
                    sValHis       = string.Format(@",null");
                }
            }
            else if (point.dbSAddress.ToUpper() == "FONLINE") // 转整型
            {
                sColnumAndVal = string.Format(@",{0} {1}", DataUtil.ToInt(point.Value), point.dbSAddress);
            }
            else                                    //转浮点数
            {
                if (point.Value != null)
                {
                    sColnumAndVal = string.Format(@",{0} {1}", DataUtil.ToDouble(point.Value), point.dbSAddress);
                    sValHis       = string.Format(@",{0}", DataUtil.ToDouble(point.Value));
                }
                else
                {
                    sColnumAndVal = string.Format(@",null {0}", point.dbSAddress);
                    sValHis       = string.Format(@",null");
                }
            }
        }