/// <summary>
        /// 设备单个测点的日图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="chartName"></param>
        /// <param name="startYYYYMMDDHH"></param>
        /// <param name="endYYYYMMDDHH"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <param name="monitorCode"></param>
        /// <returns></returns>
        public ChartData DayChart(Device device, string chartName, string startYYYYMMDDHH, string endYYYYMMDDHH, string chartType, string unit, int monitorCode, int intervalMins)
        {
            //将整天的数据截断头尾
            string[] ic = base.getXseriesFromYYYYMMDDHH(startYYYYMMDDHH, endYYYYMMDDHH, intervalMins).ToArray();

            ///结果需要按时间先后排序
            Hashtable powerHash = DeviceDayDataService.GetInstance().GetDaydataList(ic, device, startYYYYMMDDHH, endYYYYMMDDHH, intervalMins, monitorCode);

            string[] xAxis = formatXaxis(ic, this.fromApp ? ChartTimeType.Hour : ChartTimeType.Day);
            MonitorType monitorType = MonitorType.getMonitorTypeByCode(monitorCode);

            KeyValuePair<string, float?[]> data = new KeyValuePair<string, float?[]>();
            if (powerHash.Count > 0)
            {
                //先屏蔽了,因为两天跨度的中间部分平滑有问题,但不是对原来是否有影响测试后才知道
                //this.FirstHandleChartData(ic, powerHash);
                data = GenerateChartData(monitorType.name, ic, powerHash, 1.0F);
            }

            return ReportBuilder.createJsonChartXY(chartName, xAxis, data, "", unit, chartType, fromApp);
        }
 public ActionResult Ammeteredit(string id)
 {
     string didStr = Request.QueryString.ToString();
     int pid;
     int did;
     int.TryParse(id, out pid);
     int.TryParse(didStr, out did);
     Plant plant = FindPlant(pid);
     ViewData["device"] = new Device();
     foreach (PlantUnit unit in plant.allFactUnits)
     {
         foreach (Device device in unit.devices)
         {
             if (device.id.Equals(did))
             {
                 ViewData["device"] = device;
                 break;
             }
         }
     }
     return View(plant);
 }
 public Hashtable GetDaydataList(Device device, string startYYYYMMDDHH, string endYYYYMMDDHH, int intervalMins, int monitorCode)
 {
     return this.GetDaydataList(null, device, startYYYYMMDDHH, endYYYYMMDDHH, intervalMins, monitorCode);
 }
        /// <summary>
        /// 作者:鄢睿
        /// 功能:取得设备多个年度的年月发电量比较数据
        /// 创建时间:2011年02月25日
        /// </summary>
        /// <param name="device"></param>
        /// <param name="years"></param>
        /// <param name="mt"></param>
        /// <param name="unit"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public ChartData DeviceYearCompare(Device device, IList<int> years, string name, MonitorType mt, string unit, string chartType, float rate)
        {
            ICollection<ICollection> keys = new List<ICollection>();
            StringBuilder sb = new StringBuilder();
               // //foreach (int year in years)
            //{
              //  sb.Append("," + year);
               // }

            string chartName = name + " " + LanguageUtil.getDesc("CHART_TITLE_COMPARE");
            IList<KeyValuePair<string, float?[]>> datas = new List<KeyValuePair<string, float?[]>>();

            string[] chartTypes = new string[1] { chartType };
            IList<string> units = new List<string>();
            IList<string> ynames = new List<string>();
            string[] ic = null;

            bool hasData = false;
            //取得多个年度的发电月数据
            int i = 0;
            foreach (int year in years)
            {
                units.Add(unit);
                ynames.Add("");
                Hashtable dataHash = null;
                string curName = year.ToString();
                dataHash = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, year, year);
                ic = base.getMMX(year.ToString());
                //如果有多个设备进行编辑,没有数据的时候也显示
                //if (dataHash.Count > 0)
                //{
                    //add by qhb in 20120928 for 补偿发电量
                    base.addDeviceMonthEnergy(dataHash, device.id,year.ToString(),year.ToString());
                    KeyValuePair<string, float?[]> data = GenerateChartData(year.ToString(), ic, dataHash, rate);
                    datas.Add(data);
                //}
                //如果有数据则将有数据标识为true
                if (dataHash.Count > 0)
                {
                    hasData = true;
                }
                i++;
            }
            if (!hasData)
            {//如果所有设备都没数据才清空数据,即图表中显示无数据提示
                datas.Clear();
            }
            ic = base.getMMX("");
            string[] xAxis = formatXaxis(ic, ChartTimeType.Month);
            return ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes, units.ToArray(), fromApp);
        }
Exemple #5
0
        /// <summary>
        /// 发送单个设备
        /// </summary>
        /// <param name="device"></param>
        private void handleDevice(Device device, PlantUnit pu, String plantName)
        {
            if (pu == null) return;
            //实时数据串“,”逗号分隔
            string realDataValueStr = "";
            if (device.runData != null)
            {//组织数据串
                switch (device.deviceTypeCode)
                {
                    case DeviceData.INVERTER_CODE:
                        realDataValueStr = getInverterRunDataStr(device, pu.collector);
                        break;
                    case DeviceData.HUILIUXIANG_CODE:
                        realDataValueStr = getHlxRunDataStr(device);
                        break;
                    case DeviceData.AMMETER_CODE:
                        realDataValueStr = getAmmeterRunDataStr(device);
                        break;
                    case DeviceData.ENVRIOMENTMONITOR_CODE:
                        realDataValueStr = getDetectorRunDataStr(device);
                        break;
                    default:
                        break;
                }
            }
            string DataCollectTime = device.runData == null ? "" : device.runData.updateTime.ToString("yyyy-MM-dd HH:mm:ss");
            try
            {
                callwebservice(server_url, plantName, pu.displayname, device.deviceAddress, device.deviceTypeCode, DataCollectTime, realDataValueStr);
            }
            catch (Exception e)
            {
                FileLogUtil.info("-----设备" + pu.displayname + "-" + device.deviceTypeCode + "-" + StringUtil.getstr(device.deviceAddress, 3) + "上传失败" + e.Message + "-------------");
                Console.WriteLine("-----设备" + pu.displayname + "-" + device.deviceTypeCode + "-" + StringUtil.getstr(device.deviceAddress, 3) + "上传失败" + e.Message + "-------------");

            }
        }
