Module Expr Str Import alias FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Num Assign NameStore Str Assign NameStore Str TryFinally body TryExcept body With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr With Call NameLoad NameLoad Str NameStore body For NameStore NameLoad body Assign NameStore NameLoad With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore BinOpAdd BinOpAdd Str Call AttributeLoad NameLoad attr Str Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore Str Expr Call AttributeLoad NameLoad attr NameLoad With Call NameLoad NameLoad Str NameStore body For NameStore NameLoad body Assign NameStore NameLoad With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore BinOpAdd BinOpAdd Str Str Str Expr Call AttributeLoad NameLoad attr NameLoad With Call NameLoad NameLoad Str NameStore body For NameStore NameLoad body Assign NameStore NameLoad With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore BinOpMod Str TupleLoad Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr Num Num Assign NameStore Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Print Str Assign NameStore Num orelse Print Str Assign NameStore Num finalbody Expr Call AttributeLoad NameLoad attr Print Str Return NameLoad decorator_list Expr Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num
N/A N/A 
Created on 15 Oct 2014

Modules for use with Wonderware Archestra, various things to make the job easier.

USAGE:
    %prog in_file.txt out_file.txt
@author: Roan Fourie
@mail: roanfourie@gmail.com
 N/A sys create_script_tagnames N/A N/A in_file out_file N/A N/A N/A 
    Created on 15 Oct 2014
    Created for use with Wonderware Archestra to create the if statements used in the scrAssignIO scripts.
    It takes a text file containing a list of Field Attributes and creates a new text file with the if statements.
    
    USAGE:
        %prog in_file.txt out_file.txt
    @author: Roan Fourie
    @mail: roanfourie@gmail.com
     N/A return_data 0 N/A str_data N/A write_data N/A N/A N/A N/A N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data 'Wait two execution counts to make sure script executes
If Me.scrAssignIO.ExecutionCnt > 2 Then

'Declare variables

	DIM Datasource AS STRING;
	DIM AliasDB AS INDIRECT;
 N/A N/A N/A fo write write_data N/A N/A N/A fo close N/A N/A open in_file rt fi N/A N/A line fi N/A N/A str_data line N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data N/A N/A 	DIM  N/A N/A str_data rstrip _Exist AS INTEGER;
 N/A N/A N/A fo write write_data N/A N/A N/A fo close N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data 

'Datasource is the input/output source you want to allocate to your field attribute
	Datasource = Me.PLCPath + "." + Me.Tagname;

'Create the alias list that is in the Device Integration object using the PLCPath uda to make it more dynamic
	AliasDB.bindto(Me.PLCPath + ".AliasDataBase");
	'The exist variables will return an integer value when the string exists in the alias database in the DI object
	'A string comparison is done between the Alias DB list and the Attribute to see if the attribute exists in the Alias DB
	'The StringChar function looks at the ASCII value for a quote which seperates the alias tags from each other in the aliasDB

 N/A N/A N/A fo write write_data N/A N/A open in_file rt fi N/A N/A line fi N/A N/A str_data line N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data N/A N/A N/A N/A N/A N/A str_data rstrip _Exist = StringInString(AliasDB, (StringChar(34) + Me.TagName + ". N/A N/A str_data rstrip " + StringChar(34)),1,0);
 N/A N/A N/A fo write write_data N/A N/A N/A fo close N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data N/A N/A 	' The value is then assigned to the DIN Field Attribute input source or unassigned if it is not in the AliasDB
 N/A N/A N/A fo write write_data N/A N/A open in_file rt fi N/A N/A line fi N/A N/A str_data line N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data N/A 	If %s_Exist > 0 Then
		Me.%s.Input.InputSource = Datasource + ".%s";
	Else
		Me.%s.Input.InputSource = "---";
	EndIf;

 N/A N/A N/A str_data rstrip N/A N/A str_data rstrip N/A N/A str_data rstrip N/A N/A str_data rstrip N/A N/A N/A fo write write_data N/A N/A N/A fo close N/A N/A open out_file at fo N/A N/A N/A N/A fo seek 0 2 N/A write_data 
'The script is then finished by setting the trigger bit to true and it will stop executing
    Me.AssignIOCmd = True;

EndIf;

'A Log Message flag is added to see if the script executed in the SMC - This can be excluded and is for troubleshooting
'LogMessage (Me.Tagname + "Finished");

 N/A N/A N/A fo write write_data N/A N/A N/A fo close N/A N/A N/A IOError N/A N/A Error in reading/writing file. N/A return_data 2 N/A N/A Operation completed successfully. N/A return_data 1 N/A N/A N/A N/A fi close N/A done N/A return_data N/A N/A N/A create_script_tagnames N/A N/A sys argv N/A 1 N/A N/A sys argv N/A 2