Exemplo n.º 1
0
        /// <summary>
        /// 更新某一ETV当前位置
        /// </summary>
        public override void UpdateDeviceStatus(CarLocationPanelLib.PushService.CDeviceStatusDto deviceStatus)
        {
            Label lblTV = m_lLblETVEquip.Find(s => s.Name == deviceStatus.devicecode.ToString());

            if (null == lblTV)
            {
                return;
            }
            QueryServiceClient proxy = new QueryServiceClient();
            List <CarLocationPanelLib.QueryService.CDeviceFaultDto> lstDeviceFault = proxy.GetDeviceFault(m_wareHouse, deviceStatus.devicecode, string.Empty);

            lstDeviceFault = lstDeviceFault.FindAll(s => s.color == 1);
            proxy.Close();
            if (0 < lstDeviceFault.Count)
            {
                lblTV.BackColor = Color.Red;
            }
            else
            {
                // 正在作业ETV颜色为蓝色、不可用/不可接受指令为黄色、正常绿色
                SetDeviceBackColor(lblTV, deviceStatus);
            }

            #region 根据当前库车位信息设置ETV设备位置
            // 根据当前库车位信息列表设置车位状态
            string strAddr = deviceStatus.deviceaddr;

            DataGridView     dgv  = null;
            DataGridViewCell cell = null;
            GetDgvcIndexByAddr(strAddr, ref dgv, ref cell);
            if (null == dgv || null == cell)
            {
                return;
            }
            // 获取当前单元格相对位置
            int nX = dgv.Location.X;
            int nY = dgv.Location.Y;
            for (int i = 0; i < cell.ColumnIndex && i < dgv.ColumnCount; i++)
            {
                nX += dgv.Columns[i].Width;
            }

            for (int i = 0; i < cell.RowIndex && i < dgv.RowCount; i++)
            {
                nY += dgv.Rows[i].Height;
            }
            // 设置ETV位置
            lblTV.BeginInvoke(new beginInvokeDelegate(SetETVLocation), lblTV, nX, nY);
            #endregion
        }
        /// <summary>
        /// 更新某一设备是否可用状态值
        /// </summary>
        public void UpdateDeviceIsable(CarLocationPanelLib.PushService.CDeviceStatusDto deviceStatus)
        {
            if (null == deviceStatus)
            {
                return;
            }
            int    nDeviceID = deviceStatus.devicecode;
            string strTag    = deviceStatus.warehouse + "-" + nDeviceID;

            foreach (DataGridViewRow dgvr in DgvDeviceStatus.Rows)
            {
                if (null == dgvr || null == dgvr.Tag || dgvr.Tag.ToString() != nDeviceID.ToString())
                {// 行:设备号
                    continue;
                }
                bool isBreak = false;
                foreach (DataGridViewCell dgvc in dgvr.Cells)
                {
                    // 根据当前库车位信息列表设置车位状态
                    if (null == dgvc || null == dgvc.Tag)
                    {
                        continue;
                    }

                    if (null != deviceStatus.isable && strTag == dgvc.Tag.ToString())
                    {// 赋值单元格
                        if (0 != deviceStatus.isable)
                        {
                            dgvc.Value = "可用";
                        }
                        else
                        {
                            dgvc.Value = "不可用";
                        }
                        isBreak = true;
                        break;
                    }
                }

                if (isBreak)
                {
                    break;
                }
            }
        }