Esempio n. 1
0
        /// <summary>
        /// Синхронизация привязки устройств привязанных к модулю.
        /// Реализовано сразу два типа синхронизации
        /// </summary>
        /// <param name="synchronizingModule">Синхронизируемый модуль</param>
        /// <param name="IOModuleDevices">Устройства для синхронизации</param>
        private void SynchronizeIOModuleDevices(Function synchronizingModule,
                                                Dictionary <int, string> IOModuleDevices)
        {
            DocumentTypeManager.DocumentType circuitDocument =
                DocumentTypeManager.DocumentType.Circuit;
            DocumentTypeManager.DocumentType overviewDocument =
                DocumentTypeManager.DocumentType.Overview;

            foreach (int clamp in IOModuleDevices.Keys)
            {
                string functionalText =
                    SortDevices(IOModuleDevices[clamp]);
                // Конвертируем символ "плюс" обратно.
                functionalText = functionalText.
                                 Replace(SymbolForPlusReplacing, PlusSymbol.ToString());

                string functionalTextWithoutComments =
                    DeleteDevicesComments(functionalText);

                // На электрических схемах при множественной привязке
                // комментарий не пишем.
                SynchronizeDevice(synchronizingModule, clamp,
                                  functionalTextWithoutComments, circuitDocument);

                // На странице "Обзор" при множественной привязке надо писать
                // комментарии.
                SynchronizeDevice(synchronizingModule, clamp, functionalText,
                                  overviewDocument);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Необходимость в пропуске данной клеммы.
        /// </summary>
        /// <param name="module">Модуль</param>
        /// <param name="clampFunction">Функция клеммы</param>
        /// <returns></returns>
        private bool NeedToSkip(IO.IOModule module, Function clampFunction)
        {
            var skip = false;

            string clampString = clampFunction.Properties
                                 .FUNC_ADDITIONALIDENTIFYINGNAMEPART.ToString();
            int  clamp;
            bool isDigit = int.TryParse(clampString, out clamp);

            if (isDigit == false)
            {
                skip = true;
                return(skip);
            }

            IO.IOModuleInfo moduleInfo = module.Info;
            if (Array.IndexOf(moduleInfo.ChannelClamps, clamp) < 0)
            {
                skip = true;
                return(skip);
            }

            DocumentTypeManager.DocumentType documentType = clampFunction.Page
                                                            .PageType;
            if (documentType != DocumentTypeManager.DocumentType.Circuit)
            {
                skip = true;
                return(skip);
            }

            string description = ApiHelper.GetFunctionalText(
                clampFunction);

            if (description == "" || description.Contains(CommonConst.Reserve))
            {
                skip = true;
                return(skip);
            }

            return(skip);
        }
Esempio n. 3
0
        /// <summary>
        /// Синхронизация привязки устройства.
        /// </summary>
        /// <param name="synchronizingModule">Функция обновляемого модуля
        /// ввода-вывода</param>
        /// <param name="clamp">Номер клеммы</param>
        /// <param name="functionalText">Функциональный текст</param>
        /// <param name="documentType">Тип страницы для поиска подфункции
        /// </param>
        private void SynchronizeDevice(Function synchronizingModule, int clamp,
                                       string functionalText,
                                       DocumentTypeManager.DocumentType documentType)
        {
            const string ClampFunctionDefenitionName = "Дискретный выход";

            var placedFunctions = synchronizingModule.SubFunctions.
                                  Where(x => x.IsPlaced == true).ToArray();

            var clampFunction = placedFunctions.
                                Where(x => x.Page.PageType == documentType &&
                                      x.FunctionDefinition.Name.GetString(ISOCode.Language.L_ru_RU).
                                      Contains(ClampFunctionDefenitionName)).
                                FirstOrDefault(y => y.Properties.
                                               FUNC_ADDITIONALIDENTIFYINGNAMEPART.ToInt() == clamp);

            // Если null - клеммы нет на схеме.
            if (clampFunction != null)
            {
                clampFunction.Properties.FUNC_TEXT = functionalText;
                AddSynchronizedDevice(synchronizingModule, clamp);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Получить привязку для сброса канала устройства
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, string> GetBindingForResettingChannel(
            Function deviceClampFunction, IO.IOModuleInfo moduleInfo,
            string devicesDescription = "")
        {
            var    res = new Dictionary <string, string>();
            string clampNumberAsString = deviceClampFunction.Properties
                                         .FUNC_ADDITIONALIDENTIFYINGNAMEPART.ToString();

            if (deviceClampFunction.Name.Contains(DeviceManager
                                                  .ValveTerminalName))
            {
                Function IOModuleFunction = ApiHelper
                                            .GetIOModuleFunction(deviceClampFunction);
                string   bindedDevice          = deviceClampFunction.Name;
                Function IOModuleClampFunction = ApiHelper
                                                 .GetClampFunction(IOModuleFunction, bindedDevice);
                clampNumberAsString = IOModuleClampFunction.Properties
                                      .FUNC_ADDITIONALIDENTIFYINGNAMEPART.ToString();
            }

            int  clampNumber;
            bool isDigit = int.TryParse(clampNumberAsString, out clampNumber);

            if (isDigit == false)
            {
                return(res);
            }

            if (Array.IndexOf(moduleInfo.ChannelClamps, clampNumber) < 0)
            {
                return(res);
            }

            DocumentTypeManager.DocumentType pageType = deviceClampFunction
                                                        .Page.PageType;
            if (pageType != DocumentTypeManager.DocumentType.Circuit &&
                pageType != DocumentTypeManager.DocumentType.Overview)
            {
                return(res);
            }

            if (devicesDescription == "")
            {
                devicesDescription = ApiHelper.GetFunctionalText(
                    deviceClampFunction);
            }

            if (devicesDescription == "")
            {
                return(res);
            }

            var   comment      = "";
            var   clampComment = "";
            Match actionMatch;
            bool  isMultipleBinding = deviceManager.IsMultipleBinding(
                devicesDescription);

            if (isMultipleBinding == false)
            {
                int endPos = devicesDescription.IndexOf(CommonConst.NewLine);
                if (endPos > 0)
                {
                    comment            = devicesDescription.Substring(endPos + 1);
                    devicesDescription = devicesDescription.Substring(0,
                                                                      endPos);
                }

                devicesDescription = Regex.Replace(devicesDescription,
                                                   CommonConst.RusAsEngPattern, CommonConst.RusAsEnsEvaluator);

                actionMatch = Regex.Match(comment,
                                          IODevice.IOChannel.ChannelCommentPattern,
                                          RegexOptions.IgnoreCase);

                comment = Regex.Replace(comment,
                                        IODevice.IOChannel.ChannelCommentPattern,
                                        "", RegexOptions.IgnoreCase);
                comment = comment.Replace(CommonConst.NewLine, ". ").Trim();
                if (comment.Length > 0 && comment[comment.Length - 1] != '.')
                {
                    comment += ".";
                }
            }
            else
            {
                devicesDescription = Regex.Replace(devicesDescription,
                                                   CommonConst.RusAsEngPattern, CommonConst.RusAsEnsEvaluator);
                actionMatch = Regex.Match(comment,
                                          IODevice.IOChannel.ChannelCommentPattern,
                                          RegexOptions.IgnoreCase);
            }

            var descrMatch = Regex.Match(devicesDescription,
                                         DeviceManager.BINDING_DEVICES_DESCRIPTION_PATTERN);

            while (descrMatch.Success)
            {
                string devName = descrMatch.Groups["name"].Value;

                if (actionMatch.Success)
                {
                    clampComment = actionMatch.Value;
                }

                res.Add(devName, clampComment);
                descrMatch = descrMatch.NextMatch();
            }

            return(res);
        }