Beispiel #1
0
        public void GetMeasurementRange(EnumChannel CH)
        {
            var ret = Read(string.Format("AUTO_{0}?", CH));

            if (ret == "1")
            {
                MetaProperties[(int)CH].Range = EnumRange.AUTO;
            }
            else if (ret == "0")
            {
                ret = Read(string.Format("RANGE_{0}?", CH));
                if (int.TryParse(ret, out int range))
                {
                    MetaProperties[(int)CH].Range = (EnumRange)range;
                }
                else
                {
                    throw new FormatException(string.Format("the format of the response of RANGE request is error"));
                }
            }
            else
            {
                throw new FormatException(string.Format("the format of the response of AUTO request is error"));
            }
        }
 public void CloseChannelLight(EnumChannel Channel)
 {
     ExcuteCmd(new CommandCloseLight()
     {
         Channel = Channel
     }, out RxPackage pkg);
 }
 public void WriteValue(EnumChannel Channel, UInt16 Value)
 {
     ExcuteCmd(new CommandWriteValue()
     {
         Channel = Channel,
         Value   = Value,
     }, out RxPackage pkg);
 }
 public void OpenChannelLight(EnumChannel Channel, UInt16 InitValue)
 {
     ExcuteCmd(new CommandOpenLight()
     {
         Value   = InitValue,
         Channel = Channel
     }, out RxPackage pkg);
 }
        public UInt16 ReadValue(EnumChannel channel)
        {
            var Cmd = new CommandReadValue()
            {
                Channel = channel,
            };

            ExcuteCmd(Cmd, out RxPackage pkg);
            return(Cmd.QChannelValue);
        }
Beispiel #6
0
        public void SetMeasurementRange(EnumChannel CH, EnumRange Range)
        {
            if (Range == EnumRange.AUTO)
            {
                Send(string.Format("AUTO_{0} 1", CH));
            }
            else
            {
                Send(string.Format("RANGE_{0} {1}", CH, (int)Range));
            }

            MetaProperties[(int)CH].Range = Range;
        }
Beispiel #7
0
        public void SetUnit(EnumChannel CH, EnumUnits Unit)
        {
            if (Unit == EnumUnits.W_cm)
            {
                Send(string.Format("UNITS_{0} \"W/cm\"", CH));
            }
            else
            {
                Send(string.Format("UNITS_{0} \"{1}\"", CH, Unit));
            }

            MetaProperties[(int)CH].Unit = Unit;
        }
Beispiel #8
0
        public void GetLambda(EnumChannel CH)
        {
            var ret = Read(string.Format("LAMBDA_{0}?", CH));

            if (int.TryParse(ret, out int lambda))
            {
                MetaProperties[(int)CH].Lambda = lambda;
            }
            else
            {
                throw new FormatException(string.Format("the format of the response of LAMBDA request is error"));
            }
        }
        public async Task <PageResultModel <Letter> > GetNoSortingLetters(EnumChannel channel)
        {
            var letters = from letter in _dbContext.Letters
                          join sorting in _dbContext.Sortings on letter.BarcodeNo equals sorting.BarcodeNo
                          where sorting.Sorted == false && sorting.Channel == channel
                          select letter;

            return(new PageResultModel <Letter>
            {
                Rows = await letters.Include(a => a.SendDepartment).Include(a => a.ReceiveDepartment).ToListAsync(),
                Total = await letters.CountAsync()
            });
        }
Beispiel #10
0
        /// <summary>
        /// 获取箱号(初始订单创建)
        /// </summary>
        /// <param name="token"></param>
        private static void ProcessChannelOrder(CancellationToken token)
        {
            ChannelController      ch            = ChannelController.Instance;
            InputQueueCaseNum      que           = new InputQueueCaseNum();
            OrderMessageInputQueue orderOkQueue  = new OrderMessageInputQueue(EnumChannel.正常道口);
            OrderMessageInputQueue orderErrQueue = new OrderMessageInputQueue(EnumChannel.异常道口);

            NLog.Logger logger = NLog.LogManager.GetLogger("ProcessChannelOrder");
            while (!token.IsCancellationRequested)
            {//获取箱号
                InputMessageCaseNum msg = que.Receive();
                string _info            = "获取箱号:" + msg.boxId + " 订单:" + msg.orderId;
                logger.Info(_info);

                string      orderId       = msg.orderId;
                EnumChannel targetChannel = EnumChannel.异常道口;

                if (orderId != null && orderId.StartsWith("D"))
                {     //订单有效,且为正常订单
                    if (DbHelper.OrderIsFinished(orderId))
                    { //订单已完成,则返回失败
                        targetChannel = EnumChannel.异常道口;
                    }
                    else
                    {
                        targetChannel = EnumChannel.正常道口; //1. 发送订单消息
                    }
                }
                //   流水线发送目标通道
                ch.SendToChannel(targetChannel);
                //接受成功才设置这个值
                //DbHelper.SetOrderRealChannel(orderId, targetChannel);

                //发送订单队列
                if (targetChannel == EnumChannel.正常道口)
                {
                    orderOkQueue.Send(new OrderMessage()
                    {
                        orderId = orderId
                    });
                }
                else
                {
                    //2. 否,不创建任务订单ID
                    orderErrQueue.Send(new OrderMessage()
                    {
                        orderId = orderId
                    });
                }
            }
        }