Exemple #6
0
        /// <summary>
        /// 获取设备
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        private string getHlxRunDataStr(Device device)
        {
            //StringBuilder sb = new StringBuilder();
            ////1	設備状态	 	 	0:待机(waiting)1:正常(normal)3:故障(fault)
            //sb.Append(device.getStatusDefinedValue()).Append(",");
            ////2	光伏直流通道 1 	A	0.1A		7.31
            //sb.Append("7.31").Append(",");
            ////3	光伏直流通道 2 	A	0.1A		7.31
            //sb.Append("7.31").Append(",");
            ////4	光伏直流通道 3 	A	0.1A		7.16
            //sb.Append("7.16").Append(",");
            ////5	光伏直流通道 4 	A	0.1A		7.27
            //sb.Append("7.27").Append(",");
            ////6	光伏直流通道 5 	A	0.1A		7.22
            //sb.Append("7.22").Append(",");
            ////7	光伏直流通道 6 	A	0.1A		7.4
            //sb.Append("7.4").Append(",");
            ////8	光伏直流通道 7 	A	0.1A		7.4
            //sb.Append("7.4").Append(",");
            ////9	光伏直流通道 8 	A	0.1A		7.38
            //sb.Append("7.38").Append(",");
            ////10光伏直流通道 9 	A	0.1A		7.45
            //sb.Append("7.45").Append(",");
            ////11光伏直流通道 10 	A	0.1A		7.47
            //sb.Append("7.47").Append(",");
            ////12光伏直流通道 11 	A	0.1A		7.43
            //sb.Append("7.43").Append(",");
            ////13光伏直流通道 12 	A	0.1A		7.18
            //sb.Append("7.18").Append(",");
            ////14光伏直流通道 13 	A	0.1A		0
            //sb.Append("0").Append(",");
            ////15光伏直流通道 14 	A	0.1A		0
            //sb.Append("0").Append(",");
            ////16光伏直流通道 15 	A	0.1A		0
            //sb.Append("0").Append(",");
            ////17光伏直流通道 16 	A	0.1A		0
            //sb.Append("0").Append(",");
            ////18汇流母线电压 	V	0.1V		0
            //sb.Append("0").Append(",");
            ////19直流母线电压 	V	0.1V		0
            //sb.Append("0").Append(",");
            ////20AIDC 通道 3
            //sb.Append("").Append(",");
            ////21总功率(高前低后) 	W	0.1W		45470
            //sb.Append("45470").Append(",");
            ////22通道 1 功率 	W	0.1W		3774
            //sb.Append("3774").Append(",");
            ////23通道 2 功率 	W	0.1W		3779
            //sb.Append("3779").Append(",");
            ////24通道 3 功率 	W	0.1W		3702
            //sb.Append("3702").Append(",");
            ////25通道 4 功率 	W	0.1W		3755
            //sb.Append("3755").Append(",");
            ////26通道 5 功率 	W	0.1W		3730
            //sb.Append("3730").Append(",");
            ////27通道 6 功率 	W	0.1W		3825
            //sb.Append("3825").Append(",");
            ////28通道 7 功率 	W	0.1W		3823
            //sb.Append("3823").Append(",");
            ////29通道 8 功率 	W	0.1W		3815
            //sb.Append("3815").Append(",");
            ////30通道 9 功率 	W	0.1W		3851
            //sb.Append("3851").Append(",");
            ////31通道 10 功率 	W	0.1W		3858
            //sb.Append("3858").Append(",");
            ////32通道 11 功率 	W	0.1W		3841
            //sb.Append("3841").Append(",");
            ////33通道 12 功率 	W	0.1W		3712
            //sb.Append("3712").Append(",");
            ////34通道 13 功率 	W	0.1W		0
            //sb.Append("0").Append(",");
            ////35通道 14 功率 	W	0.1W		0
            //sb.Append("0").Append(",");
            ////36通道 15 功率 	W	0.1W		0
            //sb.Append("0").Append(",");
            ////37通道 16 功率 	W	0.1W		0
            //sb.Append("0").Append(",");
            ////38故障代碼			"可以by Bit表示(16*4)請提供故障代碼對照表"	EI028
            //sb.Append("16401").Append(",");
            ////39匯流箱溫度	℃	0.1℃		    45.8
            //sb.Append("45.8").Append(",");
            ////40串列轉換效率	%	0.10%		98.8
            //sb.Append("9808").Append(",");
            ////41匯流箱轉換效率	%	0.10%		99.3
            //sb.Append("99.3");

            string[] dataarr = new string[41];
            if (device.runData != null && device.runData.rundatastr != null)
                analyzeArr(device.runData.rundatastr, dataarr, hlx_no_mcodemap);
            dataarr[0] = device.getStatusDefinedValue().ToString();
            //将浮点状态值转成整形
            if (!string.IsNullOrEmpty(dataarr[37]))
                dataarr[37] = int.Parse(dataarr[37]).ToString();
            return buildRunDataStr(dataarr);
        }
Exemple #7
0
 private string getAmmeterRunDataStr(Device device)
 {
     string[] dataarr = new string[18];
     if (device.runData != null && device.runData.rundatastr != null)
         analyzeArr(device.runData.rundatastr, dataarr, ammeter_no_mcodemap);
     dataarr[0] = device.getStatusDefinedValue().ToString();
     //foxconn3.28反馈除分相功率因數和系統功率因數系統讀書較現場設備數據擴大10000倍,其餘數據都OK
     if(string.IsNullOrEmpty(dataarr[6]))
         dataarr[6] = (double.Parse(dataarr[6])/10000).ToString();
     dataarr[16] = "1";
     dataarr[17] = "1";
     //将浮点状态值转成整形
     if (!string.IsNullOrEmpty(dataarr[11]))
         dataarr[11] = int.Parse(dataarr[11]).ToString();
     return buildRunDataStr(dataarr);
     //1	設備状态			"0:待机(waiting)1:正常(normal)3:故障(fault)"		1
     ////2	有功功率	W	0.1W		有功功率	46095
     //sb.Append("46095").Append(",");
     ////3	无功功率	Var	0.1Var		無功功率	6982.5
     //sb.Append("6982.5").Append(",");
     ////4	视在功率	VA	0.1VA		視在功率	46597.5
     //sb.Append("46597.5").Append(",");
     ////5	有功电量	KWH	0.1KWH		有功電量	48366.16
     //sb.Append("48366.16").Append(",");
     ////6	无功电量	KVarh	0.1KVarh		無功電量	1393.7
     //sb.Append("1393.7").Append(",");
     ////7	功率因数				系統功率因素	0.9892
     //sb.Append("0.9892").Append(",");
     ////8	波有功電量	KWH	0.1KWH		波有功電量	1.17
     //sb.Append("1.17").Append(",");
     ////9	峰有功電量	KWH	0.1KWH		峰有功電量	17113.46
     //sb.Append("17113.46").Append(",");
     ////10	谷有功電量	KWH	0.1KWH		谷有功電量	1832.39
     //sb.Append("1832.39").Append(",");
     ////11	平有功電量	KWH	0.1KWH		平有功電量	29418.38
     //sb.Append("29418.38").Append(",");
     ////12	故障代碼			請提供故障代碼對照表	E0030
     //sb.Append("21504").Append(",");
     ////13	壓量程U0				壓量程U0	250
     //sb.Append("250").Append(",");
     ////14	流量程I0				流量程I0	5
     //sb.Append("5").Append(",");
     ////15	壓比UBB				壓比UBB	1
     //sb.Append("1").Append(",");
     ////16	流比IBB				流比IBB	100
     //sb.Append("100").Append(",");
     ////17	CEIL1				CEIL1	0
     //sb.Append("0").Append(",");
     ////18	CEIL2				CEIL2	0
     //sb.Append("0");
 }
