318 self.ReturnType = returntype_content["name"] |
318 self.ReturnType = returntype_content["name"] |
319 else: |
319 else: |
320 self.ReturnType = returntype_content["value"].getname() |
320 self.ReturnType = returntype_content["value"].getname() |
321 for varlist in interface.getcontent(): |
321 for varlist in interface.getcontent(): |
322 variables = [] |
322 variables = [] |
323 located = False |
323 located = [] |
324 for var in varlist["value"].getvariable(): |
324 for var in varlist["value"].getvariable(): |
325 vartype_content = var.gettype().getcontent() |
325 vartype_content = var.gettype().getcontent() |
326 if vartype_content["name"] == "derived": |
326 if vartype_content["name"] == "derived": |
327 var_type = vartype_content["value"].getname() |
327 var_type = vartype_content["value"].getname() |
328 GeneratePouProgram(var_type) |
328 GeneratePouProgram(var_type) |
329 blocktype = GetBlockType(var_type) |
329 blocktype = GetBlockType(var_type) |
330 if blocktype is not None: |
330 if blocktype is not None: |
331 variables.extend(blocktype["initialise"](var_type, var.getname())) |
331 for variable in blocktype["initialise"](var_type, var.getname()): |
332 located = False |
332 if variable[2] is not None: |
|
333 located.append(variable) |
|
334 else: |
|
335 variables.append(variable) |
333 else: |
336 else: |
334 initial = var.getinitialValue() |
337 initial = var.getinitialValue() |
335 if initial: |
338 if initial: |
336 initial_value = initial.getvalue() |
339 initial_value = initial.getvalue() |
337 else: |
340 else: |
338 initial_value = None |
341 initial_value = None |
339 address = var.getaddress() |
342 address = var.getaddress() |
340 if address: |
343 if address is not None: |
341 located = True |
344 located.append((vartype_content["value"].getname(), var.getname(), address, initial_value)) |
342 variables.append((vartype_content["value"].getname(), var.getname(), address, initial_value)) |
345 else: |
|
346 variables.append((vartype_content["value"].getname(), var.getname(), None, initial_value)) |
343 else: |
347 else: |
344 initial = var.getinitialValue() |
348 initial = var.getinitialValue() |
345 if initial: |
349 if initial: |
346 initial_value = initial.getvalue() |
350 initial_value = initial.getvalue() |
347 else: |
351 else: |
348 initial_value = None |
352 initial_value = None |
349 address = var.getaddress() |
353 address = var.getaddress() |
350 if address: |
|
351 located = True |
|
352 if vartype_content["name"] in ["string", "wstring"]: |
354 if vartype_content["name"] in ["string", "wstring"]: |
353 variables.append((vartype_content["name"].upper(), var.getname(), address, initial_value)) |
355 if address is not None: |
|
356 located.append((vartype_content["name"].upper(), var.getname(), address, initial_value)) |
|
357 else: |
|
358 variables.append((vartype_content["name"].upper(), var.getname(), None, initial_value)) |
|
359 elif address is not None: |
|
360 located.append((vartype_content["name"], var.getname(), address, initial_value)) |
354 else: |
361 else: |
355 variables.append((vartype_content["name"], var.getname(), address, initial_value)) |
362 variables.append((vartype_content["name"], var.getname(), None, initial_value)) |
356 if len(variables) > 0: |
363 if len(variables) > 0: |
357 self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getretain(), |
364 self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getretain(), |
358 varlist["value"].getconstant(), located, variables)) |
365 varlist["value"].getconstant(), False, variables)) |
359 |
366 if len(located) > 0: |
|
367 self.Interface.append((varTypeNames[varlist["name"]], varlist["value"].getretain(), |
|
368 varlist["value"].getconstant(), True, located)) |
|
369 |
360 def GenerateConnectionTypes(self, pou): |
370 def GenerateConnectionTypes(self, pou): |
361 body = pou.getbody() |
371 body = pou.getbody() |
362 body_content = body.getcontent() |
372 body_content = body.getcontent() |
363 body_type = body_content["name"] |
373 body_type = body_content["name"] |
364 if body_type in ["FBD", "LD", "SFC"]: |
374 if body_type in ["FBD", "LD", "SFC"]: |