From 55253b53224b2598b454e561127c23376ff73e2e Mon Sep 17 00:00:00 2001 From: LordGrey <48840279+Lord-Grey@users.noreply.github.com> Date: Tue, 26 May 2020 22:28:36 +0200 Subject: [PATCH] fix: Rewrite-/LatchTime LedDevice definitions (#785) (#799) * Fix Rewrite/Latch Time * dependencies can now be specified in the schema Signed-off-by: Paulchen-Panther * dependencies can now be specified in the schema Signed-off-by: Paulchen-Panther * correct default config Signed-off-by: Paulchen-Panther * dependencies part 2 Signed-off-by: Paulchen-Panther * Update README.md * build: Update Windows to Qt5.15 (#798) * Update compile howto - to qt5.15 - minimal install overhead - sync with vscode and cmake * Update docs with more input gh actions windows: Qt5.15 and msvc2019 * fix: Azure build * feat: Add Trapezoid to LED Layout (#791) * Update schema-ledConfig.json extend schema with corner points (vertcal and horizontal values in percent) * Update conf_leds.html input fields for corner points * Update content_leds.js add corner values and calculation of led rows * Update de.json german title for corners * CHanges 26.12.2019 Correction and PowerOff add * GrabberFix PiCam * VType as QString * Unused variable deletet * Missing new paramneters for GrabberFix * Error json * JSon error by user * Crosscompile SutnikElf frok * Warning unused variable * Revert "Crosscompile SutnikElf frok" This reverts commit 443fe8009021f15b617292868c778499c13282a7. * Fixing a linting error * Adding Grabber Override Names * Adding more Grabber Fix translations * Missed one * remove V4L2 Grabber Fix and Power Button from Dashboard Signed-off-by: Paulchen-Panther * Setting some limits to the trapezoid Co-authored-by: SputnikElf <58911932+SputnikElf@users.noreply.github.com> Co-authored-by: SputnikElf Co-authored-by: Paulchen-Panther * add Hue EntertainmentAPI + Forwarder & other Fixes (#592) * whitespaces + typo fixes * JS / LGTM fixes * SSDP Handler crash fix * MessageForwarder handlePriorityChanges Slave fixes * use aboutToQuit Signal * complete rewriten Hue Entertainment API structure combined Philips Hue and Entertainment API with new MbedTLS based SSL UDP Provider * add required cross-compile submodules * logical rebuild fn: initLeds, setLights + new logs -more detailed checks and error handling inside iniLeds and setLights - logical script procedure before ProviderUdpSSL init - first steps for multiple ProviderUdpSSL usage - better fallback support to old RestAPI, if entertainment api is not supported - just 4 u LordGrey: new log fn for cosmetic config outputs ;) * add OSX CompileHowTo - undo from CrossCompileHowTo * whitespace fixes * lightID toString fix * fix unsigned int E-API + debug output * bugfixes, reworked black signal detection, wizard: - change device config field light-ids from int to string -> real unsigned int fix - add signal detection brightness minimum threshold value 0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection reason: input may not 100% black, like mine - i have a deep dark gray input signal -> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black - wizard optimations, with fallback without entertainment support (beta state) - whitespace fixes * cleanup + minor fixes * change fixed Hue UPD SSL config to _devConfig paras * Hotfix SSL Connection, new light models, wizard: - Fix UPD SSL Connection failed Problems - add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003 - wizard: extend fallback support to classic mode + hints * whitespace, typo fix * uncheck useEntertainmentAPI, if noAPISupport detected + hint * coredump fix -> add _blackLightsTimer nullptr init * code cleanup / remove old debugs + whitespacefixes * add gamut C LCP001, LCP002 * SSL UDP config made more flexible + remove qDebug -> switch to hyerion.ng _log -> replace logCommand with verbose -> code cleanups etc... * extended mbedtls debugging infos * add adjustable ssl timeout settings * error handling * streamdebugger bugfixes * UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix + - verbose option available without dependencies - whitespace fixes * Philips Hue Assistant now recognizes non-original bridges better... + Added note if no clientkey is set when using the entertainment API + User creation (+ clientkey) for non-original bridges can now also be used + Minor changes and bug fixes * CMAKE mbedTLS detection * minor bug fixes + code cleanups * FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true: conf_grabber don't displays other devices, if V4L2 is not available * compile mbedtls via cmake as static lib * remove libmbedtls-dev from compileHowto / scripts * Fix Windows build * Fix windows build (part 2) * removed unnecessary osx x11 include directory path * QTimer Shutdown bugfix * cmake win32 fix + minor bugfixes * cmake debug msg used mbedtls libs * Bugfix: noSignalDetection wasn't switchedOn again if no signal was previously detected * Some code fixes based on alerts from lgtm.com Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> * Update devices allowing rewriteTime * Fix typo * Add missing "general_btn_saverestart" text to en-file Co-authored-by: Paulchen-Panther Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Co-authored-by: brindosch Co-authored-by: Ben Williams Co-authored-by: SputnikElf <58911932+SputnikElf@users.noreply.github.com> Co-authored-by: SputnikElf Co-authored-by: SJunkies <41368976+SJunkies@users.noreply.github.com> --- assets/webconfig/i18n/en.json | 2 + config/hyperion.config.json.default | 6 +- include/utils/jsonschema/QJsonSchemaChecker.h | 10 +++ libsrc/hyperion/schema/schema-device.json | 25 ++++--- libsrc/leddevice/dev_spi/ProviderSpi.cpp | 4 +- libsrc/leddevice/schemas/schema-adalight.json | 15 ++++- libsrc/leddevice/schemas/schema-apa102.json | 15 ++++- libsrc/leddevice/schemas/schema-apa104.json | 15 ++++- libsrc/leddevice/schemas/schema-artnet.json | 10 +-- libsrc/leddevice/schemas/schema-atmo.json | 11 ++- libsrc/leddevice/schemas/schema-atmoorb.json | 6 +- libsrc/leddevice/schemas/schema-dmx.json | 13 +++- libsrc/leddevice/schemas/schema-e131.json | 4 +- .../leddevice/schemas/schema-fadecandy.json | 4 +- libsrc/leddevice/schemas/schema-file.json | 25 ++++--- libsrc/leddevice/schemas/schema-h801.json | 2 +- .../schemas/schema-hyperionusbasp.json | 13 +++- libsrc/leddevice/schemas/schema-karate.json | 13 +++- .../leddevice/schemas/schema-lightpack.json | 13 +++- libsrc/leddevice/schemas/schema-lpd6803.json | 13 +++- libsrc/leddevice/schemas/schema-lpd8806.json | 15 ++++- .../schemas/schema-multilightpack.json | 13 +++- libsrc/leddevice/schemas/schema-p9813.json | 15 ++++- .../leddevice/schemas/schema-paintpack.json | 15 ++++- .../leddevice/schemas/schema-piblaster.json | 15 ++++- libsrc/leddevice/schemas/schema-rawhid.json | 13 +++- libsrc/leddevice/schemas/schema-sedu.json | 13 +++- .../leddevice/schemas/schema-sk6812spi.json | 15 ++++- .../leddevice/schemas/schema-sk6822spi.json | 19 ++++-- .../leddevice/schemas/schema-tinkerforge.json | 4 +- libsrc/leddevice/schemas/schema-tpm2.json | 14 +++- libsrc/leddevice/schemas/schema-tpm2net.json | 15 ++--- libsrc/leddevice/schemas/schema-udpraw.json | 4 +- libsrc/leddevice/schemas/schema-ws2801.json | 24 ++++--- .../leddevice/schemas/schema-ws2812spi.json | 15 ++++- libsrc/leddevice/schemas/schema-ws281x.json | 15 ++++- .../utils/jsonschema/QJsonSchemaChecker.cpp | 67 +++++++++++++++++++ 37 files changed, 392 insertions(+), 118 deletions(-) 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)