Exemple #8
0
        /// <summary>
        /// 将本次消息解析后的临时设备信息,转换成plant的业务对象存入list中已被批量处理程序处理的memcached和db
        /// 电站信息是无需从db或memcached还原的
        /// </summary>
        public void getDeviceInfos()
        {
            if (deviceInfos == null) return;
            //取得当前电站数据对应的采集器id
            int collectorId = this.GetCollectorId();
            int deviceId = 0;
            foreach (DeviceInfo dinfo in this.deviceInfos)
            {
                deviceId = this.GetDeviceId(collectorId, dinfo.address.ToString());
                //新设备地址
                String newAddress = dinfo.address.ToString();
                int newModelCode = dinfo.typemodel;
                String newName = dinfo.name;
                //add by qhb in 20120827 for 发送设备信息也添加设备
                if (deviceId == 0)
                {
                    //构造设备
                    Device device = new Device();
                    device.collectorID = collectorId;
                    device.deviceAddress = newAddress;
                    if (DataType.deviceTypeNoMap.ContainsKey(newModelCode))
                        device.deviceTypeCode = DataType.deviceTypeNoMap[newModelCode];
                    device.name = newName;
                    device.deviceModel = new DeviceModel() { code = newModelCode};
                    device.status = "0";
                    try
                    {
                        PlantUnit pu = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(collectorId);
                        if (pu != null)
                            device.plantUnitId = pu.id;
                    }
                    catch (Exception ee) { }
                    deviceId = DeviceService.GetInstance().Save(device);
                    LogUtil.info("has new device,collectorID is " + collectorId + ",deviceAddress is " + device.deviceAddress);
                    //有新设备要更新bank缓存
                    HttpClientUtil.requestUrl(bank_url);
                }
                else { //判断是否更新设备型号,地址和名称等
                    Device device = DeviceService.GetInstance().get(deviceId);
                    //if (!(device.name!=null && device.name.Equals(newName)) || !device.deviceAddress.Equals(newAddress) || device.deviceModelCode != newModelCode)
                    //{
                        device.deviceAddress = newAddress;
                        if (DataType.deviceTypeNoMap.ContainsKey(newModelCode))
                            device.deviceTypeCode = DataType.deviceTypeNoMap[newModelCode];
                        device.name = newName;
                        device.deviceModel = new DeviceModel() { code = newModelCode };

                        deviceId = DeviceService.GetInstance().Save(device);
                        LogUtil.info("update device,collectorID is " + collectorId + ",deviceAddress is " + device.deviceAddress);
                        //有新设备要更新bank缓存
                        HttpClientUtil.requestUrl(bank_url);
                    //}
                }
                //add end
                dinfo.deviceid = deviceId;
                if (deviceInfoMap.ContainsKey(deviceId))
                {
                    deviceInfoMap[deviceId] = dinfo;
                }
                else
                    deviceInfoMap.Add(deviceId, dinfo);
            }
        }
        /// <summary>
        /// 作者:鄢睿
        /// 功能:通过电站Id获得工作年份
        /// 创建时间:2011-02-25
        /// </summary>
        /// <param name="plantId"></param>
        /// <returns></returns>
        public IList<int> GetWorkYears(Device device)
        {
            IList<int> yearList = new List<int>();

            int minYear = _DeviceYearDataDao.GetStartWorkYear(device.id);
            for (int year = minYear; year <= DateTime.Now.Year; year++)
            {
                yearList.Add(year);
            }
            return yearList;
        }
 /// <summary>
 /// 取得单个设备的跨月度发电量
 /// </summary>
 /// <param name="device"></param>
 /// <param name="startYear"></param>
 /// <param name="endYear"></param>
 /// <returns></returns>
 public Hashtable GetDeviceBetweenYearData(Device device, int startYear, int endYear)
 {
     return this.GetDeviceBetweenYearData(new List<Device>() { device }, startYear, endYear, new List<float>() { 1.0F});
 }
        /// <summary>
        /// 取得某个设备天数据
        /// </summary>
        /// <param name="device"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <param name="startDD"></param>
        /// <param name="endDD"></param>
        /// <param name="startHH"></param>
        /// <param name="endHH"></param>
        /// <param name="intervalMins"></param>
        /// <param name="monitorCode"></param>
        /// <returns></returns>
        private Hashtable getMultiDayBetweenData(IList<string> XAxis, Device device, string year, string month, int startDD, int endDD, int intervalMins, int monitorCode)
        {
            Hashtable hhpowerHash = new Hashtable();
            //取得单个单元功率数据
            string deviceTable = getDeviceTablename(device.deviceTypeCode);

            //取得单个单元功率数据
            //如果查询天和当前时间间隔2天之内,包括2天则从数据库先缓存中查询
            bool isDB = true;
            for (int i = startDD; i <= endDD; i++)
            {
                IList unitPowerDayDatas = new List<BaseDayData>();
                if (DateTime.Now.Day >= i && DateTime.Now.Day - i <= 1)
                {
                    string key = CacheKeyUtil.buildDeviceDayDataKey(device.id, year + month, i, monitorCode);
                    object obj = MemcachedClientSatat.getInstance().Get(key);
                    if (obj != null)
                    {
                        unitPowerDayDatas.Add(obj);
                        isDB = false;
                    }
                }
                if (isDB)
                    unitPowerDayDatas = _DevicePowerDaydataDao.GetDaydataList(device.id, deviceTable, year, month, i, i, monitorCode);

                joinToPointData(XAxis, hhpowerHash, unitPowerDayDatas, intervalMins, monitorCode);
            }
            return hhpowerHash;
        }
 private Hashtable getMultiDayBetweenData(Device device, string year, string month, int startDD, int endDD, int intervalMins, int monitorCode)
 {
     return getMultiDayBetweenData(null, device, year, month, startDD, endDD, intervalMins, monitorCode);
 }
        /// <summary>
        /// 加工处理某天某个设备多测点数据到表格输出方式
        /// </summary>
        /// <param name="device"></param>
        /// <param name="yyyyMMdd"></param>
        /// <returns>//key :时间点 value : 测点和值map (key:测点 value:测点值)</returns>
        public IDictionary<string, IDictionary<string, string>> handleDayData(IList<string> allmts, Device device, string yyyyMMdd)
        {
            //首先取出某个设备的所有测点的天数据
            string year = yyyyMMdd.Substring(0, 4);
            string month = yyyyMMdd.Substring(4, 2);
            int day = int.Parse(yyyyMMdd.Substring(6, 2));

            IList<DeviceDayData> deviceDayDatas = this.getDeviceDayDatas(device, year, month, day, day);
            //保存时间点对应的测点值map
            //key :时间点 value : 测点和值map (key:测点 value:测点值)
            IDictionary<string, IDictionary<string, string>> timemtMap = new Dictionary<string, IDictionary<string, string>>();
            //循环取出所有时间点,并把所有时间点放入map
            string timepoint = "";
            IDictionary<string, string> mtMap = null;
            MonitorType omt = null;
            string mtkey = "";
            foreach (DeviceDayData dayData in deviceDayDatas) {
                if (string.IsNullOrEmpty(dayData.dataContent)) continue;
                //存储所有测点
                omt = MonitorType.getMonitorTypeByCode(dayData.monitorCode);
                //add by qhb at 20120829 for 判断逆变器测点是否符合显示规则,参照设备实时数据那里规则

                //如果是逆变器那么先取额定功率
                float outtype = 0;
                IList<int> notdisplayInverterbyPower = new List<int>();
                IList<int> notdisplayInverterbyoutType = new List<int>();
                if (device.deviceTypeCode == DeviceData.INVERTER_CODE)
                {
                    outtype = device.getMonitorValue(MonitorType.MIC_INVERTER_OUTTYPE);
                    notdisplayInverterbyoutType = DeviceRunData.getnotDisplayMonitor(outtype);
                    float power = device.getMonitorValue(MonitorType.MIC_INVERTER_POWER);
                    notdisplayInverterbyPower = DeviceRunData.getnotDisplayMonitorByPower(power);
                }
                //排除不显示的测点
                if (DeviceRunData.notDisplayMonitor.Contains(omt.code) || notdisplayInverterbyoutType.Contains(omt.code) || notdisplayInverterbyPower.Contains(omt.code)) continue;

                //重新构造一个实例,以便用tempaffix多语言显示后缀是线程安全
                string tempaffix = omt.tempaffix;
                string unit = omt.unit;
                Boolean isUP = false;//是否进制千位

                //如果是逆变器要判断abc三项电压和电流的输出类型,将输出类型作为有后缀测点的后缀
                if (device.deviceTypeCode == DeviceData.INVERTER_CODE)
                {
                    if (DeviceRunData.affixMonitors.Contains(dayData.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 || omt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        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(string.IsNullOrEmpty(mt.unit)){
                    mtkey = mt.name;
                }else{
                    mtkey = mt.name + "(" + mt.unit + ")";
                }

                string[] datas = dayData.dataContent.Split('#');
                string[] timedatas=null;
                bool isAllZero = true;
                bool isAllNovalid = true;
                foreach(string data in datas){
                    if (string.IsNullOrEmpty(data)) continue;
                    timedatas = data.Split(':');
                    timepoint = timedatas[0];
                    timepoint = string.Format("{0}:{1}:{2}", timepoint.Substring(0, 2), timepoint.Substring(2, 2), timepoint.Substring(4));
                    if (timemtMap.ContainsKey(timepoint))
                    {
                        mtMap = timemtMap[timepoint];
                    }
                    else {
                        mtMap = new Dictionary<string, string>();
                        timemtMap.Add(timepoint, mtMap);
                    }

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

                    //add by qhb for 单位进制
                    if (isUP)
                    {
                        try
                        {
                            value = Math.Round((StringUtil.stringtoDouble(value) / 1000), 2).ToString();
                        }
                        catch (Exception e)
                        {
                            //do nothing
                        }
                    }
                    //add by qhb in 20121029 for 1)功率因数为0和无功功率为0屏蔽不显示。
                    if (mt.code == MonitorType.MIC_INVERTER_TOTALPOWERFACTOR || mt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER)
                    {
                        try
                        {
                            if (StringUtil.stringtoDouble(value) == 0)
                                value="";
                            else
                            {
                                isAllZero = false;
                            }
                        }
                        catch { }
                    }
                    if ("0".Equals(value) && omt.zerotoline)
                    {
                        value = "-";
                    }

                    if (mtMap.ContainsKey(mtkey))
                    {
                        mtMap[mtkey] = value;
                    }
                    else {
                        mtMap.Add(mtkey, value);
                    }
                }
                //add by qhb in 20121029 for 1)功率因数为0和无功功率为0屏蔽不显示。
                if (isAllZero && (mt.code == MonitorType.MIC_INVERTER_TOTALPOWERFACTOR || mt.code == MonitorType.MIC_INVERTER_TOTALWGPOWER))
                {
                    continue;
                }
                if (isAllNovalid)
                    continue;
                allmts.Add(mtkey);
            }
            return timemtMap;
        }
 /// <summary>
 /// 取得某个设备跨天的所有测点天数据
 /// add by qhb in 20120915 
 /// </summary>
 /// <param name="device"></param>
 /// <param name="day"></param>
 /// <param name="year"></param>
 /// <param name="month"></param>
 /// <param name="startDD"></param>
 /// <param name="endDD"></param>
 /// <returns></returns>
 public IList<DeviceDayData> getDeviceDayDatas(Device device, string year, string month, int startDD, int endDD)
 {
     string deviceTable = getDeviceTablename(device.deviceTypeCode);
     return _DevicePowerDaydataDao.GetDaydataList(device.id, deviceTable, year, month, startDD, endDD);
 }
        /// <summary>
        /// 取得设备跨小时的测点数据
        /// </summary>
        /// <param name="device">设备</param>
        /// <param name="startYYYYMMDDHH">开始时间 精确到小时 比如:2011062807</param>
        /// <param name="endYYYYMMDDHH">截止时间 精确到小时 比如:2011062817</param>
        /// <param name="intervalMins">数据统计的间隔时间,单位是分钟,比如60表示一小时</param>
        /// <param name="monitorCode">设备测点代码,参见MonitorType.cs</param> 
        /// <returns>hashtable,key表示时间点 value是值</returns>
        public Hashtable GetDaydataList(IList<string> XAxis, Device device, string startYYYYMMDDHH, string endYYYYMMDDHH, int intervalMins, int monitorCode)
        {
            //累加多个单元的功率数据
            Hashtable hhpowerHash = new Hashtable();
            string startYYYYMM = startYYYYMMDDHH.Substring(0, 6);
            string endYYYYMM = endYYYYMMDDHH.Substring(0, 6);
            int startDD = int.Parse(startYYYYMMDDHH.Substring(6, 2));
            int endDD = int.Parse(endYYYYMMDDHH.Substring(6, 2));
            if (startYYYYMM.Equals(endYYYYMM))
            {
                string year = startYYYYMM.Substring(0, 4);
                string month = startYYYYMM.Substring(4, 2);
                return this.getMultiDayBetweenData(XAxis, device, year, month, startDD, endDD, intervalMins, monitorCode);
            }
            else
            {
                string year = startYYYYMM.Substring(0, 4);
                string month = startYYYYMM.Substring(4, 2);
                int firstEndDD = CalenderUtil.getMonthDays(year + month);
                Hashtable firstHash = this.getMultiDayBetweenData(XAxis, device, year, month, startDD, firstEndDD, intervalMins, monitorCode);
                year = endYYYYMM.Substring(0, 4);
                month = endYYYYMM.Substring(4, 2);
                Hashtable secondHash = this.getMultiDayBetweenData(XAxis, device, year, month, 1, endDD, intervalMins, monitorCode);

                foreach (Object obj in secondHash.Keys)
                {
                    firstHash.Add(obj, secondHash[obj]);
                }
                return firstHash;
            }
        }
 /// <summary>
 /// 取得设备跨月度发电量数据
 /// </summary>
 /// <param name="device"></param>
 /// <param name="startYearMM"></param>
 /// <param name="endYearMM"></param>
 /// <returns></returns>
 public Hashtable DeviceYearMMDDList(Device device, string startYearMMDD, string endYearMMDD)
 {
     return this.unionYearMMDDList(new List<Device>() { device }, startYearMMDD, endYearMMDD,new List<float>(){1.0F});
 }
Exemple #17
0
        /// <summary>
        /// 取得设备天数据列表
        /// </summary>
        /// <returns></returns>
        public void getDeviceDayDataList()
        {
            if (this.listTcpbody != null && listTcpbody.Count > 0)
            {
                Device device = null;
                int collectorID = GetCollectorId();
                DeviceDayData mdd = null;
                foreach (DeviceDataBase ddb in ListTcpbody)
                {
                    try
                    {
                        int deviceID = GetDeviceId(collectorID, ddb.deviceAddress);
                        int deviceT = 1;
                        //根据协议类型取得说属大类型
                        if (ddb.deviceType == -1)
                        {
                            deviceT = DeviceData.getProtocolTypeByCode(ddb.protocolType).deviceType.code;
                        }
                        else
                        {
                            deviceT = ddb.deviceType;
                        }
                        if (deviceID == 0)
                        {
                            //构造设备
                            device = new Device();
                            device.collectorID = collectorID;
                            device.deviceAddress = ddb.deviceAddress.ToString();

                            device.deviceTypeCode = deviceT;
                            device.deviceModel = new DeviceModel() { code = ddb.deviceXh };
                            device.status = ddb.deviceState.ToString();
                            deviceID = DeviceService.GetInstance().Save(device);
                            LogUtil.info("has new device,collectorID is " + collectorID + ",deviceAddress is " + device.deviceAddress);
                            //有新设备要更新bank缓存
                            HttpClientUtil.requestUrl(bank_url);
                        }
                        else
                        {
                            //这里影响解析性能,出了型号会变,设备类型也会变所以也要更新
                            device = DeviceService.GetInstance().get(deviceID);
                            if (ddb.deviceXh != device.deviceModelCode || (DeviceData.getProtocolTypeByCode(ddb.protocolType).typecode != device.deviceTypeCode))
                            {
                                //型号有变化更新设备信息
                                device.deviceModelCode = ddb.deviceXh;
                                device.deviceModel = new DeviceModel() { code = ddb.deviceXh };
                                device.deviceTypeCode = deviceT;
                                //device.name = "";
                                LogUtil.info("has device update,collectorID is " + collectorID + ",deviceAddress is " + device.deviceAddress);
                                DeviceService.GetInstance().Save(device);

                                //设备类型编号也要更新bank缓存
                                HttpClientUtil.requestUrl(bank_url);
                            }
                        }

                        //设置设备的发电量
                        if (ddb.todayEnergy > -1)
                        {
                            deviceEnergyMap[deviceID + ":" + messageHeader.year + messageHeader.month + messageHeader.day] = ddb.todayEnergy;
                        }

                        //设置设备的增量日照强度,参照发电量记录,用发电量的记录逻辑,因为发电量的设备id是逆变器,现在时环境监测仪所以不会重复,可以用发电量的结构
                        //如果增量日照强度大于0则表示有就记录下来,用于后面的累计 add by qianhb in 2012/01/13
                        if (ddb.todaySunshine > -1)
                        {
                            deviceEnergyMap[deviceID + ":" + messageHeader.year + messageHeader.month + messageHeader.day] = ddb.todaySunshine;
                        }

                        //这里需要改进为依据设备时间,防止设备数据的时间和采集器的时间是不一致的
                        string mapObjectKey;
                        IDictionary<string, DeviceDayData> tmpdic = null;
                        foreach (int key in ddb.historyMonitorMap.Keys)
                        {
                            tmpdic = devicedayDataMapList[deviceID % 50];
                            mapObjectKey = CacheKeyUtil.buildDeviceDayDataKey(deviceID, messageHeader.year + messageHeader.month, int.Parse(messageHeader.day), key);
                            if (!tmpdic.ContainsKey(mapObjectKey))
                            {
                                //先从缓存中取得
                                mdd = DeviceDayDataService.GetInstance().getDeviceDayData(deviceID, key, int.Parse(messageHeader.day), int.Parse(messageHeader.year), int.Parse(messageHeader.month));
                                if (mdd == null)
                                    mdd = new DeviceDayData() { deviceID = deviceID, sendDay = int.Parse(messageHeader.day), monitorCode = key, deviceType = ddb.tableType };
                                else
                                {
                                    if (mdd.id == 0)
                                        LogUtil.warn("mdd id is 0" + deviceID + "-" + key + "-" + ddb.tableType);
                                }

                                tmpdic[mapObjectKey] = mdd;
                            }
                            else
                            {
                                mdd = tmpdic[mapObjectKey];
                            }
                            //非持久化属性赋值,用于指定所在表
                            mdd.yearmonth = messageHeader.year + messageHeader.month;
                            float newValue = ddb.historyMonitorMap[key] == null ? 0 : float.Parse(ddb.historyMonitorMap[key].ToString());
                            string tmpvalue = "#" + messageHeader.hour + messageHeader.minute + messageHeader.second + ":" + newValue;
                            if (mdd.dataContent != null){//避免数据串有重复数据过大
                                if (!mdd.dataContent.Contains(tmpvalue))
                                    mdd.dataContent += tmpvalue;
                            }
                            else
                            {
                                mdd.dataContent = tmpvalue;
                            }
                            mdd.sendtime = messageHeader.TimeNow;
                            mdd.localAcceptTime = DateTime.Now;
                            mdd.deviceType = ddb.tableType;
                            mdd.changed = true;
                            //add by qhb in 20120924 for 会写到memcahced 以便持久化能取到改数据.设备天数据集中缓存处有点问题,
                            //导致曲线数据有丢失现象
                            MemcachedClientSatat.getInstance().Set(mapObjectKey, mdd);
                            //将功率和关照的最大发生时间记录下来,稍后在优化下
                            if (key == MonitorType.MIC_INVERTER_TOTALYGPOWER || key == MonitorType.MIC_DETECTOR_SUNLINGHT || key == MonitorType.MIC_BUSBAR_TOTALCURRENT)
                            {
                                //LogUtil.warn("deviceDataCounts.Add(new DeviceDataCount(): id is " +deviceID+"-"+ messageHeader.year.ToString() + messageHeader + "");
                                deviceDataCounts.Add(new DeviceDataCount() { deviceId = deviceID, monitorCode = key, year = int.Parse(messageHeader.year), month = int.Parse(messageHeader.month), day = int.Parse(messageHeader.day), deviceTable = TableUtil.DEVICE, maxValue = newValue, maxTime = messageHeader.TimeNow, localAcceptTime = DateTime.Now });
                            }

                        }
                    }
                    catch (Exception ee)
                    {
                        LogUtil.error(ee.Message);
                    }
                }
            }
        }
        /// <summary>
        /// 设备的月天统计图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="rate"></param>
        /// <param name="chartname"></param>
        /// <param name="startYearMMDD"></param>
        /// <param name="endYearMMDD"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ChartData MonthDDChartByDevice(Device device, float rate, string chartname, string startYearMMDD, string endYearMMDD, string chartType, string unit)
        {
            if (device == null)
            {
                return new ChartData() ;
            }
            string name =  LanguageUtil.getDesc("CHART_TITLE_MONTH_ENERGY");

            string startYearMM = startYearMMDD.Substring(0, 6);
            string endYearMM = endYearMMDD.Substring(0, 6);
            Hashtable monthDDEnergy = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, startYearMM, endYearMM);

            string[] ic = base.getXseriesFromYYYYMMDD(startYearMMDD, endYearMMDD).ToArray();

            string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay);
            string xname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name;

            KeyValuePair<string, float?[]> data = new KeyValuePair<string, float?[]>();
            if (monthDDEnergy.Count > 0)
            {
                data = GenerateChartData(xname, ic, monthDDEnergy, rate);
            }
            return ReportBuilder.createJsonChartXY(name, xAxis, data, "", unit, chartType, fromApp);
        }
 /// <summary>
 /// 取得单个设备的每个年度的发电量
 /// </summary>
 /// <param name="device"></param>
 /// <returns></returns>
 public Hashtable GetTotalDatasByDevice(Device device)
 {
     return this.GetTotalDatasByDevices(new List<Device>(){device});
 }
 /// <summary>
 /// 取得设备年度收益率图表
 /// </summary>
 /// <param name="device"></param>
 /// <param name="chartType"></param>
 /// <returns></returns>
 public ChartData TotalCO2ChartByDevice(Device device, string chartType, string unit)
 {
     float rate = getCO2Rate();
     return this.YearChartByDevice(device, rate, "CO2 Reduction Chart", chartType, unit);
 }
Exemple #21
0
        private string getDetectorRunDataStr(Device device)
        {
            //StringBuilder sb = new StringBuilder();
            ////1	設備状态			"0:待机(waiting)1:正常(normal)3:故障(fault)"	1
            //sb.Append(device.getStatusDefinedValue()).Append(",");
            ////2	风速	m/s	0.1m/s		2.1
            //sb.Append("2.1").Append(",");
            ////3	风向	°(角度)	1°		265
            //sb.Append("265").Append(",");
            ////4	环境温度	℃	0.1℃		11.6
            //sb.Append("11.6").Append(",");
            ////5	电池板温度	℃	0.1℃		19.1
            //sb.Append("19.1").Append(",");
            ////6	辐射强度	W/㎡	1W/㎡		306
            //sb.Append("306").Append(",");
            ////7	故障代碼			請提供故障代碼對照表	EI501
            //sb.Append("16400");

            string[] dataarr = new string[7];
            if (device.runData != null && device.runData.rundatastr != null)
                analyzeArr(device.runData.rundatastr, dataarr, detector_no_mcodemap);
            dataarr[0] = device.getStatusDefinedValue().ToString();
            //将浮点状态值转成整形
            if (!string.IsNullOrEmpty(dataarr[6]))
                dataarr[6] = int.Parse(dataarr[6]).ToString();
            return buildRunDataStr(dataarr);
        }
        /// <summary>
        /// 设备年度统计图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="rate"></param>
        /// <param name="chartname"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ChartData YearChartByDevice(Device device, float rate, string chartname, string chartType, string unit)
        {
            if (device == null)
            {
                return new ChartData();
            }

            string chartName = LanguageUtil.getDesc("CHART_TITLE_TOTAL_ENERGY");

            ///所有子站累加
            Hashtable yearEnergy = DeviceYearDataService.GetInstance().GetTotalDatasByDevice(device);

            string[] ic = sortCollection(yearEnergy.Keys);
            string[] newic = null;
            int len = 5;
            int skip = len - ic.Length;
            int left = (int)skip / 2;
            int right = 5 - ic.Length - left;
            if (ic.Length < len)
            {
                newic = new string[len];
                len = 0;
                int startYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[0]);
                int endYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[ic.Length - 1]);
                while (left > 0)
                    newic[len++] = (startYear - (left--)).ToString();
                foreach (string s in ic)
                    newic[len++] = s;
                for (int i = 1; i <= right; i++)
                    newic[len++] = (endYear + (i)).ToString();
            }
            else
            {
                newic = ic;
            }
            string[] xAxis = formatXaxis(newic, ChartTimeType.Year);

            string yname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name;
            KeyValuePair<string, float?[]> data = new KeyValuePair<string, float?[]>();
            if (yearEnergy.Count > 0)
            {
                data = GenerateChartData(yname, newic, yearEnergy, rate);
            }

            return ReportBuilder.createJsonChartXY(chartName, xAxis, data, "", unit, chartType, fromApp);
        }
