Hello
I am writing a custom log file. This also works, but if the trigger signal is low, the loop for the “line writing” hangs. How can I correct this error? Otherwise, entries are generated useless until the next trigger.
eWON_init_section:
Rem --- eWON user (start)
//Trigger for exiting
Onchange "Trigger" , "@Value_Check()"
//Create a CSV file event-controlled with process and program data
Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section
Rem --- eWON start section: User Section
Rem --- eWON user (start)
Function Value_Check()
If (Trigger@ = 1) Then
Print "Recording Start"
T$ = TIME$ // grabs the current time
Date$ = T$ (1 To 2) + "." + T$ (4 TO 5) + "." + T$ (7 TO 10)
Time$ = T$(12 To 13) + ":" + T$(15 To 16) + + + T$(18 To 19)
fileend$ = "New_" + Prodnummer@ + "_" + STR$ lfdNummer@ + "_.csv"
fileName$ = "file:/usr/"+ fileend$
Print "Filename" fileend$
@WriteToFile()
Else
CLOSE 1
Print "Recording Stop"
Return
//FTP - Upload
@File_Upload() // Share to ftp upload
Endif
Endfn
Function WriteToFile()
TSET 1, Aufzrate@ // Begin a interval timer.
ONTIMER 1, "GOTO WriteRecord"
Endfn
WriteRecord:
//Assignments for undershooting
If (Haertetemp@ < 651) Then
HT$ = "0"
Else
HT$ = STR$ Haertetemp@
Endif
If (Kuehltemp@ < 651) Then
KT$ = "0"
Else
KT$ = STR$ Kuehltemp@
Endif
If (MF_Leist@ < 5) Then
MF_Lei$ = "0"
Else
MF_Lei$ = STR$ MF_Leist@
Endif
If (MF_Spng@ < 5) Then
MF_Spa$ = "0"
Else
MF_Spa$ = STR$ MF_Spng@
Endif
//Now below we will verify if the file exists on first cycle.
SETSYS PRG, "RESUMENEXT", 1
CLOSE 1 // Close the file just in case.
OPEN fileName$ FOR BINARY INPUT AS 1
ErrorReturned = GETSYS PRG, "LSTERR"
IF(ErrorReturned = 33) THEN
CLOSE 1
Zeinr% = 0
OPEN fileName$ FOR BINARY OUTPUT AS 1
Put 1, "Recording Rate" + ";" + STR$ Aufzrate@ + ";" + CHR(13) + CHR(10)
Put 1, "Recording Cycle" + ";" + STR$ Aufzzyklus@ + ";" + CHR(13) + CHR(10)
Put 1, "Product Number" +";" + Prodnummer@ + ";" + CHR(13) + CHR(10)
Put 1, "lfd. Number" + ";" + STR$ lfdNummer@ + ";" + CHR(13) + CHR(10)
Put 1, "Date" + ";" + Date$ + CHR( 13) + CHR(10)
Put 1, "Time" + ";" + Time$ + CHR(13) + CHR(10)
Put 1, "Plant Driver" +";" + Anlf@ + ";" + CHR(13) + CHR(10)
PUT 1, "Valuer.; Speed* 0.01 [cm/min]; MF power [kW]; MF voltage [V]; Tempering temperature [°C]; Cooling temperature [°C];D back air* 0.01 [bar];D back air* 0.01 [m3/min]; Air temperature [°C]" + CHR (13) + CHR(10)
Print "Head Written" Time$
CLOSE 1
ELSE
CLOSE 1
OPEN fileName$ FOR BINARY APPEND AS 1
Put 1, STr$ Zeinr% +";" +STR$ Geschw@ +";" + MF_Lei$ +";" + MF_Spa$ +";" + HT$ +";" + KT$ +";" +STR$ Drulu_bar@ +";" +STR$ Drulu_kubikm@ +";" +STR$ Lufttemp@ +";" +CHR(13)+CHR'(10)
Print "Line written No:" Aufzzyklus@
CLOSE 1
Zeinr% = Zeinr% +1
Print "Loop recording active"
Endif
If (Zeinr% > Aufzzyklus@) Then
Close 1
OPEN fileName-FOR BINARY APPEND AS 1
Put 1, "Recording Cycle" + ";" + STR$ Aufzzyklus@ + ";" + CHR(13) + CHR(10)
Close 1
@Value_Check()
Endif
Print "File Closed" fileName$
Print "Counter Flexy" Zeinr%
Print "Counter PLC" Aufzzyklus@
End
Would I have to add another condition?
Michael