private string GetLocationString(UseablePeripheral periInfo, AllCOMHWBaseInfo info)
        {
            string comName = CustomTransform.GetSerialPortNameBySn(periInfo.FirstSenderSN, info);
            string strSender = "";
            CommonStaticMethod.GetLanguageString("发送卡", "Lang_Global_SendingBoard", out strSender);

            string strPort = "";
            CommonStaticMethod.GetLanguageString("网口", "Lang_Global_NetPort", out strPort);

            string strFuncCard = "";
            CommonStaticMethod.GetLanguageString("多功能卡", "Lang_Gloabal_FunctionCard", out strFuncCard);

            string strSensor = "";
            CommonStaticMethod.GetLanguageString("接口", "Lang_Gloabal_SensorIndexOnFuncCard", out strSensor);

            string strSensorInSender = "";
            CommonStaticMethod.GetLanguageString("发送卡上的光探头:", "Lang_Bright_SensorOnSender", out strSensorInSender);

            string strSensorInFunc = "";
            CommonStaticMethod.GetLanguageString("多功能卡上的光探头:", "Lang_Bright_SensorOnFuncCard", out strSensorInFunc);

            string msg = "";
            if (periInfo.SensorType == PeripheralsType.LightSensorOnFuncCardInPort)
            {
                msg = strSensorInFunc + comName + "-" + strSender + (periInfo.SenderIndex + 1) + "-" +
                    strPort + (periInfo.PortIndex + 1) + "-" +
                    strFuncCard + (periInfo.FuncCardIndex + 1) + "-" +
                    strSensor + (periInfo.SensorIndex + 1);
            }
            else
            {
                msg = strSensorInSender + comName + "-" + strSender + (periInfo.SenderIndex + 1);
            }
            return msg;
        }
 private bool CheckHaveValidScreenInfo(AllCOMHWBaseInfo allInfo)
 {
     bool isHave = false;
     if (allInfo == null || allInfo.AllInfoDict == null)
     {
         return isHave;
     }
     foreach (string key in allInfo.AllInfoDict.Keys)
     {
         OneCOMHWBaseInfo oneComInfo = allInfo.AllInfoDict[key];
         if (oneComInfo.LEDDisplayInfoList != null &&
             oneComInfo.LEDDisplayInfoList.Count != 0)
         {
             isHave = true;
             break;
         }
     }
     return isHave;
 }
        public InitialErryType Initialize()
        {
            _fLogService.Info("Mars开始硬件初始化...");
            lock (_lockCallBack)
            {
                _dicCallBack.Clear();
            }
            if (_allComBaseInfo_Bak == null)
            {
                _allComBaseInfo = new AllCOMHWBaseInfo();
                _allComBaseInfo.AllInfoDict = new SerializableDictionary<string, OneCOMHWBaseInfo>();
                OnNotifyExecResEvent(
                    TransferType.M3_UpdateLedScreenConfigInfo, string.Empty,
                    UpdateCfgFileResType.OK);
                return InitialErryType.NoServer;
            }
            else
            {
                if (_allComBaseInfo_Bak.AllInfoDict == null || _allComBaseInfo_Bak.AllInfoDict.Count == 0)
                {
                    _allComBaseInfo = new AllCOMHWBaseInfo();
                    _allComBaseInfo.AllInfoDict = new SerializableDictionary<string, OneCOMHWBaseInfo>();
                    OnNotifyExecResEvent(
                        TransferType.M3_UpdateLedScreenConfigInfo, string.Empty,
                        UpdateCfgFileResType.OK);
                    return InitialErryType.GetBaseInfoErr;
                }
            }
            _hwConfigs = new Dictionary<string, MarsHWConfig>();
            #region 初始化屏体等相关信息
            InitializeScreen(_allComBaseInfo_Bak);
            #endregion
            #region 初始化发送卡数据读取对象
            _readDviInfo = new ReadSenderDviInfo(_serverProxy);
            _readDviInfo.CompleteRefreshDviInfoEvent += new CompleteRefreshSenderDviEventHandler(ReadDviInfo_CompleteRefreshDviInfoEvent);
            _readDviInfo.CompleteRetryRefreshDviInfoEvent += _readDviInfo_CompleteRetryRefreshDviInfoEvent;
            #endregion

            #region 初始化常规监控数据读取对象
            Dictionary<string, List<ILEDDisplayInfo>> displayInfoList = new Dictionary<string, List<ILEDDisplayInfo>>();
            foreach (string key in _allComBaseInfo.AllInfoDict.Keys)
            {
                displayInfoList.Add(key, _allComBaseInfo.AllInfoDict[key].LEDDisplayInfoList);
            }
            _hwStatusMonitor = new HWStatusMonitor(_serverProxy, displayInfoList, _reduInfoList);
            _hwStatusMonitor.Initialize();
            _hwStatusMonitor.IsCycleMonitor = false;
            _hwStatusMonitor.CompleteRefreshAllCommPortEvent += new CompleteRefreshAllCommPortEventHandler(HWStatusMonitor_CompleteRefreshAllCommPortEvent);
            _hwStatusMonitor.BeginReadSBMonitorInfoEvent += _hwStatusMonitor_BeginReadSBMonitorInfoEvent;
            _hwStatusMonitor.CompleteReadSBMonitorInfoEvent += _hwStatusMonitor_CompleteReadSBMonitorInfoEvent;
            _hwStatusMonitor.CompleteRetryReadSBMonitorInfoEvent += new CompleteRefreshAllCommPortEventHandler(HWStatusMonitor_CompleteRetryReadSBMonitorInfoEvent);
            #endregion

            #region 硬件亮度配置
            _smartLightAccessor = new SmartLightDataAccessor(_serverProxy, string.Empty);
            #endregion

            #region 初始化多功能卡外设监控数据读取对象
            _funcMonitor = new FunctionCardOutDeviceMonitor(_serverProxy);
            #endregion
            _smartBright = new SmartBright(_serverProxy, _allComBaseInfo, _supportList);
            _smartBright.OutputLogEvent += _smartBright_OutputLogEvent;
            #region 初始化配置文件路径
            //InitConfigFileName();
            #endregion
            lock (_readHWObjLock)
            {
                _readHWCount = 0;
            }
            OnNotifyExecResEvent(
                        TransferType.M3_UpdateLedScreenConfigInfo, string.Empty,
                        UpdateCfgFileResType.OK);
            return InitialErryType.OK;
        }
 private void ReadallComBaseInfos()
 {
     Thread.Sleep(3000);
     AllCOMHWBaseInfo allInfo = new AllCOMHWBaseInfo();
     allInfo.AllInfoDict = new SerializableDictionary<string, OneCOMHWBaseInfo>();
     int createScreenCount = 3;
     for (int scrIndex = 0; scrIndex < createScreenCount; scrIndex++)
     {
         string scrUDID = "1306280000015920-" + scrIndex.ToString("X2");
         allInfo.AllInfoDict.Add(scrUDID, new OneCOMHWBaseInfo()
         {
             DisplayResult = CommonInfoCompeleteResult.OK,
             FirstSenderSN = "1306280000015920",
             GraphicsDviInfo = new GraphicsDVIPortInfo() { DviPortCols = 2, DviPortRows = 2, GraphicsHeight = 128, GraphicsWidth = 128 },
             LEDDisplayInfoList = new List<ILEDDisplayInfo>()
             { new StandardLEDDisplayInfo()
             { ScanBoardCols=2, ScanBoardRows=3, ScannerRegionList=new List<ScanBoardRegionInfo>()
             { new ScanBoardRegionInfo(){ ConnectIndex=0, Height=128, PortIndex=0, SenderIndex=0, Width=128, X=0, Y=0, XInPort=12, YInPort=12},
                 }}},
             ReduInfoList = new List<SenderRedundancyInfo>(),
             ReduResult = CommonInfoCompeleteResult.OK
         });
     }
     _allComBaseInfo_Bak = allInfo;
     _waitForInitCompletedMetux.Set();
 }
 private void ReadAllComBaseInfoCompleted(CompleteReadAllComHWBaseInfoParams allBaseInfo, object userToken)
 {
     _allComBaseInfo_Bak = allBaseInfo.AllInfo;
     if (_allComBaseInfo_Bak == null || _allComBaseInfo_Bak.AllInfoDict == null || _allComBaseInfo_Bak.AllInfoDict.Count == 0)
     {
         _fLogService.Debug("读取软件空间回调结果为空,因此无屏信息");
         OnNotifyScreenCfgChangedEvent(this, EventArgs.Empty);
         _reReadScreenTimer.Change(10000, 10000);
         lock (_readHWObjLock)
         {
             if (_readHWCount > 0)
             {
                 _readHWCount--;
             }
         }
         return;
     }
     else
     {
         _reReadScreenTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
         _fLogService.Debug("读取软件空间回调结果的个数:" + _allComBaseInfo_Bak.AllInfoDict.Count);
     }
     lock (_readHWObjLock)
     {
         if (_readHWCount > 0)
         {
             _readHWCount--;
         }
         if (_readHWCount == 0)
         {
             CheckAndSetScreenChanged(allBaseInfo);
         }
         else
         {
             _fLogService.Debug("由于后面又存在读取,因此本次的判断通知做废处理");
         }
     }
     //_waitForInitCompletedMetux.Set();
 }
        private void InitializeScreen(AllCOMHWBaseInfo allComBaseInfo)
        {
            _allComBaseInfo = allComBaseInfo;
            ClearScannerDic();
            if (allComBaseInfo == null || allComBaseInfo.AllInfoDict == null)
            {
                return;
            }
            string[] keys = new string[allComBaseInfo.AllInfoDict.Count];
            allComBaseInfo.AllInfoDict.Keys.CopyTo(keys, 0);
            for (int i = 0; i < keys.Length; i++)
            {
                if (allComBaseInfo.AllInfoDict[keys[i]].DisplayResult != CommonInfoCompeleteResult.OK)
                {
                    allComBaseInfo.AllInfoDict.Remove(keys[i]);
                }
            }
            _fLogService.Debug("InitializeScreen Finish Remove");
            _allMonitorData = new AllMonitorData();
            _comSenderList.Clear();
            _supportList.Clear();
            _reduInfoList.Clear();
            foreach (KeyValuePair<string, OneCOMHWBaseInfo> pair in allComBaseInfo.AllInfoDict)
            {
                string firstSenderSN = pair.Value.FirstSenderSN;
                string udid = "";
                int senderCount = -1;
                int tempCount = 0;
                for (int i = 0; i < pair.Value.LEDDisplayInfoList.Count; i++)
                {
                    List<OneScreenInSupperDisplay> list = new List<OneScreenInSupperDisplay>();
                    udid = GetScreenUdid(firstSenderSN, i);
                    ScreenModnitorData monitorData = new ScreenModnitorData(udid);
                    _allMonitorData.AllScreenMonitorCollection.Add(monitorData);
                    OneScreenInSupperDisplay oneDisplay = new OneScreenInSupperDisplay()
                    {
                        ScreenUDID = udid
                    };
                    list.Add(oneDisplay);

                    SupperDisplay supper = new SupperDisplay()
                    {
                        DisplayUDID = udid,
                        ScreenList = list
                    };
                    _supportList.Add(supper);

                    tempCount = GetCommportSenderCount(pair.Value.LEDDisplayInfoList[i]);
                    if (tempCount > senderCount)
                    {
                        senderCount = tempCount;
                    }
                    SetAutoReader(udid, pair.Key, pair.Value.LEDDisplayInfoList[i], pair.Value.ReduInfoList);
                }
                if (senderCount >= 0)
                {
                    _reduInfoList.Add(pair.Key, pair.Value.ReduInfoList);
                    _comSenderList.Add(pair.Key, senderCount + 1);
                }
            }
            _fLogService.Debug("InitializeScreen Finish _comSenderList");
            #region 获取点检标识
            if (Interlocked.Exchange(ref _isRunning, 1) == 0)
            {
                _screenPointDetectIdentify.Clear();
                string sn;
                ChipType cType;
                ChipInherentProperty chipInherentPro = new ChipInherentProperty();
                foreach (var item in allComBaseInfo.AllInfoDict)
                {
                    for (int i = 0; i < item.Value.LEDDisplayInfoList.Count; i++)
                    {
                        sn = GetScreenUdid(item.Value.FirstSenderSN, i);
                        if (_screenPointDetectIdentify.ContainsKey(sn))
                        {
                            continue;
                        }
                        cType = ReadChipType(item.Value.LEDDisplayInfoList[i], item.Key);
                        if (!chipInherentPro.ChipInherentPropertyDict.ContainsKey(cType))
                        {
                            _screenPointDetectIdentify.Add(sn, false);
                        }
                        else
                        {
                            _screenPointDetectIdentify.Add(sn, chipInherentPro.ChipInherentPropertyDict[cType].IsSupportPointDetect);
                        }
                    }
                }
                _isRunning = 0;
            }
            _fLogService.Debug("InitializeScreen Finish 点检");
            #endregion
        }