FreeCalypso > hg > leo2moko-debug
comparison gpf/INC/pco_view_core.h @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : PCO2 | |
4 | Modul : PCO_VIEW_CORE | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Modul contains the core viewer class | |
18 | with basic functions and handlers for several PCO control | |
19 | messages. | |
20 | It is intended to be specialized and extended, e.g. in | |
21 | GUI-server-applications. | |
22 | Some member functions are totally virtual without any | |
23 | standard body and have to be provided by the child class ! | |
24 +----------------------------------------------------------------------------- | |
25 */ | |
26 | |
27 #ifndef _PCO_VIEW_CORE_H_ | |
28 #define _PCO_VIEW_CORE_H_ | |
29 | |
30 /*==== INCLUDES ===================================================*/ | |
31 #ifndef PCO_VIEW_CORE_CPP | |
32 #include "pco_view_templ.h" | |
33 #else | |
34 #include "view/pco_view_templ.h" | |
35 #endif | |
36 #include "pco_inifile.h" | |
37 | |
38 /*==== DEFINES =====================================================*/ | |
39 | |
40 /*==== PROTOTYPES ==================================================*/ | |
41 | |
42 /*==== CLASSES =====================================================*/ | |
43 class PCOView_core : public PCOView_templ | |
44 { | |
45 public: | |
46 PCOView_core(const char* ini_file, int& err, | |
47 const char* primq_name="", const char* ctrlq_name=""); | |
48 virtual ~PCOView_core(); | |
49 | |
50 /* | |
51 +-------------------------------------------------------------------------------+ | |
52 | PROJECT : PCO2 MODULE : PCO_CTRL_CORE | | |
53 | STATE : code ROUTINE : PCOView_core::dispatch_message | | |
54 +-------------------------------------------------------------------------------+ | |
55 | |
56 PURPOSE : parses a PCO control message | |
57 PARAMS: buf ... the data | |
58 size .. size of buf | |
59 id ... id of the message | |
60 sender .. queue name of sender | |
61 | |
62 RETURNS: 0 .. if message has been handled | |
63 -1 .. otherwise | |
64 | |
65 */ | |
66 virtual int dispatch_message(void* buf, U16 size, U16 id, const char* sender); | |
67 | |
68 | |
69 /* | |
70 +-------------------------------------------------------------------------------+ | |
71 | PROJECT : PCO2 MODULE : PCO_CTRL_CORE | | |
72 | STATE : code ROUTINE : PCOView_core::interpret_message| | |
73 +-------------------------------------------------------------------------------+ | |
74 | |
75 PURPOSE : here interpretation of received raw data takes place | |
76 (has to be implemented by derived classes !) | |
77 | |
78 PARAMS: buffer .. raw data to be interpretated | |
79 bufsize .. size of buffer | |
80 data .. actual data | |
81 size .. size of data | |
82 id .. id of data message | |
83 index .. index of data message (e.g. in logfile) ... 0 means no index!! | |
84 ttype .. type of time stamp - see PCO_TTYPE_XXX constants | |
85 time .. time stamp | |
86 sender .. name of sender | |
87 receiver.. name of original receiver | |
88 | |
89 RETURNS: 0 .. success | |
90 -1 .. interpretation was not possible | |
91 | |
92 */ | |
93 virtual int interpret_message(void* buffer, U16 bufsize, | |
94 void* &data, U16 &size, ULONG &id, ULONG& index, ULONG& ttype, U32 &time, | |
95 char* &sender, char* &receiver) {return -1;} | |
96 | |
97 /* | |
98 +-------------------------------------------------------------------------------+ | |
99 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
100 | STATE : code ROUTINE : PCOView_core::on_data | | |
101 +-------------------------------------------------------------------------------+ | |
102 | |
103 PURPOSE : here reaction to received data takes place | |
104 (has to be implemented by derived classes !) | |
105 | |
106 PARAMS: data .. the data | |
107 size .. size of data | |
108 id .. id of data message | |
109 index .. index of data message (e.g. in logfile) ... 0 means no index!! | |
110 ttype .. type of time stamp - see PCO_TTYPE_XXX constants | |
111 time .. time stamp | |
112 sender .. name of sender | |
113 receiver.. name of original receiver | |
114 | |
115 */ | |
116 virtual void on_data(void* data, U16 size, ULONG id, ULONG index, | |
117 ULONG ttype, U32 time, const char* sender, char* receiver) {} | |
118 | |
119 /* | |
120 +-------------------------------------------------------------------------------+ | |
121 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
122 | STATE : code ROUTINE : PCOView_core::on_raw_data | | |
123 +-------------------------------------------------------------------------------+ | |
124 | |
125 PURPOSE : here reaction to the raw data just as received from server takes place | |
126 (may be implemented by derived classes) | |
127 if interpretation succeeded it will be called AFTER on_data(), otherwise | |
128 only on_raw_data() is called | |
129 | |
130 PARAMS: rawdata .. the data | |
131 rawsize .. size of data | |
132 | |
133 */ | |
134 virtual void on_raw_data(void* rawdata, U16 rawsize) {} | |
135 | |
136 /* | |
137 +-------------------------------------------------------------------------------+ | |
138 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
139 | STATE : code ROUTINE : PCOView_core::on_corrupt_data | | |
140 +-------------------------------------------------------------------------------+ | |
141 | |
142 PURPOSE : this function is called if corrupt data has been received | |
143 deriving viewers may, e.g., release semaphores | |
144 | |
145 PARAMS: | |
146 */ | |
147 virtual void on_corrupt_data() {} | |
148 | |
149 /* | |
150 +----------------------------------------------------------------------------------+ | |
151 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
152 | STATE : code ROUTINE : PCOView_core::propagate_inichange | | |
153 +----------------------------------------------------------------------------------+ | |
154 | |
155 PURPOSE : saves ini-file and sends an information about important ini-file changes | |
156 to the server, which will propagate it to all connected viewers | |
157 | |
158 PARAMS: | |
159 | |
160 RETURNS: 0 .. sucess | |
161 -1 .. Server not found | |
162 -2 .. error while contacting Server | |
163 */ | |
164 int propagate_inichange(); | |
165 | |
166 /* | |
167 +--------------------------------------------------------------------------------+ | |
168 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
169 | STATE : code ROUTINE : PCOView_core::self_trace | | |
170 +--------------------------------------------------------------------------------+ | |
171 | |
172 PURPOSE : adds a new trace string to the queue of this viewer | |
173 (has to be implemented by derived classes !) | |
174 | |
175 PARAMS: | |
176 | |
177 */ | |
178 virtual void self_trace(const char* trace)=0; | |
179 | |
180 /* | |
181 +-------------------------------------------------------------------------------+ | |
182 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
183 | STATE : code ROUTINE : PCOView_core::on_inichange | | |
184 +-------------------------------------------------------------------------------+ | |
185 | |
186 PURPOSE : reloads important changes from ini-file | |
187 | |
188 PARAMS: | |
189 | |
190 */ | |
191 virtual void on_inichange(); | |
192 | |
193 bool running() const {return m_running;} | |
194 | |
195 int dsize() const { return m_dsize;} | |
196 int qsize() const { return m_qsize;} | |
197 | |
198 /* | |
199 +-------------------------------------------------------------------------------+ | |
200 | PROJECT : PCO2 MODULE : PCO_VIEW_CORE | | |
201 | STATE : code ROUTINE : PCOView_core::shutdown | | |
202 +-------------------------------------------------------------------------------+ | |
203 | |
204 PURPOSE : exits the viewer threads | |
205 | |
206 PARAMS: | |
207 | |
208 */ | |
209 void shutdown(); | |
210 | |
211 virtual IniFile& inifile() { return m_inifile;} | |
212 virtual const IniFile& inifile() const { return m_inifile;} | |
213 | |
214 protected: | |
215 CMS_HANDLE m_prim_handle,m_ctrl_handle; | |
216 bool m_running; | |
217 | |
218 IniFile m_inifile; | |
219 int m_qsize, m_dsize; | |
220 | |
221 static void cms_prim_proc(long view); | |
222 static void cms_ctrl_proc(long view); | |
223 }; | |
224 | |
225 #endif /* _PCO_VIEW_CORE_H_ */ |