0,0 → 1,809 |
#include "../include/root_app.h" |
#include "../include/workstation.h" |
|
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
|
// Main window constructor (+layout) --------------------------------- |
|
TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h) |
{ |
// Define main window and menubar |
fMain = new TGMainFrame(p, w, h, kVerticalFrame); |
|
AppLayout(); |
fMain->SetWindowName(WINDOW_NAME); |
fMain->MapSubwindows(); |
fMain->MapWindow(); |
fMain->Layout(); |
} |
|
TGAppMainFrame::~TGAppMainFrame() |
{ |
fMain->Cleanup(); |
delete fMain; |
} |
|
// Closing main window and checking about information ---------------- |
|
void TGAppMainFrame::CloseWindow() |
{ |
fMain->Cleanup(); |
delete fMain; |
gApplication->Terminate(0); |
} |
|
// ------------------------------------------------------------------- |
|
// ------------------------------------------------------------------- |
|
// Separate functions ----------------------------------------- |
void GetTime(int intime, char *outtime) |
{ |
time_t rawtime; |
struct tm * timeinfo; |
if(intime < 0) |
time(&rawtime); |
else |
rawtime = (time_t)intime; |
timeinfo = localtime(&rawtime); |
sprintf(outtime, "%s", asctime(timeinfo)); |
int len = strlen(outtime); |
if(len) outtime[len-1] = 0; |
} |
|
// ---------------------------------------------------------- |
|
// Temperature sensor functions ----------------------------- |
const char* dbname = "mysql://f9lab08.ijs.si/f9phdet"; |
const char* tblname = "fprtd122"; |
const char* username = "f9daq"; |
const char* userpass = "f9lab"; |
|
// Get the temperature from MYSQL database |
double GetTemperature(int ch, const char *s) |
{ |
int bin=5+7*4-ch*4; |
char hex[16]; |
strncpy(hex, (const char *) &s[bin], 4); |
hex[4]=0; |
int ix; |
sscanf (hex,"%x",&ix); |
//printf("0x%s\t",hex); |
return (ix/65535.)*1050.-200.; |
} |
|
// Transform local time to timestamp |
int GetTimeStamp(int *intime) |
{ |
time_t rawtime; |
struct tm * timeinfo; |
time(&rawtime); |
timeinfo = localtime(&rawtime); |
|
if(DBGSIG) |
printf("%d.%d.%d, %d:%d:%d\n", intime[0], intime[1], intime[2], intime[3], intime[4], intime[5]); |
|
timeinfo->tm_mday = intime[0]; |
timeinfo->tm_mon = intime[1] - 1; |
timeinfo->tm_year = intime[2] - 1900; |
timeinfo->tm_hour = intime[3]; |
timeinfo->tm_min = intime[4]; |
timeinfo->tm_sec = intime[5]; |
|
return (int)mktime(timeinfo); |
} |
|
// Get data from MYSQL database |
void TGAppMainFrame::fieldpoint(int *timerange, int selch) |
{ |
char humantime[256]; |
|
// Display selected timestamps |
GetTime(timerange[0], humantime); |
printf("Minimum time set to: %s (%d)\n", humantime, timerange[0]); |
if(timerange[1] != -1) |
{ |
GetTime(timerange[1], humantime); |
printf("Maximum time set to: %s (%d)\n", humantime, timerange[1]); |
} |
printf("Selected fieldpoint channel: %d\n", selch); |
printf("\n"); |
|
// Database settings |
TSQLServer *db = TSQLServer::Connect(dbname, username, userpass); |
printf("Server info: %s\n", db->ServerInfo()); |
TSQLRow *row; |
TSQLResult *res; |
|
if(DBGSIG) |
{ |
// list databases available on server |
printf("\nList all databases on server %s\n", db->GetHost()); |
res = db->GetDataBases(); |
while ((row = res->Next())) { |
printf("%s\n", row->GetField(0)); |
delete row; |
} |
delete res; |
|
// list tables in database "test" (the permission tables) |
printf("\nList all tables in database \"f9phdet\" on server %s\n", db->GetHost()); |
res = db->GetTables("f9phdet"); |
while ((row = res->Next())) { |
printf("%s\n", row->GetField(0)); |
delete row; |
} |
delete res; |
|
// list columns in table "runcatalog" in database "mysql" |
printf("\nList all columns in table \"f9phdet\" in database \"f9rtd122\" on server %s\n", db->GetHost()); |
res = db->GetColumns("f9phdet", "fprtd122"); |
while ((row = res->Next())) { |
printf("%s\n", row->GetField(0)); |
delete row; |
} |
delete res; |
} |
|
// query database and print results |
char sql[1000] = "SELECT status,data,timestamp FROM fprtd122 WHERE status='A272727272727272748' AND substring(data,1,4)='A00C' "; |
if(timerange[1] == -1) |
sprintf(sql,"%s AND timestamp>='%d'", sql, timerange[0]); |
else |
sprintf(sql,"%s AND timestamp>='%d' AND timestamp<='%d'", sql, timerange[0], timerange[1]); |
if(DBGSIG) |
printf("%s\n",sql); |
|
res = db->Query(sql); |
|
int nrows = res->GetRowCount(); |
printf("\nGot %d rows in result\n", nrows); |
|
// Printing and plotting |
char timeval[256]; |
TGraph *gr; |
double *x, *y; |
double firsttime, lasttime; |
|
gr = new TGraph(nrows); |
gr->SetLineColor(kRed); |
gr->SetLineWidth(1); |
gr->SetMarkerColor(kBlack); |
gr->SetMarkerSize(0.8); |
gr->SetMarkerStyle(20); |
gr->SetTitle("Temperature sensor;Time;Temperature (deg.)"); |
|
FILE *fp; |
fp = fopen("./fieldpoint/dataout_fieldpoint.txt", "w"); |
|
if(DBGSIG) |
printf("Time\tTemperature\n"); |
for (int i = 0; i < nrows; i++) { |
row = res->Next(); |
|
GetTime((int)atof(row->GetField(2))-TIMEOFF, timeval); |
x = new double; |
y = new double; |
|
*x = atof(row->GetField(2))-TIMEOFF; |
*y = GetTemperature(selch,row->GetField(1)); |
gr->SetPoint(i,*x,*y); |
|
if(i == 0) firsttime = *x; |
else if(i == nrows-1) lasttime = *x; |
|
if(datSettings->GetSelected() == 0) |
{ |
fprintf(fp, "%s\t%d\t%f\n",timeval,(int)*x,*y); |
if(DBGSIG) |
printf("%s\t%d\t%f\n",timeval,(int)*x,*y); |
} |
else if(datSettings->GetSelected() == 1) |
{ |
fprintf(fp, "%s\t%f\n",timeval,*y); |
if(DBGSIG) |
printf("%s\t%f\n",timeval,*y); |
} |
else if(datSettings->GetSelected() == 2) |
{ |
fprintf(fp, "%d\t%f\n",(int)*x,*y); |
if(DBGSIG) |
printf("%d\t%f\n",(int)*x,*y); |
} |
|
delete x; |
delete y; |
|
delete row; |
} |
|
fclose(fp); |
|
delete res; |
delete db; |
|
TCanvas *gCanvas = displayCanvas->GetCanvas(); |
gCanvas->SetGrid(); |
gr->GetXaxis()->SetTimeDisplay(1); |
gr->GetXaxis()->SetTimeFormat("%H:%M, %d.%m."); |
gr->GetXaxis()->SetTimeOffset(0); |
gr->GetXaxis()->SetLabelSize(0.027); |
gr->GetXaxis()->SetLabelOffset(0.015); |
gr->GetXaxis()->SetTitleSize(0.038); |
gr->GetXaxis()->SetTitleOffset(1.2); |
gr->GetYaxis()->SetLabelSize(0.027); |
gr->GetYaxis()->SetTitleSize(0.038); |
gr->GetXaxis()->SetNdivisions(-507); |
gr->GetXaxis()->SetRange(firsttime,lasttime); |
gr->GetXaxis()->SetRangeUser(firsttime,lasttime); |
gr->Draw("APL"); |
|
gCanvas->Modified(); |
gCanvas->Update(); |
} |
|
// Update the temperature plot |
void TGAppMainFrame::UpdateTempPlot() |
{ |
int stime[6]; |
int etime[6]; |
|
int timestamp[2]; |
|
time_t rtime; |
int curyear; |
time(&rtime); |
curyear = (int)(localtime(&rtime))->tm_year+1900; |
|
int leapy = 0; |
|
// Getting the start time |
stime[0] = (int)(tempDay[0]->GetSelected())+1; |
stime[2] = curyear - (int)(tempYear[0]->GetSelected()); |
if(DBGSIG) |
printf("%d, %d, %d\n", stime[2], curyear, (int)(tempYear[0]->GetSelected())); |
stime[3] = (int)(tempHour[0]->GetSelected()); |
stime[4] = (int)(tempMinute[0]->GetSelected()); |
stime[5] = (int)(tempSecond[0]->GetSelected()); |
|
switch( tempMonth[0]->GetSelected() ) |
{ |
case 0: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 1: |
if( stime[2]%4 == 0) |
leapy = 1; |
|
if( (leapy == 1) && (stime[0] > 29) ) |
{ |
stime[0] = 29; |
tempDay[0]->Select(28); |
} |
else if( (leapy == 0) && (stime[0] > 28) ) |
{ |
stime[0] = 28; |
tempDay[0]->Select(27); |
} |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 2: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 3: |
if(stime[0] > 30) |
{ |
stime[0] = 30; |
tempDay[0]->Select(29); |
} |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 4: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 5: |
if(stime[0] > 30) |
{ |
stime[0] = 30; |
tempDay[0]->Select(29); |
} |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 6: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 7: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 8: |
if(stime[0] > 30) |
{ |
stime[0] = 30; |
tempDay[0]->Select(29); |
} |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 9: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 10: |
if(stime[0] > 30) |
{ |
stime[0] = 30; |
tempDay[0]->Select(29); |
} |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
case 11: |
stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
break; |
default: |
break; |
} |
|
timestamp[0] = GetTimeStamp(stime); |
if(DBGSIG) |
printf("Start time: %d\n", timestamp[0]); |
|
// Getting the end time |
etime[0] = (int)(tempDay[1]->GetSelected())+1; |
etime[2] = curyear - (int)(tempYear[1]->GetSelected()); |
etime[3] = (int)(tempHour[1]->GetSelected()); |
etime[4] = (int)(tempMinute[1]->GetSelected()); |
etime[5] = (int)(tempSecond[1]->GetSelected()); |
|
switch( tempMonth[1]->GetSelected() ) |
{ |
case 0: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 1: |
if( etime[2]%4 == 0) |
leapy = 1; |
|
if( (leapy == 1) && (etime[0] > 29) ) |
{ |
etime[0] = 29; |
tempDay[1]->Select(28); |
} |
else if( (leapy == 0) && (etime[0] > 28) ) |
{ |
etime[0] = 28; |
tempDay[1]->Select(27); |
} |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 2: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 3: |
if(etime[0] > 30) |
{ |
etime[0] = 30; |
tempDay[1]->Select(29); |
} |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 4: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 5: |
if(etime[0] > 30) |
{ |
etime[0] = 30; |
tempDay[1]->Select(29); |
} |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 6: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 7: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 8: |
if(etime[0] > 30) |
{ |
etime[0] = 30; |
tempDay[1]->Select(29); |
} |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 9: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 10: |
if(etime[0] > 30) |
{ |
etime[0] = 30; |
tempDay[1]->Select(29); |
} |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
case 11: |
etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
break; |
default: |
break; |
} |
|
if( tempEndOn->IsDown() ) |
timestamp[1] = -1; |
else |
timestamp[1] = GetTimeStamp(etime); |
if(DBGSIG) |
printf("End time: %d\n", timestamp[1]); |
|
fieldpoint(timestamp, tempCh->GetSelected()); |
} |
|
// Export the temperature plot to pdf |
void TGAppMainFrame::ExportTempPlot() |
{ |
TCanvas *gCanvas = displayCanvas->GetCanvas(); |
gCanvas->Modified(); |
gCanvas->Update(); |
gCanvas->SaveAs("./fieldpoint/plotout_fieldpoint.pdf"); |
} |
|
// Toggle the endtime settings for temperature sensor |
void TGAppMainFrame::TempEndToggle() |
{ |
if( tempEndOn->IsDown() ) |
{ |
tempDay[1]->SetEnabled(kFALSE); |
tempMonth[1]->SetEnabled(kFALSE); |
tempYear[1]->SetEnabled(kFALSE); |
tempHour[1]->SetEnabled(kFALSE); |
tempMinute[1]->SetEnabled(kFALSE); |
tempSecond[1]->SetEnabled(kFALSE); |
} |
else |
{ |
tempDay[1]->SetEnabled(kTRUE); |
tempMonth[1]->SetEnabled(kTRUE); |
tempYear[1]->SetEnabled(kTRUE); |
tempHour[1]->SetEnabled(kTRUE); |
tempMinute[1]->SetEnabled(kTRUE); |
tempSecond[1]->SetEnabled(kTRUE); |
} |
} |
|
// -------------------------------------------------------------- |
|
// Setting the application layout ------------------------------------ |
|
void TGAppMainFrame::AppLayout() |
{ |
// Fieldpoint window ------------------------ |
|
TGLayoutHints *f0 = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2); |
TGLayoutHints *f0centerx = new TGLayoutHints(kLHintsCenterX,2,2,2,2); |
TGLayoutHints *f0centery = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2); |
TGLayoutHints *f1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2); |
TGLayoutHints *f2 = new TGLayoutHints(kLHintsExpandX,2,2,2,2); |
|
TGHorizontalFrame *fH1, *fH2; |
TGGroupFrame *fG1; |
TGLabel *lab; |
|
time_t rtime; |
int yearrange[2]; |
int subwin[2]; |
char ctemp[256]; |
|
subwin[0] = winWidth-10; |
subwin[1] = 6.6*winHeight/12; |
|
// Display canvas for temperature sensor |
displayCanvas = new TRootEmbeddedCanvas("displayCanvas",fMain,subwin[0],subwin[1]); |
fMain->AddFrame(displayCanvas, f0centerx); |
TCanvas *gCanvas = displayCanvas->GetCanvas(); |
gCanvas->SetGridx(); |
gCanvas->SetGridy(); |
|
fG1 = new TGGroupFrame(fMain, "Temperature sensor settings"); |
// Channel selector |
fH1 = new TGHorizontalFrame(fG1, subwin[0], 30); |
lab = new TGLabel(fH1, "Fieldpoint channel:"); |
fH1->AddFrame(lab, f0centery); |
tempCh = new TGComboBox(fH1, 200); |
tempCh->AddEntry("0", 0); |
tempCh->AddEntry("1", 1); |
tempCh->AddEntry("2", 2); |
tempCh->AddEntry("3", 3); |
tempCh->AddEntry("4", 4); |
tempCh->AddEntry("5", 5); |
tempCh->AddEntry("6", 6); |
tempCh->AddEntry("7", 7); |
tempCh->Resize(50,22); |
tempCh->Select(1); |
fH1->AddFrame(tempCh, f0centery); |
fG1->AddFrame(fH1, f2); |
|
// Start and stop time ------------------------ |
time(&rtime); |
|
lab = new TGLabel(fG1, "Start time:"); |
fG1->AddFrame(lab, f0); |
fH1 = new TGHorizontalFrame(fG1, subwin[0], 30); |
// Start day |
lab = new TGLabel(fH1, "\tDay: "); |
fH1->AddFrame(lab, f0centery); |
tempDay[0] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 31; i++) |
{ |
sprintf(ctemp, "%d", i+1); |
tempDay[0]->AddEntry(ctemp, i); |
} |
tempDay[0]->Resize(50,22); |
tempDay[0]->Select((int)(localtime(&rtime))->tm_mday-1); |
fH1->AddFrame(tempDay[0], f0centery); |
|
// Start month |
lab = new TGLabel(fH1, " Month: "); |
fH1->AddFrame(lab, f0centery); |
tempMonth[0] = new TGComboBox(fH1, 200); |
tempMonth[0]->AddEntry("January", 0); |
tempMonth[0]->AddEntry("February", 1); |
tempMonth[0]->AddEntry("March", 2); |
tempMonth[0]->AddEntry("April", 3); |
tempMonth[0]->AddEntry("May", 4); |
tempMonth[0]->AddEntry("June", 5); |
tempMonth[0]->AddEntry("July", 6); |
tempMonth[0]->AddEntry("August", 7); |
tempMonth[0]->AddEntry("September", 8); |
tempMonth[0]->AddEntry("October", 9); |
tempMonth[0]->AddEntry("November", 10); |
tempMonth[0]->AddEntry("December", 11); |
tempMonth[0]->Resize(80,22); |
tempMonth[0]->Select((int)(localtime(&rtime))->tm_mon); |
fH1->AddFrame(tempMonth[0], f0centery); |
|
// Start year |
yearrange[0] = 2010; |
yearrange[1] = (int)(localtime(&rtime))->tm_year+1900; |
|
lab = new TGLabel(fH1, " Year: "); |
fH1->AddFrame(lab, f0centery); |
tempYear[0] = new TGComboBox(fH1, 200); |
for(int i = 0; i < (yearrange[1]-yearrange[0])+1; i++) |
{ |
sprintf(ctemp, "%d", yearrange[1]-i); |
tempYear[0]->AddEntry(ctemp, i); |
} |
tempYear[0]->Resize(60,22); |
tempYear[0]->Select(0); |
fH1->AddFrame(tempYear[0], f0centery); |
|
// Start hour |
lab = new TGLabel(fH1, " Hour: "); |
fH1->AddFrame(lab, f0centery); |
tempHour[0] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 24; i++) |
{ |
if(i < 10) |
sprintf(ctemp, "0%d", i); |
else |
sprintf(ctemp, "%d", i); |
tempHour[0]->AddEntry(ctemp, i); |
} |
tempHour[0]->Resize(50,22); |
tempHour[0]->Select(7); |
fH1->AddFrame(tempHour[0], f0centery); |
|
// Start minute |
lab = new TGLabel(fH1, " Minute: "); |
fH1->AddFrame(lab, f0centery); |
tempMinute[0] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 60; i++) |
{ |
if(i < 10) |
sprintf(ctemp, "0%d", i); |
else |
sprintf(ctemp, "%d", i); |
tempMinute[0]->AddEntry(ctemp, i); |
} |
tempMinute[0]->Resize(50,22); |
tempMinute[0]->Select(0); |
fH1->AddFrame(tempMinute[0], f0centery); |
|
// Start second |
lab = new TGLabel(fH1, " Second: "); |
fH1->AddFrame(lab, f0centery); |
tempSecond[0] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 60; i++) |
{ |
if(i < 10) |
sprintf(ctemp, "0%d", i); |
else |
sprintf(ctemp, "%d", i); |
tempSecond[0]->AddEntry(ctemp, i); |
} |
tempSecond[0]->Resize(50,22); |
tempSecond[0]->Select(0); |
fH1->AddFrame(tempSecond[0], f0centery); |
|
fG1->AddFrame(fH1, f2); |
|
// Use the end time or not |
tempEndOn = new TGCheckButton(fG1, "Draw to last time point (ON/OFF)"); |
tempEndOn->Resize(100,22); |
tempEndOn->SetState(kButtonUp); |
fG1->AddFrame(tempEndOn, f0); |
|
lab = new TGLabel(fG1, "End time:"); |
fG1->AddFrame(lab, f0); |
fH1 = new TGHorizontalFrame(fG1, subwin[0], 30); |
// End day |
lab = new TGLabel(fH1, "\tDay: "); |
fH1->AddFrame(lab, f0centery); |
tempDay[1] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 31; i++) |
{ |
sprintf(ctemp, "%d", i+1); |
tempDay[1]->AddEntry(ctemp, i); |
} |
tempDay[1]->Resize(50,22); |
tempDay[1]->Select((int)(localtime(&rtime))->tm_mday-1); |
fH1->AddFrame(tempDay[1], f0centery); |
|
// End month |
lab = new TGLabel(fH1, " Month: "); |
fH1->AddFrame(lab, f0centery); |
tempMonth[1] = new TGComboBox(fH1, 200); |
tempMonth[1]->AddEntry("January", 0); |
tempMonth[1]->AddEntry("February", 1); |
tempMonth[1]->AddEntry("March", 2); |
tempMonth[1]->AddEntry("April", 3); |
tempMonth[1]->AddEntry("May", 4); |
tempMonth[1]->AddEntry("June", 5); |
tempMonth[1]->AddEntry("July", 6); |
tempMonth[1]->AddEntry("August", 7); |
tempMonth[1]->AddEntry("September", 8); |
tempMonth[1]->AddEntry("October", 9); |
tempMonth[1]->AddEntry("November", 10); |
tempMonth[1]->AddEntry("December", 11); |
tempMonth[1]->Resize(80,22); |
tempMonth[1]->Select((int)(localtime(&rtime))->tm_mon); |
fH1->AddFrame(tempMonth[1], f0centery); |
|
// End year |
time(&rtime); |
yearrange[0] = 2010; |
yearrange[1] = (int)(localtime(&rtime))->tm_year+1900; |
|
lab = new TGLabel(fH1, " Year: "); |
fH1->AddFrame(lab, f0centery); |
tempYear[1] = new TGComboBox(fH1, 200); |
for(int i = 0; i < (yearrange[1]-yearrange[0])+1; i++) |
{ |
sprintf(ctemp, "%d", yearrange[1]-i); |
tempYear[1]->AddEntry(ctemp, i); |
} |
tempYear[1]->Resize(60,22); |
tempYear[1]->Select(0); |
fH1->AddFrame(tempYear[1], f0centery); |
|
// End hour |
lab = new TGLabel(fH1, " Hour: "); |
fH1->AddFrame(lab, f0centery); |
tempHour[1] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 24; i++) |
{ |
if(i < 10) |
sprintf(ctemp, "0%d", i); |
else |
sprintf(ctemp, "%d", i); |
tempHour[1]->AddEntry(ctemp, i); |
} |
tempHour[1]->Resize(50,22); |
tempHour[1]->Select(18); |
fH1->AddFrame(tempHour[1], f0centery); |
|
// End minute |
lab = new TGLabel(fH1, " Minute: "); |
fH1->AddFrame(lab, f0centery); |
tempMinute[1] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 60; i++) |
{ |
if(i < 10) |
sprintf(ctemp, "0%d", i); |
else |
sprintf(ctemp, "%d", i); |
tempMinute[1]->AddEntry(ctemp, i); |
} |
tempMinute[1]->Resize(50,22); |
tempMinute[1]->Select(0); |
fH1->AddFrame(tempMinute[1], f0centery); |
|
// End second |
lab = new TGLabel(fH1, " Second: "); |
fH1->AddFrame(lab, f0centery); |
tempSecond[1] = new TGComboBox(fH1, 200); |
for(int i = 0; i < 60; i++) |
{ |
if(i < 10) |
sprintf(ctemp, "0%d", i); |
else |
sprintf(ctemp, "%d", i); |
tempSecond[1]->AddEntry(ctemp, i); |
} |
tempSecond[1]->Resize(50,22); |
tempSecond[1]->Select(0); |
fH1->AddFrame(tempSecond[1], f0centery); |
|
fG1->AddFrame(fH1, f2); |
// Start and stop time ------------------------ |
|
// Dataout settings |
fH1 = new TGHorizontalFrame(fG1, subwin[0], 30); |
lab = new TGLabel(fH1, "Output data settings: "); |
fH1->AddFrame(lab, f0centery); |
datSettings = new TGComboBox(fH1, 200); |
datSettings->AddEntry("Export local time and UNIX timestamp", 0); |
datSettings->AddEntry("Export only local time", 1); |
datSettings->AddEntry("Export only UNIX timestamp", 2); |
datSettings->Resize(300,22); |
datSettings->Select(0); |
fH1->AddFrame(datSettings, f0centery); |
|
fG1->AddFrame(fH1, f2); |
|
// Control buttons |
fH2 = new TGHorizontalFrame(fG1, subwin[0], 30); |
fH1 = new TGHorizontalFrame(fH2, subwin[0], 30); |
updateTemp = new TGTextButton(fH1, "Update"); |
updateTemp->SetTextJustify(36); |
updateTemp->SetWrapLength(-1); |
updateTemp->Resize(80,22); |
fH1->AddFrame(updateTemp, f0); |
|
exportTemp = new TGTextButton(fH1, "Export"); |
exportTemp->SetTextJustify(36); |
exportTemp->SetWrapLength(-1); |
exportTemp->Resize(80,22); |
fH1->AddFrame(exportTemp, f0); |
|
closeTemp = new TGTextButton(fH1, "Close"); |
closeTemp->SetTextJustify(36); |
closeTemp->SetWrapLength(-1); |
closeTemp->Resize(80,22); |
fH1->AddFrame(closeTemp, f0); |
fH2->AddFrame(fH1, f0centerx); |
|
fG1->AddFrame(fH2, f2); |
|
fMain->AddFrame(fG1, f1); |
|
// Action connections |
updateTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()"); |
tempEndOn->Connect("Clicked()", "TGAppMainFrame", this, "TempEndToggle()"); |
exportTemp->Connect("Clicked()", "TGAppMainFrame", this, "ExportTempPlot()"); |
closeTemp->Connect("Clicked()", "TGAppMainFrame", this, "CloseWindow()"); |
|
// Fieldpoint window ------------------------ |
|
} |
|
// ------------------------------------------------------------------- |
|
// Main function ----------------------------------------------------- |
|
void root_app() |
{ |
new TGAppMainFrame(gClient->GetRoot(), winWidth, winHeight); |
} |
|
int main(int argc, char **argv) |
{ |
TApplication theApp("TGAppMainFrame", &argc, argv); |
root_app(); |
theApp.Run(); |
|
return 0; |
} |
|
// ------------------------------------------------------------------- |