root / hci / trunk / eneraptor-web-app / grails-app / controllers / com / eneraptor / hci / LogicRequestController.groovy @ 66
History | View | Annotate | Download (1.82 KB)
1 |
package com.eneraptor.hci
|
---|---|
2 |
|
3 |
import grails.converters.* |
4 |
|
5 |
class LogicRequestController { |
6 |
|
7 |
def reportService
|
8 |
def hciLogicCommService
|
9 |
|
10 |
def testConnection = {
|
11 |
|
12 |
def output = ""; |
13 |
output += reportService.println("Conection test using")
|
14 |
output += reportService.println("Logic IP address: " + session.hwSet.IPaddress)
|
15 |
output += reportService.println("Logic port number: " + session.hwSet.portNumber)
|
16 |
|
17 |
output += reportService.println("Test started")
|
18 |
|
19 |
String reqStr = "<?xml version=\"1.0\"?><hci-request type=\"checkConnection\"><data>12345</data></hci-request>" |
20 |
Map testReply = hciLogicCommService.getReplyToRequest(reqStr,session.hwSet.IPaddress,session.hwSet.portNumber)
|
21 |
|
22 |
if(testReply['status'] == "error") { |
23 |
output += reportService.println("<span style='color:red;'>Error: " + testReply['content'] + "</span>") |
24 |
} else {
|
25 |
output += reportService.println("Connection established succesfully")
|
26 |
def rootNode = XML.parse(testReply['content']) |
27 |
if(rootNode.data == "12345") { |
28 |
output += reportService.println("<span style='color:green;'>Logic unit replied! The eneraptor system is set up properly.</span>")
|
29 |
} else {
|
30 |
output += reportService.println("<span style='color:red;'>The connection was established, but there was no reply from the logic unit.</span>")
|
31 |
output += reportService.println("<span style='color:red;'>You should check the logic's port number and IP address.</span>")
|
32 |
output += reportService.println("<span style='color:red;'> Returned: " + testReply['content'].encodeAsHTML() + "</span>") |
33 |
output += reportService.println("<span style='color:red;'>Should be: " + "<logic-response type=\"checkConnection\"><data>12345</data></logic-response>".encodeAsHTML() + "</span>") |
34 |
} |
35 |
} |
36 |
|
37 |
output += reportService.println("Test ended")
|
38 |
|
39 |
[output:output]
|
40 |
|
41 |
} |
42 |
|
43 |
} |