systemzeit zu filezeit in Filename

akwung

Level-1
Beiträge
8
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Liebe Freunde

ich will Systemzeit für filezeit bei jeder neuen Fileopen erzeugen. und bei der Name wird es auch automatisch eingeschrieben.

ich habe so wie in dem Bild gemacht, program läuft, aber keine file wird erzeugt in mein FTP. was ist Los?

Vielen Dank



Arthur
 

Anhänge

  • prg.jpg
    prg.jpg
    27,5 KB · Aufrufe: 48
Hallo

no, i get nothing, the file war not successfully open, i have no idea what should i change then?

Ich habe ess versucht und...du musst die name wechseln... "'c:\20111020190757060.csv'" ohne":" "." "-" in die name und das klapt... :)

diese characters sind dass probleme

eine möglichkeit:
Code:
FUNCTION CONV_Timestruct_To_Timestamp : STRING
VAR_INPUT
    DateTime    :TIMESTRUCT;
END_VAR
VAR
    output: STRING;
END_VAR
Code:
output :=  WORD_TO_STRING(DateTime.wYear);
IF DateTime.wMonth < 10
THEN
    output := CONCAT(output, '0');
END_IF;
output := CONCAT( output, WORD_TO_STRING(DateTime.wMonth));
(*Make sure day number is always 2 digits*)
IF DateTime.wDay < 10
THEN
    output := CONCAT(output, '0');
END_IF;
output := CONCAT(output, WORD_TO_STRING(DateTime.wDay));
output := CONCAT(output, ' ');
(*Make sure hour number is always 2 digits*)
IF DateTime.wHour < 10
THEN
    output := CONCAT(output, '0');
END_IF;
output := CONCAT(output, WORD_TO_STRING(DateTime.wHour));
(*Make sure minute number is always 2 digits*)
IF DateTime.wMinute < 10
THEN
    output := CONCAT(output, '0');
END_IF;
output := CONCAT(output, WORD_TO_STRING(DateTime.wMinute));
(*Make sure second number is always 2 digits*)
IF DateTime.wSecond < 10
THEN
    output := CONCAT(output, '0');
END_IF;
output := CONCAT(output, WORD_TO_STRING(DateTime.wSecond));
CONV_Timestruct_To_Timestamp := output;

wenn sie diese function gebrauche und nicht "SYSTEMTIME_TO_STRING" hatte sie etwas, andere möglichkeiten auch :rolleyes:
 
Hallo,
hat schon mal jemand getestet wie lange diese String Functionen brauchen?
Erschreckend!
Ich bevorzuge da eher die Pointer Variante.
Code:
VAR
MyString1:STRING([COLOR=Red]22[/COLOR]);
MyString2:STRING(14);
pby1,pby2:POINTER TO BYTE;
END_VAR

MyString1:=TIME_TO_STRING([COLOR=Red][FONT=monospace]SystimeGetTimestamp[/FONT][/COLOR]()); //oder so ähnlich, [COLOR=Red]so passts[/COLOR]

(*MyString1 sollte jetzt das enthalten '[COLOR=Red]D[/COLOR]T#2011-10-26-23:10:04'*)

pby1:=ADR(MyString1);
pby2:=ADR(MyString2);
pby2[0]:=pby[[COLOR=Red]3[/COLOR]];
pby2[1]:=pby[[COLOR=Red]4[/COLOR]];
pby2[2]:=pby[[COLOR=Red]5[/COLOR]];
pby2[3]:=pby[[COLOR=Red]6[/COLOR]];
pby2[4]:=pby[[COLOR=Red]8[/COLOR]];
pby2[5]:=pby[[COLOR=Red]9[/COLOR]];
pby2[6]:=pby[[COLOR=Red]11[/COLOR]];
pby2[7]:=pby[[COLOR=Red]12[/COLOR]];
pby2[8]:=pby[[COLOR=Red]14[/COLOR]];
pby2[9]:=pby[[COLOR=Red]15[/COLOR]];
pby2[10]:=pby[[COLOR=Red]17[/COLOR]];
pby2[11]:=pby[[COLOR=Red]18[/COLOR]];
pby2[12]:=pby[[COLOR=Red]20[/COLOR]];
pby2[13]:=pby[[COLOR=Red]21[/COLOR]];

(*MyString2 sollte jetzt '20111026231004' enthalten*)
Hier du haste noch andere Möglichkeite! ;)
 
Zuletzt bearbeitet:
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo,
war ganz schön spät gestern :sm13:, hab das jetzt noch mal mit CoDeSys gemacht (optimiert) und getestet. Diesmal als Function:
Code:
FUNCTION MyTimeToString : STRING(14)
VAR
    MyString        :STRING(22);
    pby1,pby2        :POINTER TO BYTE;
    uiIndx1,uiIndx2    :UINT;
END_VAR
(*Implementierung*)
MyString:=DT_TO_STRING(UDINT_TO_DT(SysTimeGetTimestamp())); //MyString ist jetzt 'DT#2011-10-27-22:30:34'
pby1:=ADR(MyString);
pby2:=ADR(MyTimeToString);
uiIndx2:=0;
FOR uiIndx1:= 3 TO 21 DO
    CASE pby1[uiIndx1] OF
     16#30..16#39:    //ASCII-Code für Zeichen '0' - '9'
        pby2[uiIndx2]:=pby1[uiIndx1];
         uiIndx2:=uiIndx2+1;
    END_CASE
END_FOR
Die Function "SysTimeGetTimestamp" ist aus der Bibliothek SysTimeRtc in CoDeSys V3.4 (siehe Bild) So eine Function sollte aber auf jedem System verfügbar sein.
 

Anhänge

  • LibManager_SysTimeRtc.JPG
    LibManager_SysTimeRtc.JPG
    42,6 KB · Aufrufe: 17
Zurück
Oben