Scriptproblem in WInCC Flex

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
I have an MP277 touch, a 317 CPU and a PC on an ethernet network.

CPU: 192.168.0.2
MP277: 192.168.0.3
PC: 192.168.0.5

From the MP277 I am able to browse to the CPU his webserver. From the MP277 I can ping to the PC. From the PC I can Ping to the CPU and browse to the webserver and ping to the MP277. So the network is fine.


The peace of code where I have problems with is this:

Set fso = CreateObject("Scripting.FileSystemObject")
SmartTags("File") = "\\192.168.0.5\C:\HISTORIAN\" & CStr(SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER")) & ".csv"



Normally, the folder should be created on the shared C drive of my PC, but it doesn't. The MP277 gives an error:
ActiveX error: object cannot be created.

Anyone an idea where it goes wrong ?

Thanks
 
The "Set fso = CreateObject("Scripting.FileSystemObject")" is for Windows. But you have Windows CE on the MP panel.


This is for Windows CE. It should create the folder if it does not exist already:
Dim fso
Set fso = CreateObject("filectl.filesystem")
If fso.dir("\\192.168.0.5\C:\HISTORIAN\") = "" Then fso.mkdir(\\192.168.0.5\C:\HISTORIAN\)
NB. I didn't know that you could just use the IP address for referencing the remote station.
 
Last edited:
Hey

You're right about CE, the script was written on a PC Runtime. Thanks for the correction.

I hope that it will work to write to a server location like this. I did not try this, but I've red it somewhere on this forum.

Kind regards,

G

The "Set fso = CreateObject("Scripting.FileSystemObject")" is for Windows. But you have Windows CE on the MP panel.


This is for Windows CE. It should create the folder if it does not exist already:
Dim fso
Set fso = CreateObject("filectl.filesystem")
If fso.dir("\\192.168.0.5\C:\HISTORIAN\") = "" Then fso.mkdir(\\192.168.0.5\C:\HISTORIAN\)
NB. I didn't know that you could just use the IP address for referencing the remote station.
 
Hmm

I can compile it. Downloaded it in the panel. I can ping from the MP277 Panel to the PC 192.168.0.5. But, when the script runs I get the error: The Network Path was not found...

Any ideas ?

It should work, see Jeebs: http://www.plctalk.net/qanda/showthread.php?t=39653&highlight=network+location+csv&page=3

My complete program (maybe another wondows xp thing instead of CE:

Code:
[FONT=Arial][SIZE=2]Dim fso, f, ts, DataSet, Dataformat
Delay(5) '5 seconds delay
On Error Resume Next
Set fso = CreateObject("filectl.filesystem")
If fso.dir("\\192.168.0.5\C:\HISTORIAN\") = "" Then fso.mkdir("\\192.168.0.5\C:\Historian\")
 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 0 Then
SmartTags("Script_String_1")= "ø6,2 L0"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 1 Then
SmartTags("Script_String_1")= "ø6,2 L20" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 2 Then
SmartTags("Script_String_1")= "ø6,2 L40" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 3 Then
SmartTags("Script_String_1")= "ø6,2 L60"
End If 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 4 Then
SmartTags("Script_String_1")= "ø6,2 L80"
End If 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 5 Then
SmartTags("Script_String_1")= "ø6,2 L100" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 6 Then
SmartTags("Script_String_1")= "ø8,2 L0" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 7 Then
SmartTags("Script_String_1")= "ø8,2 L20" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 8 Then
SmartTags("Script_String_1")= "ø8,2 L40" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 9 Then
SmartTags("Script_String_1")= "ø8,2 L60"
End If 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 10 Then
SmartTags("Script_String_1")= "ø8,2 L80" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 11 Then
SmartTags("Script_String_1")= "ø8,2 L100"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 0 Then
SmartTags("Script_String_2")= "Geen"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 1 Then
SmartTags("Script_String_2")= "ø6,2"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 2 Then
SmartTags("Script_String_2")= "ø8,2"
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 0 Then
SmartTags("Script_String_3")= "Enkel Gat" 
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 1 Then
SmartTags("Script_String_3")= "Dubbel Gat 21mm" 
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 2 Then
SmartTags("Script_String_3")= "Dubbel Gat 31mm" 
End If 

If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._MATERIAAL") = 0 Then
SmartTags("Script_String_4")= "Aluminium" 
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._MATERIAAL") = 1 Then
SmartTags("Script_String_4")= "Verzinkt Staal" 
End If 
Dataformat = "Datum" & ";" & "Tijd" & ";" & "Ordernummer" & ";" & "Regelnummer" & ";" & "Leverdatum" & ";" & "Artikelnummer" & ";" & "Buistype" & ";" & "Klantnummer" & ";" & "Matrijs Stempel 1" & ";" & "Matrijs Stempel 2" & ";" & "Marijs Gaten" & ";" & "Buismateriaal" & ";" & "Buisdiameter" & ";" & "Buisdikte" & ";" & "Hart Op Hart" & ";" & "Hoek 1" & ";" & "Hoek 2" & ";" & "Grondstoflengte" & ";" & "Totaal aantal" & ";" & "Aantal per bundel" & ";" & "Aantal geproduceerd" & ";" 
DataSet = (Date & ";" & Time & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.ORDER_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.REGEL_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.LEVER_DATUM") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.ARTIKEL_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.BUIS_TYPE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER") & ";" & SmartTags("Script_String_2") & ";" & SmartTags("Script_String_1") & ";" & SmartTags("Script_String_3") & ";" & SmartTags("Script_String_4") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._DIAMETER") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._DIKTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._LENGTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._HOEK_1") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._HOEK_2") & ";" & SmartTags("HISTORIAN BATCH.GRONDSTOF_LENGTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._AANTAL") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._AANTAL_PER_BUNDEL") & ";" & SmartTags("BATCH STATUS.PRODUCTIE_AANTAL")) 

If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
If Not fso.FileExists (SmartTags("File")) Then
fso.CreateTextFile (SmartTags("File"))
Set f = fso.GetFile (SmartTags("File"))
Set ts = f.OpenAsTextStream(8,-2)
ts.WriteLine Dataformat
ts.WriteLine ""
ts.WriteLine DataSet
ts.Close
Else
Set f = fso.GetFile (SmartTags("File"))
Set ts = f.OpenAsTextStream(8,-2)
ts.WriteLine DataSet
ts.Close
End If
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set ts = Nothing
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Storage of the data was successful!"
[/SIZE][/FONT]
 
Last edited:
Oops, I deleted a line

SmartTags("File") = "\\192.168.0.5\C:\HISTORIAN\" & CStr(SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER")) & ".csv"


