예제 #1
0
        protected VM_Fusioncharts_Line getSensorLineChart <T>(int machineID, int paramCodeID, int top = 12) where T : MesWeb.BLL.T_CollectedDataParameters, new()
        {
            var vmChart = new VM_Fusioncharts_Line();
            // var bllParamData = new MesWeb.BLL.T_CollectedDataParameters();
            var bllParamData    = new T();
            var bllParamUnit    = new MesWeb.BLL.T_ParameterUnit();
            var bllParamSetting = new MesWeb.BLL.T_ParametersCol();
            var bllParamCode    = new MesWeb.BLL.T_ParameterCode();
            var paramCode       = bllParamCode.GetModel(paramCodeID);

            //   var dataList = bllParamData.GetModelList(top,"MachineID = " + machineID + "and ParameterCodeID = " + paramCode.ParameterCodeID,"ParameterCodeID Desc");
            var dataList = bllParamData.GetModelList("MachineID = " + machineID + "and ParameterCodeID = " + paramCode.ParameterCodeID);

            var paramSetting = bllParamSetting.GetModelList("ParameterCodeID = " + (int)paramCode.ParameterCodeID).FirstOrDefault();

            var paramUnit = bllParamUnit.GetModel((int)paramCode.ParameterUnitID);
            var chart     = new FusionChart {
                caption      = paramCode.ParameterName,
                numberSuffix = paramUnit.ParameterUnitSymbol,
                yAxisName    = paramUnit.ParameterUnitName,
                xAxisName    = "时间"
            };

            var maxLine = new FusionLine {
                startvalue   = paramSetting.ParametersColMaxiumValue,
                displayvalue = "最大值"
            };
            var minLine = new FusionLine {
                startvalue   = paramSetting.ParametersColMiniumValue,
                displayvalue = "最小值"
            };
            var trendline = new FusionTrendLine();

            trendline.line.Add(maxLine);
            trendline.line.Add(minLine);

            vmChart.chart = chart;
            vmChart.trendlines.Add(trendline);

            for (int i = 0; i < dataList.Count; i++)
            {
                vmChart.data.Add(new FusionData {
                    //    label = ((DateTime)dataList[i].CollectedTime).ToUniversalTime().Subtract(
                    //                    //  new DateTime(1969,12,30,16,0,0,DateTimeKind.Utc)
                    label = dataList[i].CollectedTime.ToString(),
                    value = dataList[i].CollectedValue.ToString()
                });
            }
            ;
            return(vmChart);
        }
예제 #2
0
        protected List <VM_Fusioncharts_Line> getParamsChartList(int machineID, params MesWeb.Model.T_ParameterCode[] paramCodeIDList)
        {
            List <VM_Fusioncharts_Line> vmChartsList = new List <VM_Fusioncharts_Line>();
            var bllParamData       = new MesWeb.BLL.T_CollectedDataParameters();
            var bllSensorParamCode = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
            var bllParamUnit       = new MesWeb.BLL.T_ParameterUnit();
            var bllParamSet        = new MesWeb.BLL.T_ParametersCol();

            foreach (var code in paramCodeIDList)
            {
                var dataList     = bllParamData.GetModelList("MachineID = " + machineID + "and ParameterCodeID = " + code.ParameterCodeID);
                var paramSetting = bllParamSet.GetModelList("ParameterCodeID = " + (int)code.ParameterCodeID).FirstOrDefault();
                var paramUnit    = bllParamUnit.GetModel((int)code.ParameterUnitID);
                var vmFusion     = new VM_Fusioncharts_Line();

                var chart = new FusionChart {
                    caption      = code.ParameterName,
                    numberSuffix = paramUnit.ParameterUnitSymbol,
                    yAxisName    = paramUnit.ParameterUnitName,
                    xAxisName    = "时间"
                };

                var maxLine = new FusionLine {
                    startvalue   = paramSetting.ParametersColMaxiumValue,
                    displayvalue = "最大值"
                };
                var minLine = new FusionLine {
                    startvalue   = paramSetting.ParametersColMiniumValue,
                    displayvalue = "最小值"
                };
                var trendline = new FusionTrendLine();
                trendline.line.Add(maxLine);
                trendline.line.Add(minLine);

                vmFusion.chart = chart;
                vmFusion.trendlines.Add(trendline);

                for (int i = 0; i < dataList.Count; i++)
                {
                    vmFusion.data.Add(new FusionData {
                        //    label = ((DateTime)dataList[i].CollectedTime).ToUniversalTime().Subtract(
                        //                    //  new DateTime(1969,12,30,16,0,0,DateTimeKind.Utc)
                        label = dataList[i].CollectedTime.ToString(),
                        value = dataList[i].CollectedValue.ToString()
                    });
                }
                ;
                vmChartsList.Add(vmFusion);
            }
            return(vmChartsList);
        }
