Create the Digital Twin State Object

Define a class that represents a state object for the real-time digital twin model. This class should reflect the state and behavior of the data source that the application needs to track as it processes messages; it extends the DigitalTwinBase abstract class. Note that each instance of a state object is created when the first incoming message arrives from its corresponding data source.

This code represents a thermostat. The digital twin maintains the state of the temperature of a room.

// RealTimeThermostat.java

public class RealTimeThermostat extends DigitalTwinBase {
        int _temperature;
        public RealTimeThermostat(){_temperature = 68;}
        public RealTimeThermostat(int startingTemperature) {
                _temperature = startingTemperature;
        }
        public void incrementTemperature(int tempChange) {
                _temperature += tempChange;
        }
        public int getTemperature() {
                return _temperature;
        }
}