コード例 #1
0
        private void SetRedundantStateInfos()
        {
            if (ScreenMonitorData.RedundantStateType != null && ScreenMonitorData.RedundantStateType.Count > 0)
            {
                if (ScreenMonitorData.TempRedundancyDict.Count > 0)
                {
                    SerializableDictionary <int, RedundantStateInfo> redundantStatDataList = null;
                    RedundantStateInfo redundantStatData = null;
                    foreach (string commPort in ScreenMonitorData.RedundantStateType.Keys)
                    {
                        if (ScreenMonitorData.RedundantStateType[commPort] == null ||
                            ScreenMonitorData.RedundantStateType[commPort].Count <= 0)
                        {
                            continue;
                        }
                        redundantStatDataList = new SerializableDictionary <int, RedundantStateInfo>();
                        foreach (int var in ScreenMonitorData.RedundantStateType[commPort].Keys)
                        {
                            redundantStatData = new RedundantStateInfo();
                            if (ScreenMonitorData.CommPortData == null)
                            {
                                break;
                            }
                            SenderRedundantStateInfo state = ScreenMonitorData.RedundantStateType[commPort][var];
                            redundantStatData.CommPort    = commPort;
                            redundantStatData.SenderIndex = (byte)var;
                            SenderRedundancyInfo senderInfo = null;

                            if (ScreenMonitorData.CommPortData.ContainsKey(commPort))
                            {
                                redundantStatData.PortCount = ScreenMonitorData.CommPortData[commPort];
                                for (int i = 0; i < ScreenMonitorData.CommPortData[commPort]; i++)
                                {
                                    if (state.RedundantStateTypeList[i] == RedundantStateType.Error)
                                    {
                                        if (ScreenMonitorData.TempRedundancyDict.ContainsKey(commPort) && ScreenMonitorData.TempRedundancyDict[commPort] != null)
                                        {
                                            for (int j = 0; j < ScreenMonitorData.TempRedundancyDict[commPort].Count; j++)
                                            {
                                                senderInfo = (SenderRedundancyInfo)ScreenMonitorData.TempRedundancyDict[commPort][j].Clone();
                                                if (senderInfo.SlavePortIndex == i && senderInfo.SlaveSenderIndex == var)
                                                {
                                                    redundantStatData.RedundantStateTypeList.Add(i, state.RedundantStateTypeList[i]);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    else if (state.RedundantStateTypeList[i] == RedundantStateType.Unknown)
                                    {
                                        continue;
                                    }
                                }
                            }
                            if (redundantStatData.RedundantStateTypeList.Count > 0)
                            {
                                redundantStatDataList.Add(var, redundantStatData);
                            }
                        }
                        if (redundantStatDataList.Count > 0)
                        {
                            _lctData.RedundantStateInfoDic.Add(commPort, redundantStatDataList);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void SetRedundantStateInfos()
        {
            if (ScreenMonitorData.RedundantStateType != null && ScreenMonitorData.RedundantStateType.Count > 0)
            {
                if (ScreenMonitorData.TempRedundancyDict.Count > 0)
                {
                    SerializableDictionary<int, RedundantStateInfo> redundantStatDataList = null;
                    RedundantStateInfo redundantStatData = null;
                    foreach (string commPort in ScreenMonitorData.RedundantStateType.Keys)
                    {
                        if (ScreenMonitorData.RedundantStateType[commPort] == null
                            || ScreenMonitorData.RedundantStateType[commPort].Count <= 0)
                        {
                            continue;
                        }
                        redundantStatDataList = new SerializableDictionary<int, RedundantStateInfo>();
                        foreach (int var in ScreenMonitorData.RedundantStateType[commPort].Keys)
                        {
                            redundantStatData = new RedundantStateInfo();
                            if (ScreenMonitorData.CommPortData == null)
                            {
                                break;
                            }
                            SenderRedundantStateInfo state = ScreenMonitorData.RedundantStateType[commPort][var];
                            redundantStatData.CommPort = commPort;
                            redundantStatData.SenderIndex = (byte)var;
                            SenderRedundancyInfo senderInfo = null;

                            if (ScreenMonitorData.CommPortData.ContainsKey(commPort))
                            {
                                redundantStatData.PortCount = ScreenMonitorData.CommPortData[commPort];
                                for (int i = 0; i < ScreenMonitorData.CommPortData[commPort]; i++)
                                {
                                    if (state.RedundantStateTypeList[i] == RedundantStateType.Error)
                                    {
                                        if (ScreenMonitorData.TempRedundancyDict.ContainsKey(commPort) && ScreenMonitorData.TempRedundancyDict[commPort] != null)
                                        {
                                            for (int j = 0; j < ScreenMonitorData.TempRedundancyDict[commPort].Count; j++)
                                            {
                                                senderInfo = (SenderRedundancyInfo)ScreenMonitorData.TempRedundancyDict[commPort][j].Clone();
                                                if (senderInfo.SlavePortIndex == i && senderInfo.SlaveSenderIndex == var)
                                                {
                                                    redundantStatData.RedundantStateTypeList.Add(i, state.RedundantStateTypeList[i]);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    else if (state.RedundantStateTypeList[i] == RedundantStateType.Unknown)
                                    {
                                        continue;
                                    }
                                }
                            }
                            if (redundantStatData.RedundantStateTypeList.Count > 0)
                            {
                                redundantStatDataList.Add(var, redundantStatData);
                            }
                        }
                        if (redundantStatDataList.Count > 0)
                        {
                            _lctData.RedundantStateInfoDic.Add(commPort, redundantStatDataList);
                        }
                    }
                }
            }
        }