Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: this_feature_currently_requires_accessing_site_using_safari
char dayWhenFileWasLastWritten[80];
while ((timediff < m_time) || m_time == 0)
{
if [color=red](strftime("%d")[/color] != dayWhenFileWasLastWritten) {
//if [color=red](strftime("%d")[/color] != dayWhenFileWasLastWritten.c_str()) {
errorcode = CAENVME_SetOutputRegister(Handle, Mask); // Sets the NIM Level of channel0 output to a logical 1 in order to prevent from any events being written to the QDC and the GPS Card.
if (rawfile != null && rawfile.is_open()) {
rawfile.close();
}
ofstream rawfile("rawfile" + [color=red]strftime("%Y-%m-%d") + ".dat");[/color]
//dayWhenFileWasLastWritten = strftime("%d");
//strftime (dayWhenFileWasLastWritten,80,"%d",localtime ( &rawtime ));
strftime(dayWhenFileWasLastWritten,80,"%d",localtime (&rawtime));
errorcode1 = CAENVME_ReadCycle(Handle, clearreg, &data, cvA24_U_DATA, cvD16);
mbg_clr_ucap_buff(dh);
errorcode = CAENVME_ClearOutputRegister(Handle, Mask); // Sets the NIM Level of channel0 output to a logical 0 in order to let events come through to the GPS Card and the QDC
}
//string dayWhenFileWasLastWritten = "";
char dayWhenFileWasLastWritten[80];
while ((timediff < m_time) || m_time == 0)
{
time_t rawtime;
if (strftime(dayWhenFileWasLastWritten,80,"%d",localtime (&rawtime)) != dayWhenFileWasLastWritten) {
//if (strftime("%d") != dayWhenFileWasLastWritten.c_str()) {
errorcode = CAENVME_SetOutputRegister(Handle, Mask); // Sets the NIM Level of channel0 output to a logical 1 in order to prevent from any events being written to the QDC and the GPS Card.
if (rawfile != null && rawfile.is_open()) {
rawfile.close();
}
ofstream rawfile("rawfile" + strftime(dayWhenFileWasLastWritten,80,"%Y-%m-%d",localtime (&rawtime)) + ".dat");
//dayWhenFileWasLastWritten = strftime("%d");
//strftime (dayWhenFileWasLastWritten,80,"%d",localtime ( &rawtime ));
strftime(dayWhenFileWasLastWritten,80,"%d",localtime (&rawtime));
errorcode1 = CAENVME_ReadCycle(Handle, clearreg, &data, cvA24_U_DATA, cvD16);
mbg_clr_ucap_buff(dh);
errorcode = CAENVME_ClearOutputRegister(Handle, Mask); // Sets the NIM Level of channel0 output to a logical 0 in order to let events come through to the GPS Card and the QDC
}
v265_j.cc:214: error: ISO C++ forbids comparison between pointer and integer
v265_j.cc:218: error: `null' undeclared (first use this function)
v265_j.cc:218: error: (Each undeclared identifier is reported only once for
each function it appears in.)
v265_j.cc:218: error: request for member `is_open' in `rawfile', which is of
non-aggregate type `std::ofstream ()()'
v265_j.cc:219: error: request for member `close' in `rawfile', which is of
non-aggregate type `std::ofstream ()()'
v265_j.cc:221: error: invalid operands of types `const char*' and `const
char[5]' to binary `operator+'
char dayWhenFileWasLastWritten[80];
...
if (strftime(dayWhenFileWasLastWritten,80,"%d",localtime (&rawtime)) != dayWhenFileWasLastWritten) {
v265_j.cc:214: error: ISO C++ forbids comparison between pointer and integer
Rechts vom = gehört das heutige Tagesdatum hin und nicht der Pointer. Dann passt der Vergleich auch.
time_t rawtime;
time (&rawtime);
char dayWhenFileWasLastWritten[80] = "0";
char currentday[80] = "0";
char currentdate[80];
strftime(dayWhenFileWasLastWritten,80,"%d",localtime (&rawtime));
ofstream rawfile(currentdate);
while ((timediff < m_time) || m_time == 0)
{
cout << "test2...\n";
strftime(currentday,80,"%d",localtime (&rawtime));
strftime(currentdate,80,"%Y-%m-%d",localtime (&rawtime));
cout << "test3...\n";
if ( currentday != dayWhenFileWasLastWritten) {
cout << "test4...\n";
//if (strftime("%d") != dayWhenFileWasLastWritten.c_str()) {
errorcode = CAENVME_SetOutputRegister(Handle, Mask); // Sets the NIM Level of channel0 output to a logical 1 in order to prevent from any events being written to the QDC and the GPS Card.
if (rawfile != NULL && rawfile.is_open()) {
rawfile.close();
}
//string completename = prefix+suffix;
//ofstream rawfile("rawfile" + currentday + ".dat");
ofstream rawfile(currentdate".dat");
//dayWhenFileWasLastWritten = strftime("%d");
//strftime (dayWhenFileWasLastWritten,80,"%d",localtime ( &rawtime ));
strftime(dayWhenFileWasLastWritten,80,"%d",localtime (&rawtime));
errorcode1 = CAENVME_ReadCycle(Handle, clearreg, &data, cvA24_U_DATA, cvD16);
mbg_clr_ucap_buff(dh);
errorcode = CAENVME_ClearOutputRegister(Handle, Mask); // Sets the NIM Level of channel0 output to a logical 0 in order to let events come through to the GPS Card and the QDC
errorcode1 = CAENVME_ReadCycle(Handle, statusreg, &data,cvA24_U_DATA, cvD16);
READY = (data & 0x8000)/32678;
while (READY ==0)
{
//read status
errorcode1 = CAENVME_ReadCycle(Handle, statusreg,&data,cvA24_U_DATA, cvD16);
READY = (data & 0x8000)/32678;
}
}
{
unsigned int last_day = -1;
ofstream rawfile;
while (true) // Hier muss deine bereits vorhandene while Schleife hin
{
time_t raw_time;
time(&raw_time);
tm* loc_time = localtime(&raw_time);
// Neue Datei öffnen wenn sich Tag ändert
if (loc_time->tm_mday != last_day)
{
last_day = loc_time->tm_mday;
// Alte Datei schließen
if(rawfile.is_open())
rawfile.close();
char file_name[80];
strftime (file_name,80,"C:\\pfad\\rawfile_%Y_%m_%d.dat",loc_time);
// Neue Datei öffnen
rawfile.open(file_name);
}
// Messwert auslesen
// Messwert in Datei schreiben
rawfile << "Ich bin der Messwert" << endl;
}
}
// Für User-Abbruch
char c;
int cancel, tem;
int cnt = 0;
if (cancel != 1) {
cancel = read(0, &c, 1);
}
iif (cancel > 0) {
cout << "Abbruch durch User" << endl;
goto endofmeasurement;
}
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
int
main()
{
char c;
int n, tem;
int cnt = 0;
tem = fcntl(0, F_GETFL, 0);
fcntl (0, F_SETFL, (tem | O_NDELAY));
while (1) {
n = read(0, &c, 1);
if (n > 0) break;
cnt = cnt + 1;
}
fcntl(0, F_SETFL, tem);
printf("cnt=%d\n", cnt);
}
#include <signal.h>
bool request_exit = false;
void handler(int sig)
{
request_exit = true;
}
int main()
{
unsigned int last_day = -1;
ofstream rawfile;
// Für Ctrl-C signal registrieren
signal(SIGINT, handler);
while (true) // Hier muss deine bereits vorhandene while Schleife hin
{
if(request_exit)
{
cout << "Abbruch durch User" << endl;
break;
}
time_t raw_time;
time(&raw_time);
tm* loc_time = localtime(&raw_time);
// Neue Datei öffnen wenn sich Tag ändert
if (loc_time->tm_mday != last_day)
{
last_day = loc_time->tm_mday;
// Alte Datei schließen
if(rawfile.is_open())
rawfile.close();
char file_name[80];
strftime (file_name,80,"C:\\temp\\rawfile_%Y_%m_%d.dat",loc_time);
// Neue Datei öffnen
rawfile.open(file_name);
}
// Messwert auslesen
// Messwert in datei schreiben
rawfile << "Ich bin der Messwert" << endl;
}
}