| | |
| | | |
| | | import com.dayu.recharge.tools.HexUtil; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * Copyright (C), 2023, |
| | | * Author: zuo |
| | |
| | | * 为方便现场更换设备时重新注册的问题,配置设备信息卡,首先刷卡,把原设备的注册号和ID号读到卡内, |
| | | * 同时卡状态则00修改为FF,再新设备上刷此卡时,注册号和ID号自动写到控制器内,可以直接刷卡使用 |
| | | */ |
| | | public class ConfigurationPowerCard { |
| | | public class ConfigurationPowerCard implements Serializable { |
| | | |
| | | |
| | | public String cardType = "BD";//卡类型 |
| | |
| | | |
| | | public String power;//功率 |
| | | |
| | | public String getPower() { |
| | | return power; |
| | | } |
| | | |
| | | public void setPower(String power) { |
| | | this.power = power; |
| | | } |
| | | |
| | | public byte[] toByte() { |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | | |
| | | public class Zero extends BaseCard { |
| | | public void toByte() { |
| | | public byte[] toByte() { |
| | | byte[] data = new byte[16]; |
| | | data[0] = HexUtil.hexToByte(cardType); |
| | | byte[] cardDatas = HexUtil.hexToByteArray(cardData); |
| | | for (int i = 0; i < 4; i++) { |
| | | data[i + 1] = cardDatas[i]; |
| | | } |
| | | float floatPower = Float.parseFloat(power); |
| | | int intPower = (int) Math.ceil(floatPower); // 将浮点数向上取整并转换为整数 |
| | | String hexPower = HexUtil.get10to16(intPower); |
| | | byte bytePower = HexUtil.hexToByte(hexPower); |
| | | data[5] = bytePower; |
| | | if (power != null) { |
| | | float floatPower = Float.parseFloat(power); |
| | | int intPower = (int) Math.ceil(floatPower); // 将浮点数向上取整并转换为整数 |
| | | String hexPower = HexUtil.get10to16(intPower); |
| | | byte bytePower = HexUtil.hexToByte(hexPower); |
| | | data[5] = bytePower; |
| | | } |
| | | |
| | | data[15] = getByteSum(data); |
| | | return data; |
| | | } |
| | | |
| | | } |