File: outstrdlg.cpp

package info (click to toggle)
rtklib 2.4.3%2Bdfsg1-2.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 41,796 kB
  • sloc: cpp: 51,592; ansic: 50,584; fortran: 987; makefile: 861; sh: 45
file content (174 lines) | stat: -rw-r--r-- 5,875 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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "rtklib.h"
#include "serioptdlg.h"
#include "cmdoptdlg.h"
#include "fileoptdlg.h"
#include "tcpoptdlg.h"
#include "outstrdlg.h"
#include "keydlg.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TOutputStrDialog *OutputStrDialog;
//---------------------------------------------------------------------------
__fastcall TOutputStrDialog::TOutputStrDialog(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::FormShow(TObject *Sender)
{
	Stream1C ->Checked  =StreamC[0];
	Stream2C ->Checked  =StreamC[1];
	Stream1  ->ItemIndex=Stream[0];
	Stream2  ->ItemIndex=Stream[1];
	Format1  ->ItemIndex=Format[0];
	Format2  ->ItemIndex=Format[1];
	FilePath1->Text     =GetFilePath(Paths[0][2]);
	FilePath2->Text     =GetFilePath(Paths[1][2]);
	SwapIntv->Text      =SwapInterval;
	TimeTagC ->Checked  =OutTimeTag;
	UpdateEnable();
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::BtnOkClick(TObject *Sender)
{
	StreamC[0]  =Stream1C->Checked;
	StreamC[1]  =Stream2C->Checked;
	Stream[0]   =Stream1->ItemIndex;
	Stream[1]   =Stream2->ItemIndex;
	Format[0]   =Format1->ItemIndex;
	Format[1]   =Format2->ItemIndex;
	Paths [0][2]=SetFilePath(FilePath1->Text);
	Paths [1][2]=SetFilePath(FilePath2->Text);
	SwapInterval=SwapIntv->Text;
	OutTimeTag  =TimeTagC->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::BtnFile1Click(TObject *Sender)
{
	SaveDialog->FileName=FilePath1->Text;
	if (!SaveDialog->Execute()) return;
	FilePath1->Text=SaveDialog->FileName;
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::BtnFile2Click(TObject *Sender)
{
	SaveDialog->FileName=FilePath2->Text;
	if (!SaveDialog->Execute()) return;
	FilePath2->Text=SaveDialog->FileName;
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::Stream1Change(TObject *Sender)
{
	UpdateEnable();
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::Stream2Change(TObject *Sender)
{
	UpdateEnable();
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::Stream1CClick(TObject *Sender)
{
	UpdateEnable();
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::Stream2CClick(TObject *Sender)
{
	UpdateEnable();
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::BtnKeyClick(TObject *Sender)
{
	KeyDialog->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::BtnStr1Click(TObject *Sender)
{
	switch (Stream1->ItemIndex) {
		case 0: SerialOpt(0,0); break;
		case 1: TcpOpt(0,1); break;
		case 2: TcpOpt(0,0); break;
		case 3: TcpOpt(0,2); break;
	}
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::BtnStr2Click(TObject *Sender)
{
	switch (Stream2->ItemIndex) {
		case 0: SerialOpt(1,0); break;
		case 1: TcpOpt(1,1); break;
		case 2: TcpOpt(1,0); break;
		case 3: TcpOpt(1,2); break;
	}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TOutputStrDialog::GetFilePath(AnsiString path)
{
	char *p,*q,buff[1024];
	strcpy(buff,path.c_str());
	if ((p=strstr(buff,"::"))) *p='\0';
	return (path=buff);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TOutputStrDialog::SetFilePath(AnsiString path)
{
	AnsiString str;
	double swap;
	if (TimeTagC->Checked) path+="::T";
	str=SwapIntv->Text;
	if (sscanf(str.c_str(),"%lf",&swap)>=1) {
		path+="::S="+str;
	}
	return path;
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::SerialOpt(int index, int opt)
{
	SerialOptDialog->Path=Paths[index][0];
	SerialOptDialog->Opt=opt;
	if (SerialOptDialog->ShowModal()!=mrOk) return;
	Paths[index][0]=SerialOptDialog->Path;
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::TcpOpt(int index, int opt)
{
	TcpOptDialog->Path=Paths[index][1];
	TcpOptDialog->Opt=opt;
	for (int i=0;i<10;i++) {
		TcpOptDialog->History[i]=History[i];
		TcpOptDialog->MntpHist[i]=MntpHist[i];
	}
	if (TcpOptDialog->ShowModal()!=mrOk) return;
	Paths[index][1]=TcpOptDialog->Path;
	for (int i=0;i<10;i++) {
		History[i]=TcpOptDialog->History[i];
		MntpHist[i]=TcpOptDialog->MntpHist[i];
	}
}
//---------------------------------------------------------------------------
void __fastcall TOutputStrDialog::UpdateEnable(void)
{
	int ena=Stream1C->Checked&&Stream1->ItemIndex==4||
			Stream2C->Checked&&Stream2->ItemIndex==4;
	Stream1  ->Enabled=Stream1C->Checked;
	Stream2  ->Enabled=Stream2C->Checked;
	BtnStr1  ->Enabled=Stream1C->Checked&&Stream1->ItemIndex<=3;
	BtnStr2  ->Enabled=Stream2C->Checked&&Stream2->ItemIndex<=3;
	FilePath1->Enabled=Stream1C->Checked&&Stream1->ItemIndex==4;
	FilePath2->Enabled=Stream2C->Checked&&Stream2->ItemIndex==4;
	BtnFile1 ->Enabled=Stream1C->Checked&&Stream1->ItemIndex==4;
	BtnFile2 ->Enabled=Stream2C->Checked&&Stream2->ItemIndex==4;
	LabelF1  ->Enabled=ena;
	Label1   ->Enabled=ena;
	Label2   ->Enabled=ena;
	TimeTagC ->Enabled=ena;
	SwapIntv ->Enabled=ena;
	BtnKey   ->Enabled=ena;
}
//---------------------------------------------------------------------------