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