|
1 /***************************************************************************** |
|
2 * Copyright (C) 2008-2014 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of the mbsePi-apps |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * mbsePi-apps is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with EC-65K; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 #include "mash.h" |
|
24 #include "xutil.h" |
|
25 #include "labview-lvm.h" |
|
26 |
|
27 |
|
28 char lvm_name[PATH_MAX] = ""; |
|
29 |
|
30 |
|
31 |
|
32 void create_lvm(char *filename, char *progname, char *data) |
|
33 { |
|
34 FILE *lvm_file; |
|
35 struct timeval now; |
|
36 struct tm ptm; |
|
37 int i; |
|
38 |
|
39 /* NOTE: in het voorbeeld wordt een , als separator gebruikt, hollandse locale ? */ |
|
40 |
|
41 snprintf(lvm_name, PATH_MAX, "/var/local/log/%s/%s", progname, filename); |
|
42 |
|
43 /* Rename excisting ... */ |
|
44 |
|
45 if (access(lvm_name, F_OK)) { |
|
46 /* |
|
47 * 2 options: |
|
48 * Append, so return here. |
|
49 * Rename file and create a new one |
|
50 */ |
|
51 } |
|
52 |
|
53 gettimeofday(&now, NULL); |
|
54 localtime_r(&now.tv_sec, &ptm); |
|
55 |
|
56 if ((lvm_file = fopen(lvm_name, "w"))) { |
|
57 |
|
58 fprintf(lvm_file, "LabVIEW Measurement\r\n"); |
|
59 fprintf(lvm_file, "Separator Tab\r\n"); |
|
60 fprintf(lvm_file, "Decimal_Separator .\r\n"); |
|
61 fprintf(lvm_file, "Writer_Version 2\r\n"); |
|
62 fprintf(lvm_file, "Reader_Version 2\r\n"); |
|
63 fprintf(lvm_file, "Multi_Headings No\r\n"); |
|
64 fprintf(lvm_file, "Date %04d/%02d/%02d\r\n", ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday); |
|
65 fprintf(lvm_file, "Time %02d:%02d:%02d.000\r\n", ptm.tm_hour, ptm.tm_min, ptm.tm_sec); |
|
66 fprintf(lvm_file, "X_Columns One\r\n"); |
|
67 fprintf(lvm_file, "Description Tcontrol Logfile\r\n"); |
|
68 fprintf(lvm_file, "Time_Pref Absolute\r\n"); |
|
69 fprintf(lvm_file, "Operator harrie\r\n"); |
|
70 fprintf(lvm_file, "***End_of_Header***\r\n"); |
|
71 fprintf(lvm_file, "\r\n"); |
|
72 fprintf(lvm_file, "Channels 9\r\n"); |
|
73 fprintf(lvm_file, "Samples 1 1 1 1 1 1 1 1 1\r\n"); |
|
74 fprintf(lvm_file, "Date"); |
|
75 for (i = 1; i <= 9; i++) |
|
76 fprintf(lvm_file, " %04d/%02d/%02d", ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday); |
|
77 fprintf(lvm_file, "\r\n"); |
|
78 fprintf(lvm_file, "Time"); |
|
79 for (i = 1; i <= 9; i++) |
|
80 fprintf(lvm_file, " %02d:%02d:%02d.000", ptm.tm_hour, ptm.tm_min, ptm.tm_sec); |
|
81 fprintf(lvm_file, "\r\n"); |
|
82 fprintf(lvm_file, "X_Dimension Time Time Time Time Time Time Time Time Time\r\n"); |
|
83 fprintf(lvm_file, "X0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0 0.0000000000000000E+0\r\n"); |
|
84 fprintf(lvm_file, "Delta_X 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000\r\n"); |
|
85 fprintf(lvm_file, "***End_of_Header***\r\n"); |
|
86 fprintf(lvm_file, "X_Value Untitled Untitled 1 Untitled 2 Untitled 3 Untitled 4 Untitled 5 Untitled 6 Untitled 7 Untitled 8 Comment\r\n"); |
|
87 } |
|
88 } |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |