Skip to content

Commit

Permalink
If applied, this commit will update the latency log registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
UellingtonDamasceno committed Feb 8, 2024
1 parent d2e155f commit abd3172
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void deliveryComplete(IMqttDeliveryToken imdt) {
MqttMessage deliveredMessage;
try {
deliveredMessage = imdt.getMessage();
if(deliveredMessage.getPayload().length == 0){
if(deliveredMessage == null || deliveredMessage.getPayload().length == 0){
return;
}
String messageContent = new String(deliveredMessage.getPayload());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/device/fot/virtual/model/FoTSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public FoTSensor(String deviceId,
this.flow = false;
this.running = false;
this.random = new Random();
this.lastValue = minValue + random.nextInt() * (maxValue - minValue);
this.lastValue = (minValue <= 0 && maxValue <= 0) ? 0 : random.nextInt(minValue, maxValue);
this.flowThreadName = this.buildFlowThreadName(deviceId, id);
}

Expand Down Expand Up @@ -139,8 +139,8 @@ private Data<Integer> getDataFlow() throws InterruptedException {
}

public Integer getCurrentValue() {
//Integer variation = random.nextInt()* delta * (random.nextBoolean() ? 1 : -1);
//this.lastValue = Math.min(maxValue, Math.max(minValue, lastValue + variation));
Integer variation = delta * (random.nextBoolean() ? 1 : -1);
this.lastValue = Math.min(maxValue, Math.max(minValue, lastValue + variation));
return lastValue;
}

Expand Down

0 comments on commit abd3172

Please sign in to comment.