Beispiel #1
0
  // Performs the logic for the steam sensor, occurs every scan cycle
  public void scanDevice() throws Exception {

    // Update the subscribed properties and events to send any updates to Thingworx
    // Without calling these methods, the property and event updates will not be sent
    // The numbers are timeouts in milliseconds.
    super.updateSubscribedProperties(15000);
    super.updateSubscribedEvents(60000);
  }
Beispiel #2
0
 // The processScanRequest is called by the SteamSensorClient every scan cycle
 @Override
 public void processScanRequest() throws Exception {
   // Be sure to call the base classes scan request
   super.processScanRequest();
   // Execute the code for this simulation every scan
   this.scanDevice();
 }
Beispiel #3
0
  public XerosWasherThing(
      String name, String description, String identifier, ConnectedThingClient client) {
    super(name, description, identifier, client);

    // Data Shape definition that is used for end of cycle data

    FieldDefinitionCollection sensorFields = new FieldDefinitionCollection();

    sensorFields.addFieldDefinition(
        new FieldDefinition(XerosWasherThing.SENSORID, BaseTypes.STRING));
    sensorFields.addFieldDefinition(new FieldDefinition(XerosWasherThing.TIME, BaseTypes.DATETIME));
    sensorFields.addFieldDefinition(
        new FieldDefinition(XerosWasherThing.DURATION, BaseTypes.NUMBER));
    defineDataShapeDefinition("SensorData", sensorFields);

    FieldDefinitionCollection cycleFields = new FieldDefinitionCollection();
    cycleFields.addFieldDefinition(
        new FieldDefinition(XerosWasherThing.WM1_LIFETIME, BaseTypes.NUMBER));
    cycleFields.addFieldDefinition(new FieldDefinition(XerosWasherThing.WM1_DAY, BaseTypes.NUMBER));
    cycleFields.addFieldDefinition(
        new FieldDefinition(XerosWasherThing.WM1_CYCLE, BaseTypes.NUMBER));
    cycleFields.addFieldDefinition(
        new FieldDefinition(XerosWasherThing.WM2_LIFETIME, BaseTypes.NUMBER));
    cycleFields.addFieldDefinition(new FieldDefinition(XerosWasherThing.WM2_DAY, BaseTypes.NUMBER));
    cycleFields.addFieldDefinition(
        new FieldDefinition(XerosWasherThing.WM2_CYCLE, BaseTypes.NUMBER));
    FieldDefinition sensorDataField =
        new FieldDefinition(XerosWasherThing.SENSOR_DATA, BaseTypes.INFOTABLE);

    sensorDataField.setLocalDataShape(this.getDataShapeDefinition("SensorData"));
    cycleFields.addFieldDefinition(sensorDataField);

    defineDataShapeDefinition("CycleComplete", cycleFields);

    // Populate the thing shape with the properties, services, and events that are annotated in this
    // code
    super.initializeFromAnnotations();
  }
Beispiel #4
0
 public void sendCycleCompleteEvent() throws Exception {
   System.out.println(this.getName() + " send CycleComplete Event to server");
   super.queueEvent("CycleEvent", DateTime.now(), this.eventInProgress);
   super.updateSubscribedEvents(60000);
 }
Beispiel #5
0
 // From the VirtualThing class
 // This method will get called when a connect or reconnect happens
 // Need to send the values when this happens
 // This is more important for a solution that does not send its properties on a regular basis
 public void synchronizeState() {
   // Be sure to call the base class
   super.synchronizeState();
   // Send the property values to Thingworx when a synchronization is required
   super.syncProperties();
 }