Statistics
| Revision:

root / hci / trunk / eneraptor-web-app / grails-app / controllers / com / eneraptor / hci / LogicRequestController.groovy @ 52

History | View | Annotate | Download (1.63 KB)

1 3 alexbesir
package com.eneraptor.hci
2
3
class LogicRequestController {
4
5
        def reportService
6 6 alexbesir
        def hciLogicCommService
7 3 alexbesir
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 6 alexbesir
17 52 alexbesir
                String reqStr = "<?xml version=\"1.0\"?><hci-request type=\"checkConnection\"><data>12345</data></hci-request>"
18 6 alexbesir
                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 52 alexbesir
                        if(testReply['content'] == "<logic-response type=\"checkConnection\"><data>12345</data></logic-response>") {
25 6 alexbesir
                                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 52 alexbesir
                                output += reportService.println("<span style='color:red;'>Returned: " + testReply['content'].encodeAsHTML() + "</span>");
30 6 alexbesir
                        }
31
                }
32
33 3 alexbesir
                output += reportService.println("Test ended")
34
35
                [output:output]
36
37
        }
38
39
}