| | |
| | | } |
| | | Integer type = 0; |
| | | this.deviceType = hex.substring(0, 4); |
| | | if(this.deviceType.equals(DeviceType.SENSOR_V1.getType())) { |
| | | if (this.deviceType.equals(DeviceType.SENSOR_V1.getType())) { |
| | | type = 1; |
| | | } |
| | | this.moduleWarmUpStatusFlag = hex.substring(4, 6); |
| | | this.temperature = Double.parseDouble( |
| | | parseVal(hex,6,8) |
| | | parseVal(hex, 6, 8) |
| | | + "." |
| | | + parseVal(hex,8,10) |
| | | + parseVal(hex, 8, 10) |
| | | ); |
| | | this.humidity = Double.parseDouble( |
| | | parseVal(hex,10,12) |
| | | parseVal(hex, 10, 12) |
| | | + "." |
| | | + parseVal(hex,12,14) |
| | | + parseVal(hex, 12, 14) |
| | | ); |
| | | this.windSpeed = parseVal(hex,14,18) * .1; |
| | | this.windDirection = parseVal(hex,18,22) * .1; |
| | | this.pressure = parseVal(hex,22,26); |
| | | this.lightIntensity = parseVal(hex,26,32); |
| | | this.noise = parseVal(hex,32, 36); |
| | | this.pm25 = parseVal(hex,36, 40); |
| | | this.pm10 = parseVal(hex,40,44); |
| | | this.tsp = parseVal(hex,44,48); |
| | | this.windSpeed = parseVal(hex, 14, 18) * .1; |
| | | this.windDirection = parseVal(hex, 18, 22) * .1; |
| | | this.pressure = parseVal(hex, 22, 26); |
| | | this.lightIntensity = parseVal(hex, 26, 32); |
| | | this.noise = parseVal(hex, 32, 36); |
| | | this.pm25 = parseVal(hex, 36, 40); |
| | | this.pm10 = parseVal(hex, 40, 44); |
| | | this.tsp = parseVal(hex, 44, 48); |
| | | |
| | | /** |
| | | * 以下区分版本 |
| | | */ |
| | | if(type.equals(1)) { |
| | | this.ech2o = parseVal(hex,48, 52); |
| | | this.tvoc = parseVal(hex,52, 56); |
| | | this.co2 = parseVal(hex,56, 60); |
| | | if (type.equals(1)) { |
| | | this.ech2o = parseVal(hex, 48, 52); |
| | | this.tvoc = parseVal(hex, 52, 56); |
| | | this.co2 = parseVal(hex, 56, 60); |
| | | } else { |
| | | this.so2 = parseVal(hex,48, 52); |
| | | this.ech2o = parseVal(hex,48, 52); |
| | | this.tvoc = parseVal(hex,52, 56); |
| | | this.no2 = parseVal(hex,52, 56); |
| | | this.co = parseVal(hex,56, 60); |
| | | this.co2 = parseVal(hex,56, 60); |
| | | this.so2 = parseVal(hex, 48, 52); |
| | | this.ech2o = parseVal(hex, 48, 52); |
| | | this.tvoc = parseVal(hex, 52, 56); |
| | | this.no2 = parseVal(hex, 52, 56); |
| | | this.co = parseVal(hex, 56, 60); |
| | | this.co2 = parseVal(hex, 56, 60); |
| | | } |
| | | |
| | | this.o3 = parseVal(hex,60, 62); |
| | | this.fluoride = parseVal(hex,62, 64); |
| | | this.o3 = parseVal(hex, 60, 62); |
| | | this.fluoride = parseVal(hex, 62, 64); |
| | | |
| | | return this; |
| | | } |
| | | |
| | | private Integer parseVal (String frame, int start, int end) { |
| | | return Integer.parseInt(frame.substring(start,end),16); |
| | | private Integer parseVal(String frame, int start, int end) { |
| | | return Integer.parseInt(frame.substring(start, end), 16); |
| | | } |
| | | } |
| | | |