ThingWorx Edge .NET SDK > ThingWorx Edge .NET SDK Reference > Duty Cycle Modulation in the .NET SDK
Duty Cycle Modulation in the .NET SDK
Duty Cycle Modulation is the ability for an SDK application to regulate the amount of time that it is connected to the ThingWorx platform. Periodically, the application checks to see if it is above or below its threshold for connections (a percentage), and connects to or disconnects from the ThingWorx platform accordingly. Duty Cycle Modulation is useful when conservation of power and resources is important.
When a disconnect is initiated, pending requests are not terminated. The application waits for pending requests to finish.
The ClientConfigurator provides properties that support forcing a connection to be established for multiple operation (methods):
Invoking a service (forceConnectOnInvokeService)
Reading a property value (forceConnectOnReadProperty)
Writing a value to a property (forceConnectOnWriteProperty)
Generating an event (forceConnectOnFireEvent)
Duty Cycle Modulation has two parameters that you can set in the client:
1. DutyCycleInfo.Period specifies the length of the duty cycle, in milliseconds. A value of 0 (the default value) means the connections always stays alive. It is recommended that this value be greater than 10 seconds (10000 ms) at a minimum.
2. DutyCycleInfo.DutyCycle specifies the percentage of time in the duty cycle period to maintain a connection to ThingWorx platform. The default value is 100 percent, which means that the connection always stays alive.
A Period of 400 seconds (400000 ms) and a DutyCycle of 40 percent results in the client application being connected to ThingWorx platform for the first 160 seconds of each 400 second duty cycle period (0.4 * 400 = 160). At the end of a duty cycle period, the percentage is checked again to determine how long to keep the connection alive for the next period.