You are on page 1of 11

'---------------------------------------------------------------------------------

---------'
'
'
' MESAIEED Dynamic Action
'
' file name: Site.pdl
'
'
'
'---------------------------------------------------------------------------------
---------'

'####################################################################'
'##### Transmitters I/O Gauge Animation #####'
'####################################################################'

Sub TransmittersDynamics()

Dim objCScript As HMIScriptInfo 'configure the code lang. 'Dim


objVBScript As HMIScriptInfo
Dim colSelection As HMISelectedObjects 'define the selected objects
Dim objObject As HMICustomizedObject
Dim strCode As String 'to insert the c or vb code to
the selected obj as it.
Dim objDConnection As HMIDirectConnection
Dim objTrigger As HMIVariableTrigger
Dim objVariableTrigger As HMIVariableTrigger

Set colSelection = ActiveDocument.Selection


For Each objObject In colSelection

'----------------------------------------------------'
' Blinking I/O Border '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(10).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define FEN """ & objObject.ObjectName & ".FEN""" & vbCrLf
strCode = strCode & "if (GetTagBit (FEN))" & vbCrLf
strCode = strCode & "return GetTagDWord(""T_FEN"")" & ";" & vbCrLf
strCode = strCode & "else" & vbCrLf
strCode = strCode & "return CO_BLACK" & ";"

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".FEN",


hmiVariableCycleTypeOnChange)

End With
'----------------------------------------------------'
' I/O Background Color '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(11).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define ACKD """ & objObject.ObjectName & ".ACKD""" & vbCrLf
strCode = strCode & "#define ALARM """ & objObject.ObjectName & ".ALARM""" &
vbCrLf

strCode = strCode & "if (GetTagBit (ALARM))" & vbCrLf


strCode = strCode & "return GetTagDWord(""T_ALARM"")" & ";" & vbCrLf

strCode = strCode & "else" & vbCrLf


strCode = strCode & "return GetTagDWord(""T_ACKD"")" & ";"

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".ACKD",


hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &
".ALARM", hmiVariableCycleTypeOnChange)

End With
'----------------------------------------------------'
' I/O Background Blinking Color '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(13).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define ACKD """ & objObject.ObjectName & ".ACKD""" & vbCrLf
strCode = strCode & "return ! GetTagBit(""" & objObject.ObjectName & ".ACKD"")" &
";"
With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".ACKD",


hmiVariableCycleTypeOnChange)

End With

'----------------------------------------------------'
' Events '
'----------------------------------------------------'
'Directconnection is initiated by mouseclick:
Set objDConnection =
objObject.Events(1).Actions.AddAction(hmiActionCreationTypeDirectConnection)

With objDConnection

'Sourceobject:

.SourceLink.Type = hmiSourceTypeConstant

.SourceLink.ObjectName = 1
'Destinationobject:

.DestinationLink.Type = hmiDestTypeProperty

.DestinationLink.ObjectName = objObject.ObjectName & "_FP"

.DestinationLink.AutomationName = "Visible"
End With

'----------------------------------------------------'
' Dynamic Tag '
'----------------------------------------------------'
Set objVariableTrigger =
objObject.Properties.Item(14).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"T_ACKD")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange

Set objVariableTrigger =
objObject.Properties.Item(15).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"T_ALARM")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange

Set objVariableTrigger =
objObject.Properties.Item(17).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
objObject.ObjectName & ".VALUE")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange

Next objObject
End Sub

'####################################################################'
'##### Transmitters Gauge Event #####'
'####################################################################'
Sub TransEventDynamics()

'Directconnection is initiated by mouseclick:


Set objDConnection =
objObject.Events(1).Actions.AddAction(hmiActionCreationTypeDirectConnection)

With objDConnection

'Sourceobject:

.SourceLink.Type = hmiSourceTypeConstant

.SourceLink.ObjectName = 1

'Destinationobject:

