diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index ca16108a..c3973527 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -41,6 +41,7 @@ "general_btn_rename" : "Rename", "general_btn_continue" : "Continue", "general_btn_save" : "Save", + "general_btn_saverestart" : "Save and restart", "general_btn_saveandreload" : "Save and reload", "general_btn_restarthyperion" : "Restart Hyperion", "general_btn_off" : "Off", @@ -472,6 +473,7 @@ "edt_dev_spec_cid_title" : "CID", "edt_dev_spec_LBap102Mode_title" : "LightBerry APA102 Mode", "edt_dev_spec_universe_title" : "Universe", + "edt_dev_spec_chanperfixture_title" : "Channels per Fixture", "edt_dev_spec_whiteLedAlgor_title" : "White LED algorithm", "edt_dev_spec_useRgbwProtocol_title" : "Use RGBW protocol", "edt_dev_spec_maximumLedCount_title" : "Maximum LED count", diff --git a/config/hyperion.config.json.default b/config/hyperion.config.json.default index 32c2be8c..1d93ec18 100644 --- a/config/hyperion.config.json.default +++ b/config/hyperion.config.json.default @@ -15,10 +15,9 @@ "type" : "file", "hardwareLedCount" : 1, "output" : "/dev/null", - "rate" : 1000000, "colorOrder" : "rgb", - "latchTime" : 1, - "rewriteTime": 5000 + "latchTime" : 0, + "rewriteTime": 0 }, "color" : @@ -212,7 +211,6 @@ "pblv" : 100, "pbrh" : 100, "pbrv" : 100 - }, "matrix": diff --git a/include/utils/jsonschema/QJsonSchemaChecker.h b/include/utils/jsonschema/QJsonSchemaChecker.h index 57191b67..d7fa5cbf 100644 --- a/include/utils/jsonschema/QJsonSchemaChecker.h +++ b/include/utils/jsonschema/QJsonSchemaChecker.h @@ -97,6 +97,16 @@ private: /// void checkProperties(const QJsonObject & value, const QJsonObject & schema); + /// + /// Checks whether certain properties of a JSON object exist under certain dependencies and are the same. + /// If this is not the case _error is set to true and an error-message is added + /// to the message-queue. + /// + /// @param[in] value The given json-object + /// @param[in] schema The schema of the json-object + /// + void checkDependencies(const QJsonObject & value, const QJsonObject & schema); + /// /// Verifies the additional configured properties of an json-object. If this is not the case /// _error is set to true and an error-message is added to the message-queue. diff --git a/libsrc/hyperion/schema/schema-device.json b/libsrc/hyperion/schema/schema-device.json index 9785f3d2..571280ae 100644 --- a/libsrc/hyperion/schema/schema-device.json +++ b/libsrc/hyperion/schema/schema-device.json @@ -2,7 +2,7 @@ "type" : "object", "title" : "edt_dev_general_heading_title", "required" : true, - "defaultProperties": ["hardwareLedCount","colorOrder","rewriteTime"], + "defaultProperties": ["hardwareLedCount", "colorOrder"], "properties" : { "type" : @@ -29,15 +29,20 @@ "enum_titles" : ["edt_conf_enum_rgb", "edt_conf_enum_bgr", "edt_conf_enum_rbg", "edt_conf_enum_brg", "edt_conf_enum_gbr", "edt_conf_enum_grb"] }, "propertyOrder" : 3 - }, - "rewriteTime": { - "type": "integer", - "title":"edt_dev_general_rewriteTime_title", - "default": 1000, - "append" : "edt_append_ms", - "minimum": 0, - "access" : "expert", - "propertyOrder" : 4 + } + }, + "dependencies" : + { + "rewriteTime" : + { + "properties" : + { + "type" : + { + "enum" : ["file", "apa102", "apa104", "ws2801", "lpd6803", "lpd8806", "p9813", "sk6812spi", "sk6822spi", "ws2812spi","ws281x", "piblaster", "adalight", "dmx", "atmo", "hyperionusbasp", "lightpack", "multilightpack", "paintpack", "rawhid", "sedu", "tpm2", "karate"] + } + }, + "additionalProperties" : true } }, "additionalProperties" : true diff --git a/libsrc/leddevice/dev_spi/ProviderSpi.cpp b/libsrc/leddevice/dev_spi/ProviderSpi.cpp index 588c8ddd..d4082bf9 100644 --- a/libsrc/leddevice/dev_spi/ProviderSpi.cpp +++ b/libsrc/leddevice/dev_spi/ProviderSpi.cpp @@ -52,8 +52,8 @@ int ProviderSpi::open() if ( init(_devConfig) ) { - Debug(_log, "_baudRate_Hz %d, _latchTime_ns %d", _baudRate_Hz, _latchTime_ms); - Debug(_log, "_spiDataInvert %d, _spiMode %d", _spiDataInvert, _spiMode); + Debug(_log, "_baudRate_Hz [%d], _latchTime_ms [%d]", _baudRate_Hz, _latchTime_ms); + Debug(_log, "_spiDataInvert [%d], _spiMode [%d]", _spiDataInvert, _spiMode); const int bitsPerWord = 8; diff --git a/libsrc/leddevice/schemas/schema-adalight.json b/libsrc/leddevice/schemas/schema-adalight.json index d555a9d3..60e99449 100644 --- a/libsrc/leddevice/schemas/schema-adalight.json +++ b/libsrc/leddevice/schemas/schema-adalight.json @@ -30,13 +30,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 15, + "default": 30, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 5 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-apa102.json b/libsrc/leddevice/schemas/schema-apa102.json index 0fca87bf..eba9a708 100644 --- a/libsrc/leddevice/schemas/schema-apa102.json +++ b/libsrc/leddevice/schemas/schema-apa102.json @@ -24,13 +24,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-apa104.json b/libsrc/leddevice/schemas/schema-apa104.json index 0478669d..fa409884 100644 --- a/libsrc/leddevice/schemas/schema-apa104.json +++ b/libsrc/leddevice/schemas/schema-apa104.json @@ -23,13 +23,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-artnet.json b/libsrc/leddevice/schemas/schema-artnet.json index e2557dab..fce78dae 100644 --- a/libsrc/leddevice/schemas/schema-artnet.json +++ b/libsrc/leddevice/schemas/schema-artnet.json @@ -11,8 +11,8 @@ "type": "integer", "title":"edt_dev_spec_port_title", "default": 6454, - "minimum" : 0, - "maximum" : 65535, + "minimum": 0, + "maximum": 65535, "propertyOrder" : 2 }, "universe": { @@ -30,9 +30,9 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, - "append" : "edt_append_ms", - "minimum": 1, + "default": 0, + "append": "edt_append_ms", + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 5 diff --git a/libsrc/leddevice/schemas/schema-atmo.json b/libsrc/leddevice/schemas/schema-atmo.json index b722c7ad..c5f75fc3 100644 --- a/libsrc/leddevice/schemas/schema-atmo.json +++ b/libsrc/leddevice/schemas/schema-atmo.json @@ -26,10 +26,19 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 } }, "additionalProperties": true diff --git a/libsrc/leddevice/schemas/schema-atmoorb.json b/libsrc/leddevice/schemas/schema-atmoorb.json index 34b9cf0f..ba0cb012 100644 --- a/libsrc/leddevice/schemas/schema-atmoorb.json +++ b/libsrc/leddevice/schemas/schema-atmoorb.json @@ -37,13 +37,13 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 6 - } + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-dmx.json b/libsrc/leddevice/schemas/schema-dmx.json index f7066995..febf4edc 100644 --- a/libsrc/leddevice/schemas/schema-dmx.json +++ b/libsrc/leddevice/schemas/schema-dmx.json @@ -25,11 +25,20 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-e131.json b/libsrc/leddevice/schemas/schema-e131.json index 523b665f..fa0dc204 100644 --- a/libsrc/leddevice/schemas/schema-e131.json +++ b/libsrc/leddevice/schemas/schema-e131.json @@ -24,9 +24,9 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 diff --git a/libsrc/leddevice/schemas/schema-fadecandy.json b/libsrc/leddevice/schemas/schema-fadecandy.json index e159d1f5..0a491f2f 100644 --- a/libsrc/leddevice/schemas/schema-fadecandy.json +++ b/libsrc/leddevice/schemas/schema-fadecandy.json @@ -17,9 +17,9 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 3 diff --git a/libsrc/leddevice/schemas/schema-file.json b/libsrc/leddevice/schemas/schema-file.json index 7f8a069d..3962bd22 100644 --- a/libsrc/leddevice/schemas/schema-file.json +++ b/libsrc/leddevice/schemas/schema-file.json @@ -8,6 +8,13 @@ "default" : "/dev/null", "propertyOrder" : 1 }, + "printTimeStamp": { + "type": "boolean", + "title":"edt_dev_spec_printTimeStamp_title", + "default": false, + "access" : "advanced", + "propertyOrder" : 2 + }, "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", @@ -16,15 +23,17 @@ "minimum": 0, "maximum": 1000, "access" : "expert", - "propertyOrder" : 2 - }, - "printTimeStamp": { - "type": "boolean", - "title":"edt_dev_spec_printTimeStamp_title", - "default": false, - "access" : "expert", "propertyOrder" : 3 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 4 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-h801.json b/libsrc/leddevice/schemas/schema-h801.json index 5af7ed15..c06765a1 100644 --- a/libsrc/leddevice/schemas/schema-h801.json +++ b/libsrc/leddevice/schemas/schema-h801.json @@ -28,7 +28,7 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 diff --git a/libsrc/leddevice/schemas/schema-hyperionusbasp.json b/libsrc/leddevice/schemas/schema-hyperionusbasp.json index 531764ba..fdf30a74 100644 --- a/libsrc/leddevice/schemas/schema-hyperionusbasp.json +++ b/libsrc/leddevice/schemas/schema-hyperionusbasp.json @@ -7,17 +7,26 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 1 }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 2 + }, "ledType": { "type": "string", "title":"edt_dev_spec_ledType_title", "enum" : ["ws2801","ws2812"], "default": "ws2801", - "propertyOrder" : 2 + "propertyOrder" : 3 } }, "additionalProperties": true diff --git a/libsrc/leddevice/schemas/schema-karate.json b/libsrc/leddevice/schemas/schema-karate.json index eff50244..f394de8e 100644 --- a/libsrc/leddevice/schemas/schema-karate.json +++ b/libsrc/leddevice/schemas/schema-karate.json @@ -26,11 +26,20 @@ "title":"edt_dev_spec_latchtime_title", "default": 15, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-lightpack.json b/libsrc/leddevice/schemas/schema-lightpack.json index 1fc9c24e..7260a63e 100644 --- a/libsrc/leddevice/schemas/schema-lightpack.json +++ b/libsrc/leddevice/schemas/schema-lightpack.json @@ -12,11 +12,20 @@ "title":"edt_dev_spec_latchtime_title", "default": 11, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 2 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 3 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-lpd6803.json b/libsrc/leddevice/schemas/schema-lpd6803.json index e0d4a038..28c31866 100644 --- a/libsrc/leddevice/schemas/schema-lpd6803.json +++ b/libsrc/leddevice/schemas/schema-lpd6803.json @@ -23,12 +23,21 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 } }, "additionalProperties": true diff --git a/libsrc/leddevice/schemas/schema-lpd8806.json b/libsrc/leddevice/schemas/schema-lpd8806.json index e0d4a038..bbe5b474 100644 --- a/libsrc/leddevice/schemas/schema-lpd8806.json +++ b/libsrc/leddevice/schemas/schema-lpd8806.json @@ -23,13 +23,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-multilightpack.json b/libsrc/leddevice/schemas/schema-multilightpack.json index 6a3d31dc..babbb985 100644 --- a/libsrc/leddevice/schemas/schema-multilightpack.json +++ b/libsrc/leddevice/schemas/schema-multilightpack.json @@ -7,11 +7,20 @@ "title":"edt_dev_spec_latchtime_title", "default": 11, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 1 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 2 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-p9813.json b/libsrc/leddevice/schemas/schema-p9813.json index e0d4a038..a2450b5a 100644 --- a/libsrc/leddevice/schemas/schema-p9813.json +++ b/libsrc/leddevice/schemas/schema-p9813.json @@ -23,13 +23,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-paintpack.json b/libsrc/leddevice/schemas/schema-paintpack.json index 28fee6f5..2d332b58 100644 --- a/libsrc/leddevice/schemas/schema-paintpack.json +++ b/libsrc/leddevice/schemas/schema-paintpack.json @@ -23,13 +23,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-piblaster.json b/libsrc/leddevice/schemas/schema-piblaster.json index d935e460..cf6c634b 100644 --- a/libsrc/leddevice/schemas/schema-piblaster.json +++ b/libsrc/leddevice/schemas/schema-piblaster.json @@ -13,15 +13,24 @@ "title":"edt_dev_spec_latchtime_title", "default": 5, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 2 }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 3 + }, "gpiomap": { "type": "array", "title":"edt_dev_spec_gpioMap_title", - "propertyOrder" : 2, + "propertyOrder" : 3, "minimum" : 1, "maximum" : 27, "items" : { @@ -56,7 +65,7 @@ } } }, - "propertyOrder" : 3 + "propertyOrder" : 4 } }, "additionalProperties": true diff --git a/libsrc/leddevice/schemas/schema-rawhid.json b/libsrc/leddevice/schemas/schema-rawhid.json index 144eaa22..f104a626 100644 --- a/libsrc/leddevice/schemas/schema-rawhid.json +++ b/libsrc/leddevice/schemas/schema-rawhid.json @@ -25,11 +25,20 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-sedu.json b/libsrc/leddevice/schemas/schema-sedu.json index d84f27d4..0f398753 100644 --- a/libsrc/leddevice/schemas/schema-sedu.json +++ b/libsrc/leddevice/schemas/schema-sedu.json @@ -25,11 +25,20 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-sk6812spi.json b/libsrc/leddevice/schemas/schema-sk6812spi.json index b8c02c29..229181d4 100644 --- a/libsrc/leddevice/schemas/schema-sk6812spi.json +++ b/libsrc/leddevice/schemas/schema-sk6812spi.json @@ -33,13 +33,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 5 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 6 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-sk6822spi.json b/libsrc/leddevice/schemas/schema-sk6822spi.json index 870f566d..6116937e 100644 --- a/libsrc/leddevice/schemas/schema-sk6822spi.json +++ b/libsrc/leddevice/schemas/schema-sk6822spi.json @@ -22,14 +22,23 @@ }, "latchTime": { "type": "integer", - "title":"edt_dev_general_latchTime_title", - "default": 1, + "title":"edt_dev_spec_latchtime_title", + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", - "propertyOrder" : 4 - } + "propertyOrder" : 5 + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-tinkerforge.json b/libsrc/leddevice/schemas/schema-tinkerforge.json index fa572524..cc13a53d 100644 --- a/libsrc/leddevice/schemas/schema-tinkerforge.json +++ b/libsrc/leddevice/schemas/schema-tinkerforge.json @@ -30,9 +30,9 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 5 diff --git a/libsrc/leddevice/schemas/schema-tpm2.json b/libsrc/leddevice/schemas/schema-tpm2.json index d84f27d4..5130e85a 100644 --- a/libsrc/leddevice/schemas/schema-tpm2.json +++ b/libsrc/leddevice/schemas/schema-tpm2.json @@ -25,11 +25,19 @@ "title":"edt_dev_spec_latchtime_title", "default": 10, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } - }, + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-tpm2net.json b/libsrc/leddevice/schemas/schema-tpm2net.json index 2d3eb258..4d87bac2 100644 --- a/libsrc/leddevice/schemas/schema-tpm2net.json +++ b/libsrc/leddevice/schemas/schema-tpm2net.json @@ -15,29 +15,22 @@ "default" : 50200, "propertyOrder" : 2 }, - "latchtime": { - "type": "integer", - "title":"edt_dev_spec_latchtime_title", - "default": 104000, - "append" : "edt_append_s", - "propertyOrder" : 3 - }, "max-packet": { "type": "integer", "title":"edt_dev_spec_maxPacket_title", "minimum" : 0, "default" : 170, - "propertyOrder" : 4 + "propertyOrder" : 3 }, "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", - "propertyOrder" : 5 + "propertyOrder" : 4 } }, "additionalProperties": true diff --git a/libsrc/leddevice/schemas/schema-udpraw.json b/libsrc/leddevice/schemas/schema-udpraw.json index 7955603c..bd9e893f 100644 --- a/libsrc/leddevice/schemas/schema-udpraw.json +++ b/libsrc/leddevice/schemas/schema-udpraw.json @@ -18,9 +18,9 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 3 diff --git a/libsrc/leddevice/schemas/schema-ws2801.json b/libsrc/leddevice/schemas/schema-ws2801.json index 63c606d8..fca1dd1d 100644 --- a/libsrc/leddevice/schemas/schema-ws2801.json +++ b/libsrc/leddevice/schemas/schema-ws2801.json @@ -14,29 +14,31 @@ "default": 1000000, "propertyOrder" : 2 }, - "latchtime": { - "type": "integer", - "title":"edt_dev_spec_latchtime_title", - "default": 500000, - "append" : "ns", - "propertyOrder" : 3 - }, "invert": { "type": "boolean", "title":"edt_dev_spec_invert_title", "default": false, - "propertyOrder" : 4 + "propertyOrder" : 3 }, "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", + "propertyOrder" : 4 + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", "propertyOrder" : 5 - } + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-ws2812spi.json b/libsrc/leddevice/schemas/schema-ws2812spi.json index 42c2bbed..2949565f 100644 --- a/libsrc/leddevice/schemas/schema-ws2812spi.json +++ b/libsrc/leddevice/schemas/schema-ws2812spi.json @@ -23,13 +23,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 4 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 5 + } }, "additionalProperties": true } diff --git a/libsrc/leddevice/schemas/schema-ws281x.json b/libsrc/leddevice/schemas/schema-ws281x.json index da5ee24a..46718d23 100644 --- a/libsrc/leddevice/schemas/schema-ws281x.json +++ b/libsrc/leddevice/schemas/schema-ws281x.json @@ -53,13 +53,22 @@ "latchTime": { "type": "integer", "title":"edt_dev_spec_latchtime_title", - "default": 1, + "default": 0, "append" : "edt_append_ms", - "minimum": 1, + "minimum": 0, "maximum": 1000, "access" : "expert", "propertyOrder" : 8 - } + }, + "rewriteTime": { + "type": "integer", + "title":"edt_dev_general_rewriteTime_title", + "default": 1000, + "append" : "edt_append_ms", + "minimum": 0, + "access" : "expert", + "propertyOrder" : 9 + } }, "additionalProperties": true } diff --git a/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp b/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp index e6b11a73..1ee0e6d7 100644 --- a/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp +++ b/libsrc/utils/jsonschema/QJsonSchemaChecker.cpp @@ -85,6 +85,17 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s continue; } } + else if (attribute == "dependencies") + { + if (value.isObject()) + checkDependencies(value.toObject(), attributeValue.toObject()); + else + { + _schemaError = true; + setMessage("dependencies attribute is only valid for objects"); + continue; + } + } else if (attribute == "additionalProperties") { if (value.isObject()) @@ -239,6 +250,62 @@ void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonO } } +void QJsonSchemaChecker::checkDependencies(const QJsonObject & value, const QJsonObject & schema) +{ + for (QJsonObject::const_iterator i = schema.begin(); i != schema.end(); ++i) + { + QString property = i.key(); + const QJsonValue & propertyValue = *i; + + if (propertyValue.toObject().contains("properties")) + { + _currentPath.append("." + property); + + const QJsonObject & dependencies = propertyValue.toObject()["properties"].toObject(); + + bool valid = false; + for (QJsonObject::const_iterator d = dependencies.begin(); d != dependencies.end(); ++d) + { + QString dependency = d.key(); + const QJsonValue & dependencyValue = *d; + + if (dependencyValue.toObject()["enum"].isArray()) + { + QJsonArray jArray = dependencyValue.toObject()["enum"].toArray(); + for(int a = 0; a < jArray.size(); ++a) + { + if (value[dependency] == jArray[a]) + { + valid = true; + break; + } + else + valid = false; + } + } + else + valid = (value[dependency] == dependencyValue.toObject()["enum"]); + } + + if (value.contains(property) && !valid) + { + _error = true; + + if (_correct == "remove") + { + QJsonUtils::modify(_autoCorrected, _currentPath); + setMessage("Removed property: "+property); + } + + if (_correct == "") + setMessage("Property not required"); + } + + _currentPath.removeLast(); + } + } +} + void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, const QJsonValue & schema, const QStringList & ignoredProperties) { for (QJsonObject::const_iterator i = value.begin(); i != value.end(); ++i)