Skip to main content
1-Visitor
June 22, 2016
Question

with out refresh button how to generate random values

  • June 22, 2016
  • 8 replies
  • 3043 views

Hi

  Actually when I ran the java sdk code the properties values reflect in thing ,i mean generate random values.

in Mashup values generate. But my thing i want to generate the values in Properties through Java Sdk.

8 replies

5-Regular Member
June 22, 2016

Have you considered writing a random number generator function in Java which you can call in the processScanRequest() via a setProperty(), thus every time the scan is performed the function will have a random number to set in the property in the Java SDK.

int temp = <value>;

write getter and setter for temp property and in the processScanRequest() you can call this setter(). Therefore, whenever the updateSubscribedProperties(); is called the temp property should have a new value

Hope this helps.

dcbb1-VisitorAuthor
1-Visitor
June 22, 2016

I am writing like this

public void processScanRequest() throws Exception {

  super.getProperty("CompressionRate");

  super.getProperty("UniversalInput");

  super.getProperty("Inputvolt");

// Be sure to call the base classes scan request

super.processScanRequest();

// Execute the code for this simulation every scan

this.scanDevice();

}

// Performs the logic for the steam sensor, occurs every scan cycle

public  void scanDevice() throws Exception {

double compressionRate = 1+20*Math.random();

double universalInput = 2+20*Math.random();

double inputvolt = 1+20*Math.random();

String currentStatus = "Float";

String equipmentType = "Active";

String controllerType = "Float";

super.setProperty("CompressionRate",compressionRate);

super.setProperty("UniversalInput",universalInput);

super.setProperty("Inputvolt", inputvolt);

super.setProperty("CurrentStatus", currentStatus);

super.setProperty("EquipmentType", equipmentType);

super.setProperty("ControllerType", controllerType);

//System.out.println("@@## came to scanDevice method ");

super.updateSubscribedProperties(15000);

super.updateSubscribedEvents(60000);

}

dcbb1-VisitorAuthor
1-Visitor
June 22, 2016

it is ok,,can you reply me