WinCC C Script Ordner anlegen

hello1986

Level-2
Beiträge
11
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo,
ich habe folgendes Problem. Ich habe ein C Script mit dem ich Raumtemperaturen alle zehn Minuten speichere.
Dieses mache ich folgendermaßen, indem ich zwei Scripte aufrufe eins alle 24h einmal, dabei wird der Kopf für die .csv Datei erstellt
und das zweite alle zehn Minuten, indem werden die Raumtemperaturen geschrieben.
Nun will ich aber das die Ordner Automatisiert erstellt werden und das einmal für das Jahr und für den jeweiligen Monat und die .csv Datei im
richtigen Ordner abgelegt wird.
Hierbei komme ich nun nicht weiter da ich nicht weiß wie ich mit C Script einen Ordner erstelle! Falls jemand einen passenden Code hat würde ich mich freuen.

Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"apdefap.h"[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] gscAction( [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] )[/SIZE]
[SIZE=2]
{

[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]// WINCC:TAGNAME_SECTION_START

// syntax: #define TagNameInAction "DMTagName"

// next TagID : 1

// WINCC:TAGNAME_SECTION_END

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000]
[/COLOR][/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]// WINCC:PICNAME_SECTION_START

// syntax: #define PicNameInAction "PictureName"

// next PicID : 1

// WINCC:PICNAME_SECTION_END

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000]
[/COLOR] 

 

[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]// Wird einmalig augerufen um 00:00h

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]HWND Handle;

time_t timer;

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]struct
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] tm *ptm;[/SIZE]
[SIZE=2]

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] path1[130]=[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"C:\\Raumtemperaturen\\R305\\Temp_R305_"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];        [/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Lokaler Pfad[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Datum[20],DatUhr[20];[/SIZE]
[SIZE=2]

FILE *file;


time(&timer);

ptm=localtime(&timer);

Handle = FindWindow(
[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"PDLRTisAliveAndWaitsForYou"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"WinCC-Runtime - "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]

 

[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Dateiname erstellen

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sprintf(Datum,
[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"%04d-%02d-%02d"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
[SIZE=2]
    ptm->tm_year+1900,    
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Jahr[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]    ptm->tm_mon+1,        
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Monat[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]    ptm->tm_mday        
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Tag[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]    );


 

strcat(path1,Datum);                         
[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Dateiname mit lokalem Pfad zusammenbauen[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]strcat(path1,
[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]".csv"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);                         [/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Datei-Endung csv[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
 

[/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]// Kopfzeile für csv-Datei erzeugen

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]file=fopen(path1,
[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"a"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);                          [/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Neue Datei zum Schreiben am Dateiende öffnen[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (file!=NULL)                              [/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Datei-Pfad vorhanden?[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]    {

    fprintf(file,
[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"Datum Uhrzeit;Soll R305;Ist R305 Z1;R305 Z2;Ist R305 Z3;Ist R305 Z4;Ist R305 Z5;\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]
    fclose(file);

    }


 

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]                                [/SIZE][SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]//Kann Pfad für Datei Temperatur -Erfassung nicht finden[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#008080][SIZE=2][COLOR=#008080]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]    {

    MessageBox(Handle,
[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"Kann Pfad für Datei R305 nicht finden!"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]"Datenspeichern"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/SIZE]
[SIZE=2]
                MB_OK|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);

    }


 

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE]
[SIZE=2]
}
[/SIZE]

MFG Hello
 
Zurück
Oben