Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions solarpilot/CoPilot_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,36 @@ SPEXPORT bool sp_save_from_script(sp_data_t p_data, const char* sp_fname)
return false;
}

SPEXPORT bool sp_load_from_script(sp_data_t p_data, const char* sp_fname)
{
/*
Load a SolarPILOT .spt file. Returns true if successful.
Returns: (string:path):boolean
*/

api_helper *mc = static_cast<api_helper*>(p_data);
var_map* V = &mc->variables;

if (!ioutil::file_exists(sp_fname))
{
return false;
}

try
{
parametric p;
optimization o;

ioutil::parseXMLInputFile(sp_fname, *V, p, o);
return true;
}
catch (...)
{

}
return false;
}

SPEXPORT bool sp_dump_varmap(sp_data_t p_data, const char* sp_fname)
{
/*
Expand Down
2 changes: 2 additions & 0 deletions solarpilot/CoPilot_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ extern "C" {

SPEXPORT bool sp_save_from_script(sp_data_t p_data, const char* sp_fname);

SPEXPORT bool sp_load_from_script(sp_data_t p_data, const char* sp_fname);

SPEXPORT bool sp_dump_varmap(sp_data_t p_data, const char* sp_fname);

#ifdef __cplusplus
Expand Down