19 public abstract partial class BaseMAC_use_casesEM : TiaEquipmentModule, ITiaAttributeUser
22 private EquipmentModuleEditorProvider _editorProvider;
24 [JsonIgnore]
public List<TiaAttribute> Attributes {
get; } =
new List<TiaAttribute>();
26 [JsonIgnore]
public ResourceManagement ResourceManagement {
get;
private set; } =
new ResourceManagement();
28 protected BaseMAC_use_casesEM()
31 string resourceName = typeof(BaseMAC_use_casesEM).Assembly.ManifestModule.Name;
32 resourceName = System.IO.Path.GetFileNameWithoutExtension(resourceName);
33 ResourceDictionary dictionary_en = (ResourceDictionary)Application.LoadComponent(
34 new Uri(
@"/" + resourceName +
";;;component/Resources/Lang_en.xaml", UriKind.Relative));
35 ResourceDictionary dictionary_de = (ResourceDictionary)Application.LoadComponent(
36 new Uri(
@"/" + resourceName +
";;;component/Resources/Lang_de.xaml", UriKind.Relative));
37 ResourceDictionary dictionary_zh = (ResourceDictionary)Application.LoadComponent(
38 new Uri(
@"/" + resourceName +
";;;component/Resources/Lang_zh.xaml", UriKind.Relative));
40 LanguageResources.Add(
"en", dictionary_en);
41 LanguageResources.Add(
"de", dictionary_de);
42 LanguageResources.Add(
"zh", dictionary_zh);
46 public override IEnumerable<TiaLibraryInfo> GetLibraryInfos()
48 List<TiaLibraryInfo> libraryInfos = ResourceManagement.GetLibraryInfos();
49 foreach (var controlModule
in ControlModules)
51 if (controlModule is TiaEquipmentModule tiaModule)
53 libraryInfos.AddRange(tiaModule.GetLibraryInfos());
64 RunGeneratedTasksInitModule();
70 base.AfterEquipmentModuleLoad();
71 RunGeneratedTasksAfterEQMLoad();
77 base.BeforeModuleDeleted();
78 RunGeneratedBeforeDelete();
81 public override EquipmentModuleEditorProvider GetEditorProvider()
83 if (_editorProvider ==
null)
85 _editorProvider =
new EquipmentModuleEditorProvider(
new MultiPageFrame(
this));
88 return _editorProvider;
91 protected string GetContentAdditionalResource(
string name)
93 System.Reflection.Assembly
asm = System.Reflection.Assembly.GetExecutingAssembly();
95 new StreamReader(
asm.GetManifestResourceStream(
"MAC_use_cases.TiaImports.AdditionalResources." + name))
107 RunGeneratedTasksConstructor();
120 protected PlcDevice GetPlcDevice(TiaTemplateContext tiaTemplateContext)
122 if (tiaTemplateContext ==
null)
124 throw new ArgumentNullException(nameof(tiaTemplateContext));
127 PlcDevice plcDevice = tiaTemplateContext.TiaDevice as PlcDevice;
129 if (plcDevice ==
null)
131 if (tiaTemplateContext.TiaDevice !=
null)
133 throw new ArgumentException(
134 $
"{nameof(TiaTemplateContext.TiaDevice)} must be '{typeof(PlcDevice)}' but it was '{tiaTemplateContext.TiaDevice.GetType()}'");
137 throw new ArgumentNullException($
"{nameof(TiaTemplateContext.TiaDevice)}");
140 if (plcDevice.Name != ParentDevice.Name)
142 throw new ArgumentException(
143 $
"ParentDevice name: '{ParentDevice.Name}' of this module does not match with the name of the TiaDevice: '{plcDevice.Name}' in {nameof(TiaTemplateContext)}");
149 protected void LogGenerationWarning(
string message,
string source)
151 MacManagement.LoggingService.LogMessage(LogTypes.GenerationWarning, message, source);
160 protected void AddGsdFiles(
string[] gsdFiles,
string resourceDirPath =
"Resources")
162 string dllDirectory = Path.GetDirectoryName(GetType().Assembly.Location);
163 var gsdFileInfos =
new List<FileInfo>(gsdFiles.Length);
165 foreach (
string gsdFile
in gsdFiles)
167 var f =
new FileInfo(Path.Combine(dllDirectory, resourceDirPath, gsdFile));
171 AddGsdFileToTiaProject(gsdFileInfos);