Example #1
0
        /// <summary>
        /// 设置测点
        /// </summary>
        /// <param name="ProIdType"></param>
        private void SetMI(string ProIdType)
        {
            List <SelectListItem> listmi = new List <SelectListItem>();
            int deviceTypeCode           = DeviceData.PLANT_CODE;

            if (!string.IsNullOrEmpty(ProIdType))
            {
                string[] strvalue = ProIdType.Split('&');
                deviceTypeCode = int.Parse(strvalue[1].Trim());
            }
            string[]      items  = new string[] { };
            MonitorConfig config = MonitorConfigService.GetInstance().Get(deviceTypeCode);

            if (config != null)
            {
                items = config.items.Split(',');
            }
            Hashtable           has = new Hashtable();
            IList <MonitorType> mts = MonitorType.getMonitorTypesByTypeCode(deviceTypeCode);

            if (mts != null)
            {
                foreach (MonitorType item in mts)
                {
                    foreach (string s in items)
                    {
                        if (s.Equals(item.code.ToString()))
                        {
                            listmi.Add(new SelectListItem()
                            {
                                Text = item.name, Value = item.code.ToString()
                            });
                            break;
                        }
                    }
                }
            }

            ViewData["MonitorItems"] = listmi;
        }
Example #2
0
        /// <summary>
        /// 将实时数据串转换成键值对象
        /// </summary>
        /// <param name="deviceRunData">实时数据对象</param>
        /// <returns>值对列表</returns>
        public IList <IList <KeyValuePair <MonitorType, string> > > convertRunstrToList(bool isOorder, int deviceTypeCode)
        {
            IList <IList <KeyValuePair <MonitorType, string> > > resList   = new List <IList <KeyValuePair <MonitorType, string> > >();
            IList <KeyValuePair <MonitorType, string> >          resGroup1 = new List <KeyValuePair <MonitorType, string> >();
            IList <KeyValuePair <MonitorType, string> >          resGroup2 = new List <KeyValuePair <MonitorType, string> >();
            IList <KeyValuePair <MonitorType, string> >          resGroup3 = new List <KeyValuePair <MonitorType, string> >();
            IList <KeyValuePair <MonitorType, string> >          resGroup4 = new List <KeyValuePair <MonitorType, string> >();
            IList <KeyValuePair <MonitorType, string> >          resGroup5 = new List <KeyValuePair <MonitorType, string> >();
            //先取得逆变器的输出类型

            string rundatastr = this.rundatastr;

            string[] rundatas = rundatastr.Split('#');

            //先取得传感器接入路数,以决定显示多少路汇流箱路数
            int displayHxlroute = 0;

            if (deviceTypeCode == DeviceData.HUILIUXIANG_CODE)
            {
                displayHxlroute = getHlxroute(rundatas);
            }

            //如果是逆变器那么先取额定功率
            float       outtype = 0;
            IList <int> notdisplayInverterbyPower   = new List <int>();
            IList <int> notdisplayInverterbyoutType = new List <int>();

            if (deviceTypeCode == DeviceData.INVERTER_CODE)
            {
                outtype = this.getMonitorValue(MonitorType.MIC_INVERTER_OUTTYPE);
                notdisplayInverterbyoutType = getnotDisplayMonitor(outtype);
                float power = this.getMonitorValue(MonitorType.MIC_INVERTER_POWER);
                notdisplayInverterbyPower = getnotDisplayMonitorByPower(power);
            }

            string[] datas = null;
            foreach (string data in rundatas)
            {
                datas = data.Split(':');
                int         monitorCode = int.Parse(datas[0]);
                MonitorType omt         = MonitorType.getMonitorTypeByCode(monitorCode);
                if (omt == null)
                {
                    continue;
                }

                //如果该测点不属于此设备则也不显示,add by qhb in 20120913
                if (!MonitorType.getMonitorTypesByTypeCode(deviceTypeCode).Contains(omt))
                {
                    continue;
                }

                //重新构造一个实例,以便用tempaffix多语言显示后缀是线程安全
                string  tempaffix = omt.tempaffix;
                string  unit      = omt.unit;
                Boolean isUP      = false;//是否进制千位
                //如果是逆变器要判断abc三项电压和电流的输出类型,将输出类型作为有后缀测点的后缀
                if (deviceTypeCode == DeviceData.INVERTER_CODE)
                {
                    if (affixMonitors.Contains(monitorCode) && !float.IsNaN(outtype) && (outtype == 0 || outtype == 2))
                    {
                        tempaffix = outtype.ToString();
                    }
                    //add by qhb in 20120921 for 2)逆变器带功率的单位显示kW,不要显示W  (注意大小写)
                    if (omt.code == MonitorType.MIC_INVERTER_TOTALDPOWER || omt.code == MonitorType.MIC_INVERTER_ADIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_BDIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_CDIRECTPOWER || omt.code == MonitorType.MIC_INVERTER_TOTALYGPOWER)
                    {
                        unit = "kW";
                        isUP = true;
                    }
                    if (omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        unit = "kvar";
                        isUP = true;
                    }
                }

                MonitorType mt = new MonitorType(omt.code, unit, omt.zerotoline, tempaffix);

                //排除不显示的测点
                if (notDisplayMonitor.Contains(mt.code) || notdisplayInverterbyoutType.Contains(mt.code) || notdisplayInverterbyPower.Contains(mt.code))
                {
                    continue;
                }

                //如果是汇流箱非显示路数则跳过
                if (deviceTypeCode == DeviceData.HUILIUXIANG_CODE)
                {
                    if (displayHxlroute > 0 && monitorCode > displayHxlroute && monitorCode <= MonitorType.MIC_BUSBAR_16CURRENT)
                    {
                        continue;
                    }
                }

                string value = datas[1];
                //如果值为-表示该值无效,不显示该测点,“-”,数据解析器会把发送的无效值固定设为“-”
                if ("-".Equals(value))
                {
                    continue;
                }

                value = getStatusValue(monitorCode, value);

                if ("0".Equals(value) && MonitorType.getMonitorTypeByCode(monitorCode).zerotoline)
                {
                    value = "-";
                }

                //add by qhb for 单位进制
                if (isUP)
                {
                    try
                    {
                        value = Math.Round((double.Parse(value) / 1000), 2).ToString();
                    }
                    catch (Exception e)
                    {
                        //do nothing
                    }
                }
                //add by qhb in 20120917 for 1)功率因数为0和无功功率为0屏蔽不显示。
                if (omt.code == MonitorType.MIC_INVERTER_TOTALPOWERFACTOR || omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                {
                    try
                    {
                        if (double.Parse(value) == 0)
                        {
                            continue;
                        }
                    }catch {}
                }

                if (isOorder)
                {
                    if (sortGroup["group1"].Contains(monitorCode))
                    {
                        resGroup1.Add(new KeyValuePair <MonitorType, string>(mt, value));
                    }
                    else if (sortGroup["group2"].Contains(monitorCode))
                    {
                        resGroup2.Add(new KeyValuePair <MonitorType, string>(mt, value));
                    }
                    else if (sortGroup["group3"].Contains(monitorCode))
                    {
                        resGroup3.Add(new KeyValuePair <MonitorType, string>(mt, value));
                    }
                    else if (sortGroup["group4"].Contains(monitorCode))
                    {
                        resGroup4.Add(new KeyValuePair <MonitorType, string>(mt, value));
                    }
                    else
                    {
                        resGroup5.Add(new KeyValuePair <MonitorType, string>(mt, value));
                    }
                }
                else
                {
                    resGroup5.Add(new KeyValuePair <MonitorType, string>(mt, value));
                }
            }
            if (resGroup1.Count > 0)
            {
                resList.Add(resGroup1);
            }
            if (resGroup2.Count > 0)
            {
                resList.Add(resGroup2);
            }
            if (resGroup3.Count > 0)
            {
                resList.Add(resGroup3);
            }
            if (resGroup4.Count > 0)
            {
                resList.Add(resGroup4);
            }
            if (resGroup5.Count > 0)
            {
                resList.Add(resGroup5);
            }
            return(resList);
        }