From bbdefa05ebd6eb4b0620d8f470d0c71988b697c5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 6 Jan 2024 14:48:20 +0000 Subject: [PATCH] Un-comment and repair AM and SFFM sources. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16529 --- eeschema/sim/sim_model.cpp | 22 +++++------ eeschema/sim/sim_model.h | 8 ++-- eeschema/sim/sim_model_source.cpp | 61 ++++++++++++++----------------- eeschema/sim/sim_model_source.h | 8 ++-- 4 files changed, 46 insertions(+), 53 deletions(-) diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index b7732084ae..fed90c1996 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -187,8 +187,8 @@ SIM_MODEL::INFO SIM_MODEL::TypeInfo( TYPE aType ) case TYPE::V_SIN: return { DEVICE_T::V, "SIN", "Sine" }; case TYPE::V_PULSE: return { DEVICE_T::V, "PULSE", "Pulse" }; case TYPE::V_EXP: return { DEVICE_T::V, "EXP", "Exponential" }; - //case TYPE::V_SFAM: return { DEVICE_T::V, "SFAM", "Single-frequency AM" }; - //case TYPE::V_SFFM: return { DEVICE_T::V, "SFFM", "Single-frequency FM" }; + case TYPE::V_AM: return { DEVICE_T::V, "AM", "Amplitude modulated" }; + case TYPE::V_SFFM: return { DEVICE_T::V, "SFFM", "Single-frequency FM" }; case TYPE::V_VCL: return { DEVICE_T::E, "", "Voltage-controlled" }; case TYPE::V_CCL: return { DEVICE_T::H, "", "Current-controlled" }; case TYPE::V_PWL: return { DEVICE_T::V, "PWL", "Piecewise linear" }; @@ -205,8 +205,8 @@ SIM_MODEL::INFO SIM_MODEL::TypeInfo( TYPE aType ) case TYPE::I_SIN: return { DEVICE_T::I, "SIN", "Sine" }; case TYPE::I_PULSE: return { DEVICE_T::I, "PULSE", "Pulse" }; case TYPE::I_EXP: return { DEVICE_T::I, "EXP", "Exponential" }; - //case TYPE::I_SFAM: return { DEVICE_T::I, "SFAM", "Single-frequency AM" }; - //case TYPE::I_SFFM: return { DEVICE_T::I, "SFFM", "Single-frequency FM" }; + case TYPE::I_AM: return { DEVICE_T::I, "AM", "Amplitude modulated" }; + case TYPE::I_SFFM: return { DEVICE_T::I, "SFFM", "Single-frequency FM" }; case TYPE::I_VCL: return { DEVICE_T::G, "", "Voltage-controlled" }; case TYPE::I_CCL: return { DEVICE_T::F, "", "Current-controlled" }; case TYPE::I_PWL: return { DEVICE_T::I, "PWL", "Piecewise linear" }; @@ -324,8 +324,8 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType ) case TYPE::V_SIN: return { "V", "", "SIN" }; case TYPE::V_PULSE: return { "V", "", "PULSE" }; case TYPE::V_EXP: return { "V", "", "EXP" }; - //case TYPE::V_SFAM: return { "V", "", "AM" }; - //case TYPE::V_SFFM: return { "V", "", "SFFM" }; + case TYPE::V_AM: return { "V", "", "AM" }; + case TYPE::V_SFFM: return { "V", "", "SFFM" }; case TYPE::V_VCL: return { "E", "", "" }; case TYPE::V_CCL: return { "H", "", "" }; case TYPE::V_PWL: return { "V", "", "PWL" }; @@ -342,8 +342,8 @@ SIM_MODEL::SPICE_INFO SIM_MODEL::SpiceInfo( TYPE aType ) case TYPE::I_PULSE: return { "I", "", "PULSE" }; case TYPE::I_SIN: return { "I", "", "SIN" }; case TYPE::I_EXP: return { "I", "", "EXP" }; - //case TYPE::I_SFAM: return { "V", "", "AM" }; - //case TYPE::I_SFFM: return { "V", "", "SFFM" }; + case TYPE::I_AM: return { "V", "", "AM" }; + case TYPE::I_SFFM: return { "V", "", "SFFM" }; case TYPE::I_VCL: return { "G", "", "" }; case TYPE::I_CCL: return { "F", "", "" }; case TYPE::I_PWL: return { "I", "", "PWL" }; @@ -913,10 +913,10 @@ std::unique_ptr SIM_MODEL::Create( TYPE aType ) case TYPE::I_PULSE: case TYPE::V_EXP: case TYPE::I_EXP: - /*case TYPE::V_SFAM: - case TYPE::I_SFAM: + case TYPE::V_AM: + case TYPE::I_AM: case TYPE::V_SFFM: - case TYPE::I_SFFM:*/ + case TYPE::I_SFFM: case TYPE::V_VCL: case TYPE::V_CCL: case TYPE::V_PWL: diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index 327cb6f86e..72b0f8f34e 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -239,8 +239,8 @@ public: V_SIN, V_PULSE, V_EXP, - //V_SFAM, - //V_SFFM, + V_AM, + V_SFFM, V_VCL, V_CCL, V_PWL, @@ -257,8 +257,8 @@ public: I_SIN, I_PULSE, I_EXP, - //I_SFAM, - //I_SFFM, + I_AM, + I_SFFM, I_VCL, I_CCL, I_PWL, diff --git a/eeschema/sim/sim_model_source.cpp b/eeschema/sim/sim_model_source.cpp index 37011d1d4b..832004dcfd 100644 --- a/eeschema/sim/sim_model_source.cpp +++ b/eeschema/sim/sim_model_source.cpp @@ -337,11 +337,11 @@ const std::vector& SIM_MODEL_SOURCE::makeParamInfos( TYP static std::vector vexp = makeExpParamInfos( "y", "V" ); static std::vector iexp = makeExpParamInfos( "y", "A" ); - /*static std::vector vsfam = makeSfamParamInfos( "y", "V" ); - static std::vector isfam = makeSfamParamInfos( "y", "A" ); + static std::vector vam = makeAMParamInfos( "y", "V" ); + static std::vector iam = makeAMParamInfos( "y", "A" ); - static std::vector vsffm = makeSffmParamInfos( "y", "V" ); - static std::vector isffm = makeSffmParamInfos( "y", "A" );*/ + static std::vector vsffm = makeSFFMParamInfos( "y", "V" ); + static std::vector isffm = makeSFFMParamInfos( "y", "A" ); static std::vector vcvs = makeVcParamInfos( "" ); static std::vector ccvs = makeCcParamInfos( "ohm" ); @@ -382,10 +382,10 @@ const std::vector& SIM_MODEL_SOURCE::makeParamInfos( TYP case TYPE::I_PULSE: return ipulse; case TYPE::V_EXP: return vexp; case TYPE::I_EXP: return iexp; - //case TYPE::V_SFAM: return vsfam; - //case TYPE::I_SFAM: return isfam; - //case TYPE::V_SFFM: return vsffm; - //case TYPE::I_SFFM: return isffm; + case TYPE::V_AM: return vam; + case TYPE::I_AM: return iam; + case TYPE::V_SFFM: return vsffm; + case TYPE::I_SFFM: return isffm; case TYPE::V_VCL: return vcvs; case TYPE::V_CCL: return ccvs; case TYPE::V_PWL: return vpwl; @@ -630,40 +630,26 @@ std::vector SIM_MODEL_SOURCE::makeExpParamInfos( const s } -/*std::vector SIM_MODEL_SOURCE::makeSfamParamInfos( const std::string& aPrefix, const std::string& aUnit ) +std::vector SIM_MODEL_SOURCE::makeAMParamInfos( const std::string& aPrefix, + const std::string& aUnit ) { std::vector paramInfos; PARAM::INFO paramInfo; - paramInfo.name = "dc"; - paramInfo.type = SIM_VALUE::TYPE_FLOAT; - paramInfo.unit = aUnit; - paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; - paramInfo.defaultValue = ""; - paramInfo.description = "DC offset"; - - paramInfo.name = "ampl"; + paramInfo.name = "va"; paramInfo.type = SIM_VALUE::TYPE_FLOAT; paramInfo.unit = aUnit; paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; paramInfo.defaultValue = ""; paramInfo.description = "Amplitude"; - - paramInfos.push_back( paramInfo ); - paramInfo.name = "mo"; - paramInfo.type = SIM_VALUE::TYPE_FLOAT; - paramInfo.unit = ""; - paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; - paramInfo.defaultValue = ""; - paramInfo.description = "Modulating signal offset"; paramInfos.push_back( paramInfo ); - paramInfo.name = "fc"; + paramInfo.name = "vo"; paramInfo.type = SIM_VALUE::TYPE_FLOAT; - paramInfo.unit = "Hz"; + paramInfo.unit = aUnit; paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; paramInfo.defaultValue = ""; - paramInfo.description = "Carrier frequency"; + paramInfo.description = "DC offset"; paramInfos.push_back( paramInfo ); paramInfo.name = "mf"; @@ -674,17 +660,25 @@ std::vector SIM_MODEL_SOURCE::makeExpParamInfos( const s paramInfo.description = "Modulating frequency"; paramInfos.push_back( paramInfo ); - appendAcParamInfos( paramInfos, aUnit ); + paramInfo.name = "fc"; + paramInfo.type = SIM_VALUE::TYPE_FLOAT; + paramInfo.unit = "Hz"; + paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; + paramInfo.defaultValue = ""; + paramInfo.description = "Carrier frequency"; + paramInfos.push_back( paramInfo ); + return paramInfos; } -std::vector SIM_MODEL_SOURCE::makeSffmParamInfos( const std::string& aPrefix, const std::string& aUnit ) +std::vector SIM_MODEL_SOURCE::makeSFFMParamInfos( const std::string& aPrefix, + const std::string& aUnit ) { std::vector paramInfos; PARAM::INFO paramInfo; - paramInfo.name = "dc"; + paramInfo.name = "vo"; paramInfo.type = SIM_VALUE::TYPE_FLOAT; paramInfo.unit = aUnit; paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; @@ -692,7 +686,7 @@ std::vector SIM_MODEL_SOURCE::makeSffmParamInfos( const paramInfo.description = "DC offset"; paramInfos.push_back( paramInfo ); - paramInfo.name = "ampl"; + paramInfo.name = "va"; paramInfo.type = SIM_VALUE::TYPE_FLOAT; paramInfo.unit = aUnit; paramInfo.category = SIM_MODEL::PARAM::CATEGORY::PRINCIPAL; @@ -740,9 +734,8 @@ std::vector SIM_MODEL_SOURCE::makeSffmParamInfos( const paramInfo.description = "Signal phase"; paramInfos.push_back( paramInfo ); - appendAcParamInfos( paramInfos, aUnit ); return paramInfos; -}*/ +} std::vector SIM_MODEL_SOURCE::makeCcParamInfos( const std::string& aGainUnit ) diff --git a/eeschema/sim/sim_model_source.h b/eeschema/sim/sim_model_source.h index bcabaaa8a0..11d2f5144f 100644 --- a/eeschema/sim/sim_model_source.h +++ b/eeschema/sim/sim_model_source.h @@ -90,10 +90,10 @@ private: const std::string& aUnit ); static std::vector makeExpParamInfos( const std::string& aPrefix, const std::string& aUnit ); - //static std::vector makeSfamParamInfos( const std::string& aPrefix, - // const std::string& aUnit ); - //static std::vector makeSffmParamInfos( const std::string& aPrefix, - // const std::string& aUnit ); + static std::vector makeAMParamInfos( const std::string& aPrefix, + const std::string& aUnit ); + static std::vector makeSFFMParamInfos( const std::string& aPrefix, + const std::string& aUnit ); static std::vector makeVcParamInfos( const std::string& aGainUnit ); static std::vector makeCcParamInfos( const std::string& aGainUnit ); static std::vector makePwlParamInfos( const std::string& aPrefix,