Stupid... hmzz
 
NB. I didn't know that you could just use the IP address for referencing the remote station.


You still can't.
I think thats the problem here.
The PC needs to be in a domain, think with a DNS even, and needs to be reffered to with it's name.
Spent 2 days trying to get the IP adressing to work. Still haven't managed. When using the computer name it works from the first go.

Still looking into it. Probably will have to contact Siemens about this.......see what they say.
 
okay

This is my last code, and indeed, I still get: Error: The Network Path was not found...

About a domain, I'm testing with a Laptop, MP277 and 317 CPU as network devices. Domain names is something that a server manages normally, so is there an alternative option to test things ?

Kind regards



Code:
[FONT=Arial][SIZE=2]
Dim fso, f, ts, DataSet, Dataformat
Delay(5) '5 seconds delay
On Error Resume Next
Set fso = CreateObject("filectl.filesystem")
If fso.dir("\\192.168.0.5\C:\S\HISTORIAN\") = "" Then fso.mkdir("\\192.168.0.5\C:\HISTORIAN\")
SmartTags("File") = "\\192.168.0.5\C:\S\HISTORIAN\" & CStr(SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER")) & ".csv"
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 0 Then
SmartTags("Script_String_1")= "ø6,2 L0"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 1 Then
SmartTags("Script_String_1")= "ø6,2 L20" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 2 Then
SmartTags("Script_String_1")= "ø6,2 L40" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 3 Then
SmartTags("Script_String_1")= "ø6,2 L60"
End If 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 4 Then
SmartTags("Script_String_1")= "ø6,2 L80"
End If 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 5 Then
SmartTags("Script_String_1")= "ø6,2 L100" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 6 Then
SmartTags("Script_String_1")= "ø8,2 L0" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 7 Then
SmartTags("Script_String_1")= "ø8,2 L20" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 8 Then
SmartTags("Script_String_1")= "ø8,2 L40" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 9 Then
SmartTags("Script_String_1")= "ø8,2 L60"
End If 
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 10 Then
SmartTags("Script_String_1")= "ø8,2 L80" 
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_1") = 11 Then
SmartTags("Script_String_1")= "ø8,2 L100"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 0 Then
SmartTags("Script_String_2")= "Geen"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 1 Then
SmartTags("Script_String_2")= "ø6,2"
End If
If SmartTags ("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._STEMPEL_2") = 2 Then
SmartTags("Script_String_2")= "ø8,2"
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 0 Then
SmartTags("Script_String_3")= "Enkel Gat" 
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 1 Then
SmartTags("Script_String_3")= "Dubbel Gat 21mm" 
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.MATRIJS._GATEN") = 2 Then
SmartTags("Script_String_3")= "Dubbel Gat 31mm" 
End If 

