/// <summary> /// Синхронизация названий устройств и модулей /// </summary> /// <returns>Возвращает сообщения об ошибках во время выполнения. /// </returns> public string Execute() { ProjectConfiguration.GetInstance().ReadIO(); if (ProjectConfiguration.GetInstance().DevicesIsRead == true) { ProjectConfiguration.GetInstance().SynchronizeDevices(); } else { ProjectConfiguration.GetInstance().ReadDevices(); } ProjectConfiguration.GetInstance().ReadBinding(); ProjectConfiguration.GetInstance().Check(); IO.IOManager.GetInstance().CalculateIOLinkAdresses(); var selection = new SelectionSet(); Project project = selection.GetCurrentProject(true); var objectFinder = new DMObjectsFinder(project); var functionsFilter = new FunctionsFilter(); var properties = new FunctionPropertyList(); properties.FUNC_MAINFUNCTION = true; functionsFilter.SetFilteredPropertyList(properties); functionsFilter.Category = Function.Enums.Category.PLCBox; Function[] devicesFunctions = objectFinder. GetFunctions(functionsFilter); project.LockAllObjects(); Dictionary <string, string> deviceConnections = CollectIOModulesData(devicesFunctions); bool containsNewValveTerminal = GetProjectVersionFromDevices( deviceConnections); synchronizedDevices.Clear(); if (!containsNewValveTerminal) { SynchronizeAsOldProject(deviceConnections, devicesFunctions); } else { SynchronizeAsNewProject(deviceConnections, devicesFunctions); } ClearNotExistingBinding(); return(errorMessage); }
/// <summary> /// Подготовка к чтению привязки. /// </summary> private void PrepareForReading() { var objectsFinder = new DMObjectsFinder(ApiHelper.GetProject()); var properties = new FunctionPropertyList(); properties.FUNC_MAINFUNCTION = true; var plcFilter = new FunctionsFilter(); plcFilter.SetFilteredPropertyList(properties); plcFilter.Category = Function.Enums.Category.PLCBox; functionsForSearching = objectsFinder.GetFunctions(plcFilter); }
/// <summary> /// Подготовка к чтению устройств /// </summary> private void PrepareForReading() { deviceManager.Clear(); var objectFinder = new DMObjectsFinder(ApiHelper.GetProject()); var propertyList = new FunctionPropertyList(); propertyList.FUNC_MAINFUNCTION = true; var functionsFilter = new FunctionsFilter(); functionsFilter.IsPlaced = true; functionsFilter.SetFilteredPropertyList(propertyList); deviceFunctions = objectFinder.GetFunctions(functionsFilter); }
/// <summary> /// Поиск функции модуля ввода-вывода к которой привязан пневмоостров /// </summary> /// <param name="clampFunction">Функция клеммы модуля /// ввода-вывода</param> /// <returns>Функция модуля ввода-вывода</returns> private static Function GetValveTerminalIOModuleFunction( Function clampFunction) { var IOModuleFunction = new Function(); string valveTerminalName = Regex.Match(clampFunction.Name, Device.DeviceManager.valveTerminalPattern).Value; if (string.IsNullOrEmpty(valveTerminalName)) { const string Message = "Ошибка поиска ОУ пневмоострова"; throw new Exception(Message); } var objectFinder = new DMObjectsFinder(ApiHelper.GetProject()); var functionsFilter = new FunctionsFilter(); var properties = new FunctionPropertyList(); properties.FUNC_MAINFUNCTION = true; functionsFilter.SetFilteredPropertyList(properties); functionsFilter.Category = Function.Enums.Category.PLCBox; Function[] functions = objectFinder.GetFunctions(functionsFilter); foreach (Function function in functions) { Function[] subFunctions = function.SubFunctions; if (subFunctions != null) { foreach (Function subFunction in subFunctions) { var functionalText = subFunction.Properties .FUNC_TEXT_AUTOMATIC .ToString(ISOCode.Language.L___); if (functionalText.Contains(valveTerminalName)) { IOModuleFunction = subFunction.ParentFunction; return(IOModuleFunction); } } } } return(IOModuleFunction); }
/// <summary> /// Подготовка к чтению IO. /// </summary> private void PrepareForReading() { var project = ApiHelper.GetProject(); var objectsFinder = new DMObjectsFinder(project); var functionsFilter = new FunctionsFilter(); var properties = new FunctionPropertyList(); properties.FUNC_MAINFUNCTION = true; functionsFilter.SetFilteredPropertyList(properties); functionsFilter.Category = Function.Enums.Category.PLCBox; functionsForSearching = objectsFinder.GetFunctions(functionsFilter) .ToList(); functionsForSearching.Sort(CompareFunctions); IOManager.Clear(); isContainsNodes = false; isContainsA1 = CheckA1(); }