Пример #1
0
 /// <summary>
 /// 从信号机取得所有的配时方案信息。
 /// </summary>
 /// <returns></returns>
 public static List<Pattern> GetPattern()
 {
     TscData td = (TscData)Application.Current.Properties[Define.TSC_DATA];
     byte[] byt = Udp.recvUdp(td.Node.sIpAddress, Define.GBT_PORT, Define.GET_PATTERN);
     if (!CheckGBT(byt, "配时方案"))
     {
         return null;
     }
     List<Pattern> listPattern = new List<Pattern>();
     //取得)
     byte[] arrayPattern = new byte[Convert.ToInt32(byt[3]) * Define.PATTERN_BYTE_SIZE];
     Array.Copy(byt, 4, arrayPattern, 0, Convert.ToInt32(byt[3]) * Define.PATTERN_BYTE_SIZE);
     byte[,] twoArray = ByteUtils.oneArray2TwoArray(arrayPattern, Convert.ToInt32(byt[3]), Define.PATTERN_BYTE_SIZE);
     Pattern obj;
     for (int i = 0; i < Convert.ToInt32(byt[3]); i++)
     {
         obj = new Pattern();
         obj.ucPatternId = twoArray[i, 0];
         obj.ucCycleTime = twoArray[i, 1];
         obj.ucOffset = twoArray[i, 2];
         obj.ucCoorPhase = twoArray[i, 3];
         obj.ucStagePatternId = twoArray[i, 4];
         listPattern.Add(obj);
     }
     return listPattern;
 }
Пример #2
0
        private void setPatternAndStagePattern(List<Pattern> lp ,List<StagePattern> lsp , StageItem currentStage,PhaseToDirec ptd)
        {
            //半断是新增加stage还是,老的更新用的
            Pattern ptemp= null;
           // List<Pattern> lptemp = new List<Pattern>();
            bool newPattern = false;
            bool oldPattern = false;
            foreach(Pattern p in lp)
            {
               
                if (sldSchemeId.Value == p.ucPatternId )
                {
                    p.ucCoorPhase = Convert.ToByte(cbxCoordination.SelectedItem);
                    p.ucCycleTime = Convert.ToByte(tbxCycle.Text);
                    p.ucOffset = Convert.ToByte(tbxOffset.Text);
                    p.ucPatternId = Convert.ToByte(sldSchemeId.Value);
                    p.ucStagePatternId = Convert.ToByte(sldStagePatternId.Value);
                    oldPattern = true;
                    //if (sldStagePatternId.Value == p.ucStagePatternId)
                    //{
                    //    p.ucCoorPhase = Convert.ToByte(cbxCoordination.SelectedItem);
                    //    p.ucCycleTime = Convert.ToByte(tbxCycle.Text);
                    //    p.ucOffset = Convert.ToByte(tbxOffset.Text);
                    //    p.ucPatternId = Convert.ToByte(sldSchemeId.Value);
                    //    p.ucStagePatternId = Convert.ToByte(sldStagePatternId.Value);
                    //}
                    //else
                    //{
                       
                    //}
                    //p.ucPatternId = Convert.ToByte(sldSchemeId.Value);
                    //p.ucStagePatternId = Convert.ToByte(sldStagePatternId.Value);
                    //ptemp = null;
                }
                else
                {
                    newPattern = true;
                }
            
            }
            if (!oldPattern)
            {
                if (newPattern)
                {
                    ptemp = new Pattern();
                    ptemp.ucCoorPhase = Convert.ToByte(cbxCoordination.SelectedItem);
                    ptemp.ucCycleTime = Convert.ToByte(tbxCycle.Text);
                    ptemp.ucOffset = Convert.ToByte(tbxOffset.Text);
                    ptemp.ucPatternId = Convert.ToByte(sldSchemeId.Value);
                    ptemp.ucStagePatternId = Convert.ToByte(sldStagePatternId.Value);
                    lp.Add(ptemp);
                }
               
            }
            //if (!lp.Contains(ptemp))//这里主要 是,新的方案号需要增加。旧的方案,不用进行增加,
            //{
                
            //}
           
            

            foreach (StagePattern sp in lsp)
            {
                if (sp.ucStagePatternId == sldStagePatternId.Value)
                {
                    
                    if (sp.ucStageNo == Convert.ToByte(currentStage.lblNumber.Content))
                    {
                        sp.ucStagePatternId = Convert.ToByte(sldStagePatternId.Value);
                        sp.ucStageNo = Convert.ToByte(currentStage.lblNumber.Content);
                        sp.ucGreenTime = Convert.ToByte(sldGreenTime.Value);
                        sp.ucYellowTime = Convert.ToByte(sldYellowTime.Value);
                        sp.ucRedTime = Convert.ToByte(sldRedTime.Value);
                        sp.ucOption = returnReactionTrueOrFalse();
                        sp.usAllowPhase = returnAllowPhase(ptd.ucPhase, sp.usAllowPhase);
                        Console.WriteLine(sp.usAllowPhase);
                        break;
                    }
                    else if(sp.ucStageNo == 0)
                    {
                        sp.ucStagePatternId = Convert.ToByte(sldStagePatternId.Value);
                        sp.ucStageNo = Convert.ToByte(currentStage.lblNumber.Content);
                        sp.ucGreenTime = Convert.ToByte(sldGreenTime.Value);
                        sp.ucYellowTime = Convert.ToByte(sldYellowTime.Value);
                        sp.ucRedTime = Convert.ToByte(sldRedTime.Value);
                        sp.ucOption = returnReactionTrueOrFalse();
                        sp.usAllowPhase = returnAllowPhase(ptd.ucPhase, sp.usAllowPhase);
                        Console.WriteLine(sp.usAllowPhase);
                        break;
                    }
                    else
                    {
                        //MessageBox.Show("研发专用,程序异常。没有进行stage,stageNo 不为0,也不为小图上的编号\n");
                    }
                }
            }
               
        }