public TimeInfoOneQueryVm(int areaId, VSluTimeScheme.VSluTimeSchemeItem info, VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne ctrls)
            : base(areaId, info)
        {
            if (info.SluTimePlanInfo.IsNotUsed)
            {
                Status = "停用";
            }
            else
            {
                Status = "使用";
            }

            if (ctrls.OperatorType == 101)
            {
                CtrlInfos = "无操作";
            }
            if (ctrls.OperatorType == 1)
            {
                CtrlInfos = "全部节点";
            }

            if (ctrls.OperatorType == 2)
            {
                CtrlInfos = "分组:";

                foreach (var g in ctrls.CtrlOrGrp)
                {
                    CtrlInfos += g + "  ";
                }
            }
            if (ctrls.OperatorType == 3)
            {
                CtrlInfos = "控制器:";

                foreach (var g in ctrls.CtrlOrGrp)
                {
                    CtrlInfos += g + "  ";
                }
            }
        }
Esempio n. 2
0
        public TimeInfoOneVm(int areaId, VSluTimeScheme.VSluTimeSchemeItem info)
        {
            CmdPwmValueStrs = "0%";
            UsedSluCount    = info.SluCtrls.Count;
            //this.SchemeDesc = info.SchemeDesc;
            this.SchemeId   = info.SchemeId;
            this.SchemeName = info.SluTimePlanInfo.SchemeName;
            this.CmdType    = info.SluTimePlanInfo.CmdType;
            //this.IsSluOrCtrlScheme = info.IsSluOrCtrlScheme;
            this.IsNotUsed = info.SluTimePlanInfo.IsNotUsed;

            //this.OperationArgu = info.OperationArgu;

            if (LightUsedRtuIdColl.Count > 0)
            {
                CurrentSelectLightUsedRtuId = LightUsedRtuIdColl[0];
            }
            foreach (var g in LightUsedRtuIdColl)
            {
                if (g.Value == info.SluTimePlanInfo.LightUsedRtuId)
                {
                    CurrentSelectLightUsedRtuId = g;
                    break;
                }
            }

            this.OperationMethod = info.SluTimePlanInfo.OperationMethod == 3 ? 11 : info.SluTimePlanInfo.OperationMethod;
            if (info.SluTimePlanInfo.OperationMethod == 1)
            {
                this.OperationArguHour   = info.SluTimePlanInfo.OperationArgu / 60;
                this.OperationArguMinute = info.SluTimePlanInfo.OperationArgu % 60;
            }
            if (info.SluTimePlanInfo.OperationMethod == 2)
            {
                this.OperationArguOffset = info.SluTimePlanInfo.OperationArgu;
            }
            //if (info.OperationMethod == 12)
            //{
            //    this.OperationArguOffset = info.OperationArgu;
            //}
            if (info.SluTimePlanInfo.OperationMethod == 3)
            {
                this.OperationArguLightStart = info.SluTimePlanInfo.OperationArgu / 10000;

                this.OperationArguLightEnd = info.SluTimePlanInfo.OperationArgu % 10000;
            }

            //this.OperationOrder = info.SluTimePlanInfo.OperationOrder + 1;
            this.LightEndEffectHour   = info.SluTimePlanInfo.LightEndEffect / 60;
            this.LightEndEffectMinute = info.SluTimePlanInfo.LightEndEffect % 60;

            this.LightStartEffectHour   = info.SluTimePlanInfo.LightStartEffect / 60;
            this.LightStartEffectMinute = info.SluTimePlanInfo.LightStartEffect % 60;

            //this.LightEndEffect = info.LightEndEffect;
            //this.LightStartEffect = info.LightStartEffect;
            // this.LightUsedRtuId = info.LightUsedRtuId;
            foreach (var g in this.OperationWeekSet)
            {
                if (info.SluTimePlanInfo.OperationWeekSet.Contains(g.Value))
                {
                    g.IsSelected = true;
                }
                else
                {
                    g.IsSelected = false;
                }
            }

            if (info.SluTimePlanInfo.CmdMix.Count > 3)
            {
                CmdMix1 = info.SluTimePlanInfo.CmdMix[0] + 1;
                CmdMix2 = info.SluTimePlanInfo.CmdMix[1] + 1;
                CmdMix3 = info.SluTimePlanInfo.CmdMix[2] + 1;
                CmdMix4 = info.SluTimePlanInfo.CmdMix[3] + 1;
            }



            CmdPwmValue = info.SluTimePlanInfo.CmdPwmScaleValue;


            for (int i = 0; i < 4; i++)
            {
                CmdPwmSel[i].IsSelected = info.SluTimePlanInfo.CmdPwmScale.Contains(i + 1);
            }

            if (info.SluTimePlanInfo.OperationMethod == 2 && info.SluTimePlanInfo.CmdType == 4)
            {
                bool openlight  = false;
                bool closelight = false;
                foreach (var g in info.SluTimePlanInfo.CmdMix)
                {
                    if (g == 4)
                    {
                        closelight = true;
                    }
                    if (g == 1 || g == 2 || g == 3)
                    {
                        openlight = true;
                    }
                }
                if (openlight == closelight)
                {
                    this.OperationMethod = 2;
                }
                else
                {
                    if (openlight)
                    {
                        this.OperationMethod = 2;
                    }
                    else
                    {
                        this.OperationMethod = 12;
                    }
                }
            }


            OnChanged();


            Ctrls = new Dictionary <int, VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne>();
            var tu = new Tuple <int, int>(areaId, info.SchemeId);//lvfff

            foreach (
                var t in TimeInfos.MySelf.Info[tu].SluCtrls)   //var tu = new Tuple<int, int>(AreaId , g.GrpId);
            {
                var para = SluSglFieldGrpHold.MySlef.Get(t.VSluId);
                //if (Ctrls.ContainsKey(t.VSluId)) Ctrls[t.VSluId] = t;

                if (t.OperatorType == 3)
                {
                    var sluCtrl = new VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne()
                    {
                        VSluId = t.VSluId, OperatorType = 4, CtrlOrGrp = new List <int>()
                    };
                    var xx = t.CtrlOrGrp.ToList();
                    if (Ctrls.ContainsKey(t.VSluId))
                    {
                        xx.AddRange(Ctrls[t.VSluId].CtrlOrGrp);
                    }
                    sluCtrl.CtrlOrGrp = xx;
                    Ctrls[t.VSluId]   = sluCtrl;
                }
                else if (t.OperatorType == 2)
                {
                    foreach (var f in para)
                    {
                        var sluCtrl = new VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne()
                        {
                            VSluId = t.VSluId, OperatorType = 4, CtrlOrGrp = new List <int>()
                        };
                        if (t.CtrlOrGrp.Contains(f.GrpId))
                        {
                            sluCtrl.CtrlOrGrp.AddRange(f.CtrlLst);
                            if (Ctrls.ContainsKey(t.VSluId))
                            {
                                sluCtrl.CtrlOrGrp.AddRange(Ctrls[t.VSluId].CtrlOrGrp);
                            }
                            Ctrls[t.VSluId] = sluCtrl;
                        }
                    }
                }
                else if (t.OperatorType == 1)
                {
                    Ctrls[t.VSluId] = t;
                }
            }
            UsedSluCount = Ctrls.Count;
            UpdateOperatorAboutTime();
        }
