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