VB Script
VB Script
'Tip:
' 1. Use the <CTRL+SPACE> or <CTRL+I> keystroke to open a list of all objects and
functions
' 2. Write the code using the HMIRuntime object.
' Example: HmiRuntime.Screens("Screen_1").
' 3. Use the <CTRL+J> keystroke to create an object reference.
'Write the code as of this position:
'----------------------------------------------------------------------------------
---------------
'Script Name : DataLogging
'Functions : 1. Write the data into a csv file (also create the csv file if it
doesnot exist).
' 2. Update the values in the GUI Components of Main Screen.
'----------------------------------------------------------------------------------
---------------
Dim PLC_Year
Dim PLC_Month
Dim PLC_Day
Dim PLC_Hour
Dim PLC_Minute
Dim PLC_Second
'SmartTags("Parameter_A") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_B") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_C") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_D") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_E") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_F") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_G") = FormatNumber(Rnd,2,-1)
'SmartTags("Parameter_H") = FormatNumber(Rnd,2,-1)
Parameter_A = FormatNumber(SmartTags("Parameter_A"),2,-1)
Parameter_B = FormatNumber(SmartTags("Parameter_B"),2,-1)
Parameter_C = FormatNumber(SmartTags("Parameter_C"),2,-1)
Parameter_D = FormatNumber(SmartTags("Parameter_D"),2,-1)
Parameter_E = FormatNumber(SmartTags("Parameter_E"),2,-1)
Parameter_F = FormatNumber(SmartTags("Parameter_F"),2,-1)
Parameter_G = FormatNumber(SmartTags("Parameter_G"),2,-1)
Parameter_H = FormatNumber(SmartTags("Parameter_H"),2,-1)
PLC_Year = CStr(Year(Date))
PLC_Month = CStr(Month(Date))
PLC_Day = CStr(Day(Date))
PLC_Hour = CStr(Hour(Time))
PLC_Minute = CStr(Minute(Time))
PLC_Second = CStr(Second(Time))
WriteStream = ( _
PLC_Year & "/" & PLC_Month & "/" & PLC_Day & "," & _
PLC_Hour & ":" & PLC_Minute & ":" & PLC_Second & "," & _
Parameter_A & "," & _
Parameter_B & "," & _
Parameter_C & "," & _
Parameter_D & "," & _
Parameter_E & "," & _
Parameter_F & "," & _
Parameter_G & "," & _
Parameter_H)
SmartTags("Alarm_Text") = AlarmText
If SmartTags("TRIGGER_2") = 1 Then
SmartTags("TRIGGER_2") = 0
Else
SmartTags("TRIGGER_2") = 1
End If
File_Object.LinePrint WriteStream
File_Object.Close