27#include <nlohmann/json.hpp>
37 auto saveViaOverrideConfigurationLine =
40 const nlohmann::json item_json = { {
"signal_layer_from",
LSET::Name( item.m_SignalLayerFrom ) },
41 {
"signal_layer_to",
LSET::Name( item.m_SignalLayerTo ) },
42 {
"via_layer_from",
LSET::Name( item.m_ViaLayerFrom ) },
43 {
"via_layer_to",
LSET::Name( item.m_ViaLayerTo ) },
44 {
"delay", item.m_Delay } };
46 json_array.push_back( item_json );
49 auto readViaOverrideConfigurationLine = [](
const nlohmann::json& entry )
51 wxString signalLayerFromName = entry[
"signal_layer_from"];
54 wxString signalLayerToName = entry[
"signal_layer_to"];
57 wxString viaLayerFromName = entry[
"via_layer_from"];
60 wxString viaLayerToName = entry[
"via_layer_to"];
63 int delay = entry[
"delay"];
73 auto saveUserDefinedProfileConfigurationLine =
74 [&saveViaOverrideConfigurationLine]( nlohmann::json& json_array,
const DELAY_PROFILE& item )
76 nlohmann::json layer_velocities = nlohmann::json::array();
78 for(
const auto& [layerId, velocity] : item.m_LayerPropagationDelays )
80 nlohmann::json layer_json = { {
"layer",
LSET::Name( layerId ) }, {
"delay", velocity } };
81 layer_velocities.push_back( layer_json );
84 nlohmann::json via_overrides = nlohmann::json::array();
88 saveViaOverrideConfigurationLine( via_overrides, viaOverride );
91 const nlohmann::json item_json = { {
"profile_name", item.m_ProfileName.ToUTF8() },
92 {
"via_prop_delay", item.m_ViaPropagationDelay },
93 {
"layer_delays", layer_velocities },
94 {
"via_overrides", via_overrides } };
96 json_array.push_back( item_json );
99 auto readUserDefinedProfileConfigurationLine = [&readViaOverrideConfigurationLine](
const nlohmann::json& entry )
101 const wxString profileName = entry[
"profile_name"];
102 const int viaPropDelay = entry[
"via_prop_delay"];
103 std::map<PCB_LAYER_ID, int> traceDelays;
105 for(
const nlohmann::json& layerEntry : entry[
"layer_delays"] )
107 if( !layerEntry.is_object() || !layerEntry.contains(
"layer" ) )
110 wxString layerName = layerEntry[
"layer"];
112 const int velocity = layerEntry[
"delay"];
113 traceDelays[
static_cast<PCB_LAYER_ID>( layerId )] = velocity;
116 std::vector<DELAY_PROFILE_VIA_OVERRIDE_ENTRY> viaOverrides;
118 for(
const nlohmann::json& viaEntry : entry[
"via_overrides"] )
120 if( !viaEntry.is_object() || !viaEntry.contains(
"signal_layer_from" ) )
123 viaOverrides.push_back( readViaOverrideConfigurationLine( viaEntry ) );
126 DELAY_PROFILE item{ profileName, viaPropDelay, std::move( traceDelays ), std::move( viaOverrides ) };
132 "delay_profiles_user_defined",
133 [&]() -> nlohmann::json
135 nlohmann::json ret = nlohmann::json::array();
138 saveUserDefinedProfileConfigurationLine( ret, entry );
142 [&](
const nlohmann::json& aJson )
144 if( !aJson.is_array() )
149 for(
const nlohmann::json& entry : aJson )
151 if( !entry.is_object() || !entry.contains(
"profile_name" ) )
154 m_delayProfiles.emplace_back( readUserDefinedProfileConfigurationLine( entry ) );
Helper functions and common defines between schematic and PCB Archive files.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void ReleaseNestedSettings(NESTED_SETTINGS *aSettings)
Saves and frees a nested settings object, if it exists within this one.
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
NESTED_SETTINGS is a JSON_SETTINGS that lives inside a JSON_SETTINGS.
JSON_SETTINGS * m_parent
A pointer to the parent object to load and store from.
Like a normal param, but with custom getter and setter functions.
TIME_DOMAIN_PARAMETERS stores the configuration for time-domain tuning.
virtual ~TIME_DOMAIN_PARAMETERS()
bool operator==(const TIME_DOMAIN_PARAMETERS &aOther) const
TIME_DOMAIN_PARAMETERS(JSON_SETTINGS *aParent, const std::string &aPath)
void ClearDelayProfiles()
std::vector< DELAY_PROFILE > m_delayProfiles
PCB_LAYER_ID
A quick note on layer IDs:
Represents a single line in the time domain configuration via overrides configuration grid.
Represents a single line in the time domain configuration net class configuration grid.
constexpr int timeDomainParametersSchemaVersion