1 | throw new Error("Description for built in functions. Must not be included!");
|
---|
2 | /**
|
---|
3 | * @fileOverview
|
---|
4 | * Documentation of dim namespace.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * @namespace
|
---|
9 | *
|
---|
10 | * Namespace for extension functions dealing with the DIM network.
|
---|
11 | *
|
---|
12 | * @author <a href="mailto:thomas.bretz@epfl.ch">Thomas Bretz</a>
|
---|
13 | */
|
---|
14 | var dim = { };
|
---|
15 |
|
---|
16 | /**
|
---|
17 | *
|
---|
18 | * Post a message into the dim log stream.
|
---|
19 | *
|
---|
20 | * It will be logged by the datalogger, displayed on the console
|
---|
21 | * and in the smartfact web-gui.
|
---|
22 | *
|
---|
23 | * @param argument
|
---|
24 | * Any kind of argument can be given. If it is not a String, it
|
---|
25 | * is converted using the toString() member function.
|
---|
26 | *
|
---|
27 | * @param [. . .]
|
---|
28 | * Any number of additional arguments. Each argument will appear in
|
---|
29 | * a new line.
|
---|
30 | *
|
---|
31 | * @example
|
---|
32 | * dim.log("Five="+5, "--- new line ---");
|
---|
33 | *
|
---|
34 | */
|
---|
35 | dim.log = function() { /* [native code] */ }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | *
|
---|
39 | * Posts a message to the dim network with alarm severity.
|
---|
40 | *
|
---|
41 | * Similar to dim.log, but the message is posted to the network
|
---|
42 | * with alarm severity. This means that it is displayed in red
|
---|
43 | * and the smartfact web-gui will play an alarm sound.
|
---|
44 | * The alarm state will stay valid (displayed in the web-gui) until it
|
---|
45 | * is reset.
|
---|
46 | *
|
---|
47 | * @param argument
|
---|
48 | * Any kind of argument can be given. If it is not a String, it
|
---|
49 | * is converted using the toString() member function.
|
---|
50 | *
|
---|
51 | * @param [. . .]
|
---|
52 | * Any number of additional arguments. Each argument will appear as
|
---|
53 | * individual alarm.
|
---|
54 | *
|
---|
55 | * @example
|
---|
56 | * dim.alarm("Alarm for 30 seconds!");
|
---|
57 | * v8.sleep(30000);
|
---|
58 | * dim.alarm();
|
---|
59 | */
|
---|
60 | dim.alarm = function() { /* [native code] */ }
|
---|
61 |
|
---|
62 | /**
|
---|
63 | *
|
---|
64 | * Send a dim command to a dim client.
|
---|
65 | *
|
---|
66 | * @param {String} commandId
|
---|
67 | * The command id is a string and usually compiles like
|
---|
68 | * 'SERVER/COMMAND'
|
---|
69 | *
|
---|
70 | * @param argument
|
---|
71 | * Any kind of argument can be given. Arguments are internally
|
---|
72 | * converted into strings using toString() and processed as
|
---|
73 | * if they were typed on th console.
|
---|
74 | *
|
---|
75 | * @param [. . .]
|
---|
76 | * Any number of additional arguments.
|
---|
77 | *
|
---|
78 | * @example
|
---|
79 | * dim.send('DRIVE_CONTROL/TRACK_SOURCE 0.5 180 "Mrk 421"');
|
---|
80 | * dim.send('DRIVE_CONTROL/TRACK_SOURCE', 0.5, 180, 'Mrk 421');
|
---|
81 | *
|
---|
82 | * @returns
|
---|
83 | * A boolean value is returned whether the command was succesfully
|
---|
84 | * posted into the network or not. Note that true does by no means
|
---|
85 | * mean that the command was sucessfully received or even processed.
|
---|
86 | */
|
---|
87 | dim.send = function() { /* [native code] */ }
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Returns the state of the given server.
|
---|
91 | *
|
---|
92 | * @param {String} name
|
---|
93 | * The name of the server of which you want to get the state.
|
---|
94 | *
|
---|
95 | * @throws
|
---|
96 | * If number or type of arguments is wrong
|
---|
97 | *
|
---|
98 | * @returns {Object}
|
---|
99 | * An object with the properties 'index' {Integer} and 'name' {String}
|
---|
100 | * is returned if a connection to the server is established and
|
---|
101 | * state information have been received, 'undefined' otherwise. If
|
---|
102 | * the time of the last state change is available, it is stored
|
---|
103 | * in the 'property'. If a server disconnected, a valid object will
|
---|
104 | * be returned, but without any properties.
|
---|
105 | */
|
---|
106 | dim.state = function() { /* [native code] */ }
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Wait for the given state of a server.
|
---|
110 | *
|
---|
111 | * Note that the function is internally asynchornously checking the
|
---|
112 | * state, that means that theoretically, a state could be missed if
|
---|
113 | * it changes too fast. If this can happen callbacks have to be used.
|
---|
114 | *
|
---|
115 | * @param {String} name
|
---|
116 | * The name of the server of which you want to wait for a state.
|
---|
117 | * The name must not contain quotation marks.
|
---|
118 | *
|
---|
119 | * @param {String,Integer} state
|
---|
120 | * The state you want to wait for. It can either be given as an Integer
|
---|
121 | * or as the corresponding short name. If given as String it must
|
---|
122 | * not contain quotation marks.
|
---|
123 | *
|
---|
124 | * @param {Integer} [timeout]
|
---|
125 | * An optional timeout. If no timeout is given or a timeout of undefined,
|
---|
126 | * waiting will not stop until the condition is fulfilled. A timeout
|
---|
127 | * of 0 is allowed and will essentially just check if the server is
|
---|
128 | * in this state or not. If a negative value is given, exceptions are
|
---|
129 | * suppressed and false is returned in case of timeout. As timeout
|
---|
130 | * the absolute value is used.
|
---|
131 | *
|
---|
132 | * @throws
|
---|
133 | * <li> If number or type of arguments is wrong
|
---|
134 | * <li> If no connection to the server is established or no state
|
---|
135 | * has been received yet. This is identical to dim.state()
|
---|
136 | * returning 'undefined' (only in case a positive timeout
|
---|
137 | * is given)
|
---|
138 | *
|
---|
139 | * @returns {Boolean}
|
---|
140 | * true if the state was achived within the timeout, false otherwise.
|
---|
141 | */
|
---|
142 | dim.wait = function() { /* [native code] */ }
|
---|
143 |
|
---|
144 | /**
|
---|
145 | *
|
---|
146 | * Returns a list of all known state of a given server.
|
---|
147 | *
|
---|
148 | * The returned object has all states with their index as property.
|
---|
149 | * Each state is returned as a String object with the property description.
|
---|
150 | *
|
---|
151 | * @param {String} [server='DIM_CONTROL']
|
---|
152 | * Name of the server for which states should be listed.
|
---|
153 | * The states of the DIM_CONTROl server are the default.
|
---|
154 | *
|
---|
155 | * @throws
|
---|
156 | * If number or type of arguments is wrong
|
---|
157 | *
|
---|
158 | * @type Object[StringObject]
|
---|
159 | *
|
---|
160 | * @example
|
---|
161 | * var states = dim.getStates("SERVER");
|
---|
162 | * console.out(JSON.stringify(states));
|
---|
163 | * for (var index in states)
|
---|
164 | * console.out(index+"="+states[index]+": "+states[index].description);
|
---|
165 | */
|
---|
166 | dim.getStates = function() { /* [native code] */ }
|
---|
167 |
|
---|
168 | /**
|
---|
169 | *
|
---|
170 | * Returns a description for one service
|
---|
171 | *
|
---|
172 | * The returned array has objects with the properties: name, description and unit. The last
|
---|
173 | * two are optional. The array itself has the properties name, server, service, isCommand
|
---|
174 | * and optionally format.
|
---|
175 | *
|
---|
176 | * @param {String} service
|
---|
177 | * String specifying the name of the service to be returned.
|
---|
178 | *
|
---|
179 | * @throws
|
---|
180 | * If number or type of arguments is wrong
|
---|
181 | *
|
---|
182 | * @type {Description}
|
---|
183 | *
|
---|
184 | * @example
|
---|
185 | * var s = dim.getDescription("TNG_WEATHER/DATA");
|
---|
186 | * console.out("Name="+s.name);
|
---|
187 | * console.out("Server="+s.server);
|
---|
188 | * console.out("Service="+s.service);
|
---|
189 | * console.out("Format="+s.format);
|
---|
190 | * console.out("Description="+s.name);
|
---|
191 | * console.out("IsCommand="+s.isCommand);
|
---|
192 | * console.out(JSON.stringify(s));
|
---|
193 | */
|
---|
194 | dim.getDescription = function() { /* [native code] */ }
|
---|
195 |
|
---|
196 | /**
|
---|
197 | *
|
---|
198 | * Returns a list of all known services
|
---|
199 | *
|
---|
200 | * The returned array has objects with the properties: name, server, service, command
|
---|
201 | * and (optional) format.
|
---|
202 | *
|
---|
203 | * @param {String} [service='*']
|
---|
204 | * String a service has to start with to be returned. The default is to return
|
---|
205 | * all available services. An empty string or '*' are wildcards for all
|
---|
206 | * services.
|
---|
207 | *
|
---|
208 | * @param {Boolean} [isCommand=undefined]
|
---|
209 | * If no second argument is specified, data services and commands are returned.
|
---|
210 | * With true, only commands, with false, only data-services are returned.
|
---|
211 | *
|
---|
212 | * @throws
|
---|
213 | * If number or type of arguments is wrong
|
---|
214 | *
|
---|
215 | * @type Array[Object]
|
---|
216 | *
|
---|
217 | * @example
|
---|
218 | * // Return all services of the FAD_CONTROL starting with E
|
---|
219 | * var services = dim.getServices("FAD_CONTROL/E");
|
---|
220 | * console.out(JSON.stringify(services));
|
---|
221 | */
|
---|
222 | dim.getServices = function() { /* [native code] */ }
|
---|
223 |
|
---|
224 | /**
|
---|
225 | *
|
---|
226 | * Callback in case of state changes.
|
---|
227 | *
|
---|
228 | * To install a callback in case the state of a server changes. set
|
---|
229 | * the corresponding property of this array to a function. The argument
|
---|
230 | * provided to the function is identical with the object returned
|
---|
231 | * by dim.state(). In addition the name of the server is added
|
---|
232 | * as the 'name' property and the comment sent with the state change
|
---|
233 | * as 'comment' property. For the code executed, the same rules apply
|
---|
234 | * than for a thread created with Thread.<P>
|
---|
235 | *
|
---|
236 | * If a state change is defined for a server for which no callback
|
---|
237 | * has been set, the special entry '*' is checked.
|
---|
238 | *
|
---|
239 | *
|
---|
240 | * @type Array[Function]
|
---|
241 | *
|
---|
242 | * @example
|
---|
243 | * dim.onchange['*'] = function(state) { console.out("State change from "+state.name+" received"); }
|
---|
244 | * dim.onchange['DIM_CONTROL'] = function(state) { console.out(JSON.stringify(state); }
|
---|
245 | * ...
|
---|
246 | * delete dim.onchange['DIM_CONTROL']; // to remove the callback
|
---|
247 | *
|
---|
248 | */
|
---|
249 | dim.onchange = [];
|
---|
250 |
|
---|
251 |
|
---|
252 | /**
|
---|
253 | * DIM version number
|
---|
254 | *
|
---|
255 | * @constant
|
---|
256 | * @type Integer
|
---|
257 | */
|
---|
258 | dim.version = 0;
|
---|