예제 #3
0
        public JsonResult GetParamUnitInfoAction(int Id)
        {
            var retData      = new VM_Result_Data();
            var bllParamUnit = new MesWeb.BLL.T_ParameterUnit();
            var paramUnit    = bllParamUnit.GetModel(Id);

            if (paramUnit != null)
            {
                retData.Code     = RESULT_CODE.OK;
                retData.Appendix = paramUnit;
            }
            else
            {
                retData.Content = "获取参数类型失败";
            }
            return(Json(retData));
        }
예제 #4
0
        protected VM_Fusioncharts_MSLine getMachineCPKMSLineData(int machineID, MesWeb.Model.T_ParameterCode code, int dataCount = 12)
        {
            var msLine             = new VM_Fusioncharts_MSLine();
            var bllParamData       = new MesWeb.BLL.T_CollectedDataParameters();
            var bllSensorParamCode = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
            var bllParamUnit       = new MesWeb.BLL.T_ParameterUnit();
            var bllParamSet        = new MesWeb.BLL.T_ParametersCol();

            var dataList     = bllParamData.GetModelList("MachineID = " + machineID + "and ParameterCodeID = " + code.ParameterCodeID);
            var paramSetting = bllParamSet.GetModelList("ParameterCodeID = " + (int)code.ParameterCodeID).FirstOrDefault();
            var paramUnit    = bllParamUnit.GetModel((int)code.ParameterUnitID);

            var chart = new FusionChart {
                caption      = code.ParameterName,
                numberSuffix = paramUnit.ParameterUnitSymbol,
                yAxisName    = paramUnit.ParameterUnitName,
                xAxisName    = "时间"
            };

            var maxLine = new FusionLine {
                startvalue   = paramSetting.ParametersColMaxiumValue,
                displayvalue = "最大值",
            };
            var minLine = new FusionLine {
                startvalue   = paramSetting.ParametersColMiniumValue,
                displayvalue = "最小值",
            };
            var maxCPKLine = new FusionLine {
                startvalue   = "2.0",
                displayvalue = "CPK最大值"
            };
            var minCPKLine = new FusionLine {
                startvalue   = "0.2",
                displayvalue = "CPK最小值"
            };

            var trendline = new FusionTrendLine();

            trendline.line.Add(maxLine);
            trendline.line.Add(minLine);
            trendline.line.Add(maxCPKLine);
            trendline.line.Add(minCPKLine);
            var cpkDataSet    = new FusionMSDataset();
            var sensorDataSet = new FusionMSDataset();

            cpkDataSet.seriesname    = "CPK";
            sensorDataSet.seriesname = code.ParameterName;
            var categories = new FusionMSCategories();

            for (int i = 0; i < dataList.Count; i++)
            {
                var data = dataList[i];
                categories.category.Add(new FusionMSCategorie {
                    label = data.CollectedTime.ToString().Split(' ')[1]
                });
                sensorDataSet.data.Add(new MSlineValue {
                    value = float.Parse(data.CollectedValue).ToString("0.00")
                });
                cpkDataSet.data.Add(new MSlineValue {
                    value = GetCPKValue(code.ParameterCodeID, machineID).ToString("0.00")
                });
            }
            msLine.categories.Add(categories);
            msLine.chart = chart;
            msLine.trendlines.Add(trendline);
            msLine.dataset.Add(sensorDataSet);
            msLine.dataset.Add(cpkDataSet);
            return(msLine);
        }