Exemple #23
0
        /// <summary>
        /// 按照设备
        /// </summary>
        /// <param name="device"></param>
        /// <param name="collector"></param>
        /// <returns></returns>
        private string getInverterRunDataStr(Device device, Collector collector)
        {
            //1	逆变器运行状态	 	 	0:待机(waiting)1:正常(normal)3:故障(fault)	1
            string[] dataarr = new string[37];
            if (device.runData != null && device.runData.rundatastr != null)
                analyzeArr(device.runData.rundatastr, dataarr, invert_no_mcodemap);

            dataarr[0] = device.getStatusDefinedValue().ToString();
            double dv, dc;
            double.TryParse(dataarr[1], out dv);
            double.TryParse(dataarr[2], out dc);
            dataarr[4] = (dv * dc).ToString();//第一路电池板输出功率

            double.TryParse(dataarr[4], out dv);
            double.TryParse(dataarr[5], out dc);
            dataarr[7] = (dv * dc).ToString();//直流电压2 *直流电流2 第二路电池板输出功率

            dataarr[33] = collector.code;
            dataarr[34] = "000";//逆变器地址
            //将浮点状态值转成整形
            if (!string.IsNullOrEmpty(dataarr[23]))
                dataarr[23] = int.Parse(dataarr[23]).ToString();

            //12 + 15 +18
            //处理37	逆变器交流输出总功率	W	0.1W	第一、二、三相交流输出功率之和	4893.9
            if (dataarr[12] == null) dataarr[12] = "0";
            if (dataarr[15] == null) dataarr[15] = "0";
            if (dataarr[18] == null) dataarr[18] = "0";
            dataarr[36] = Math.Round(double.Parse(dataarr[12]) + double.Parse(dataarr[15]) + double.Parse(dataarr[18]),2).ToString();
            return buildRunDataStr(dataarr);
            //sb.Append(device.getStatusDefinedValue()).Append(",");
            ////2	逆变器输入总功率	W	0.1W
            //sb.Append("333.4").Append(",");
            ////3	第一路电池板电压	V	0.1V
            //sb.Append("33.4").Append(",");
            ////4	第一路电池板电流	A	0.1A
            //sb.Append("23.4").Append(",");
            ////5	第一路电池板输出功率	W	0.1W
            //sb.Append("23.4").Append(",");
            ////6	第二路电池板电压	V	0.1V
            //sb.Append("23.4").Append(",");
            ////7	第二路电池板电流	A	0.1A
            //sb.Append("23.4").Append(",");
            ////8	第二路电池板输出功率	W	0.1W
            //sb.Append("23.4").Append(",");
            ////9	逆变器输出总功率	W	0.1W
            //sb.Append("23.4").Append(",");
            ////10	电网频率	Hz	0.01Hz
            //sb.Append("224.14").Append(",");
            ////11	第一相电压	V	0.1V
            //sb.Append("23.4").Append(",");
            ////12	第一相电流	A	0.1A
            //sb.Append("23.4").Append(",");
            ////13	第一相输出功率	W	0.1W
            //sb.Append("23.4").Append(",");
            ////14	第二相电压	V	0.1V
            //sb.Append("23.4").Append(",");
            ////15	第二相电流	A	0.1A
            //sb.Append("23.4").Append(",");
            ////16	第二相输出功率	W	0.1W
            //sb.Append("23.4").Append(",");
            ////17	第三相电压	V	0.1V
            //sb.Append("23.4").Append(",");
            ////18	第三相电流	A	0.1A
            //sb.Append("23.4").Append(",");
            ////19	第三相输出功率	W	0.1W
            //sb.Append("23.4").Append(",");
            ////20	今日发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////21	累计发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////22	总发电时间	S	0.5S
            //sb.Append("23.4").Append(",");
            ////23	逆变器内部温度	℃	0.1℃
            //sb.Append("23.4").Append(",");
            ////24	逆变器运行错误码
            //sb.Append("9984").Append(",");
            ////25	逆变器输出功率因数
            //sb.Append("1.4").Append(",");
            ////26	第一路电池板今日发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////27	第一路电池板累计发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////28	第二路电池板今日发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////29	第二路电池板累计发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////30	电池板累计发电量	KWH	0.1KWH
            //sb.Append("23.4").Append(",");
            ////31	交流端无功功率	Var	0.1Var
            //sb.Append("23.4").Append(",");
            ////32	今日无功电能	KVarH	0.1KVarH
            //sb.Append("23.4").Append(",");
            ////33	累计无功电能	KVarH	0.1KVarH
            //sb.Append("23.4").Append(",");
            ////34	数据采集器序列号
            //sb.Append(collector.code).Append(",");
            ////35	逆变器序列号
            //sb.Append("");
        }
        /// <summary>
        /// 设备的年月统计图表
        /// </summary>
        /// <param name="device"></param>
        /// <param name="rate"></param>
        /// <param name="chartname"></param>
        /// <param name="startYearMM"></param>
        /// <param name="endYearMM"></param>
        /// <param name="chartType"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ChartData YearMMChartByDevice(Device device, float rate, string chartname, string startYearMM, string endYearMM, string chartType, string unit)
        {
            if (device == null)
            {
                return new ChartData();
            }
            string name = LanguageUtil.getDesc("CHART_TITLE_YEAR_ENERGY");

            int startYear = int.Parse(startYearMM.Substring(0, 4));
            int endYear = int.Parse(endYearMM.Substring(0, 4));
            Hashtable yearMonthEnergy = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(device, startYear, endYear);

            string[] ic = base.getXseriesFromYYYYMM(startYearMM, endYearMM).ToArray();

            string[] xAxis = formatXaxis(ic, ChartTimeType.YearMonth);

            string yname = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE).name;

            KeyValuePair<string, float?[]> data = new KeyValuePair<string, float?[]>();
            if (yearMonthEnergy.Count > 0)
            {
                data = GenerateChartData(yname, ic, yearMonthEnergy, rate);
            }
            return ReportBuilder.createJsonChartXY(name, xAxis, data, "", unit, chartType, fromApp);
        }
