Human Computer Interaction » History » Version 16

Aleksander Bešir, 31.12.2010 19:21

1 5 Aleksander Bešir
h1. Human Computer Interaction
2 1 Aleksander Bešir
3 1 Aleksander Bešir
{{toc}}
4 1 Aleksander Bešir
5 1 Aleksander Bešir
h2. 1 Basic concept
6 1 Aleksander Bešir
7 1 Aleksander Bešir
h3. 1.1 Hardware
8 1 Aleksander Bešir
9 5 Aleksander Bešir
p. The HCI will will be realised as a website. It will run on an Apache Tomcat http server, which will not run on the same device as Eneraptor's logic. Instead it will run on an independent proxy server.
10 1 Aleksander Bešir
11 1 Aleksander Bešir
p=. !HMI_website_overall.png!
12 1 Aleksander Bešir
13 1 Aleksander Bešir
p. The intended server-side html generating aplication is Tomcat's Jasper, making JSP the intended website programming language.
14 1 Aleksander Bešir
15 8 Aleksander Bešir
h3. 1.2 HCI features
16 1 Aleksander Bešir
17 8 Aleksander Bešir
The picture below shows basic HCI features:
18 8 Aleksander Bešir
19 8 Aleksander Bešir
!HCI_basic.png!
20 1 Aleksander Bešir
21 9 Aleksander Bešir
h2. 2 Communication with other parts
22 9 Aleksander Bešir
23 13 Aleksander Bešir
h3. 2.1 Logged data (instructions for syslog dev)
24 9 Aleksander Bešir
25 9 Aleksander Bešir
All logged data has to be written in a *PostgreSQL* database. Database's name must be *eneraptor-db*. Data must be writen in *standard public schema* (default).
26 9 Aleksander Bešir
27 9 Aleksander Bešir
The database table will exist prior to logging unit's (Janez) first run, so logging unit does not need to create the table. The logging unit *must* know, how to add a log entry to the database correctly, so that HCI will be able to use this data:
28 9 Aleksander Bešir
29 9 Aleksander Bešir
Every new log entry should be added with the following SQL query:
30 9 Aleksander Bešir
31 9 Aleksander Bešir
<pre>
32 9 Aleksander Bešir
INSERT INTO logged_data(
33 9 Aleksander Bešir
            id, "version", date_recieved, device_id, reported_data)
34 9 Aleksander Bešir
    VALUES (nextval('hibernate_sequence'), 0, now(), 'enterDeviceIdHere', 'enterReportedDataHere');
35 9 Aleksander Bešir
</pre>
36 9 Aleksander Bešir
37 9 Aleksander Bešir
enterDeviceIdHere and enterReportedDataHere should be replaced with actual data. Logging unit *must not* change other parts of the SQL query above.
38 9 Aleksander Bešir
39 10 Aleksander Bešir
While developing the logging unit (Janez) it may be useful to have a test database like the one HCI will create in the final product. You can create such a database with the following SQL query:
40 10 Aleksander Bešir
41 10 Aleksander Bešir
[[createEneraptorDatabase.backup]]
42 10 Aleksander Bešir
43 13 Aleksander Bešir
h3. 2.2 Getting info from the logic unit (instructions for DMS dev)
44 11 Aleksander Bešir
45 11 Aleksander Bešir
Every time HCI wants to get any information from the logic directly, it establishes a TCP connection (using sockets). The logic unit should use a socket to listen to a port for an incoming connection.
46 11 Aleksander Bešir
47 11 Aleksander Bešir
48 11 Aleksander Bešir
When a connection is established, HCI sends a series of lines that together represent some XML data and waits until the logic unit sends some XML data back. The connection is then closed. The root node of HCI's request will always be:
49 12 Aleksander Bešir
<pre><code class="xml">
50 11 Aleksander Bešir
<hci-request type="...">
51 11 Aleksander Bešir
   ...
52 11 Aleksander Bešir
</hci-request>
53 11 Aleksander Bešir
</code></pre>
54 11 Aleksander Bešir
55 11 Aleksander Bešir
The _type_ attribute value may be one of the following: checkConnection, getConfig, setConfig, getActions, setActions, executeAction.
56 11 Aleksander Bešir
57 11 Aleksander Bešir
| *type* | *purpose*                                                    | *what HCI expects in the reply*                 |
58 11 Aleksander Bešir
| @checkConnection@ | a simple echo for testing connectivity            | echoed data                                     |
59 11 Aleksander Bešir
| @getConfig      @ | HCI gets current logic's configuration            | logic's current configuration                   |
60 11 Aleksander Bešir
| @setConfig      @ | HCI sends new configuration to the logic unit     | confirmation that new config was accepted       |
61 11 Aleksander Bešir
| @getActions     @ | HCI gets a list of actions                        | logic's currently installed actions             |
62 1 Aleksander Bešir
| @setActions     @ | HCI sends a new list of actions to the logic unit | confirmation that new actions list was accepted |
63 1 Aleksander Bešir
| @executeAction  @ | HCI demands executing an action instantly         | confirmation that the action has been executed  |
64 13 Aleksander Bešir
65 15 Aleksander Bešir
h4. 2.2.1 The @checkConnection@ protocol
66 13 Aleksander Bešir
67 13 Aleksander Bešir
This performs a simple test to check, if the connection between HCI and the logic unit can be established succesfully.
68 13 Aleksander Bešir
69 13 Aleksander Bešir
The check connection request has the following structure:
70 13 Aleksander Bešir
71 13 Aleksander Bešir
<pre><code class="xml">
72 13 Aleksander Bešir
<hci-request type="checkConnection">
73 13 Aleksander Bešir
   <data>
