9度通讯程序适用于9度多组设备
Administrator
2023-12-27 c736aaea5522e295b42676f094d313e7f6a4afb4
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package com.dev.fbs9009;
 
import java.nio.ByteBuffer;
import java.util.Date;
 
import com.base.Com;
import com.base.ComBase;
 
public class LD_date_time {
    public static int BYTE_LEN=3;              //¼Ä´æÆ÷¸öÊý
    private int cmd;                        //·¢ËÍÊý¾ÝµÄÃüÁî
    private int cmd_addr;                    //Ä£¿éµØÖ·(»ò·¢ËÍʱµÄ¼Ä´æÆ÷µÄÆðʼµØÖ·)
    private int cmd_addr_back;                //½ÓÊռĴæÆ÷µÄÆðʼµØÖ·
    private int dataCount;                    //Êý¾ÝµÄ³¤¶È
    private int year;
    private int month;
    private int day;
    private int hour;
    private int minute;
    private int second;
    
    
    
    //»ñȡϵͳʱ¼ä
    public boolean setLD_param(ByteBuffer bf){
        boolean flag = false;
        ByteBuffer tmpbuf = bf;        
        tmpbuf.position(0);
        try {
            this.cmd_addr = ComBase.changeByteToInt(tmpbuf.get());
            this.cmd = ComBase.changeByteToInt(tmpbuf.get());                        //ÃüÁîµØÖ·
            this.cmd_addr_back =  ComBase.changeShortToInt(tmpbuf.getShort());        
            this.dataCount = ComBase.changeByteToInt(tmpbuf.get());
            
            System.out.println("Êý¾ÝÇø×Ö½ÚÊýµÄ³¤¶È:"+this.dataCount);
            int Y_M=tmpbuf.getShort();
            this.year=Y_M&0xFF00;
            this.month=Y_M&0x00FF;
            
            int D_H=tmpbuf.getShort();
            this.day=D_H&0xFF00;
            this.hour=D_H&0x00FF;
            
            int M_S=tmpbuf.getShort();
            this.minute=M_S&0xFF00;
            this.second=M_S&0x00FF;
            
            flag = true;
        } catch (Exception e) {
              e.printStackTrace();
          }                
          return flag;
    }
    
    /**
     * ¸ñʽ»¯Ê±¼ä
     * @return
     */
    public String formartDate(){
        return this.year+"-"+this.month+"-"+this.day+" "+this.hour+":"+this.minute+":"+second;
    }
    
    /**
     * »ñÈ¡µ±Ç°Ï̵߳Äʱ¼ä
     * @return
     */
    public Date getNowTime(){
        String datestr = formartDate();
        Date time = Com.getDateTimeFromStr(datestr, Com.DTF_YMDhms);
        return time;
    }
    
    
    public int getCmd() {
        return cmd;
    }
 
    public void setCmd(int cmd) {
        this.cmd = cmd;
    }
 
    public int getCmd_addr() {
        return cmd_addr;
    }
 
    public void setCmd_addr(int cmd_addr) {
        this.cmd_addr = cmd_addr;
    }
 
    public int getDataCount() {
        return dataCount;
    }
 
    public void setDataCount(int dataCount) {
        this.dataCount = dataCount;
    }
 
    public int getYear() {
        return year;
    }
 
    public void setYear(int year) {
        this.year = year;
    }
 
    public int getMonth() {
        return month;
    }
 
    public void setMonth(int month) {
        this.month = month;
    }
 
    public int getDay() {
        return day;
    }
 
    public void setDay(int day) {
        this.day = day;
    }
 
    public int getHour() {
        return hour;
    }
 
    public void setHour(int hour) {
        this.hour = hour;
    }
 
    public int getMinute() {
        return minute;
    }
 
    public void setMinute(int minute) {
        this.minute = minute;
    }
 
    public int getSecond() {
        return second;
    }
 
    public void setSecond(int second) {
        this.second = second;
    }
 
    @Override
    public String toString() {
        return "LD_date_time [cmd=" + cmd + ", cmd_addr=" + cmd_addr + ", dataCount=" + dataCount + ", year=" + year
                + ", month=" + month + ", day=" + day + ", hour=" + hour + ", minute=" + minute + ", second=" + second
                + "]";
    }
    
    
}