@@ -83,13 +83,13 @@ public ModuleEdge ModuleStart
83
83
/// This attribute is the string which is used for the renaming of the FB.
84
84
/// This string can be changed in the View
85
85
/// </summary>
86
- public string NameOfMyFb { get ; set ; } = "myFB " ;
86
+ public string NameOfMyFb { get ; set ; } = "MyFunctionBlock " ;
87
87
88
88
/// <summary>
89
89
/// This attribute is the string which is used for the renaming of the safety-FB.
90
90
/// This string can be changed in the View
91
91
/// </summary>
92
- public string NameOfMyFailSafeFb { get ; set ; } = "myFailSafeFB " ;
92
+ public string NameOfMyFailSafeFb { get ; set ; } = "MyFunctionBlock_FailSafe " ;
93
93
94
94
[ JsonIgnore ]
95
95
public string NameAndType => NamingConventions . CreateModuleNameAndTypeForEM ( "MAC_use_cases" , this ) ;
@@ -131,54 +131,70 @@ public override bool GenerateTiaPortal(TiaTemplateContext tiaTemplateContext, st
131
131
case TiaGenerationPhases . Build :
132
132
133
133
// Add equipment module specific code generation here.
134
-
135
134
var opennessTIAPortalProject = GeneralSupport . GetOpennessProject ( tiaTemplateContext . TiaProject ) ;
136
135
var opennessCPU = GeneralSupport . GetOpennessDeviceItem ( tiaTemplateContext . TiaDevice ) ;
137
136
m_softwareUnit = SoftwareUnits . GetOrCreateSoftwareUnit ( m_plcDevice , "MyUnit" , this ) ;
138
137
138
+ // Configure a Technology Object
139
139
myTO . ConfigureTO ( myTO . TechnologicalObject , this ) ;
140
-
140
+ // Log messages
141
141
GeneralSupport . LogMessage ( LogTypes . GenerationInfo , "Generate technology objects" , this ) ;
142
+ // Create Technology Object
142
143
TechnologyObjectClass . CreateTOs ( m_plcDevice , this ) ;
143
144
144
- IntegrateLibraries . CreateInstanceDB ( this , ResourceManagement . MAC_use_casesFB ,
145
- "CreatedDbFromMasterCopy" , ResourceManagement . ModuleBlocksRootGroup ) ;
146
-
147
- IntegrateLibraries . CreateInstanceDB ( this , ResourceManagement . MAC_use_casesFB_FailSafe ,
148
- "CreatedDbFromFailSafeFbMasterCopy" , ResourceManagement . ModuleBlocksRootGroup ) ;
149
-
150
- IntegrateLibraries . CreateInstanceDB_via_XmlInstDB ( this , ResourceManagement . MAC_use_casesFB ,
145
+ IntegrateLibraries . CreateInstanceDB_via_XmlInstDB ( this , ResourceManagement . MyFunctionBlock ,
151
146
"CreatedDbFromMasterCopy_XmlInstDB" , ResourceManagement . ModuleBlocksRootGroup , m_plcDevice ) ;
152
147
153
- GenericBlockCreation . GenerateDB ( "myDB" , m_plcDevice , this ) ;
148
+ var myDataBlockGlobal =
149
+ GenericBlockCreation . GenerateGlobalDataBlock ( "MyDataBlock_Global" , m_plcDevice , this ) ;
154
150
155
- GenericBlockCreation . SetDefaultValue ( "myDB" , "myParameterName" , TIATYPE . INT , "99" , this ) ;
151
+ GenericBlockCreation . SetDefaultValue ( myDataBlockGlobal . Name , "myParameterName" , TIATYPE . INT , "99" ,
152
+ this ) ;
156
153
157
154
GenericBlockCreation . GenerateMultiInstanceFB ( m_plcDevice ,
158
155
tiaTemplateContext . TiaProject . GetEditingLanguage ( ) , this ) ;
159
156
160
- GenericBlockCreation . GenerateOB_Main ( "CreatedDbFromMasterCopy" , this ,
157
+ var dbFromMasterCopy = IntegrateLibraries . CreateInstanceDataBlock ( this ,
158
+ ResourceManagement . MyFunctionBlock ,
159
+ $ "{ nameof ( ResourceManagement . MyFunctionBlock ) } Db", ResourceManagement . ModuleBlocksRootGroup ) ;
160
+
161
+ GenericBlockCreation . GenerateOB_Main ( dbFromMasterCopy . Name , this ,
161
162
tiaTemplateContext . TiaProject . GetEditingLanguage ( ) , m_plcDevice ) ;
162
163
163
164
GenericBlockCreation . GenerateMainOBWithMultipleCalls ( "myOB" , 10 ,
164
165
tiaTemplateContext . TiaProject . GetEditingLanguage ( ) , m_plcDevice , this ) ;
165
166
166
- GenericBlockCreation . CreateFunctionBlock ( $ "{ NameOfMyFb } _FBD", "CreatedDbFromMasterCopy" ,
167
+ GenericBlockCreation . CreateFunctionBlock ( $ "{ NameOfMyFb } _FBD", dbFromMasterCopy . Name ,
167
168
ProgrammingLanguage . FBD ,
168
169
m_plcDevice ) ;
169
- GenericBlockCreation . CreateFunctionBlock ( $ "{ NameOfMyFb } _LAD", "CreatedDbFromMasterCopy" ,
170
+ GenericBlockCreation . CreateFunctionBlock ( $ "{ NameOfMyFb } _LAD", dbFromMasterCopy . Name ,
170
171
ProgrammingLanguage . LAD ,
171
172
m_plcDevice ) ;
172
- GenericBlockCreation . CreateFunctionBlock ( $ "{ NameOfMyFb } _SCL", "CreatedDbFromMasterCopy" ,
173
+ GenericBlockCreation . CreateFunctionBlock ( $ "{ NameOfMyFb } _SCL", dbFromMasterCopy . Name ,
173
174
ProgrammingLanguage . SCL ,
174
175
m_plcDevice ) ;
176
+
177
+ var dbFromFailSafeFbMasterCopy = IntegrateLibraries . CreateInstanceDataBlock ( this ,
178
+ ResourceManagement . MyFunctionBlock_FailSafe ,
179
+ $ "{ nameof ( ResourceManagement . MyFunctionBlock_FailSafe ) } Db",
180
+ ResourceManagement . ModuleBlocksRootGroup ) ;
181
+
175
182
GenericBlockCreation . CreateFailSafeFunctionBlock ( $ "{ NameOfMyFailSafeFb } _F_LAD",
176
- "CreatedDbFromFailSafeFbMasterCopy" ,
183
+ dbFromFailSafeFbMasterCopy . Name ,
177
184
ProgrammingLanguage . F_LAD ,
178
185
m_plcDevice ) ;
179
186
GenericBlockCreation . CreateFunctionBlockInSoftwareUnit ( m_softwareUnit , "MyFb_FBD" ,
180
187
ProgrammingLanguage . FBD ) ;
181
188
189
+ var dbFromTypedMasterCopy = IntegrateLibraries . CreateInstanceDataBlock ( this ,
190
+ ResourceManagement . MyFunctionBlock_Typed ,
191
+ $ "{ nameof ( ResourceManagement . MyFunctionBlock_Typed ) } Db", ResourceManagement . ModuleBlocksRootGroup ) ;
192
+
193
+ GenericBlockCreation . CreateFunctionBlock ( $ "{ nameof ( ResourceManagement . MyFunctionBlock_Typed ) } _FBD",
194
+ dbFromTypedMasterCopy . Name ,
195
+ ProgrammingLanguage . FBD ,
196
+ m_plcDevice ) ;
197
+
182
198
var myTagTable = CreateVariables . CreateTagTable ( m_plcDevice , "myTagTable" ) ;
183
199
var mySoftwareUnitTagTable = CreateVariables . CreateTagTable ( m_softwareUnit , "mySoftwareUnitTagTable" ) ;
184
200
0 commit comments