If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._MATERIAAL") = 0 Then
SmartTags("Script_String_4")= "Aluminium" 
End If 
If SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._MATERIAAL") = 1 Then
SmartTags("Script_String_4")= "Verzinkt Staal" 
End If 
Dataformat = "Datum" & ";" & "Tijd" & ";" & "Ordernummer" & ";" & "Regelnummer" & ";" & "Leverdatum" & ";" & "Artikelnummer" & ";" & "Buistype" & ";" & "Klantnummer" & ";" & "Matrijs Stempel 1" & ";" & "Matrijs Stempel 2" & ";" & "Marijs Gaten" & ";" & "Buismateriaal" & ";" & "Buisdiameter" & ";" & "Buisdikte" & ";" & "Hart Op Hart" & ";" & "Hoek 1" & ";" & "Hoek 2" & ";" & "Grondstoflengte" & ";" & "Totaal aantal" & ";" & "Aantal per bundel" & ";" & "Aantal geproduceerd" & ";" 
DataSet = (Date & ";" & Time & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.ORDER_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.REGEL_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.LEVER_DATUM") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.ARTIKEL_NUMMER") & ";" & SmartTags("HISTORIAN BATCH.BUIS_TYPE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.KLANT_NUMMER") & ";" & SmartTags("Script_String_2") & ";" & SmartTags("Script_String_1") & ";" & SmartTags("Script_String_3") & ";" & SmartTags("Script_String_4") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._DIAMETER") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.BUIS._DIKTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._LENGTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._HOEK_1") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._HOEK_2") & ";" & SmartTags("HISTORIAN BATCH.GRONDSTOF_LENGTE") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._AANTAL") & ";" & SmartTags("HISTORIAN BATCH.ORDER_DATABASE.WENS._AANTAL_PER_BUNDEL") & ";" & SmartTags("BATCH STATUS.PRODUCTIE_AANTAL")) 

