예제 #1
0
        public JsonResult GetSelParamIds(int layoutId)
        {
            var retData = new VM_Result_Data();

            try {
                var layout = bllLayout.GetModel(layoutId);
                var bllParamCode_Sensor = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
                var bllSensor           = new MesWeb.BLL.T_SensorModule();
                var sensor = bllSensor.GetModel((int)layout.TableRowID);
                var paramCode_SensorList = bllParamCode_Sensor.GetModelList("SensorModuleID = " + sensor.SensorModuleID);
                var paramCodeIds         = new List <int?>();
                foreach (var item in paramCode_SensorList)
                {
                    paramCodeIds.Add(item.ParameterCodeID);
                }
                if (paramCodeIds.Count > 0)
                {
                    retData.Code     = RESULT_CODE.OK;
                    retData.Appendix = paramCodeIds;
                }
            } catch (Exception e) {
                log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name);
                log.Error("获取模块参数失败!", e);
                retData.Content = "获取模块参数失败!";
            }
            return(Json(retData));
        }
예제 #2
0
        public JsonResult DeleteSensorLayoutAction(int Id)
        {
            log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name);
            var retData = new VM_Result_Data();
            var layout  = bllLayout.GetModel(Id);

            try {
                if (deleteLayout(layout))
                {
                    var bllSensor           = new MesWeb.BLL.T_SensorModule();
                    var bllSensorParamCode  = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
                    var sensorParamCodeList = bllSensorParamCode.GetModelList("SensorModuleID=" + layout.TableRowID);
                    var deleteList          = new StringBuilder();
                    for (int i = 0; i < sensorParamCodeList.Count; i++)
                    {
                        deleteList.Append(sensorParamCodeList[i].SensorModule_PARCODEID.ToString());
                        if (i != sensorParamCodeList.Count - 1)
                        {
                            deleteList.Append(",");
                        }
                    }
                    if (bllSensorParamCode.DeleteList(deleteList.ToString()))
                    {
                        if (bllSensor.Delete((int)layout.TableRowID))
                        {
                            retData.Code    = RESULT_CODE.OK;
                            retData.Content = "删除成功";
                        }
                        else
                        {
                            log.Error("删除传感器失败");
                            retData.Content = "删除传感器失败";
                        }
                    }
                    else
                    {
                        log.Error("删除关系失败");
                        retData.Content = "删除传感器失败";
                    }
                }
                else
                {
                    log.Error("删除传感器布局失败");
                    retData.Content = "删除失败!";
                }
            } catch (Exception e) {
                retData.Content = "系统错误";
                log.Fatal("系统错误", e);
            }

            return(Json(retData));
        }