.DestinationLink.Type = hmiDestTypeProperty

.DestinationLink.ObjectName = objObject.ObjectName & "_FP"

.DestinationLink.AutomationName = "Visible"
End With

End Sub
'####################################################################'
'##### Var. Speed PUMP as Custumized Object #####'
'####################################################################'
Sub PumpDynamics()

Dim objCScript As HMIScriptInfo 'configure the code lang. 'Dim


objVBScript As HMIScriptInfo
Dim colSelection As HMISelectedObjects 'define the selected objects
Dim objObject As HMICustomizedObject
Dim strCode As String 'to insert the c or vb code to
the selected obj as it.
Dim objDConnection As HMIDirectConnection
Dim objTrigger As HMIVariableTrigger
Dim objVariableTrigger As HMIVariableTrigger

Set colSelection = ActiveDocument.Selection


For Each objObject In colSelection

'----------------------------------------------------'
' Blinking Background Object Script '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(12).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define ACKD """ & objObject.ObjectName & ".ACKD""" & vbCrLf
strCode = strCode & "return ! GetTagBit(""" & objObject.ObjectName & ".ACKD"")" &
";" & vbCrLf

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".ACKD",


hmiVariableCycleTypeOnChange)

End With
'----------------------------------------------------'
' Background Color Object Script1 '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(10).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define ACKD """ & objObject.ObjectName & ".ACKD""" & vbCrLf
strCode = strCode & "#define ALARM""" & objObject.ObjectName & ".ALARM""" & vbCrLf

strCode = strCode & "#define RNNG""" & objObject.ObjectName & ".RNNG""" & vbCrLf
strCode = strCode & "#define STPD""" & objObject.ObjectName & ".STPD""" & vbCrLf

strCode = strCode & "if (GetTagBit (ALARM))" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_ALARM"")" & ";" & vbCrLf

strCode = strCode & "if (GetTagBit (STPD))" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_STPD"")" & ";" & vbCrLf

strCode = strCode & "if (GetTagBit (RNNG))" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_RNNG"")" & ";" & vbCrLf

strCode = strCode & "else" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_ACKD"")" & ";" & vbCrLf

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".ACKD",


hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &
".ALARM", hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".RNNG",
hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".STPD",
hmiVariableCycleTypeOnChange)

End With
'----------------------------------------------------'
' Events '
'----------------------------------------------------'
'Directconnection is initiated by mouseclick:
Set objDConnection =
objObject.Events(1).Actions.AddAction(hmiActionCreationTypeDirectConnection)

With objDConnection

'Sourceobject:

.SourceLink.Type = hmiSourceTypeConstant

.SourceLink.ObjectName = 1

'Destinationobject:

.DestinationLink.Type = hmiDestTypeProperty

.DestinationLink.ObjectName = objObject.ObjectName & "_FP"

.DestinationLink.AutomationName = "Visible"
End With

'----------------------------------------------------'
' Dynamic Tag '
'----------------------------------------------------'
Set objVariableTrigger =
objObject.Properties.Item(13).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"P_ACKD")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange
Set objVariableTrigger =
objObject.Properties.Item(14).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"P_ALARM")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange
Next objObject
End Sub

'####################################################################'
'##### Fixed Speed PUMP as Custumized Object #####'
'####################################################################'
Sub FixedPumpDynamics()

Dim objCScript As HMIScriptInfo 'configure the code lang. 'Dim


objVBScript As HMIScriptInfo
Dim colSelection As HMISelectedObjects 'define the selected objects
'Dim objObject As HMIObject 'define the object type for HMI
Object
Dim objObject As HMICustomizedObject
Dim strCode As String 'to insert the c or vb code to
the selected obj as it.
Dim objDConnection As HMIDirectConnection
Dim objTrigger As HMIVariableTrigger
Dim objVariableTrigger As HMIVariableTrigger

Set colSelection = ActiveDocument.Selection


