Add functions to merge JSONs more easily for EC
The end-cap powerboards have some special features:
- R4/R5 powerboards carry two HVMuxes
- R3 powerboards carry two AMACs (and are basically two barrel Pbs)
This necessitates to run some tests for two HVMuxes / AMACs, depending on the PB type. However, as the results of these tests are for different components of the same powerboard, it makes sense to merge the results of the two tests. To disentangle the two HVMuxes / AMACs, test results should remain unique such that one can disentangle the two HVMuxes or AMACs. This is intended to be done by giving the test result entries (which come in a JSON) different names.
As the same test function is ran though for both HVMuxes / AMACs, some JSON modification functions are needed to give the test result entries unique names. This is what this MR tackles. It does:
- small modifications to
mergeResult
: accounting for cases where there is nopassed
in the JSON and whenTIMESTART
should be taken from the original JSON, rather than being overwritten by the second one - add
findAndReplace
: replaces all instances of a string in another string - add
renameKeyCompContaining
: rename all keys in a JSON by finding and replacing a substring of the key by another string - add
renameKeyAddToEnd
: rename all keys in a JSON by adding a string to the end - add
accountJSONForHVMuxN
: a helper function dedicated to the HVMux case, where the replacements are carried out as shown in the function definition
Tagging @kkrizka
Edited by Ben Bruers