File: maindisplay.fl

package info (click to toggle)
obdgpslogger 0.16-1.3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,160 kB
  • ctags: 7,498
  • sloc: ansic: 73,206; cpp: 2,055; php: 407; sh: 51; makefile: 4
file content (419 lines) | stat: -rw-r--r-- 11,419 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# data file for the Fltk User Interface Designer (fluid)
version 1.0300 
header_name {.h} 
code_name {.cxx}
decl {\#include <stdio.h>} {} 

decl {\#include <unistd.h>} {} 

decl {\#include <FL/Fl.H>} {} 

decl {\#include <FL/Fl_File_Chooser.H>} {} 

decl {\#include "obdconfig.h"} {} 

decl {\#include "obdconfigfile.h"} {public
} 

decl {\#include "obdservicecommands.h"} {} 

decl {\#include "logwindow.h"} {public
} 

decl {\#include "loggerhandler.h"} {public
} 

decl {\#include "guessdevs.h"} {} 

decl {\#include "convertwindow.h"} {} 

decl {\#include "gpsdwizard.h"} {public
} 

decl {class obdconvertwindow;} {public
} 

decl {\#include "obdgui.h"} {public
} 

comment {Button "state machine":
1) Execution begins.
    Go button active
    start and end inactive
2) Click "Go"
    Go button changes to "starting...", inactive
    start and end still inactive
3) Once logger is running
    Change go button to "Stop", active
    make start active. end still inactive
4a) Clicking start
     make start inactive, end active
4b) Clicking end
     make start active, end inactive
5) Click "Stop"} {in_source not_in_header
} 

class OBDUI {open
} {
  Function {OBDUI()} {open
  } {
    code {mLH = NULL;} {}
    code {configfile = obd_loadConfig(0);} {}
    Fl_Window MainWindow {
      label {OBD GPS Logger} open
      private xywh {830 91 545 390} type Double align 80 resizable visible
    } {
      Fl_Group alldials_group {open
        private xywh {25 150 495 215} deactivate
      } {
        Fl_Group vss_group {open
          private xywh {25 150 145 85}
        } {
          Fl_Dial vss_dial {
            label {Vehicle Speed}
            private xywh {25 150 145 85} type Line
            code0 {struct obdservicecmd *osc = obdGetCmdForColumn("vss");}
            code1 {if(NULL == osc) o->range(0,200);}
            code2 {else o->range(osc->min_value,osc->max_value);}
          }
          Fl_Value_Output vss_value {
            private xywh {75 206 45 24}
          }
        }
        Fl_Group throttlepos_group {open
          private xywh {25 260 145 85}
        } {
          Fl_Dial throttlepos_dial {
            label {Throttle Position}
            private xywh {25 260 145 85} type Line
            code0 {struct obdservicecmd *osc = obdGetCmdForColumn("throttle");}
            code1 {if(NULL == osc) o->range(0,200);}
            code2 {else o->range(osc->min_value,osc->max_value);}
          }
          Fl_Value_Output throttlepos_value {
            private xywh {75 316 45 24}
          }
        }
        Fl_Group rpm_group {open
          private xywh {200 150 145 85}
        } {
          Fl_Dial rpm_dial {
            label {Engine RPM}
            private xywh {200 150 145 85} type Line
            code0 {struct obdservicecmd *osc = obdGetCmdForColumn("rpm");}
            code1 {if(NULL == osc) o->range(0,7000);}
            code2 {else o->range(osc->min_value,osc->max_value);}
          }
          Fl_Value_Output rpm_value {
            private xywh {250 206 45 24}
          }
        }
        Fl_Group temp_group {open
          private xywh {200 260 145 85}
        } {
          Fl_Dial temp_dial {
            label {Oil Temperature}
            private xywh {200 260 145 85} type Line
            code0 {struct obdservicecmd *osc = obdGetCmdForColumn("temp");}
            code1 {if(NULL == osc) o->range(0,200);}
            code2 {else o->range(osc->min_value,osc->max_value);}
          }
          Fl_Value_Output temp_value {
            private xywh {250 316 45 24}
          }
        }
        Fl_Group maf_group {open
          private xywh {375 150 145 85}
        } {
          Fl_Dial maf_dial {
            label {Mass Airflow}
            private xywh {375 150 145 85} type Line
            code0 {struct obdservicecmd *osc = obdGetCmdForColumn("maf");}
            code1 {if(NULL == osc) o->range(0,2000);}
            code2 {else o->range(osc->min_value,osc->max_value);}
          }
          Fl_Value_Output maf_value {
            private xywh {425 206 45 24}
          }
        }
        Fl_Group {} {
          label {GPS Position} open
          private xywh {410 281 105 84}
        } {
          Fl_Value_Output gpslat {
            label Latitude
            private xywh {410 281 105 24}
          }
          Fl_Value_Output gpslon {
            label Longitude
            private xywh {410 311 105 24}
          }
          Fl_Value_Output gpsalt {
            label Altitude
            private xywh {410 341 105 24}
          }
        }
      }
      Fl_Menu_Bar menubar {open
        private xywh {0 0 600 20} align 20
      } {
        Submenu {} {
          label File open
          private xywh {0 0 100 20} labelsize 14
        } {
          MenuItem {} {
            label Quit
            callback {MainWindow->hide();
mLogWindow->hide();}
            private xywh {0 0 100 20} labelsize 14
          }
        }
        Submenu {} {
          label Window open
          private xywh {0 0 100 20} labelsize 14
        } {
          MenuItem {} {
            label {Raw Output}
            callback {mLogWindow->show();}
            private xywh {0 0 100 20} labelsize 14
          }
        }
      }
      Fl_Group loggeroptions {open
        private xywh {15 20 505 115}
      } {
        Fl_Input_Choice serialfilename {
          label {OBD Device} open
          xywh {115 62 300 26}
        } {}
        Fl_File_Input logfilename {
          label Logfile
          private xywh {115 25 300 30} when 0
          code0 {logfilename->value(OBD_DEFAULT_DATABASE);}
        }
        Fl_Button logchoosebutton {
          label {Choose...}
          callback {Fl_File_Chooser f(logfilename->value(),
  "OBDGPS Logfiles (*.db)\\tAll Files (*)",
  Fl_File_Chooser::CREATE, "Choose OBD GPS Logfile" );
f.show();
while(f.shown()) {
  Fl::check();
}
if(0 < f.count())
  logfilename->value(f.value());}
          private xywh {420 25 95 30}
        }
        Fl_Button serialchoosebutton {
          label {Choose...}
          callback {Fl_File_Chooser f("/dev/",
  "All Files (*)",
  Fl_File_Chooser::SINGLE, "Choose Serial Port" );
f.show();
while(f.shown()) {
  Fl::check();
}
if(0 < f.count())
  serialfilename->value(f.value());}
          private xywh {420 60 95 30}
        }
      }
      Fl_Button gobutton {
        label Go
        callback {if(mLH) {
  if(TRIP_STOPPED != mTripState) {
    mLH->endtrip();
    sleep(1);
  }
  delete mLH;
  mLH = NULL;
  setUIRunning(UI_STOPPED);
} else {
  mLH = new loggerhandler(this);
  setUIRunning(UI_STARTING);
}}
        private xywh {55 95 120 45} resizable
      }
      Fl_Button starttripbutton {
        label {Start Trip}
        callback {if(mLH) {
  mLH->starttrip();
  setUIRunning(UI_STARTED, TRIP_STARTED);
}} selected
        private xywh {180 95 115 20} hide deactivate
      }
      Fl_Button endtripbutton {
        label {End Trip}
        callback {if(mLH) {
  mLH->endtrip();
  setUIRunning(UI_STARTED, TRIP_STOPPED);
}}
        private xywh {180 120 115 20} hide deactivate
      }
      Fl_Button convertbutton {
        label {Convert log  to ...}
        callback {mConvertWindow->show();}
        private xywh {360 110 155 25}
      }
      Fl_Button gpsdwizardbutton {
        label {GPSD Launch Wizard}
        callback {mGpsdWindow->show();}
        private xywh {190 110 160 25}
      }
    }
    code {setUIRunning(UI_STOPPED);} {}
    code {mLogWindow = new OBDLogWindow();
mLogWindow->hide();} {}
    code {mConvertWindow = new obdconvertwindow(this);
mConvertWindow->hide();
// mLogWindow->append_stdout("Cookies out");
// mLogWindow->append_stderr("Cookies err");} {}
    code {reset_dials();} {}
    code {mGpsdWindow = new GPSDWizardWindow();
mGpsdWindow->hide();} {}
    code {populateSerialDevs(serialfilename, NULL==configfile?OBD_DEFAULT_SERIALPORT:configfile->obd_device);} {}
  }
  Function {~OBDUI()} {open
  } {
    code {if(NULL != mLH) {
  delete mLH;
  mLH = NULL;
}
delete mLogWindow;
delete mConvertWindow;
delete mGpsdWindow;

obd_freeConfig(configfile);} {}
  }
  Function {setUIRunning(enum ui_state newstate, enum trip_state tripstate = TRIP_NONE)} {open
  } {
    code {mUIState = newstate;
mTripState = tripstate;

switch(newstate) {
  case UI_STOPPED:
    gobutton->activate();
    gobutton->copy_label("Go");
    loggeroptions->activate();
    convertbutton->activate();
    gpsdwizardbutton->activate();
    reset_dials();
    alldials_group->deactivate();
    break;
  case UI_STARTING:
    gobutton->deactivate();
    gobutton->copy_label("Starting...");
    loggeroptions->deactivate();
    convertbutton->deactivate();
    gpsdwizardbutton->deactivate();
    alldials_group->deactivate();
    break;
  case UI_STARTED:
    gobutton->activate();
    gobutton->copy_label("Stop");
    loggeroptions->deactivate();
    convertbutton->deactivate();
    gpsdwizardbutton->deactivate();
    alldials_group->activate();
    break;
}

switch(tripstate) {
  case TRIP_STOPPED:
    starttripbutton->activate();
    endtripbutton->deactivate();
    break;
  case TRIP_STARTED:
    starttripbutton->deactivate();
    endtripbutton->activate();
    break;
  case TRIP_NONE:
    starttripbutton->deactivate();
    endtripbutton->deactivate();
    break;
}} {}
  }
  Function {getOBDHandler()} {return_type {loggerhandler *}
  } {
    code {return mLH;} {}
  }
  Function {show(int argc, char **argv)} {} {
    code {MainWindow->show(argc,argv);} {}
  }
  Function {getLogfilename()} {return_type {const char *}
  } {
    code {return logfilename->value();} {}
  }
  Function {getSerialfilename()} {return_type {const char *}
  } {
    code {return serialfilename->value();} {}
  }
  Function {checkLogger()} {} {
    code {if(NULL != mLH) {
  mLH->checkRunning(false);

  if(!mLH->isUsable()) {
    delete mLH;
    mLH = NULL;
  }
}

if(NULL == mLH) {
  setUIRunning(UI_STOPPED);
} else {
  mLH->pulse();
  if(mLH->isStarted()) {
    if(mUIState == UI_STARTING) {
      setUIRunning(UI_STARTED, TRIP_STOPPED);
    }
  }
}} {}
  }
  Function {append_stderr_log(const char *text)} {} {
    code {mLogWindow->append_stderr(text);} {}
  }
  Function {append_stdout_log(const char *text)} {} {
    code {mLogWindow->append_stdout(text);} {}
  }
  decl {loggerhandler *mLH;} {}
  decl {enum ui_state mUIState;} {}
  decl {enum trip_state mTripState;} {}
  decl {OBDLogWindow *mLogWindow;} {}
  decl {obdconvertwindow *mConvertWindow;} {}
  decl {GPSDWizardWindow *mGpsdWindow;} {}
  decl {struct OBDGPSConfig *configfile;} {public
  }
  Function {reset_dials()} {} {
    code {setvss(vss_dial->minimum());
setrpm(rpm_dial->minimum());
setmaf(maf_dial->minimum());
setthrottlepos(throttlepos_dial->minimum());
settemp(temp_dial->minimum());
setgps(0,0,0);} {}
  }
  Function {setvss(float val)} {} {
    code {vss_dial->value(val);
vss_value->value(val);} {}
  }
  Function {setrpm(float val)} {} {
    code {rpm_dial->value(val);
rpm_value->value(val);} {}
  }
  Function {setmaf(float val)} {} {
    code {maf_dial->value(val);
maf_value->value(val);} {}
  }
  Function {setthrottlepos(float val)} {} {
    code {throttlepos_dial->value(val);
throttlepos_value->value(val);} {}
  }
  Function {settemp(float val)} {} {
    code {temp_dial->value(val);
temp_value->value(val);} {}
  }
  Function {setgps(float lat, float lon, float alt)} {} {
    code {gpslat->value(lat);
gpslon->value(lon);
gpsalt->value(alt);} {}
  }
}