|
NetBurner 3.5.6
PDF Version |
This example demonstrates how to create JSON configuration objects (data or structures) in a "detached" mode, meaning they do not appear in the web page configuration screen, nor are they saved, but are exposed via individual web pages. In Detached mode they are created at boot time and can be modified and used by the application.
The example will:
For example, if your device IP address is 10.1.1.10, opening a web browser and typing "10.1.1.10/set.json" will display that object and it's data:
This NetBurner application demonstrates how to create JSON configuration objects in "detached" mode. In detached mode, configuration objects are created at boot time and can be modified and used by the application, but they do not appear in the Configuration Server web interface and may or may not be saved to persistent storage depending on the application requirements. However, they can, and usually are, used by individual web pages.
Base class for temperature-related configuration:
MaxTemp: Maximum temperature (integer, default: 100)SetTemp: Set temperature (integer, default: 30)MinTemp: Minimum temperature (integer, default: 10)Extends TempRange with additional thermostat-specific settings:
Active: Enable/disable thermostat (boolean, default: true)Location: Physical location (string, default: "Warehouse 1")TempScale: Temperature scale chooser (Fahrenheit/Celsius/Kelvin, default: Fahrenheit)PID controller configuration:
P: Proportional term (double, default: 1.0)I: Integral term (double, default: 0.0001)D: Differential term (double, default: 0.0)Container for PID control settings:
Hset: Horizontal PID settingsVset: Vertical PID settingsrev: Settings revision number (integer, default: 0)The application supports two modes controlled by the DETACHED_MODE preprocessor definition:
detached parameterappdata parentThe application exposes three JSON endpoints:
<device_ip>/set.json - Displays the ControlSet object<device_ip>/thermo.json - Displays the Thermostat object <device_ip>/anint.json - Displays a simple integer configurationAccessing <device_ip>/set.json displays:
config_objHtmlConfigExposer to make configuration objects accessible via HTTPConfigEndMarker must be placed after all configuration members in each class