| | |
| | | import com.ruoyi.other.emind.mapper.EmindStationMapper; |
| | | import com.ruoyi.other.emind.mapper.EmindStorageDashboardMapper; |
| | | import com.ruoyi.other.emind.service.EmindEnergyChainDetailService; |
| | | import com.ruoyi.other.udan.model.EmsState; |
| | | import com.ruoyi.other.udan.model.BatteryStackState; |
| | | import com.ruoyi.other.udan.model.ElectricMeterState; |
| | | import com.ruoyi.other.udan.model.PcsState; |
| | | import com.ruoyi.other.udan.model.PowerMeterState; |
| | | import com.ruoyi.other.udan.model.TmsState; |
| | | import com.ruoyi.other.udan.model.UdanEmsDeviceState; |
| | | import com.ruoyi.other.udan.model.*; |
| | | import com.ruoyi.other.udan.util.UdanEmsKafkaUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | else if (type == 2 && field == 8) state.setPowerMeterState(parsePowerMeter(in.readBytes().toByteArray())); |
| | | else if (type == 2 && field == 14 && state.getTmsState() == null) { |
| | | state.setTmsState(parseTms(in.readBytes().toByteArray())); |
| | | } |
| | | else if (type == 2 && field == 15 && state.getPeripheralDeviceState() == null) { |
| | | state.setPeripheralDeviceState(parsePeripheral(in.readBytes().toByteArray())); |
| | | } |
| | | else skip(in, type); |
| | | }); |
| | |
| | | return value; |
| | | } |
| | | |
| | | private PeripheralDeviceState parsePeripheral(byte[] bytes) throws IOException { |
| | | PeripheralDeviceState value = new PeripheralDeviceState(); |
| | | read(bytes, (field, type, input) -> { |
| | | switch (field) { |
| | | case 1: value.setDeviceId(str(input, type)); break; |
| | | case 2: value.setDiState(u32(input, type)); break; |
| | | default: skip(input, type); |
| | | } |
| | | }); |
| | | value.convert(); |
| | | return value; |
| | | } |
| | | |
| | | private void read(byte[] bytes, Reader reader) throws IOException { |
| | | CodedInputStream input = CodedInputStream.newInstance(bytes == null ? new byte[0] : bytes); |
| | | while (!input.isAtEnd()) { |
| | |
| | | private interface Reader { |
| | | void read(int field, int type, CodedInputStream input) throws IOException; |
| | | } |
| | | |
| | | } |