WinCC Flexible scripting

Okay, wrote something

Okay, I used something out of your examples...

And this is what I did:

I write data to a text file on an event, it work fine.


But, I see a little light now in my head... o_O

If this data can be stored in txt files... then it must be possible to do some database...

What I want to do is, storing some usefull information.

Let's try in this code that I have until now...

I want to store a tag for example, and in adition I want the time + date. Do I have to convert the time and the date in integers in the PLC to achieve something like this?

Additional question: when the panel is connected on ethernet, can we get the textfiles from a PC on the network ?



Code:
Dim f, path
path = "\Storage Card MMC\Posities.txt"

On Error Resume Next

Set f = CreateObject("FileCtl.File")

If Err.Number <> 0 Then
 ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
 Err.Clear
 Exit Sub
End If

f.open path , 2 

If Err.Number <> 0 Then
 ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
 Err.Clear
 Exit Sub
End If

f.LinePrint("Positie Aanvoer Pneg: " & Pos_A_neg )
f.LinePrint("Positie Aanvoer P0: " & Pos_A_0 )
f.LinePrint("Positie Aanvoer P1: " & Pos_A_1 )
f.LinePrint("Positie Aanvoer P2: " & Pos_A_2 )
f.LinePrint("Positie Aanvoer P3: " & Pos_A_3 )
f.LinePrint("Positie Aanvoer P4: " & Pos_A_4 )
f.LinePrint("Positie Aanvoer P5: " & Pos_A_5 )
f.LinePrint("Positie Aanvoer P6: " & Pos_A_6 )
f.LinePrint("Positie Aanvoer P7: " & Pos_A_7 )
f.LinePrint("Positie Aanvoer P8: " & Pos_A_8 )
f.LinePrint("Positie Aanvoer P9: " & Pos_A_9 )
f.LinePrint("Positie Aanvoer P10: " & Pos_A_10 )
f.LinePrint("Positie Aanvoer P11: " & Pos_A_11 )
f.LinePrint("Positie Aanvoer P12: " & Pos_A_12 )
f.LinePrint("Positie Aanvoer P13: " & Pos_A_13 )
f.LinePrint("Positie Aanvoer P14: " & Pos_A_14 )
f.LinePrint("Positie Aanvoer P15: " & Pos_A_15 )
f.LinePrint("Positie Aanvoer P16: " & Pos_A_16 )
f.LinePrint("Positie Aanvoer P17: " & Pos_A_17 )
f.LinePrint("Positie Aanvoer P18: " & Pos_A_18 )

f.LinePrint("Positie Ponsbank P1: " & Pos_P_1 )
f.LinePrint("Positie Ponsbank P2: " & Pos_P_2 )
f.LinePrint("Positie Ponsbank P3: " & Pos_P_3 )

f.LinePrint("Positie Afvoer Pneg: " & Pos_F_neg )
f.LinePrint("Positie Afvoer P0: " & Pos_F_0 )
f.LinePrint("Positie Afvoer P1: " & Pos_F_1 )
f.LinePrint("Positie Afvoer P2: " & Pos_F_2 )
f.LinePrint("Positie Afvoer P3: " & Pos_F_3 )
f.LinePrint("Positie Afvoer P4: " & Pos_F_4 )
f.LinePrint("Positie Afvoer P5: " & Pos_F_5 )
f.LinePrint("Positie Afvoer P6: " & Pos_F_6 )
f.LinePrint("Positie Afvoer P7: " & Pos_F_7 )
f.LinePrint("Positie Afvoer P8: " & Pos_F_8 )
f.LinePrint("Positie Afvoer P9: " & Pos_F_9 )
f.LinePrint("Positie Afvoer P10: " & Pos_F_10 )
f.LinePrint("Positie Afvoer P11: " & Pos_F_11 )
f.LinePrint("Positie Afvoer P12: " & Pos_F_12 )

f.Close
Set f = Nothing

ShowSystemAlarm "Storage of the data was successful!"
 
You are beginning to get the idea with scripts.
There is a FAQ on Siemens support site that more closely resembles your requirement, including logging with time and date, and it is also for Windows CE.

I do not know if there is some way to get a file out of an ethernet enabled panel.
It is possible to log directly to a network drive, and even to an SQL database, but only for a PC RT. I think that the panels are limited in this respect.
 
ok

okay, I'll try to find it

only the PC runtime...
that's a pitty...


JesperMP said:
You are beginning to get the idea with scripts.
There is a FAQ on Siemens support site that more closely resembles your requirement, including logging with time and date, and it is also for Windows CE.

I do not know if there is some way to get a file out of an ethernet enabled panel.
It is possible to log directly to a network drive, and even to an SQL database, but only for a PC RT. I think that the panels are limited in this respect.
 
If you want to log alarms, then dont waste any time with developing your own script based logging.
Simply setup an archive for alarms and it will happen fully automatically.
 
JesperMP said:
I do not know if there is some way to get a file out of an ethernet enabled panel.
It is possible to log directly to a network drive, and even to an SQL database, but only for a PC RT. I think that the panels are limited in this respect.

As long as you use: \\servername(or IP)\shared folder(or drive)\
As long as the server exists and the folder/drive is shared, then it should be no problem.
The logs will be .csv format and will be 'in use' as long as the runtime is running. 'In use' means should you open it, with excel for example, while the runtime is still active, it will stop logging.
We use OP270.......even those, without built in ethernet, can log to servers.
I suppose it should be possible to make the script save the .txt file on a server also.
 
