public void SendMonitorDataToLCT(LCTMainMonitorData lctData)
 {
     _lctMainData = lctData;
     string strText = string.Empty;
     if (lctData != null)
     {
         strText = CommandTextParser.GetJsonSerialization<LCTMainMonitorData>(lctData);
     }
     Action action = new Action(() =>
     {
         ClientDispatcher.Instance.SendCommand(new Command()
         {
             Code = CommandCode.MonitorDataToLCT,
             Target = TargetType.ToClient,
             CommandText = strText
         });
     });
     action.BeginInvoke(null, null);
 }
        public bool OnCmdInitialize()
        {
            IsGetData = false;
            if (MonitorAllConfig.Instance().ScreenMonitorData == null || MonitorAllConfig.Instance().ScreenMonitorData.AllScreenMonitorCollection == null
                || MonitorAllConfig.Instance().ScreenMonitorData.AllScreenMonitorCollection.Count == 0)
            {
                ScreenMonitorData = null;
                _fLogService.Error("获取数据结果为空,导致界面失败");
                return false;
            }
            foreach (ScreenModnitorData oneScreenData in MonitorAllConfig.Instance().ScreenMonitorData.AllScreenMonitorCollection)
            {
                if (oneScreenData.SenderMonitorCollection == null || oneScreenData.SenderMonitorCollection.Count == 0
                    || oneScreenData.ScannerMonitorCollection == null || oneScreenData.ScannerMonitorCollection.Count == 0)
                {
                    _fLogService.Error("获取数据结果不完整,因此不能推送到主界面");
                    return false;
                }
            }
            IsGetData = true;

            ScreenMonitorData = (AllMonitorData)MonitorAllConfig.Instance().ScreenMonitorData.Clone();
            List<string> screenList = new List<string>();

            _lctData = new LCTMainMonitorData();
            foreach (LedMonitoringConfig monitorConfig in MonitorAllConfig.Instance().LedMonitorConfigs)
            {
                _lctData.RefreshTypeInfo.IsUpdateMCStatus = true;
                LedBasicInfo led = MonitorAllConfig.Instance().LedInfoList.FirstOrDefault(a => a.Sn == monitorConfig.SN);
                if (led == null)
                {
                    continue;
                }
                if (monitorConfig.MonitoringCardConfig != null && monitorConfig.MonitoringCardConfig.MonitoringEnable == true
                    && monitorConfig.MonitoringCardConfig.ParameterConfigTable != null)
                {
                    foreach (ParameterMonitoringConfig param in monitorConfig.MonitoringCardConfig.ParameterConfigTable)
                    {
                        if (param.Type == StateQuantityType.FlatCableStatus
                            && _lctData.RefreshTypeInfo.IsUpdateRowLine == false && param.MonitoringEnable)
                        {
                            _lctData.RefreshTypeInfo.IsUpdateRowLine = true;
                        }
                        if (param.Type == StateQuantityType.DoorStatus
                            && _lctData.RefreshTypeInfo.IsUpdateGeneralStatus == false && param.MonitoringEnable)
                        {
                            _lctData.RefreshTypeInfo.IsUpdateGeneralStatus = true;
                        }
                        if (param.Type == StateQuantityType.Humidity
                            && _lctData.RefreshTypeInfo.IsUpdateHumidity == false && param.MonitoringEnable)
                        {
                            _lctData.RefreshTypeInfo.IsUpdateHumidity = true;
                        }
                        if (param.Type == StateQuantityType.Smoke
                            && _lctData.RefreshTypeInfo.IsUpdateSmoke == false && param.MonitoringEnable)
                        {
                            _lctData.RefreshTypeInfo.IsUpdateSmoke = true;
                        }
                        if (param.Type == StateQuantityType.FanSpeed
                            && _lctData.RefreshTypeInfo.IsUpdateFan == false && param.MonitoringEnable)
                        {
                            _lctData.RefreshTypeInfo.IsUpdateFan = true;
                        }
                        if (param.Type == StateQuantityType.Voltage
                            && _lctData.RefreshTypeInfo.IsUpdatePower == false && param.MonitoringEnable)
                        {
                            _lctData.RefreshTypeInfo.IsUpdatePower = true;
                        }
                    }
                }
            }

            foreach (ScreenModnitorData oneScreenData in ScreenMonitorData.AllScreenMonitorCollection)
            {
                screenList.Add(oneScreenData.ScreenUDID);
                MonitorDataFlag monitorFlag = MonitorDataFlags.Find(a => a.SN == oneScreenData.ScreenUDID);
                if (monitorFlag == null)
                {
                    monitorFlag = new MonitorDataFlag();
                    monitorFlag.SN = oneScreenData.ScreenUDID;
                    monitorFlag.SNName = GetSnAlia(oneScreenData.ScreenUDID);
                    MonitorDataFlags.Add(monitorFlag);
                }
                else
                {
                    monitorFlag.SNName = GetSnAlia(oneScreenData.ScreenUDID);
                }
                LedAlarmConfig ledAlarmConfig = MonitorAllConfig.Instance().LedAlarmConfigs.Find(a =>
                    a.SN == oneScreenData.ScreenUDID);

                LedMonitoringConfig ledMonitorConfig = MonitorAllConfig.Instance().LedMonitorConfigs.Find(a =>
                    a.SN == oneScreenData.ScreenUDID);
                if (ledMonitorConfig == null)
                {
                    if (oneScreenData == null || string.IsNullOrEmpty(oneScreenData.ScreenUDID))
                    {
                        _fLogService.Error("获取数据结果:没有硬件配置导致异常");
                    }
                    else
                    {
                        _fLogService.Error("获取数据结果:没有硬件配置导致异常:" + oneScreenData.ScreenUDID);
                    }
                    ledMonitorConfig = new LedMonitoringConfig();
                    ledMonitorConfig.SN = oneScreenData.ScreenUDID;
                    ledMonitorConfig.MonitoringCardConfig = new MonitoringCardConfig();
                    ledMonitorConfig.MonitoringCardConfig.MonitoringEnable = false;
                }

                LedBasicInfo ledInfo = MonitorAllConfig.Instance().LedInfoList.Find(a => a.Sn == oneScreenData.ScreenUDID);
                if (ledInfo == null)
                {
                    continue;
                }
                SetSenderMonitor(ledInfo, oneScreenData.SenderMonitorCollection, monitorFlag);
                SetScannerMonitor(ledInfo, oneScreenData.ScannerMonitorCollection, ledAlarmConfig, monitorFlag);
                SetMonitorCardMonitor(ledInfo, oneScreenData.MonitorCardInfoCollection, ledAlarmConfig, ledMonitorConfig, monitorFlag);
                SetRegisterMonitor(monitorFlag);
            }
            for (int i = 0; i < MonitorDataFlags.Count; )
            {
                if (screenList.Contains(MonitorDataFlags[i].SN))
                {
                    i++;
                }
                else
                {
                    MonitorDataFlags.RemoveAt(i);
                }
            }
            SetRedundantStateInfos();
            MonitorAllConfig.Instance().SendMonitorDataToLCT(_lctData);
            return true;
        }