For Each objObject In colSelection

'----------------------------------------------------'
' Blinking Background Object Script '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(12).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define FAILED_ACKD """ & objObject.ObjectName & ".FAILED_ACKD""" &


vbCrLf
strCode = strCode & "return ! GetTagBit(FAILED_ACKD)" & ";" & vbCrLf

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &


".FAILED_ACKD", hmiVariableCycleTypeOnChange)

End With
'----------------------------------------------------'
' Background Color Object Script '
'----------------------------------------------------'
Set objCScript =
objObject.Properties.Item(10).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define FAILED_ACKD """ & objObject.ObjectName & ".FAILED_ACKD""" &


vbCrLf
strCode = strCode & "#define FAILED""" & objObject.ObjectName & ".FAILED""" &
vbCrLf
strCode = strCode & "#define RNNG""" & objObject.ObjectName & ".RNNG""" & vbCrLf &
vbCrLf
strCode = strCode & "if (GetTagBit (FAILED))" & vbCrLf
strCode = strCode & "return GetTagDWord(""P_ALARM"")" & ";" & vbCrLf & vbCrLf

strCode = strCode & "if (!GetTagBit (RNNG))" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_STPD"")" & ";" & vbCrLf & vbCrLf

strCode = strCode & "if (GetTagBit (RNNG))" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_RNNG"")" & ";" & vbCrLf & vbCrLf

strCode = strCode & "else" & vbCrLf


strCode = strCode & "return GetTagDWord(""P_ACKD"")" & ";" & vbCrLf

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &


".FAILED_ACKD", hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &
".FAILED", hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".RNNG",
hmiVariableCycleTypeOnChange)

End With
'----------------------------------------------------'
' Events '
'----------------------------------------------------'
'Directconnection is initiated by mouseclick:
Set objDConnection =
objObject.Events(1).Actions.AddAction(hmiActionCreationTypeDirectConnection)

With objDConnection

'Sourceobject:

.SourceLink.Type = hmiSourceTypeConstant

.SourceLink.ObjectName = 1

'Destinationobject:

.DestinationLink.Type = hmiDestTypeProperty

.DestinationLink.ObjectName = objObject.ObjectName & "_FP"

.DestinationLink.AutomationName = "Visible"
End With

'----------------------------------------------------'
' Dynamic Tag '
'----------------------------------------------------'
Set objVariableTrigger =
objObject.Properties.Item(13).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"P_ACKD")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange
Set objVariableTrigger =
objObject.Properties.Item(14).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"P_ALARM")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange

Next objObject
End Sub

'####################################################################'
'##### Valve as Custumized Object #####'
'####################################################################'
Sub ValveDynamics()

Dim objCScript As HMIScriptInfo 'configure the code lang. 'Dim


objVBScript As HMIScriptInfo
Dim colSelection As HMISelectedObjects 'define the selected objects
Dim objObject As HMICustomizedObject
Dim strCode As String 'to insert the c or vb code to
the selected obj as it.
Dim objDConnection As HMIDirectConnection
Dim objTrigger As HMIVariableTrigger
Dim objVariableTrigger As HMIVariableTrigger

Set colSelection = ActiveDocument.Selection


For Each objObject In colSelection

'######## Blinking Background Object Script ########


Set objCScript =
objObject.Properties.Item(12).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define ACKD """ & objObject.ObjectName & ".ACKD""" & vbCrLf
strCode = strCode & "return ! GetTagBit(ACKD)" & ";" & vbCrLf

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".ACKD",


hmiVariableCycleTypeOnChange)

End With

'######## Background Color Object Script ########


Set objCScript =
objObject.Properties.Item(10).CreateDynamic(hmiDynamicCreationTypeCScript)

strCode = "#define ACKD """ & objObject.ObjectName & ".ACKD""" & vbCrLf
strCode = strCode & "#define ALARM""" & objObject.ObjectName & ".ALARM""" & vbCrLf