If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
If Not fso.FileExists (SmartTags("File")) Then
fso.CreateTextFile (SmartTags("File"))
Set f = fso.GetFile (SmartTags("File"))
Set ts = f.OpenAsTextStream(8,-2)
ts.WriteLine Dataformat
ts.WriteLine ""
ts.WriteLine DataSet
ts.Close
Else
Set f = fso.GetFile (SmartTags("File"))
Set ts = f.OpenAsTextStream(8,-2)
ts.WriteLine DataSet
ts.Close
End If
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set ts = Nothing
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Storage of the data was successful!"
[/SIZE][/FONT]

You still can't.
I think thats the problem here.
The PC needs to be in a domain, think with a DNS even, and needs to be reffered to with it's name.
Spent 2 days trying to get the IP adressing to work. Still haven't managed. When using the computer name it works from the first go.

Still looking into it. Probably will have to contact Siemens about this.......see what they say.
 
All of the methods used, FileExists, GetFile, OpenAsTextStream etc. are for the normal Windows FileSystemObject.

I think this will work with Win CE:
Code:
//REMOTEPC is the name of the PC in the workgroup
Dim f,fs, file_name, file_path, file_name_path, str_data
 
Set f = CreateObject("filectl.file")
Set fs = CreateObject("filectl.filesystem")
 
file_path = "\\REMOTEPC\C:\HISTORIAN\"
 
// modify this line to specify the correct file name
file_name = CStr(SmartTags("HISTORIANBATCH.ORDER_DATABASE.KLANT_NUMMER")) & ".csv"
 
file_name_path = file_path & file_name
 
// modify this line to fill str_data with the needed information
str_data = SmartTags("Script_String_1") 
 
//make the directory
If fs.dir(file_path) = "" Then fs.mkdir(file_path)
 
//make the file or append to the file
If fs.dir(file_name_path) = "" Then 
  f.open file_name_path, 2 //"2" is for writing
  f.LinePrint str_data
  f.Close
Else
  f.open file_name_path, 8 //"8" is for appending
  f.LinePrint str_data
  f.Close
End If
 
Last edited:
It just dawned on me.
Are you testing on a PC ?
But you intend to run it on an MP panel !?
Then the code will have to be different depending on if you are testing on the PC or running it on the panel.
 
I changed the IP adress with my PC name: PLC_102

I can ping to the Hostname PLC_102

Still the same error
 
Mp

I first wrote it on a PC Runtime (stated with basic script from the siemens site, for PC Runtime).

Now that I have the MP277, I need to run the same script on that MP, not the PC anymore, it's the MP that needs to write to the PC.

I'll take a look at the things you saw that were not okay for CE


It just dawned on me.
Are you testing on a PC ?
But you intend to run it on an MP panel !?
Then the code will have to be different depending on if you are testing on the PC or running it on the panel.
 
Taken directly from the isntallation manual for the MP277:

Addressing

Within a PROFINET network, computers are usually addressed using computer names. These computer names are translated from a DNS or WINS server to TCP/IP addresses. This is why a DNS or WINS server is needed for addressing via computer names when the HMI device is in a PROFINET network.
The corresponding servers are generally available in PROFINET networks.

Note
The use of TCP/IP addresses to address PCs is not supported by the operating system.


Consult your network administrator if you have questions in this regard




You need the PC to be in a domain with a DNS or WINS server. Else it's never gonna connect.
 

Similar Topics

hello s7-400h and wincc are connected to each other via Ethernet. I need help on how to do time synchronization
Replies
0
Views
41
Greetings I have a problem, my system is the following: wincc v8.0 (demo), logo8.3, abb m2m analyzer. I created some pages to display the...
Replies
0
Views
53
Hi, We have upgraded our laptop which includes Windows 11. It appears that WinCC flexible 2008 advanced does not support Windows 11. What...
Replies
11
Views
254
In our production plant we have multiple different networks (subnets). IT dept have setup routing between them so different subnets can...
Replies
0
Views
84
Is it possible to connect a PC with running WinCC Advanced or Unified to a siemens PLC such as S7-1200 across different subnets? The computers can...
Replies
0
Views
74
Back
Top Bottom