Beispiel #11
0
        public void GetUnit(EnumChannel CH)
        {
            var ret = Read(string.Format("UNITS_{0}?", CH));

            ret = ret.Replace("\\", "").Replace("\"", "");
            if (ret == "W/cm")
            {
                MetaProperties[(int)CH].Unit = EnumUnits.W_cm;
            }
            else
            {
                MetaProperties[(int)CH].Unit = (EnumUnits)Enum.Parse(typeof(EnumUnits), ret);
            }
        }
Beispiel #12
0
        public void ResetCount(EnumChannel channel)
        {
            switch (channel)
            {
            case EnumChannel.正常道口:
                CountOkArrived = new ChannelCount();
                CountOkTake    = new ChannelCount();
                client.WriteAndCheckResponse("AT+CLEAROKCHA");
                break;

            case EnumChannel.异常道口:
                CountErr = new ChannelCount();
                client.WriteAndCheckResponse("AT+CLEARERCHA");
                break;
            }
        }
Beispiel #13
0
        public async Task <ResultEntity> CreateSortingList(EnumChannel channel, List <int> letterIds, int userId)
        {
            var result  = new ResultEntity();
            var letters = await _letterRepository.GetQueryable().Where(a => letterIds.Contains(a.Id)).ToListAsync();

            var sortings = _sortingRepository.GetQueryable().Where(a => letters.Any(b => b.BarcodeNo == a.BarcodeNo));

            foreach (var sorting in sortings)
            {
                sorting.Sorted = true;
            }

            var serialNumber = await _serialNumberManager.GetSerialNumber(0, EnumSerialNumberType.分拣);

            var sortingList = new SortingList
            {
                Channel    = channel,
                ListNo     = DateTime.Now.Year + serialNumber.ToString("00000000"),
                CreateBy   = userId,
                CreateTime = DateTime.Now
            };
            await _sortingListRepository.AddAsync(sortingList);

            foreach (var letterId in letterIds)
            {
                var listDetail = new SortingListDetail
                {
                    LetterId    = letterId,
                    SortingList = sortingList
                };
                await _sortingListDetailRepository.AddAsync(listDetail);

                //将事务提交上移,应对保存顺序不规则,最好是添加序号字段,暂时这么改
                await _unitOfWork.CommitAsync();
            }

            result.Success = true;
            result.Data    = sortingList.Id;

            return(result);
        }
Beispiel #14
0
        bool Send(EnumChannel channel, int timeout)
        {
            string cmd = "";

            switch (channel)
            {
            case EnumChannel.正常道口:
                cmd = string.Format("AT+TOOKCHA_{0:00000}", CountSendOK);
                OnOkUpdate.BeginInvoke(null, null, null, null);
                break;

            case EnumChannel.异常道口:
                cmd = string.Format("AT+TOERCHA_{0:00000}", CountSendErr);
                OnErrUpdate.BeginInvoke(null, null, null, null);
                break;

            default:
                cmd = string.Format("AT+TOOKCHA_{0:00000}", CountSendOK);
                break;
            }
            return(client.WriteAndCheckResponse(cmd));
        }