strCode = strCode & "#define OPENED""" & objObject.ObjectName & ".OPENED""" &
vbCrLf
strCode = strCode & "#define CLOSED""" & objObject.ObjectName & ".CLOSED""" &
vbCrLf
strCode = strCode & "if (GetTagBit (ALARM))" & vbCrLf
strCode = strCode & "return GetTagDWord(""V_ALARM"")" & ";" & vbCrLf

strCode = strCode & "if (GetTagBit (CLOSED))" & vbCrLf


strCode = strCode & "return GetTagDWord(""V_CLOSED"")" & ";" & vbCrLf

strCode = strCode & "if (GetTagBit (OPENED))" & vbCrLf


strCode = strCode & "return GetTagDWord(""V_OPENED"")" & ";" & vbCrLf

strCode = strCode & "else" & vbCrLf


strCode = strCode & "return GetTagDWord(""V_ACKD"")" & ";" & vbCrLf

With objCScript

.SourceCode = strCode

Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName & ".ACKD",


hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &
".ALARM", hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &
".OPENED", hmiVariableCycleTypeOnChange)
Set objTrigger = .Trigger.VariableTriggers.Add(objObject.ObjectName &
".CLOSED", hmiVariableCycleTypeOnChange)

End With

'####### Events #######


'Directconnection is initiated by mouseclick:
Set objDConnection =
objObject.Events(1).Actions.AddAction(hmiActionCreationTypeDirectConnection)

With objDConnection

'Sourceobject:

.SourceLink.Type = hmiSourceTypeConstant

.SourceLink.ObjectName = 1

'.SourceLink.AutomationName = ""

'Destinationobject:

.DestinationLink.Type = hmiDestTypeProperty

.DestinationLink.ObjectName = objObject.ObjectName & "_FP"

.DestinationLink.AutomationName = "Visible"
End With
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'###### Dynamic Tag ######
Set objVariableTrigger =
objObject.Properties.Item(13).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"V_ACKD")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange
Set objVariableTrigger =
objObject.Properties.Item(14).CreateDynamic(hmiDynamicCreationTypeVariableDirect,
"V_ALARM")
objVariableTrigger.CycleType = hmiVariableCycleTypeOnChange

Next objObject
End Sub

''####################################################################'
''##### Sol Pictures Window (Object Name & Tag Prefix & Caption Text #####'
''####################################################################'

Sub SolPictureWindow()
Dim Object_Name As String
Dim counter As Integer
Dim var As Integer
Dim EachSlct As HMISelectedObjects
Dim objPictureWindow As HMIPictureWindow
Set EachSlct = ActiveDocument.Selection
counter = 0
var = 0
For Each objPictureWindow In EachSlct
counter = counter + 1
If (counter <= EachSlct.Count) Then
'objPictureWindow.ObjectName = "MV0" & counter + var & "_FP"
objPictureWindow.TagPrefix = objPictureWindow.ObjectName
'"VSP" & counter + var '& "_SC"
objPictureWindow.CaptionText = objPictureWindow.ObjectName
objPictureWindow.PictureName = "FP_DRIVE.PDL"
'FP_DRIVE.PDL,FP_CVALVE.PDL,FP_AI.PDL
End If
Next objPictureWindow

End Sub

''####################################################################'
''##### Custmized Object(Object Name & Tag Prefix & Caption Text #####'
''####################################################################'

Sub NameCustomizedObject()
Dim Object_Name As String
Dim counter As Integer
Dim var As Integer
Dim EachSlct As HMISelectedObjects
Dim objObject As HMICustomizedObject
Set EachSlct = ActiveDocument.Selection
counter = 0
var = 0
For Each objObject In EachSlct
counter = counter + 1
If (counter <= EachSlct.Count) Then
objObject.ObjectName = "VSP" & counter + var '& "DC"
End If
Next objObject

End Sub