严智鑫
2025-11-13 945bc394f40d8af1072a53da9a94f24207124e6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.northglass.service.machine;
 
import com.northglass.constants.StateConstants.ConnectState;
import com.northglass.constants.StateConstants.MachineState;
import com.northglass.entity.Machine;
 
public abstract class MachineService {
 
    public static String getConnectStateHtml(String state) {
        StringBuffer html = new StringBuffer();
        
        if (ConnectState.NO_CONNECT.equals(state)) {
            html.append("<span class='label'>").append(state).append("</span>");
        }
        else if (ConnectState.CONNECTING.equals(state)) {
            html.append("<span class='label label-warning'>").append(state).append("</span>");
        }
        else if (ConnectState.CONNECTED.equals(state)) {
            html.append("<span class='label label-success'>").append(state).append("</span>");
        }
        
        return html.toString();
    }
    
    public static String getMachineStateHtml(String state) {
        StringBuffer html = new StringBuffer();
        
        if (MachineState.IN_WORK.equals(state)) {
            html.append("<span class='label label-success'>").append(state).append("</span>");
        }
        else if (MachineState.STOPPED.equals(state)) {
            html.append("<span class='label'>").append(state).append("</span>");
        }
        else if (MachineState.WARNING.equals(state)) {
            html.append("<span class='label label-warning'>").append(state).append("</span>");
        }
        else if (MachineState.SERIOUS_WARNING.equals(state)) {
            html.append("<span class='label label-important'>").append(state).append("</span>");
        }
        
        return html.toString();
    }
    
    public abstract void setConnectState(Machine machine, String connectState);
    
    public abstract void resetState();
    
    public abstract void connect();
    
    public abstract String generateReturnMessage(String sendMessageHex, Machine machine);
}