Skip to content

Commit

Permalink
Replicate adjust widget handling in shade factor
Browse files Browse the repository at this point in the history
  • Loading branch information
mjprilliman committed Nov 17, 2023
1 parent 5d017a4 commit 6d53edb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/inputpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ bool ActiveInputPage::DataExchange( Case *c, wxUIObject *obj, VarValue &val, Ddx
}
else if ( ShadingButtonCtrl *sb = obj->GetNative<ShadingButtonCtrl>() )
{
if ( dir == VAR_TO_OBJ ) sb->Read( &val );
else sb->Write( &val );
if ( dir == VAR_TO_OBJ ) sb->Read( c, ndxHybrid );
else sb->Write( c, ndxHybrid );
}
else if ( AFValueMatrixButton *vm = obj->GetNative<AFValueMatrixButton>() )
{
Expand Down
45 changes: 45 additions & 0 deletions src/shadingfactors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ void ShadingInputData::write( VarValue *vv, wxString name )
tab.Set( name + "_diff", VarValue( (float)diff ) );
}

void ShadingInputData::write(Case* c, size_t ndxHybrid, wxString name)
{
auto& tab = c->Values(ndxHybrid); // Case VarTable
tab.Set(name + "_en_string_option", VarValue(true)); // to enable optional values
if (!en_timestep) string_option = -1;
tab.Set(name + "_string_option", VarValue((int)string_option));
tab.Set(name + "_en_timestep", VarValue((bool)en_timestep));
tab.Set(name + "_timestep", VarValue(timestep));

tab.Set(name + "_en_mxh", VarValue((bool)en_mxh));
tab.Set(name + "_mxh", VarValue(mxh));
tab.Set(name + "_en_azal", VarValue((bool)en_azal));
tab.Set(name + "_azal", VarValue(azal));
tab.Set(name + "_en_diff", VarValue((bool)en_diff));
tab.Set(name + "_diff", VarValue((float)diff));
}

bool ShadingInputData::read( VarValue *root, wxString name )
{
clear();
Expand All @@ -240,6 +257,24 @@ bool ShadingInputData::read( VarValue *root, wxString name )
return false;
}

bool ShadingInputData::read(Case *c, size_t ndxHybrid, wxString name)
{
clear();
auto& tab = c->Values(ndxHybrid); // Case VarTable

if (VarValue* vv = tab.Get(name + "_string_option")) string_option = vv->Integer();
if (VarValue* vv = tab.Get(name + "_en_timestep")) en_timestep = vv->Boolean();
if (VarValue* vv = tab.Get(name + "_timestep")) timestep = vv->Matrix();
if (VarValue* vv = tab.Get(name + "_en_mxh")) en_mxh = vv->Boolean();
if (VarValue* vv = tab.Get(name + "_mxh")) mxh = vv->Matrix();
if (VarValue* vv = tab.Get(name + "_en_azal")) en_azal = vv->Boolean();
if (VarValue* vv = tab.Get(name + "_azal")) azal = vv->Matrix();
if (VarValue* vv = tab.Get(name + "_en_diff")) en_diff = vv->Boolean();
if (VarValue* vv = tab.Get(name + "_diff")) diff = vv->Value();
return true;

}


static const char *hourly_text_basic = "Enter or import a beam shading loss percentage for each of the simulation time steps in a single year. No shading is 0%, and full shading is 100%. Choose a time step in minutes equivalent to the weather file time step.\n\nNote that the 3D Shade Calculator automatically populates this beam shading table.";
static const char *hourly_text_strings = "Enter or import a beam shading loss percentage for each of the simulation time steps in a single year. No shading is 0%, and full shading is 100%. Choose a time step in minutes equivalent to the weather file time step. For a subarray of modules with c-Si cells and up to 8 strings of modules, you can use the partial shading model to estimate the impact of partial shading on the subarray's DC output.\n\nIf you use the 3D Shade Calculator to populate this beam shading table, be sure that the active surface subarray number(s) and string number(s) match the system design.";
Expand Down Expand Up @@ -568,11 +603,21 @@ void ShadingButtonCtrl::Write( VarValue *vv )
m_shad.write( vv, m_name );
}

void ShadingButtonCtrl::Write(Case *c, size_t ndxHybrid)
{
m_shad.write(c, ndxHybrid, m_name);
}

bool ShadingButtonCtrl::Read( VarValue *vv )
{
return m_shad.read( vv, m_name );
}

bool ShadingButtonCtrl::Read(Case *c, size_t ndxHybrid)
{
return m_shad.read(c, ndxHybrid, m_name);
}

void ShadingButtonCtrl::OnPressed(wxCommandEvent &evt)
{
ShadingDialog dlg( this, m_descText, m_show_db_options );
Expand Down
5 changes: 5 additions & 0 deletions src/shadingfactors.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class VarValue;
class AFMonthByHourFactorCtrl;
class Case;

/* utility class to save/load shading data */
struct ShadingInputData
Expand Down Expand Up @@ -80,7 +81,9 @@ struct ShadingInputData
bool load( const std::vector<double> &data );

void write( VarValue *vv, wxString name );
void write(Case* c, size_t ndxHybrid, wxString name);
bool read( VarValue *vv, wxString name );
bool read(Case* c, size_t ndxHybrid, wxString name);


};
Expand All @@ -93,7 +96,9 @@ class ShadingButtonCtrl : public wxButton
const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize);

void Write( VarValue * );
void Write(Case* c, size_t ndxHybrid);
bool Read( VarValue * );
bool Read(Case* c, size_t ndxHybrid);
void SetDescription( const wxString &s ) { m_descText = s; }
void OnPressed(wxCommandEvent &evt);
void SetName(const wxString& _name) { m_name = _name; }
Expand Down

0 comments on commit 6d53edb

Please sign in to comment.