package com.dev.simpower.dev;
|
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
import java.util.Arrays;
|
|
import com.dev.bts.data.FBS9100_ComBase;
|
|
/**
|
* ¼«¼ò»¯µçÔ´·Öʱ¿ØÖƲÎÊý
|
* @author DELL
|
*
|
*/
|
public class Power_TimeControl {
|
public static final int REG_Count = 14 * 6;
|
|
public static final int Total_Load_Count = 12; //×Ü·Êý
|
|
public static final int Total_Load_Count_Sigle = 6; //µ¥´ÎÉèÖ÷Êý
|
|
public TimeControl[] timeControls = new TimeControl[Total_Load_Count];
|
|
public Power_TimeControl() {
|
for(int i = 0;i<timeControls.length;i++) {
|
timeControls[i] = new TimeControl();
|
}
|
}
|
|
|
public boolean putByteBuffer1(ByteBuffer bbf_rx) {
|
if(bbf_rx.limit() < REG_Count * 2) {
|
return false;
|
}
|
bbf_rx.position(0);
|
|
for(int k = 0;k<Total_Load_Count_Sigle;k++) {
|
timeControls[k].putTimeByteBuffer(bbf_rx);
|
}
|
|
bbf_rx.compact();
|
bbf_rx.flip();
|
|
return true;
|
}
|
|
public ByteBuffer getByteBuffer1() {
|
ByteBuffer buffer = ByteBuffer.allocate(REG_Count*2);
|
buffer.order(ByteOrder.BIG_ENDIAN);
|
buffer.position(0);
|
|
for(int k = 0;k<Total_Load_Count_Sigle;k++) {
|
buffer.put(timeControls[k].getTimeByteBuffer());
|
}
|
|
buffer.flip();
|
return buffer;
|
}
|
|
public boolean putByteBuffer2(ByteBuffer bbf_rx) {
|
if(bbf_rx.limit() < REG_Count * 2) {
|
return false;
|
}
|
bbf_rx.position(0);
|
|
for(int k = Total_Load_Count_Sigle;k<timeControls.length;k++) {
|
timeControls[k].putTimeByteBuffer(bbf_rx);
|
}
|
|
bbf_rx.compact();
|
bbf_rx.flip();
|
|
return true;
|
}
|
|
public ByteBuffer getByteBuffer2() {
|
ByteBuffer buffer = ByteBuffer.allocate(REG_Count*2);
|
buffer.order(ByteOrder.BIG_ENDIAN);
|
buffer.position(0);
|
|
for(int k = Total_Load_Count_Sigle;k<timeControls.length;k++) {
|
buffer.put(timeControls[k].getTimeByteBuffer());
|
}
|
|
buffer.flip();
|
return buffer;
|
}
|
|
public class TimeControl{
|
public static final int REG_Count = 14;
|
|
public int time_close_en; //3000 ·Ö·1¶¨Ê±¹Ø¶ÏʹÄÜ 1£ºÊ¹Äܶ¨Ê±¹Ø¶Ï
|
public int time_close_year; //3001 ·Ö·1¹Ø¶Ïʱ¼ä¡ªÄê 0~100£¬Àý£º2024Ä꣬2024-2000=24
|
public int time_close_month; //3002 ·Ö·1¹Ø¶Ïʱ¼ä¡ªÔÂ
|
public int time_close_day; //3003 ·Ö·1¹Ø¶Ïʱ¼ä¡ªÈÕ
|
public int time_close_hour; //3004 ·Ö·1¹Ø¶Ïʱ¼ä¡ªÊ±
|
public int time_close_minute; //3005 ·Ö·1¹Ø¶Ïʱ¼ä¡ª·Ö
|
public int time_close_second; //3006 ·Ö·1¹Ø¶Ïʱ¼ä¡ªÃë
|
|
public int time_repetcomm_en; //3007 ·Ö·1¶¨Ê±¸´Í¨Ê¹ÄÜ
|
public int time_repetcomm_year; //3008 ·Ö·1¸´Í¨Ê±¼ä¡ªÄê 0~100£¬Àý£º2024Ä꣬2024-2000=24
|
public int time_repetcomm_month; //3009 ·Ö·1¸´Í¨Ê±¼ä¡ªÔÂ
|
public int time_repetcomm_day; //3010 ·Ö·1¸´Í¨Ê±¼ä¡ªÈÕ
|
public int time_repetcomm_hour; //3011 ·Ö·1¸´Í¨Ê±¼ä¡ªÊ±
|
public int time_repetcomm_minute; //3012 ·Ö·1¸´Í¨Ê±¼ä¡ª·Ö
|
public int time_repetcomm_second; //3013 ·Ö·1¸´Í¨Ê±¼ä¡ªÃë
|
|
public TimeControl() {
|
|
}
|
|
public boolean putTimeByteBuffer(ByteBuffer bbf_rx) {
|
if(bbf_rx.limit() < REG_Count * 2) {
|
return false;
|
}
|
bbf_rx.position(0);
|
this.time_close_en = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());
|
this.time_close_year = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()) + 2000; //2800 Äê 0~100£¬Àý£º2024Ä꣬2024-2000=24
|
this.time_close_month = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2801 ÔÂ
|
this.time_close_day = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2802 ÈÕ
|
this.time_close_hour = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2803 ʱ
|
this.time_close_minute = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2804 ·Ö
|
this.time_close_second = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2805 Ãë
|
|
this.time_repetcomm_en = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort());
|
this.time_repetcomm_year = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()) + 2000; //2800 Äê 0~100£¬Àý£º2024Ä꣬2024-2000=24
|
this.time_repetcomm_month = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2801 ÔÂ
|
this.time_repetcomm_day = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2802 ÈÕ
|
this.time_repetcomm_hour = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2803 ʱ
|
this.time_repetcomm_minute = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2804 ·Ö
|
this.time_repetcomm_second = FBS9100_ComBase.changeShortToInt(bbf_rx.getShort()); //2805 Ãë
|
|
bbf_rx.compact();
|
bbf_rx.flip();
|
|
|
System.err.println(this);
|
return true;
|
}
|
|
public ByteBuffer getTimeByteBuffer() {
|
ByteBuffer buffer = ByteBuffer.allocate(REG_Count*2);
|
buffer.order(ByteOrder.BIG_ENDIAN);
|
buffer.position(0);
|
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_en));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_year - 2000));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_month));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_day));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_hour));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_minute));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_close_second));
|
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_en));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_year - 2000));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_month));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_day));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_hour));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_minute));
|
buffer.putShort(FBS9100_ComBase.changeIntToShort(this.time_repetcomm_second));
|
|
buffer.flip();
|
return buffer;
|
}
|
|
@Override
|
public String toString() {
|
return "TimeControl [time_close_en=" + time_close_en + ", time_close_year=" + time_close_year
|
+ ", time_close_month=" + time_close_month + ", time_close_day=" + time_close_day
|
+ ", time_close_hour=" + time_close_hour + ", time_close_minute=" + time_close_minute
|
+ ", time_close_second=" + time_close_second + ", time_repetcomm_en=" + time_repetcomm_en
|
+ ", time_repetcomm_year=" + time_repetcomm_year + ", time_repetcomm_month=" + time_repetcomm_month
|
+ ", time_repetcomm_day=" + time_repetcomm_day + ", time_repetcomm_hour=" + time_repetcomm_hour
|
+ ", time_repetcomm_minute=" + time_repetcomm_minute + ", time_repetcomm_second="
|
+ time_repetcomm_second + "]";
|
}
|
|
|
}
|
|
@Override
|
public String toString() {
|
return "Power_TimeControl [timeControls=" + Arrays.toString(timeControls) + "]";
|
}
|
|
|
}
|