@@ -173,19 +173,21 @@ void builder_PySAM::all_options_of_cmod(const std::string &cmod) {
173173void builder_PySAM::create_PySAM_files (const std::string &cmod, const std::string &file_dir, bool stateful) {
174174 std::string cmod_symbol = format_as_symbol (cmod);
175175
176- std::string tech_symbol = cmod_symbol;
177176 if (cmod_symbol == " 6parsolve" )
178- tech_symbol = " SixParsolve" ;
177+ cmod_symbol = " SixParsolve" ;
178+ else if (cmod_symbol == " Tcsmslf" )
179+ cmod_symbol = " TcsMSLF" ;
179180 else if (root->m_vardefs .find (cmod_symbol) != root->m_vardefs .end ())
180- tech_symbol += " Model" ;
181+ cmod_symbol += " Model" ;
182+ std::string tech_symbol = cmod_symbol;
181183
182184 std::ofstream fx_file;
183185 fx_file.open (file_dir + " /modules/" + tech_symbol + " .c" );
184186 assert (fx_file.is_open ());
185187
186188 fx_file << " #include <Python.h>\n "
187189 " \n "
188- " #include <SAM_" << cmod_symbol << " .h>\n "
190+ " #include <SAM_" << tech_symbol << " .h>\n "
189191 " #include <SAM_api.h>\n "
190192 " \n "
191193 " #include \" PySAM_utils.h\"\n\n " ;
@@ -612,6 +614,30 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
612614
613615 fx_file << " \t PyObject_Del(self);\n "
614616 " }\n\n\n " ;
617+ fx_file << " static PyObject *\n "
618+ " " << tech_symbol << " _get_data_ptr(" << object_type << " *self, PyObject *args)\n "
619+ " {\n\t PyObject* ptr = PyLong_FromVoidPtr((void*)self->data_ptr);\n "
620+ " \t return ptr;\n }\n\n\n " ;
621+
622+ fx_file << " static PyObject *\n "
623+ " " << tech_symbol << " _set_data_ptr(" << object_type << " *self, PyObject *args)\n "
624+ " {\n "
625+ " \t long long int ptr = 0; // 64 bit arch\n "
626+ " \t if (!PyArg_ParseTuple(args, \" L:data_ptr\" , &ptr)){\n "
627+ " \t\t PyErr_BadArgument();\n "
628+ " \t\t return NULL;\n "
629+ " \t }\n\t self->data_ptr = (void*)ptr;\n " ;
630+
631+ // modify the data ptr for all the groups
632+ for (auto & i : root->vardefs_order ) {
633+ auto mm = root->m_vardefs .find (i);
634+ if (mm->second .empty ()) continue ;
635+ std::string module_symbol = format_as_symbol (mm->first );
636+ fx_file << " \t VarGroupObject* " << module_symbol << " _obj = (VarGroupObject*)PyDict_GetItemString(self->x_attr, \" " << module_symbol << " \" );\n "
637+ " \t " << module_symbol << " _obj->data_ptr = (void*)ptr;\n " ;
638+ }
639+
640+ fx_file << " \t return Py_None;\n }\n\n\n " ;
615641
616642 if (stateful) {
617643 fx_file << " static PyObject *\n "
@@ -693,6 +719,10 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
693719
694720 fx_file << " \t\t {\" execute\" , (PyCFunction)" << tech_symbol << " _execute, METH_VARARGS,\n "
695721 " \t\t\t\t PyDoc_STR(\" execute(int verbosity) -> None\\ n Execute simulation with verbosity level 0 (default) or 1\" )},\n "
722+ " \t\t {\" get_data_ptr\" , (PyCFunction)" << tech_symbol << " _get_data_ptr, METH_VARARGS,\n "
723+ " \t\t\t\t PyDoc_STR(\" get_data_ptr() -> Pointer\\ n Get ssc_data_t pointer\" )},\n "
724+ " \t\t {\" set_data_ptr\" , (PyCFunction)" << tech_symbol << " _set_data_ptr, METH_VARARGS,\n "
725+ " \t\t\t\t PyDoc_STR(\" set_data_ptr(data_ptr)\\ n Set ssc_data_t pointer\" )},\n "
696726 " \t\t {\" assign\" , (PyCFunction)" << tech_symbol << " _assign, METH_VARARGS,\n "
697727 " \t\t\t\t PyDoc_STR(\" assign(dict) -> None\\ n Assign attributes from nested dictionary, except for Outputs\\ n\\ n"
698728 " ``nested_dict = { '" << root->vardefs_order [0 ] << " ': { var: val, ...}, ...}``\" )},\n "
@@ -1100,8 +1130,17 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
11001130 fx_file << " -" ;
11011131 fx_file << " -\n\n " ;
11021132
1103- fx_file << " .. autoclass:: PySAM." << tech_symbol << " ." << tech_symbol << " ." << module_symbol << " \n " ;
1104- fx_file << " \t :members:\n\n " ;
1133+ if (module_symbol == " AdjustmentFactors" ) {
1134+ fx_file << " .. autoclass:: PySAM.AdjustmentFactors.AdjustmentFactors\n " ;
1135+ }
1136+ else {
1137+ fx_file << " .. autoclass:: PySAM." << tech_symbol << " ." << tech_symbol << " ." << module_symbol << " \n " ;
1138+ }
1139+ fx_file << " \t :members:\n " ;
1140+ if (module_symbol == " AdjustmentFactors" ) {
1141+ fx_file << " \t :noindex:\n " ;
1142+ }
1143+ fx_file << " \n " ;
11051144 }
11061145
11071146 fx_file.close ();
@@ -1127,6 +1166,12 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
11271166 " \t def export(self):\n "
11281167 " \t\t pass\n "
11291168 " \n "
1169+ " \t def get_data_ptr(self):\n "
1170+ " \t\t pass\n "
1171+ " \n "
1172+ " \t def set_data_ptr(self, data_ptr):\n "
1173+ " \t\t pass\n "
1174+ " \n "
11301175 " \t def __getattribute__(self, *args, **kwargs):\n "
11311176 " \t\t pass\n "
11321177 " \n "
@@ -1159,14 +1204,26 @@ void builder_PySAM::create_PySAM_files(const std::string &cmod, const std::strin
11591204 " \t\t\t pass\n "
11601205 " \t\n "
11611206 " \t\t constant = float\n "
1207+ " \t\t en_hourly = float\n "
1208+ " \t\t en_periods = float\n "
1209+ " \t\t en_timeindex = float\n "
1210+ " \t\t hourly = tuple\n "
1211+ " \t\t periods = tuple\n "
1212+ " \t\t imeindex = tuple\n "
11621213 " \t\t dc_constant = float\n "
1214+ " \t\t dc_en_hourly = float\n "
1215+ " \t\t dc_en_periods = float\n "
1216+ " \t\t dc_en_timeindex = float\n "
11631217 " \t\t dc_hourly = tuple\n "
11641218 " \t\t dc_periods = tuple\n "
1165- " \t\t hourly = tuple\n "
1166- " \t\t periods = tuple\n "
1219+ " \t\t dc_imeindex = tuple\n "
11671220 " \t\t sf_constant = float\n "
1221+ " \t\t sf_en_hourly = float\n "
1222+ " \t\t sf_en_periods = float\n "
1223+ " \t\t sf_en_timeindex = float\n "
11681224 " \t\t sf_hourly = tuple\n "
1169- " \t\t sf_periods = tuple\n\n " ;
1225+ " \t\t sf_periods = tuple\n "
1226+ " \t\t sf_timeindex = tuple\n\n " ;
11701227 continue ;
11711228 }
11721229
0 commit comments