Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add statistics files #49

Open
Jerome-PS opened this issue Aug 9, 2013 · 0 comments
Open

Feature Request: Add statistics files #49

Jerome-PS opened this issue Aug 9, 2013 · 0 comments

Comments

@Jerome-PS
Copy link

Hi,

I would like to collect statistics of my prints (mostly print times).
Could you please add this feature.

For example:

-(GCode_)popData
{
if (jobList->count == 0) return nil;
linesSend++;
GCode gc = [[[GCode alloc] initFromString:[jobList removeFirst]] autorelease];
/_[timeLock lock];
[times addLast:[[[PrintTime alloc] initWithLine:linesSend] autorelease]];
if (times->count > 1500)
[times removeFirst];
[timeLock unlock];
/
if (jobList->count == 0 && dataComplete)
{
dataComplete = false;
mode = 2;
[self setJobFinished:[NSDate date]];
double ticks = (jobFinished.timeIntervalSince1970 - jobStarted.timeIntervalSince1970);
int hours = ticks / 3600;
ticks -= 3600 * hours;
int min = ticks / 60;
ticks -= 60 * min;
int sec = ticks;
[rhlog addInfo:[NSString stringWithFormat:@"Printjob finished at %@",[dateFormatter stringFromDate:jobFinished]]];
NSMutableString *s = [NSMutableString stringWithCapacity:40];
if (hours > 0)
{
[s appendFormat:@"%d",hours];
[s appendString:@"h:"];
}
if (min > 0)
{
[s appendFormat:@"%02d",min];
[s appendString:@"m:"];
}
[s appendFormat:@"%02d",sec];
[s appendString:@"s"];
[rhlog addInfo:[NSString stringWithFormat:@"Printing time: %@",s]];
[rhlog addInfo:[NSString stringWithFormat:@"lines send: %d",linesSend]];
[connection firePrinterState:[NSString stringWithFormat:@"Finished in %@",s]];
[sound playPrintjobFinished:NO];
[self doEndKillActions];
[ThreadedNotification notifyASAP:@"RHJobChanged" object:self];
FILE * statFile = fopen("JobStats.txt", "a");
fprintf(statFile, "%s\n", [[NSString stringWithFormat:@"Printjob finished at %@",[dateFormatter stringFromDate:jobFinished]] cStringUsingEncoding:NSUTF8StringEncoding]);
fprintf(statFile, "File: %s\n", [app->gcodeView.fileName cStringUsingEncoding:NSUTF8StringEncoding]);
fprintf(statFile, "%s\n", [[NSString stringWithFormat:@"Printing time: %@",s] cStringUsingEncoding:NSUTF8StringEncoding]);
fprintf(statFile, "%s\n", [[NSString stringWithFormat:@"lines send: %d",linesSend] cStringUsingEncoding:NSUTF8StringEncoding]);
fprintf(statFile, "----------\n");
fclose(statFile);
}
return gc;
}

Thank you,
Jérôme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant