-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_GUI.m
More file actions
165 lines (132 loc) · 6.78 KB
/
Copy pathMain_GUI.m
File metadata and controls
165 lines (132 loc) · 6.78 KB
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
function Main_GUI
hs.main_fig = figure('ToolBar', 'none', ...
'MenuBar', 'none', ...
'NumberTitle', 'off', ...
'Name', 'DATABASE Updater', ...
'Color', 'white', ...
'Resize', 'off', ...
'Position', [400,400,330,165], ...
'Visible', 'off'); % make it invisible at the beginning
hs.run_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'Update', ...
'Position', [10,15,50,25]);
hs.manual_bttn = uicontrol('Style', 'togglebutton', ...
'String', 'Manual', ...
'Max', 1, ...
'Min', 0, ...
'Value', 1, ...
'Position', [70,15,50,25]);
hs.start_text = uicontrol('Style', 'text', ...
'String', 'From:', ...
'BackgroundColor', 'white', ...
'Enable', 'off', ...
'Position', [130,20,40,15]);
hs.end_text = uicontrol('Style', 'text', ...
'String', 'To:', ...
'BackgroundColor', 'white', ...
'Enable', 'off', ...
'Position', [230,20,30,15]);
hs.start_edit = uicontrol('Style', 'edit', ...
'String', getcfgdata('start_date'), ...
'BackgroundColor', 'white', ...
'Enable', 'off', ...
'Position', [170,15,60,25]);
hs.end_edit = uicontrol('Style', 'edit', ...
'String', getcfgdata('end_date'), ...
'BackgroundColor', 'white', ...
'Enable', 'off', ...
'Position', [260,15,60,25]);
hs.dateUpdate_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'Update 1', ...
'Position', [10,70,50,25]);
hs.dateUpdate_text = uicontrol('Style', 'text', ...
'String', '1. Update All Trade Date List', ...
'FontName', 'Tahoma', ...
'FontWeight', 'bold', ...
'HorizontalAlignment','left', ...
'BackgroundColor', 'white', ...
'Enable', 'on', ...
'Position', [70,70,190,15]);
hs.ts_com_status = uicontrol('Style', 'pushbutton', ...
'String', 'TS.COM', ...
'CreateFcn', {@ts_com}, ...
'Position', [270, 70, 50, 25]);
hs.app1_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'App1', ...
'Position', [10, 125, 50, 25]);
hs.app2_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'App2', ...
'Position', [70, 125, 50, 25]);
hs.app3_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'App3', ...
'Position', [130, 125, 50, 25]);
hs.app4_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'App4', ...
'Position', [190, 125, 50, 25]);
hs.app4_bttn = uicontrol('Style', 'pushbutton', ...
'String', 'App5', ...
'Position', [250, 125, 50, 25]);
% initial...GUI..Data
%
set(hs.run_bttn, 'Callback', {@run_func, hs});
set(hs.manual_bttn, 'Callback', {@manual_toggle, hs});
set(hs.dateUpdate_bttn, 'Callback', {@dateUpdate});
set(hs.ts_com_status, 'Callback', {@ts_com});
set(hs.app1_bttn, 'Callback', {@run_app1});
% Show me!
set(hs.main_fig, 'Visible', 'on');
% block execution for daemon.
waitfor(hs.main_fig);
end
%%
function manual_toggle(hobj, ~, hs)
% Note: togglebutton's Value Property is changed automatically behind by system
%
hobj_status = get(hobj, 'Value');
if hobj_status == 0
set(hs.start_text, 'Enable', 'on');
set(hs.end_text, 'Enable', 'on');
set(hs.start_edit, 'Enable', 'on');
set(hs.end_edit, 'Enable', 'on');
else
set(hs.start_text, 'Enable', 'off');
set(hs.end_text, 'Enable', 'off');
set(hs.start_edit, 'Enable', 'off');
set(hs.end_edit, 'Enable', 'off');
end
end
%%
function run_func(~, ~, hs)
manual_status = get(hs.manual_bttn, 'Value');
if manual_status == 1
setcfgdata('auto_or_manual', 1);
elseif manual_status == 0
setcfgdata('auto_or_manual', 0);
setcfgdata('start_date', get(hs.start_edit, 'String'));
setcfgdata('end_date', get(hs.end_edit, 'String'));
end
Main_stocksDQ;
end
%%
function dateUpdate(~, ~)
com_obj = get_wsVar('base', 'ts');
if(~iscom(com_obj))
error('TinySoft COM Automation Server error!!!');
end
all_trade_dates = get_RemoteDateList(com_obj, '20000101', datestr(date, 'yyyymmdd'));
setcfgdata('all_trade_dates', all_trade_dates);
fprintf(1, '''all_trade_dates'' updated!');
end
%%
function ts_com(hobj, ~)
tmp_a = evalin('base', 'exist(''ts'', ''var'')');
if tmp_a == 0
set(hobj, 'BackgroundColor', 'red');
else
set(hobj, 'BackgroundColor', 'green');
end
end
%%
function run_app1(~, ~)
Run_App1;
end