Example #1
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LumluxSSYDB.Model.tMeasurePowerInfoes model)
 {
     return(dal.Update(model));
 }
Example #2
0
        public ActionResult HostRealStateDefaultView(string guid, int result, string datetime = "")
        {
            ModelState.Clear();
            BLL.tHostInfo               hostbll               = new BLL.tHostInfo();
            Model.tHostInfo             hostmodel             = new Model.tHostInfo();
            BLL.tMeasureConfigs         measureconfigbll      = new BLL.tMeasureConfigs();
            Model.tMeasureConfigs       measureconfigmodel    = new Model.tMeasureConfigs();
            BLL.tBranchConfigs          branchconfigbll       = new BLL.tBranchConfigs();
            List <Model.tBranchConfigs> branchconfigmodellist = new List <Model.tBranchConfigs>();

            BLL.tMeasureInfoes          measurebll       = new BLL.tMeasureInfoes();
            Model.tMeasureInfoes        measuremodel     = new Model.tMeasureInfoes();
            List <Model.tMeasureInfoes> measuremodellist = new List <Model.tMeasureInfoes>();

            Model.tMeasurePowerInfoes   measurepowermodel   = new Model.tMeasurePowerInfoes();
            BLL.tMeasurePowerInfoes     measurepowerbll     = new BLL.tMeasurePowerInfoes();
            Model.tMeasureCurrentInfoes measurecurrentmodel = new Model.tMeasureCurrentInfoes();
            BLL.tMeasureCurrentInfoes   measurecurrentbll   = new BLL.tMeasureCurrentInfoes();

            A = new GetAllStateVM();
            A.OneCircuitList               = new MeasureState();
            A.TwoCircuitList               = new MeasureState();
            A.ThreeCircuitList             = new MeasureState();
            A.ThreeCircuitList.CircuitList = new List <CircuitStateVM>();
            A.OneCircuitList.CircuitList   = new List <CircuitStateVM>();
            A.TwoCircuitList.CircuitList   = new List <CircuitStateVM>();
            //default
            A.Name                    = "获取失败";
            A.MesureCount             = 0;
            A.UpdateTime              = "获取失败";
            A.OneCircuitList.AState   = "获取失败";
            A.OneCircuitList.BState   = "获取失败";
            A.OneCircuitList.CState   = "获取失败";
            A.OneCircuitList.Avoltage = "N/A";
            A.OneCircuitList.Bvoltage = "N/A";
            A.OneCircuitList.Cvoltage = "N/A";
            A.guid                    = guid;

            switch (result)
            {
            case 0:
                A.Name = "参数错误";
                return(View(A));

            case 1:
                A.Name = "主机未设置地址";
                return(View(A));

            case 2:
                A.Name = "写数据库失败";
                return(View(A));

            case 3:
                A.Name = "参数错误";
                return(View(A));

            case 4:
                A.Name = "无此主机";
                return(View(A));

            case 5:
                A.Name = "未配置测量板";
                return(View(A));

            case 6:
                A.Name = "无返回";
                return(View(A));

            case 7:
                try
                {
                    DateTime ResultTime = DateTime.Parse(datetime);
                    hostmodel = hostbll.GetModel(guid);
                    if (hostmodel != null)
                    {
                        if (hostmodel.sName != null)
                        {
                            A.Name = hostmodel.sName;
                        }
                        measureconfigmodel = measureconfigbll.GetModelByHostGuid(guid);
                        if (measureconfigmodel != null)
                        {
                            if (measureconfigmodel.iMeasureNumber != null)
                            {
                                A.MesureCount = (int)measureconfigmodel.iMeasureNumber;
                                if (measuremodel.dCreateDate != null)
                                {
                                    A.UpdateTime = measuremodel.dCreateDate.ToString();
                                }
                                for (int i = 0; i < measureconfigmodel.iMeasureNumber; i++)
                                {
                                    measuremodel = measurebll.GetModelByHostGuidAndIdAndTime(guid, i + 1, ResultTime);
                                    if (measuremodel != null)
                                    {
                                        if (measuremodel.fVlotA != null)
                                        {
                                            A.OneCircuitList.Avoltage = measuremodel.fVlotA.ToString();
                                        }
                                        if (measuremodel.fVlotB != null)
                                        {
                                            A.OneCircuitList.Bvoltage = measuremodel.fVlotB.ToString();
                                        }
                                        if (measuremodel.fVlotC != null)
                                        {
                                            A.OneCircuitList.Cvoltage = measuremodel.fVlotC.ToString();
                                        }
                                        if (measuremodel.iAlarmVlotA != null)
                                        {
                                            switch ((VoltageAlarm)measuremodel.iAlarmVlotA)
                                            {
                                            case VoltageAlarm.Va_Normal: A.OneCircuitList.AState = "正常";
                                                break;

                                            case VoltageAlarm.Va_Zero: A.OneCircuitList.AState = "缺相";
                                                break;

                                            case VoltageAlarm.Va_OvUpper: A.OneCircuitList.AState = "过压";
                                                break;

                                            case VoltageAlarm.Va_OverLower: A.OneCircuitList.AState = "欠压";
                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        if (measuremodel.iAlarmVlotB != null)
                                        {
                                            switch ((VoltageAlarm)measuremodel.iAlarmVlotB)
                                            {
                                            case VoltageAlarm.Va_Normal: A.OneCircuitList.BState = "正常";
                                                break;

                                            case VoltageAlarm.Va_Zero: A.OneCircuitList.BState = "缺相";
                                                break;

                                            case VoltageAlarm.Va_OvUpper: A.OneCircuitList.BState = "过压";
                                                break;

                                            case VoltageAlarm.Va_OverLower: A.OneCircuitList.BState = "欠压";
                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        if (measuremodel.iAlarmVlotC != null)
                                        {
                                            switch ((VoltageAlarm)measuremodel.iAlarmVlotC)
                                            {
                                            case VoltageAlarm.Va_Normal: A.OneCircuitList.CState = "正常";
                                                break;

                                            case VoltageAlarm.Va_Zero: A.OneCircuitList.CState = "缺相";
                                                break;

                                            case VoltageAlarm.Va_OvUpper: A.OneCircuitList.CState = "过压";
                                                break;

                                            case VoltageAlarm.Va_OverLower: A.OneCircuitList.CState = "欠压";
                                                break;

                                            default:
                                                break;
                                            }
                                        }

                                        branchconfigmodellist = branchconfigbll.GetModelList("sMeasureConfigGUID = '" + measureconfigmodel.sGUID + "' and iEnable = " + StateEnable.Enable);
                                        if (branchconfigmodellist != null)
                                        {
                                            foreach (var item in branchconfigmodellist.OrderBy(c => c.iID))
                                            {
                                                if (item.iID != null)
                                                {
                                                    CircuitStateVM C = new CircuitStateVM();
                                                    measurepowermodel   = measurepowerbll.GetModelByHostGuidAndIDAndTime(measuremodel.sGUID, (int)item.iID);
                                                    measurecurrentmodel = measurecurrentbll.GetModelByHostGuidAndIDAndTime(measuremodel.sGUID, (int)item.iID);
                                                    if ((measurepowermodel != null) && (measurecurrentmodel != null))
                                                    {
                                                        if (measurecurrentmodel.fValue != null)
                                                        {
                                                            C.Current = measurecurrentmodel.fValue.ToString();
                                                        }
                                                        C.ID = item.iID.ToString();
                                                        if (measurepowermodel.fValue != null)
                                                        {
                                                            C.Power = measurepowermodel.fValue.ToString();
                                                        }
                                                        if (measurecurrentmodel.iAlarm != null)
                                                        {
                                                            switch ((CurrentAlarm)measurecurrentmodel.iAlarm)
                                                            {
                                                            case CurrentAlarm.I_Normal: C.State = "正常";
                                                                break;

                                                            case CurrentAlarm.IO_Nmatch_CIR: C.State = "接触器断路";
                                                                break;

                                                            case CurrentAlarm.IO_Nmatch_SW: C.State = "接触器吸合";
                                                                break;

                                                            case CurrentAlarm.IO_Nmatch_All: C.State = "回路开路";
                                                                break;

                                                            case CurrentAlarm.INO_Nmatch_CIR: C.State = "接触器未释放";
                                                                break;

                                                            case CurrentAlarm.INO_Nmatch_SW: C.State = "辅助触点故障";
                                                                break;

                                                            case CurrentAlarm.INO_Nmatch_All: C.State = "异常有电流";
                                                                break;

                                                            case CurrentAlarm.INO_OverUpper: C.State = "电流越上限";
                                                                break;

                                                            case CurrentAlarm.INO_OverLower: C.State = "电流越下限";
                                                                break;

                                                            default:
                                                                break;
                                                            }
                                                        }
                                                        if (item.iVoltType != null)
                                                        {
                                                            switch ((VoltageType)item.iVoltType)
                                                            {
                                                            case VoltageType.A: C.Phase = "A"; break;

                                                            case VoltageType.B: C.Phase = "B"; break;

                                                            case VoltageType.C: C.Phase = "C"; break;

                                                            default:
                                                                break;
                                                            }
                                                        }
                                                        if (item.iID <= 12)
                                                        {
                                                            A.OneCircuitList.CircuitList.Add(C);
                                                        }
                                                        else if (item.iID <= 24)
                                                        {
                                                            A.TwoCircuitList.CircuitList.Add(C);
                                                        }
                                                        else
                                                        {
                                                            A.ThreeCircuitList.CircuitList.Add(C);
                                                        }
                                                    }
                                                    //else
                                                    //{
                                                    //    //功率电流为null
                                                    //}
                                                }
                                                //else
                                                //{
                                                //    //item.id为null
                                                //}
                                            }
                                        }
                                        //else
                                        //{
                                        //    //回路表为空
                                        //}
                                    }
                                    //else
                                    //{
                                    //    //查询到的测量板信息为空
                                    //}
                                }
                                return(View(A));
                            }
                            else
                            {
                                //测量板个数为空
                                A.Name = "测量板个数为空";
                                return(View(A));
                            }
                        }
                        else
                        {
                            //测量板配置表为空
                            A.Name = "测量板配置表为空";
                            return(View(A));
                        }
                    }
                    else
                    {
                        //主机未找到
                        A.Name = "未找到该主机";
                        return(View(A));
                    }
                }
                catch
                {
                    //发生异常
                    A.Name = "异常错误";
                    return(View(A));
                }

            default:
                A.Name = "传输错误";
                return(View(A));
            }
        }
Example #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(LumluxSSYDB.Model.tMeasurePowerInfoes model)
 {
     return(dal.Add(model));
 }