74 13 Aleksander Bešir
      INTEGER_VALUE
75 13 Aleksander Bešir
   </data>
76 13 Aleksander Bešir
</hci-request>
77 13 Aleksander Bešir
</code></pre>
78 13 Aleksander Bešir
79 13 Aleksander Bešir
Example:
80 13 Aleksander Bešir
81 13 Aleksander Bešir
<pre><code class="xml">
82 13 Aleksander Bešir
<hci-request type="checkConnection">
83 13 Aleksander Bešir
   <data>
84 13 Aleksander Bešir
      123456
85 13 Aleksander Bešir
   </data>
86 13 Aleksander Bešir
</hci-request>
87 13 Aleksander Bešir
</code></pre>
88 13 Aleksander Bešir
89 13 Aleksander Bešir
Logic's response shoud have the following structure:
90 13 Aleksander Bešir
91 13 Aleksander Bešir
<pre><code class="xml">
92 14 Aleksander Bešir
<logic-response type="checkConnection">
93 13 Aleksander Bešir
   <data>
94 13 Aleksander Bešir
      INTEGER_VALUE
95 13 Aleksander Bešir
   <data>
96 13 Aleksander Bešir
</logic-reply>
97 13 Aleksander Bešir
</code></pre>
98 13 Aleksander Bešir
99 13 Aleksander Bešir
Example:
100 13 Aleksander Bešir
101 13 Aleksander Bešir
<pre><code class="xml">
102 14 Aleksander Bešir
<logic-response type="checkConnection">
103 13 Aleksander Bešir
   <data>
104 13 Aleksander Bešir
      123456
105 13 Aleksander Bešir
   <data>
106 13 Aleksander Bešir
</logic-reply>
107 13 Aleksander Bešir
</code></pre>
108 13 Aleksander Bešir
109 13 Aleksander Bešir
The same value of @INTEGER_VALUE@ in the request should be returned in the response.
110 13 Aleksander Bešir
111 16 Aleksander Bešir
h4. 2.2.2 The @getConfig@ protocol
112 16 Aleksander Bešir
113 16 Aleksander Bešir
This is used for obtaining current logic configuration. HCI then may change it and send it back using @setConfig@ request.
114 16 Aleksander Bešir
115 16 Aleksander Bešir
HCI's request is static:
116 16 Aleksander Bešir
117 16 Aleksander Bešir
<pre><code class="xml">
118 16 Aleksander Bešir
<hci-request type="getConfig">
119 16 Aleksander Bešir
</hci-request>
120 16 Aleksander Bešir
</code></pre>
121 16 Aleksander Bešir
122 16 Aleksander Bešir
Logic's response should have the following structure:
123 16 Aleksander Bešir
124 16 Aleksander Bešir
<pre><code class="xml">
125 16 Aleksander Bešir
<logic-response type="getConfig">
126 16 Aleksander Bešir
   <setting id="settingId1">
127 16 Aleksander Bešir
      <label>Setting 1 label</label>
128 16 Aleksander Bešir
      <desc>Setting 1 description</desc>
129 16 Aleksander Bešir
      <type>SETTING_TYPE</type>
130 16 Aleksander Bešir
      <value>SETTING_VAL</value>
131 16 Aleksander Bešir
   </setting>
132 16 Aleksander Bešir
   ...
133 16 Aleksander Bešir
</logic-reply>
134 16 Aleksander Bešir
</code></pre>
135 16 Aleksander Bešir
136 16 Aleksander Bešir
SETTING_TYPE may take one of the following values: byte, short, int, bool, string, float, double.
137 16 Aleksander Bešir
SETTING_VAL must be either a numer (for byte, short, int, float and double types), a string (for string type) or 'true' or 'false' (for bool type).
138 16 Aleksander Bešir
139 16 Aleksander Bešir
The setting's id attribute may be anything. HCI doessn't need to know which settings exist in the logic - the configuration form gets generated from this reply.
140 16 Aleksander Bešir
141 16 Aleksander Bešir
Example:
142 16 Aleksander Bešir
143 16 Aleksander Bešir
<pre><code class="xml">
144 16 Aleksander Bešir
<logic-response type="getConfig">
145 16 Aleksander Bešir
   <setting id="loggingOn">
146 16 Aleksander Bešir
      <label>Logging active</label>
147 16 Aleksander Bešir
      <desc>Sets logging on or off</desc>
148 16 Aleksander Bešir
      <type>bool</type>
149 16 Aleksander Bešir
      <value>true</value>
150 16 Aleksander Bešir
   </setting>
151 16 Aleksander Bešir
   <setting id="ignoreAllMeasurements">
152 16 Aleksander Bešir
      <label>Ignore measurements</label>
153 16 Aleksander Bešir
      <desc>Suspends decision making software by ignoring all measurements</desc>
154 16 Aleksander Bešir
      <type>bool</type>
155 16 Aleksander Bešir
      <value>false</value>
156 16 Aleksander Bešir
   </setting>
157 16 Aleksander Bešir
</logic-reply>
158 16 Aleksander Bešir
</code></pre>
159 11 Aleksander Bešir
160 1 Aleksander Bešir
h2. References
161 1 Aleksander Bešir
162 1 Aleksander Bešir
# Chopra, Vivek, et al., _Professional Apache Tomcat 6_, Wrox - Wiley, 2007
163 1 Aleksander Bešir
# Basham, Bryan, et al., _Head First Servlets and JSP™_, O’Reilly, 2008
164 1 Aleksander Bešir
165 1 Aleksander Bešir
h2. Attachments