Exemple #25
0
        public ActionResult UpdateDeviceMonitor(Device device, string pid)
        {
            if (device.name == device.comFullName) device.name = "";//组合名称不保存到name字段,避免自定义被修改

            DeviceService.GetInstance().UpdateDeviceById(device);

            return RedirectToAction("DeviceMonitor", "plant", new { @id = pid });
        }
        /// <summary>
        /// 设备年月pr性能
        /// </summary>
        /// <param name="invertDevice"></param>
        /// <param name="detectorDevice"></param>
        /// <param name="chartName"></param>
        /// <param name="startYearMM"></param>
        /// <param name="endYearMM"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public ChartData yearMonthRPChartBypList(Device invertDevice,Device detectorDevice, string chartName, string startYearMM, string endYearMM, string chartType)
        {
            if (invertDevice == null)
            {
                return new ChartData();
            }
            MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE);

            IList<string> chartTypes = new List<string>(); //图表类型
            IList<string> units = new List<string>();      //单位
            IList<string> ynames = new List<string>();     //y轴名称
            //IList<string> compareObjs = null;//图例比较对象,因为是同一个电站,不追加
            chartTypes.Add(chartType);
            chartTypes.Add(chartType);
            ynames.Add(mt.name);
            ynames.Add(mt.name);
            //产生坐标
            int startYear = int.Parse(startYearMM.Substring(0, 4));
            int endYear = int.Parse(endYearMM.Substring(0, 4));

            string[] ic = base.getXseriesFromYYYYMM(startYearMM, endYearMM).ToArray();

            string[] xAxis = formatXaxis(ic, ChartTimeType.YearMonth);

            float rate = 1.0F;
            string newseriekey;
            //取得多个采集器的实际发电量
            Hashtable yearMonthEnergy = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(invertDevice, startYear, endYear);

            units.Add(mt.unit);
            units.Add(mt.unit);
            IList<KeyValuePair<string, float?[]>> datas = new List<KeyValuePair<string, float?[]>>();
            KeyValuePair<string, float?[]> data = new KeyValuePair<string, float?[]>();
            if (yearMonthEnergy.Count > 0)
            {
                newseriekey = LanguageUtil.getDesc("ACTUALENERGY");
                data = GenerateChartData(newseriekey, ic, yearMonthEnergy, rate);
            }
            //string comobj = "";//plantList.Count > 1 ? "" : plantList[0].name;
            datas.Add(data);
            //取得日照增量强度,并依次计算理论发电量
            //取得有增量日照迁强度的环境监测仪设备
            rate = this.getEnergyRate(invertDevice.designPower);

            yearMonthEnergy = DeviceYearMonthDataService.GetInstance().GetDeviceBetweenYearData(detectorDevice, startYear, endYear);
            newseriekey = LanguageUtil.getDesc("THEORYENERGY");
            data = GenerateChartData(newseriekey, ic, yearMonthEnergy, rate);
            datas.Add(data);

            float?[] newDataArr = computeByType(xAxis.ToArray(), datas, ComputeType.Ratio);
            KeyValuePair<string, float?[]> newdata = new KeyValuePair<string, float?[]>("PR", newDataArr);
            datas.Add(newdata);
            chartTypes.Add(ChartType.line);
            units.Add("%");
            ynames.Add("PR");

            return ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes.ToArray(), units.ToArray(), fromApp);
        }
        /// <summary>
        /// 作者:鄢睿
        /// 功能:取得设备多个年度的年月比较数据
        /// 创建时间:2011年02月25日
        /// </summary>
        /// <param name="device"></param>
        /// <param name="years"></param>
        /// <param name="monitorCode"></param>
        /// <param name="unit"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public ChartData DeviceMMCompare(Device device, IList<string> yearmms, MonitorType mt, string unit, string chartType, float rate)
        {
            ICollection<ICollection> keys = new List<ICollection>();
            StringBuilder sb = new StringBuilder();
               // foreach (string year in yearmms)
            //{
               // sb.Append("," + year);
            //}
            string chartName = mt.name + " " + LanguageUtil.getDesc("CHART_TITLE_COMPARE");
            IList<KeyValuePair<string, float?[]>> datas = new List<KeyValuePair<string, float?[]>>();

            string[] chartTypes = new string[1] { chartType };
            string[] units = new string[1] { unit };
            string[] ynames = new string[1] { "" };
            string[] ic = null;

            bool hasData = false;
            //取得多个年度的发电月数据
            int i = 0;
            foreach (string yearMM in yearmms)
            {
                Hashtable dataHash = null;
                string curName = yearMM;
                dataHash = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, yearMM, yearMM);
                string[] tmpic = base.getXseriesFromYYYYMMDD(yearMM + "01", yearMM + CalenderUtil.getMonthDays(yearMM).ToString("00")).ToArray();
                if (ic == null || tmpic.Length > ic.Length) ic = tmpic;
                //如果有多个设备进行编辑,没有数据的时候也显示
                //if (dataHash.Count > 0)
                //{
                    //add by qhb in 20120928 for 补偿发电量
                    base.addDeviceDayEnergy(dataHash, device.id, yearMM, yearMM);
                    KeyValuePair<string, float?[]> data = GenerateChartData(curName, ic, dataHash, rate);
                    datas.Add(data);
                //}
                //如果有数据则将有数据标识为true
                if (dataHash.Count > 0)
                {
                    hasData = true;
                }
                i++;
            }
            if (!hasData)
            {
                //如果所有设备都没数据才清空数据,即图表中显示无数据提示
                datas.Clear();
            }
            string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay);
            return ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, fromApp);
        }
        /// <summary>
        /// 取得总体年度pr性能
        /// </summary>
        /// <param name="invertDevice"></param>
        /// <param name="detectorDevice"></param>
        /// <param name="chartName"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public ChartData YearPRChartBypList(Device invertDevice,Device detectorDevice, string chartName, string chartType)
        {
            if (invertDevice == null)
            {
                return new ChartData();
            }

            MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE);
            IList<string> chartTypes = new List<string>(); //图表类型
            IList<string> units = new List<string>();      //单位
            IList<string> ynames = new List<string>();     //y轴名称
            //IList<string> compareObjs = null;//图例比较对象,因为是同一个电站,不追加
            chartTypes.Add(chartType);
            chartTypes.Add(chartType);
            ynames.Add(mt.name);
            ynames.Add(mt.name);

            //产生坐标
            Hashtable yearEnergy = DeviceYearDataService.GetInstance().GetTotalDatasByDevice(invertDevice);
            string[] ic = sortCollection(yearEnergy.Keys);
            string[] newic = null;
            int len = 5;
            int skip = len - ic.Length;
            int left = (int)skip / 2;
            int right = 5 - ic.Length - left;
            if (ic.Length < len)
            {
                newic = new string[len];
                len = 0;
                int startYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[0]);
                int endYear = ic.Length == 0 ? DateTime.Now.Year : int.Parse(ic[ic.Length - 1]);
                while (left > 0)
                    newic[len++] = (startYear - (left--)).ToString();
                foreach (string s in ic)
                    newic[len++] = s;
                for (int i = 1; i <= right; i++)
                    newic[len++] = (endYear + (i)).ToString();
            }
            else
            {
                newic = ic;
            }
            string[] xAxis = formatXaxis(newic, ChartTimeType.Year);

            float rate = 1.0F;
            string newseriekey;
            //取得多个采集器的实际发电量

            units.Add(mt.unit);
            units.Add(mt.unit);
            IList<KeyValuePair<string, float?[]>> datas = new List<KeyValuePair<string, float?[]>>();
            KeyValuePair<string, float?[]> data = new KeyValuePair<string, float?[]>();
            if (yearEnergy.Count > 0)
            {
                newseriekey = LanguageUtil.getDesc("ACTUALENERGY");
                data = GenerateChartData(newseriekey, newic, yearEnergy, rate);
            }

            datas.Add(data);
            //取得日照增量强度,并依次计算理论发电量
            //取得有增量日照迁强度的环境监测仪设备
            //计算理论发电量换算率
            rate = this.getEnergyRate(invertDevice.designPower);

            yearEnergy = DeviceYearDataService.GetInstance().GetTotalDatasByDevice(detectorDevice);
            newseriekey = LanguageUtil.getDesc("THEORYENERGY");
            data = GenerateChartData(newseriekey, ic, yearEnergy, rate);
            datas.Add(data);

            float?[] newDataArr = computeByType(xAxis.ToArray(), datas, ComputeType.Ratio);
            KeyValuePair<string, float?[]> newdata = new KeyValuePair<string, float?[]>("PR", newDataArr);
            datas.Add(newdata);
            chartTypes.Add(ChartType.line);
            units.Add("%");
            ynames.Add("PR");

            return ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames.ToArray(), chartTypes.ToArray(), units.ToArray(), fromApp);
        }
        /// <summary>
        /// 取得汇流箱设备某个测点的详细数据,目前主要是数字输入和工作状态
        /// add by qhb in 20120825 for 显示测点的详细信息
        /// </summary>
        /// <param name="device"></param>
        /// <param name="monitorCode"></param>
        /// <returns></returns>
        private IList<DigitalInputDetailVO> getDetails(Device device, int monitorCode, int displayHxlroute)
        {
            IList<DigitalInputDetailVO> details = new List<DigitalInputDetailVO>();
            //如果有数字输入测点,则返回相应的符合显示要求的数据结构
            if (device.runData != null && device.runData.hasMonitor(monitorCode))
            {
                //数字输入值
                string value = device.runData.getMonitorValueWithStatus(monitorCode);
                if (monitorCode == MonitorType.MIC_BUSBAR_STATUS)
                {
                    value = StringUtil.getFullbitstr(int.Parse(value));
                }
                else
                {
                    value = StringUtil.getFullbitstr(int.Parse(value));
                }
                char[] desArray = new char[value.Length];
                value.CopyTo(0, desArray, 0, value.Length);
                //一次取得相应bit位的值
                string bitkey = null;
                int bitvalue = 0;
                string bitdesc;//bit位多语言描述
                string bitvaluedesc = "";//bit位值代表的状态码描述,从资源库中取得
                string bititem;
                string status;//状态
                DigitalInputDetailVO digitalInputDetailVO = null;
                int n = 0;
                for (int i = desArray.Length - 1; i >= 0; i--)
                {
                    n++;
                    bitkey = monitorCode.ToString() + n;
                    //判断该bit位定义是否存在
                    if (MonitorType.bitStatusMap.ContainsKey(bitkey))
                    {
                        //取得该bit位对应值
                        bitvalue = int.Parse(desArray[i].ToString());
                        bititem = MonitorType.bitStatusMap[bitkey];
                        bitdesc = LanguageUtil.getDesc(bititem);
                        bitvaluedesc = LanguageUtil.getDesc(bititem + bitvalue);
                        if (bititem.Equals(MonitorType.digital_input_item_flq) || bititem.Equals(MonitorType.work_status_item_run))
                        {
                            status = bitvalue == 0 ? DigitalInputDetailVO.status_off : DigitalInputDetailVO.status_no;
                        }
                        else
                            status = bitvalue == 0 ? DigitalInputDetailVO.status_no : DigitalInputDetailVO.status_off;

                        digitalInputDetailVO = new DigitalInputDetailVO(status, bitdesc, bitvaluedesc);
                        if (monitorCode == MonitorType.MIC_BUSBAR_STATUS)
                        {
                            //取得状态项目对应的各路状态
                            int mcode = 0;
                            if (bititem.Equals(MonitorType.work_status_item_duanlu))
                            {
                                mcode = MonitorType.MIC_BUSBAR_DUANLUDATA;
                            }
                            else if (bititem.Equals(MonitorType.work_status_item_dlgg))
                            {
                                mcode = MonitorType.MIC_BUSBAR_DLGGDATA;
                            }
                            else if (bititem.Equals(MonitorType.work_status_item_dlgd))
                            {
                                mcode = MonitorType.MIC_BUSBAR_DLGDDATA;
                            }
                            else if (bititem.Equals(MonitorType.work_status_item_kailu))
                            {
                                mcode = MonitorType.MIC_BUSBAR_KAILUDATA;
                            }
                            if (mcode > 0)
                            {
                                string routestatusvalue = device.runData.getMonitorValueWithStatus(mcode);
                                routestatusvalue = StringUtil.getFullbitstr(int.Parse(routestatusvalue));
                                char[] routeArray = new char[routestatusvalue.Length];
                                routestatusvalue.CopyTo(0, routeArray, 0, routestatusvalue.Length);
                                int m = 0;
                                //先取得传感器接入路数,以决定显示多少路汇流箱路数
                                string[] routeStringArray = new string[displayHxlroute];
                                for (int k = routeArray.Length - 1; k >= 0; k--)
                                {
                                    //取得该bit位对应值
                                    int tmpbitvalue = int.Parse(routeArray[k].ToString());
                                    if (m < displayHxlroute)
                                    {
                                        routeStringArray[m] = (status.Equals(DigitalInputDetailVO.status_off) && tmpbitvalue == 1) ? DigitalInputDetailVO.status_off : DigitalInputDetailVO.status_no;
                                    }

                                    m++;
                                }
                                digitalInputDetailVO.routeStatus = routeStringArray;
                            }
                            else
                            {
                                digitalInputDetailVO.statusItem = digitalInputDetailVO.statusDesc;
                            }
                        }
                        details.Add(digitalInputDetailVO);
                    }
                }
            }
            return details;
        }
Exemple #30
0
 public int UpdateDeviceById(Device device)
 {
     return _deviceDao.UpdateDeviceById(device);
 }