Exemple #1
0
 private void UpdateAGVStatus(AGVTemp agvCar)
 {
     IEnumerable<AGVCar> member = AGVStatus.Where<AGVCar>(p => p.AGVNum == agvCar.AGVNum);
     int listindex;
     if (member.Count() == 0)
     {
         //WorklineNum避免异步,Add的时间过长,进入一个掉线的数据,界面出现new AGVCar()错误数据
         if (agvCar.AGVNum > 0 && agvCar.WorklineNum > 0)
         {
             AGVStatus.Add(new AGVCar());
             listindex = AGVStatus.Count - 1;
         }
         else
         {
             return;
         }
     }
     else
     {
         AGVCar member1 = member.First<AGVCar>();
         listindex = AGVStatus.IndexOf(member1);
     }
     if (agvCar.WlLinkCount > 0)
     {
         AGVStatus[listindex].WlLinkCount += agvCar.WlLinkCount;//+1
         if (AGVStatus[listindex].WlLinkCount > 5)
         {
             //第一次断线时,连接失败,更新交通管制参数,如果在交通管制区则出交通管制区
             AGVStatus[listindex].MarkNum = 0;
             AGVStatus[listindex].DockNum = 0;
             AGVStatus[listindex].LineNum = 0;
             if (agvTrafficList != null)
             {
                 TrafficRetParam retparam = agvTrafficList.UpdateTraffic(AGVStatus[listindex].WlLink, AGVStatus[listindex].AGVNum,
                     AGVStatus[listindex].TrafficNum, AGVStatus[listindex].WorklineNum, AGVStatus[listindex].MarkNum);
                 AGVStatus[listindex].TrafficNum = retparam.trafficNum;
                 AGVStatus[listindex].TrafficStatus = retparam.trafficResult;
             }
             data_total[agvCar.AGVNum - 1] = 0x00;
             AGVStatus[listindex].WlLink = AGVWLLINK_ERROR;//一定放在最后,先更新了管制区,然后再删除
         }
         return;
     }
     AGVStatus[listindex].WorklineNum = agvCar.WorklineNum;
     AGVStatus[listindex].DockNum = agvCar.DockNum;
     AGVStatus[listindex].AGVNum = agvCar.AGVNum;
     AGVStatus[listindex].TrafficNum = agvCar.TrafficNum;
     AGVStatus[listindex].TrafficStatus = agvCar.TrafficStatus;
     AGVStatus[listindex].LineNum = agvCar.LineNum;
     AGVStatus[listindex].MarkFunction = agvCar.MarkFunction;
     AGVStatus[listindex].AGVSpeed = agvCar.AGVSpeed;
     AGVStatus[listindex].MarkNum = agvCar.MarkNum;
     AGVStatus[listindex].AGVPower = agvCar.AGVPower;
     AGVStatus[listindex].AGVCharge = agvCar.AGVCharge;
     AGVStatus[listindex].WlLinkCount = agvCar.WlLinkCount;
     AGVStatus[listindex].WlLink = agvCar.WlLink;
     AGVStatus[listindex].AGVStatus = agvCar.AGVStatus;
 }
Exemple #2
0
 private AGVTemp DrvWlCon_AgvStatus(byte[] buf)  //更新AGV运行参数
 {
     lock (syncRoot)
     {
         AGVTemp agvCar = new AGVTemp();
         byte SpeedGrade = 0;
         int bMarkNum = 0;
         byte AgvNum = buf[2];  //得到AGV编号,编号从0x01开始
         if (AgvNum > AGVNUM_MAX || AgvNum < 1)
         {
             return null;//AGV编号错误
         }
         if (DrvWlConCheck(buf, buf.Length - 2) == VERIFY_NOERROR)  //校验无错
         {
             agvCar.WorklineNum = DrvWlConWorkLineInit(AgvNum);
             agvCar.WlLinkCount = 0;
             //由于生产区在运行过程中不会改变,故将此放置在AGV的初始化中,不需要每次更新
             agvCar.AGVNum = AgvNum;
             //修改说明:地标号扩展两位,速度等级的bit8,bit7作为地标号的bit9,bit10
             bMarkNum = buf[3] | ((buf[7] & 0xC0) << 2);
             if (bMarkNum > 0)
             {
                 //当前AGV运行路线
                 agvCar.LineNum = buf[6];
                 //当前地标功能
                 if (buf[4] > 0 && buf[4] < MarkFuncOpt.Length)
                 {
                     agvCar.MarkFunction = buf[4];
                 }
                 //当前AGV运行速度等级,不会接收到保持现状的0
                 //修改时间:2013-11-28
                 //修改说明:屏蔽速度等级的bit8,bit7
                 SpeedGrade = Convert.ToByte(buf[7] & 0x3F);
                 if (SpeedGrade > 0 && SpeedGrade < SpeedOpt.Count)
                 {
                     agvCar.AGVSpeed = SpeedGrade;
                 }
                 agvCar.MarkNum = bMarkNum;
                 //AGV当前剩余电量
                 if (buf[8] > 0 && buf[8] <= 100)
                 {
                     agvCar.AGVPower = buf[8];
                 }
             }
             //无线连接正常
             agvCar.WlLink = AGVWLLINK_OK;
             //当前AGV状态,由于接收到数据不是按照顺序,中间有间隔,在使用时才验证数据正确性 
             agvCar.AGVStatus = buf[5];
         }
         else
         {
             agvCar.AGVNum = AgvNum;
             agvCar.WlLinkCount = 1;
         }
         return agvCar;
     }
 }