Esempio n. 3
0
        public VSluTimeScheme.VSluTimeSchemeItem BackToSluTimeSchemeOne()
        {
            var infof = new VSluTimeScheme.VSluTimeSchemeItem()
            {
                SluTimePlanInfo = new VSluTimeScheme.VSluTimeSchemeItem.VSluTimePlan()
                {
                    CmdType          = this.CmdType,
                    LightEndEffect   = LightEndEffectHour * 60 + LightEndEffectMinute,
                    LightStartEffect = LightStartEffectHour * 60 + LightStartEffectMinute,
                    LightUsedRtuId   =
                        CurrentSelectLightUsedRtuId == null ? 0 : CurrentSelectLightUsedRtuId.Value,
                    //OperationOrder = OperationOrder - 1,
                    CmdMix           = new List <int>(),
                    CmdPwmScale      = new List <int>(),
                    OperationWeekSet = new List <int>(),
                    OperationArgu    = 0,
                    OperationMethod  = OperationMethod
                },
                //IsSluOrCtrlScheme = IsSluOrCtrlScheme,
                //Nindex = 0,
                // SluCtrls =Ctrls ,
                //SchemeName = SchemeName,
                //SchemeDesc = SchemeDesc,
                SchemeId = SchemeId,
                //SchemeDescSec = "",
                //IsNotUsed =this .IsNotUsed ,
                SluCtrls = new List <VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne>(),
            };

            infof.SluTimePlanInfo.SchemeName = SchemeName;
            infof.SluTimePlanInfo.IsNotUsed  = IsNotUsed;
            if (OperationMethod == 12)
            {
                infof.SluTimePlanInfo.OperationMethod = 2;
            }
            infof.SluTimePlanInfo.CmdMix.Add(CmdMix1 - 1);
            infof.SluTimePlanInfo.CmdMix.Add(CmdMix2 - 1);
            infof.SluTimePlanInfo.CmdMix.Add(CmdMix3 - 1);
            infof.SluTimePlanInfo.CmdMix.Add(CmdMix4 - 1);
            //   int pwmvalue = CmdPwmValue - 1;
            foreach (var g in CmdPwmSel)
            {
                if (g.IsSelected)
                {
                    infof.SluTimePlanInfo.CmdPwmScale.Add(g.Value);
                }
            }
            infof.SluTimePlanInfo.CmdPwmScaleValue = CmdPwmValue;

            foreach (var g in OperationWeekSet)
            {
                if (g.IsSelected)
                {
                    infof.SluTimePlanInfo.OperationWeekSet.Add(g.Value);
                }
            }
            if (OperationMethod == 1)
            {
                infof.SluTimePlanInfo.OperationArgu = OperationArguHour * 60 + OperationArguMinute;
            }
            if (OperationMethod == 2 || OperationMethod == 12)
            {
                infof.SluTimePlanInfo.OperationArgu = OperationArguOffset;
            }
            if (OperationMethod == 11)
            {
                infof.SluTimePlanInfo.OperationMethod = 3;
                infof.SluTimePlanInfo.OperationArgu   = OperationArguLightStart * 10000 + OperationArguLightEnd;
            }

            //分组或终端
            foreach (var g in Ctrls)
            {
                if (g.Value.OperatorType == 1)
                {
                    infof.SluCtrls.Add(g.Value);
                    continue;
                }
                var sluCtrl1 = new VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne {
                    VSluId = g.Key, OperatorType = 2, CtrlOrGrp = new List <int>()
                };
                var sluCtrl2 = new VSluTimeScheme.VSluTimeSchemeItem.VSluTimeCtrlSluOne {
                    VSluId = g.Key, OperatorType = 3, CtrlOrGrp = new List <int>()
                };
                var para = SluSglFieldGrpHold.MySlef.Get(g.Key);
                foreach (var t in para)
                {
                    var i = 0;
                    foreach (var f in t.CtrlLst)
                    {
                        if (g.Value.CtrlOrGrp.Contains(f))
                        {
                            i++;
                        }
                    }
                    if (i == t.CtrlLst.Count)
                    {
                        sluCtrl1.CtrlOrGrp.Add(t.GrpId);
                        foreach (var f in t.CtrlLst)
                        {
                            g.Value.CtrlOrGrp.Remove(f);
                        }
                    }
                }
                sluCtrl2.CtrlOrGrp.AddRange(g.Value.CtrlOrGrp);
                if (sluCtrl1.CtrlOrGrp.Count != 0)
                {
                    infof.SluCtrls.Add(sluCtrl1);
                }
                if (sluCtrl2.CtrlOrGrp.Count != 0)
                {
                    infof.SluCtrls.Add(sluCtrl2);
                }
                //infof.SluCtrls.Add(g.Value);
            }


            return(infof);
        }