Statistics
| Revision:

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

History | View | Annotate | Download (1.41 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 = "<hci-request type='checkConnection'><data>012345</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'] == "012345") {
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
                        }
30
                }
31
                
32
                output += reportService.println("Test ended")
33
                
34
                [output:output]
35
                
36
        }
37
        
38
}