Project

General

Profile

Javascript » History » Version 6

Torbjorn Carlqvist Admin, 09/01/2021 02:26 PM

1 2 Torbjorn Carlqvist Admin
h1. Javascript guide for DTXr code IDE
2 1 Torbjorn Carlqvist Admin
3
4 6 Torbjorn Carlqvist Admin
h2. Commands
5
6
7
h3. *print*  - Prints a message to footer log window as well as the automation.log file
8
9 1 Torbjorn Carlqvist Admin
<pre><code class="javascript">print("hello");</code></pre>
10
11 6 Torbjorn Carlqvist Admin
h3. *readProperty*  - Reads an object property value
12 3 Torbjorn Carlqvist Admin
13 4 Torbjorn Carlqvist Admin
<pre><code class="javascript">
14
//Reads a present value from analog input object 0.
15
Controller.readProperty(85343,analogInput,0,presentValue);
16 5 Torbjorn Carlqvist Admin
17
//Use the result to print and in logic
18
res = Controller.readProperty(85343,analogInput,0,presentValue);
19
print(res);
20 1 Torbjorn Carlqvist Admin
if ( res > 0 ){
21
  print("value larger than 0!");
22 6 Torbjorn Carlqvist Admin
}
23
</code></pre>
24
25
h2. Events
26
27
h3. eventNotificationReceived
28
29
<pre><code class="javascript">
30
/***********************************************************************************************
31
 * Called when the controller receives a notification (intrinsic reporting) from another device
32
 * @param {Number} device - The device that send the event
33
 * @param {Number} objectType - The source object of the event
34
 * @param {Number} objectInstance - The instance of source object
35
 * @param {Number} eventType - The type of event received
36
 * @param {String} fromState - The previous state
37
 * @param {String} toState - The current state after the change
38
 * @param {Object} eventValues - A map of specific values for this particular eventType 
39
 ***********************************************************************************************/
40
function eventNotificationReceived(processIdentifier,initiatingDevice,object,objectType,objectInstance,timeStampUTC,notificationClass,priority,eventType,messageText,notifyType,ackRequired,fromState,toState,eventValues){
41 5 Torbjorn Carlqvist Admin
}
42 4 Torbjorn Carlqvist Admin
</code></pre>