예제 #3
0
        /// <summary>
        /// 初始化模块状态缓存字典
        /// </summary>
        private void initCurModuelStateDic()
        {
            var bllMachine      = new MesWeb.BLL.T_Machine();
            var machList        = bllMachine.GetModelList("");
            var bllSensor       = new MesWeb.BLL.T_SensorModule();
            var bllParam        = new MesWeb.BLL.T_ParameterCode();
            var bllSensor_Param = new MesWeb.BLL.T_SensorModule_T_ParameterCode();

            //遍历所有机台
            foreach (var machine in machList)
            {
                var machineId = machine.MachineID;
                //为每个机台的所有模块生成一个字典
                var moduleDic = new ConcurrentDictionary <string, List <Param> >();
                //添加机台
                if (curModuleStateDic.TryAdd(machineId, moduleDic))
                {
                    var sensors = bllSensor.GetModelList("MachineID = " + machineId);
                    //遍历模块
                    foreach (var sensor in sensors)
                    {
                        //初始化每个模块的参数列表
                        var paramList = new List <Param>();
                        //添加模块
                        if (moduleDic.TryAdd(sensor.SerialNum, paramList))
                        {
                            var sensor_param = bllSensor_Param.GetModelList("SensorModuleID = " + sensor.SensorModuleID);
                            //遍历模块对应的参数
                            foreach (var sp in sensor_param)
                            {
                                //获得参数
                                var param = bllParam.GetModel(sp.ParameterCodeID.Value);
                                //添加参数
                                paramList.Add(new Param {
                                    ParamCodeID = param.ParameterCodeID.ToString(),
                                    ParamCode   = param.ParameterCode.ToString(),
                                    ParamName   = param.ParameterName
                                });
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public JsonResult AddSensorAction(VM_AddSensorAdmin sensorAdmin)
        {
            log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name);
            var retData = new VM_Result_Data();

            var sensorModule = sensorAdmin.SensorModule;
            var sensorLayout = sensorAdmin.SensorLayout;

            if (sensorModule.SerialNum != null && sensorAdmin.ParentLayoutPictureID != null && sensorAdmin.ParameterCodeIDs.Count > 0)
            {
                try {
                    var bllMachine         = new MesWeb.BLL.T_Machine();
                    var machineLayout      = bllLayout.GetModel((int)sensorLayout.ParentLayoutPictureID);
                    var bllSensor          = new MesWeb.BLL.T_SensorModule();
                    var bllSensorParamCode = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
                    sensorModule.MachineID    = bllMachine.GetModel((int)machineLayout.TableRowID).MachineID;
                    sensorLayout.LayoutTypeID = (int)LAYOUT_TPYE.SENSOR_MODULE;

                    //add sensor
                    sensorLayout.TableRowID = bllSensor.Add(sensorModule);
                    //build sensor and parametercode relationship
                    foreach (var param in sensorAdmin.ParameterCodeIDs)
                    {
                        bllSensorParamCode.Add(new MesWeb.Model.T_SensorModule_T_ParameterCode {
                            SensorModuleID  = sensorLayout.TableRowID,
                            ParameterCodeID = int.Parse(param)
                        });
                    }
                    //add sensor layout
                    bllLayout.Add(sensorLayout);

                    retData.Code    = RESULT_CODE.OK;
                    retData.Content = "添加模块成功!";
                } catch (Exception e) {
                    log.Fatal("往数据库写入数据失败", e);
                }
            }
            else
            {
                log.Warning("字段校验失败");
                retData.Content = "字段校验失败";
            }
            return(Json(retData));
        }
예제 #5
0
        protected List <VM_Fusioncharts_Line> getSensorLineChartList(int sensorModuleID, int machineID, int size = -1)
        {
            List <VM_Fusioncharts_Line> vmChartsList = new List <VM_Fusioncharts_Line>();
            var bllSensor = new MesWeb.BLL.T_SensorModule();
            var sensor    = bllSensor.GetModel(sensorModuleID);

            if (sensor != null)
            {
                var bllSensorParamCode  = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
                var bllParamCode        = new MesWeb.BLL.T_ParameterCode();
                var sensorParamCodeList = bllSensorParamCode.GetModelList("SensorModuleID = " + sensor.SensorModuleID);
                var codeList            = new List <MesWeb.Model.T_ParameterCode>();
                foreach (var sensorCode in sensorParamCodeList)
                {
                    var paramCode = bllParamCode.GetModel((int)sensorCode.ParameterCodeID);
                    codeList.Add(paramCode);
                }
                vmChartsList = getParamsChartList(machineID, codeList.ToArray());
            }
            return(vmChartsList);
        }
예제 #6
0
        public ActionResult Machine()
        {
            var bllMachine      = new MesWeb.BLL.T_Machine();
            var machineList     = bllMachine.GetModelList("");
            var bllParam        = new MesWeb.BLL.T_ParameterCode();
            var bllSensor       = new MesWeb.BLL.T_SensorModule();
            var bllSensor_Param = new MesWeb.BLL.T_SensorModule_T_ParameterCode();

            //机台参数树状结构
            var vmJSTree = new List <VM_JSTree>();

            //遍历机台
            foreach (var machine in machineList)
            {
                var machineTreeId = "mach_" + machine.MachineID.ToString();
                var machTree      = new VM_JSTree {
                    text = machine.MachineName, id = machineTreeId
                };
                var sensorList = bllSensor.GetModelList("MachineID = " + machine.MachineID);
                machTree.children = new List <VM_JSTree>();
                foreach (var sensor in sensorList)
                {
                    var spList = bllSensor_Param.GetModelList("SensorModuleID = " + sensor.SensorModuleID);
                    //遍历参数
                    foreach (var sp in spList)
                    {
                        var param = bllParam.GetModel(sp.ParameterCodeID.Value);
                        machTree.children.Add(
                            new VM_JSTree {
                            text = param.ParameterName,
                            id   = machineTreeId + "_param_" + param.ParameterCodeID.ToString()
                        });
                    }
                }
                vmJSTree.Add(machTree);
            }
            return(View(vmJSTree));
        }
예제 #7
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));
        }