예제 #5
0
        public JsonResult GetParamChartProperties(int layoutId)
        {
            var retData = new VM_Result_Data();

            log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name);
            var properties          = new List <VM_Highcharts_Property>();
            var bllParamCode        = new MesWeb.BLL.T_ParameterCode();
            var bllSensor_ParamCode = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
            var bllSensor           = new MesWeb.BLL.T_SensorModule();
            var bllUnit             = new MesWeb.BLL.T_ParameterUnit();
            var bllParamCol         = new MesWeb.BLL.T_ParametersCol();

            try {
                var sensroLayout = bllLayout.GetModel(layoutId);
                if (sensroLayout.LayoutTypeID != (int)LAYOUT_TPYE.SENSOR_MODULE)
                {
                    retData.Content = "施工有误,请联系管理员";
                    log.Error("传感器模块参数错误");
                    return(Json(retData));
                }
                var machLayout   = GetParentLayout(layoutId);
                var machineId    = machLayout.TableRowID.Value;
                var sensor       = bllSensor.GetModel(sensroLayout.TableRowID.Value);
                var sensor_codes = bllSensor_ParamCode.GetModelList("SensorModuleID = " + sensor.SensorModuleID);
                foreach (var sc in sensor_codes)
                {
                    var property = new VM_Highcharts_Property();
                    //获取参数
                    var code = bllParamCode.GetModel(sc.ParameterCodeID.Value);
                    //是否能够画曲线
                    property.CanDrawChart = canDrawChart(code.ParameterCodeID);
                    //曲线类型,将drawType为一样的曲线画在同一图上
                    property.drawType    = code.ParameterType;
                    property.Title       = code.ParameterName;
                    property.ParamCodeId = code.ParameterCodeID;

                    //获取参数单位
                    if (code.ParameterUnitID.HasValue)
                    {
                        var unit = bllUnit.GetModel(code.ParameterUnitID.Value);
                        if (unit != null)
                        {
                            property.Symbol = unit.ParameterUnitSymbol;
                        }
                    }
                    else
                    {
                        property.Symbol = "未设置";
                    }
                    //获取参数最值
                    var paramCol = bllParamCol.GetModelList("ParameterCodeID = " + code.ParameterCodeID + "AND MachineID = " + machineId).FirstOrDefault();
                    if (paramCol != null)
                    {
                        property.MaxValue = float.Parse(paramCol.ParametersColMaxiumValue);
                        property.MinValue = float.Parse(paramCol.ParametersColMiniumValue);
                    }

                    //是否带有 CPK
                    if (Enum.IsDefined(typeof(CPK_PARAM_CODE), sc.ParameterCodeID))
                    {
                        property.IsCPK = true;
                    }
                    else
                    {
                        property.IsCPK = false;
                    }
                    properties.Add(property);
                }

                if (properties.Count > 0)
                {
                    retData.Code = RESULT_CODE.OK;
                    //每参数曲线基本值(最值,标题,单位等等)
                    //每个模块有多个参数,所以这里是一个properties集合
                    retData.Appendix = properties;
                    //给每个模块绑定传感器编号,便于接受485报警
                    retData.Content = sensor.SerialNum;
                }
            } catch (Exception e) {
                log.Error("获取模块参数失败", e);
                retData.Content = "获取模块参数失败";
            }
            return(Json(retData));
        }