Hi

I agree, but I have problems with it...

When I insert an MMC, it logs,

but, after one day, I take a look, I replace the file, and nothing happens, it doesn't log anymore.

Look at the attachement, change the txt extension to csv please, there is something strange also, look at the date's.

Question: do I have to delete the log file before I replace the MMC card ?

Logging method: Create segmental circular logs, this doesn't happen either. Set to 50 Logs. No of Records is set to 500000

SOmething I do wrong ?



JesperMP said:
If you want to log alarms, then dont waste any time with developing your own script based logging.
Simply setup an archive for alarms and it will happen fully automatically.
 
useful

That's useful information, thanks.

So, the alarm logging has to be okay first, I need trustable alarmlogfiles. When I achieve that I can do some script things if still needed...

One script is allready in use..., the autosave of parameters to a txt file. Very useful, tnx Jesper.




Jeebs said:
As long as you use: \\servername(or IP)\shared folder(or drive)\
As long as the server exists and the folder/drive is shared, then it should be no problem.
The logs will be .csv format and will be 'in use' as long as the runtime is running. 'In use' means should you open it, with excel for example, while the runtime is still active, it will stop logging.
We use OP270.......even those, without built in ethernet, can log to servers.
I suppose it should be possible to make the script save the .txt file on a server also.
 
Combo said:
I agree, but I have problems with it...

When I insert an MMC, it logs,

but, after one day, I take a look, I replace the file, and nothing happens, it doesn't log anymore.

Look at the attachement, change the txt extension to csv please, there is something strange also, look at the date's.

Question: do I have to delete the log file before I replace the MMC card ?

Logging method: Create segmental circular logs, this doesn't happen either. Set to 50 Logs. No of Records is set to 500000

SOmething I do wrong ?
If you have setup alarm logging to an MMC card, then you must setup a button with the StopLogging function. Before removing the MMC card the operator must use this button. Setup another button with StartLogging to be used after the MMC card has been inserted again.
Have you done the above ?
You dont have to delete the logfiles.
It works OK for me with PC RT. Cannot speak for CE panels.
 
Jeebs said:
As long as you use: \\servername(or IP)\shared folder(or drive)\
As long as the server exists and the folder/drive is shared, then it should be no problem.
The logs will be .csv format and will be 'in use' as long as the runtime is running. 'In use' means should you open it, with excel for example, while the runtime is still active, it will stop logging.
We use OP270.......even those, without built in ethernet, can log to servers.
I suppose it should be possible to make the script save the .txt file on a server also.
Aha. So that is what the "\\" selection was for in the "Path" dialog for the log setup.
 
okay

okay,

but, there is no feedback if the runtime is actually logging or not after pressing such buttons ...

I replaced my MMC, 1 hour ago, I now saw that it didn't log..., I rebooted, now it's logging I hope... ?



JesperMP said:
If you have setup alarm logging to an MMC card, then you must setup a button with the StopLogging function. Before removing the MMC card the operator must use this button. Setup another button with StartLogging to be used after the MMC card has been inserted again.
Have you done the above ?
You dont have to delete the logfiles.
It works OK for me with PC RT. Cannot speak for CE panels.
 
I saw a FAQ once that it is important to have a MMC inserted if logging is on. If not, Windows CE gets confused and redirects the log path to the internal flash memory (= bad !).
It should be important that the very first time that logging is started that the flash card is inserted as some registry entries gets set at this time. If the problem can also occur at a later time, and the flash card is not there, I do not know.
You may have to reinstall the OS (OS update) !
 
:-(

I don't like reading such things...

To read the data of the flashcard, we need to take it out..., so there must be a good way to pull it out...?



JesperMP said:
I saw a FAQ once that it is important to have a MMC inserted if logging is on. If not, Windows CE gets confused and redirects the log path to the internal flash memory (= bad !).
It should be important that the very first time that logging is started that the flash card is inserted as some registry entries gets set at this time. If the problem can also occur at a later time, and the flash card is not there, I do not know.
You may have to reinstall the OS (OS update) !
 
Yes, that is why you have to use the StopLogging and StartLogging functions. There is also CloseAllLogs and OpenAllLogs.
Again, I am not sure that the consequences are so grave if you remove the card without stopping the datalogs, if the registry values have already been set.
Anyway, try to program CloseAllLogs and OpenAllLogs. It should reestablish all logging.

If this is not acceptable to you, try to see if you can use the network logging that Jeebs mentioned.
 

Similar Topics

I currently have a script that load on startup that reads maybe 16 values off a DB on my PLC. I take those values and then store them on another...
Replies
15
Views
4,459
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
247
Hello everyone I Have an Issue with the usage of recipes in Wincc Flexible 2008, I create the recipe to change the values in a fast way The...
Replies
0
Views
101
Hi colleagues.We do data logging system.We want to record three temperatures under a certain condition. We prepared the project as follows. We do...
Replies
1
Views
745
Hello to everyone. I change the value of a "PQW" with a button in Wincc flexible. The code of the button is defined as M102.0. Value reset...
Replies
10
Views
4,563
Back
Top Bottom