Beispiel #15
0
        public ErrorCode SendToChannel(EnumChannel channelId)
        {
            if (this.client == null)
            {
                return(ErrorCode.通道控制_设备离线);
            }
            switch (channelId)
            {
            case EnumChannel.异常道口:
                CountSendErr++;
                if (OnErrUpdate != null)
                {
                    OnErrUpdate.BeginInvoke(null, null, null, null);
                }
                break;

            case EnumChannel.正常道口:
                CountSendOK++;
                if (OnOkUpdate != null)
                {
                    OnOkUpdate.BeginInvoke(null, null, null, null);
                }
                break;
            }
            int retry = 3;

            while (!Send(channelId, 2000))
            {
                retry--;
                if (retry == 0)
                {
                    //3次重发超时异常
                    NLog.LogManager.GetCurrentClassLogger().Error(string.Format("Channel({0}) Retry Send 3 Times Failed", channelId));
                    return(ErrorCode.通道控制_重试3次后发送失败或超时未收到应答);
                }
            }

            return(ErrorCode.成功);
        }
Beispiel #16
0
 public OrderMessageInputQueue(EnumChannel channel)
     : base(string.Format(@".\Private$\LXS.PCService.OrderMessageInputQueue_{0}", channel.ToString("D")))
 {
 }
Beispiel #17
0
 public static void SetOrderRealChannel(int orderId, EnumChannel channel)
 {
 }
Beispiel #18
0
        private static void ProcessOrderMain(CancellationToken token)
        {
            BoxInChannelInputQueue boxQueue        = new BoxInChannelInputQueue();
            LightMessageQueue      lightRedQueue   = new LightMessageQueue(LightColor.RED.ToString("D"));
            LightMessageQueue      lightGreenQueue = new LightMessageQueue(LightColor.GREEN.ToString("D"));

            LightManager lightManager = LightManager.Instance;

            NLog.Logger logger    = NLog.LogManager.GetLogger("ProcessOrderMain");
            LightColor  nextColor = LightColor.RED;

            while (!token.IsCancellationRequested)
            {
                //等待货物到达道口
                BoxInChannelMessage msg = boxQueue.Receive();
                string      orderId     = msg.orderId;
                EnumChannel channelId   = DbHelper.GetCurrentOrderChannel(orderId);
                if ((int)channelId != msg.channelId)
                {//当前到达通道与期望目标不一致,货物走错通道!
                    string _err = string.Format("货物到达通道与目标不一致! 到达通道:{0},目标通道:{1}", msg.channelId, (int)channelId);
                    logger.Error(_err);
                }



                // 是否正常道口
                if (msg.channelId == (int)EnumChannel.正常道口)
                {
                    //绑定并获取灯ID
                    //绑定09-灯表
                    int?lightId = DbHelper.GetBindedLightByOrder(orderId, ref nextColor);
                    if (null == lightId)
                    {
                        logger.Error("数据库中无可用的灯!");
                    }
                    else
                    {
                        //设置当前灯为占用状态
                        DbHelper.SetLightOccupied((int)lightId);
                        LightColor color = DbHelper.GetLightColor((int)lightId);
                        //将lightId发送到灯消息队列
                        switch (color)
                        {
                        case LightColor.RED:
                            lightRedQueue.Send(new LightMessage()
                            {
                                orderId = orderId, lightId = (int)lightId
                            });
                            nextColor = LightColor.GREEN;
                            break;

                        case LightColor.GREEN:
                            lightGreenQueue.Send(new LightMessage()
                            {
                                orderId = orderId, lightId = (int)lightId
                            });
                            nextColor = LightColor.RED;
                            break;
                        }
                    }
                }
                else
                {//异常道口,货物到达
                    DbHelper.SetOrderState(msg.orderId, (int)OrderState.已完成);
                }
            }
        }
Beispiel #19
0
        public async Task <PageResultModel <LetterSortingDto> > GetNoSortingLetters(EnumChannel channel)
        {
            var letters = await _letterRepository.GetNoSortingLetters(channel);

            return(Mapper.Map <PageResultModel <LetterSortingDto> >(letters));
        }
Beispiel #20
0
 public void SetLambda(EnumChannel CH, int Lambda)
 {
     Send(string.Format("LAMBDA_{0} {1}", CH, Lambda));
     MetaProperties[(int)CH].Lambda = Lambda;
 }
Beispiel #21
0
 public void SetDisplayChannel(EnumChannel CH)
 {
     ActiveChannel = (int)CH;
     Send(string.Format("DISPCH {0}", CH));
 }
 /// <summary>
 /// 设置订单货物实际到达的道口
 /// </summary>
 /// <param name="orderId">订单</param>
 /// <param name="channel">通道编号</param>
 public static void SetOrderRealChannel(string orderId, EnumChannel channel)
 {
 }