| View previous topic :: View next topic |
| Author |
Message |
SohrabB Junior 2

Joined: 04 May 2012 Posts: 29
|
Posted: 01/01/2018 20:57 Post subject: TIA Portal 14 VBScript for MHI MP277 10" |
|
|
Hi everyone
I have written a VBScript on the TIA Portal, and it works well with simulation on Windows, but it does not work on the HMI MP277 (Windows CE 5.0). Can anyone correct it for me?
My file is attached. Many thanks
[url=http://www.girlshare.ro/3490003606.1]US_Data_Log_2.vbs[/url]
-------------------------------------------------------------------------------
Sub US_Data_Log_SB()
Dim fso, f, ts
'Declaration of local tags - Deklaration der lokalen Variablen
Dim path
Dim mode
Dim delimiter
Dim gap
Dim NewJob
NewJob=False
Dim NextStep
SmartTags("LOG_US_Start")=1
Path = SmartTags("LOG_US_WriteFileName") = "\Storage Card USB\LOG_US_" & CStr(DatePart("yyyy",Date)) & "-" & CStr(DatePart("m",Date)) & "-" & CStr(DatePart("d",Date)) & "_" & CStr(SmartTags("Job_Number")) & ".csv"
SmartTags("LOG_US_WriteFileName") = Path
'Starting error routine - Starten der Fehlerroutine
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<> 0 Then
ShowSystemAlarm "Error # " & CStr(Err.Number)& " "& Err.Description
Err.Clear
Exit Sub
End If
If Not fso.FileExists(path) Then
fso.CreateTextFile path
NewJob = True
End If
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<> 0 Then
ShowSystemAlarm "Error # " & CStr(Err.Number)& " "& Err.Description
Err.Clear
Exit Sub
End If
'Initialization of Tags - Initialisierung von Variablen
mode=8 '8 = Append
Set f = fso.GetFile(path)
Set ts = f.OpenAsTextStream(8, -2)
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<0>=NextStep Then
'Write data into file - Daten werden in die Datein geschrieben
ts.WriteLine (CStr(Date) & "," & CStr(Time) & "," & SmartTags("US_Density") & "," & SmartTags("US_Pump1_Pressure") & "," & SmartTags("US_Pump2_Pressure") & "," & SmartTags("US_Pump1_Flow") & "," & SmartTags("US_Pump2_Flow") & "," & SmartTags("US_Pump1_Volume") & "," & SmartTags("US_Pump2_Volume") & "," & SmartTags("US_Pumps_Total_Flow") & "," & SmartTags("US_Pumps_Total_Volume") & ",")
'Check if any errors happend - Auf Fehler prüfen
If Err.Number<> 0 Then
ShowSystemAlarm "Error # " & CStr(Err.Number)& " "& Err.Description
Err.Clear
Exit Sub
End If
' NextStep=Timer+1
NextStep=Timer + SmartTags("LOG_Interval_Time")
End If
Loop Until SmartTags("LOG_US_Stop")=1
ts.Close
ShowSystemAlarm "Storage of data finished"
End Sub
Last edited by SohrabB on 02/01/2018 09:21; edited 2 times in total |
|
| Back to top |
|
 |
commit Junior

Joined: 28 Dec 2017 Posts: 3
|
Posted: 01/01/2018 21:23 Post subject: |
|
|
| No file..reupload.. |
|
| Back to top |
|
 |
SohrabB Junior 2

Joined: 04 May 2012 Posts: 29
|
Posted: 02/01/2018 11:24 Post subject: |
|
|
| commit wrote: | | No file..reupload.. |
Hi Thanks
The post has been modified. |
|
| Back to top |
|
 |
maersk Member 3


Joined: 17 Aug 2014 Posts: 891
|
Posted: 02/01/2018 14:55 Post subject: |
|
|
Read on how do you store data with a script in a file with WinCC TIA Portal on
http://plc.myforum.ro/viewtopic.php?p=27086#27086
Adapt your script eventually. |
|
| Back to top |
|
 |
SohrabB Junior 2

Joined: 04 May 2012 Posts: 29
|
Posted: 04/01/2018 19:28 Post subject: |
|
|
| maersk wrote: | Read on how do you store data with a script in a file with WinCC TIA Portal on
http://plc.myforum.ro/viewtopic.php?p=27086#27086
Adapt your script eventually. |
Thanks ........................................................... |
|
| Back to top |
|
 |
|