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
1 change: 1 addition & 0 deletions WISE/cpp/Initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const struct _error_msg _error_msgs[] = {
{ ERROR_WEATHER_STREAM_ATTEMPT_OVERWRITE, "Attempt to overwrite existing data in the weather stream failed." },
{ WARNING_WEATHER_STREAM_INTERPOLATE, "There were missing hours in the imported data that were filled using interpolation." },
{ WARNING_WEATHER_STREAM_INTERPOLATE_BEFORE_INVALID_DATA, "There were missing hours in the imported data that were filled using interpolation, before encountering invalid data." },
{ ERROR_START_AFTER_NOON | ERROR_SEVERITY_WARNING, "Weather stream cannot start after noon." },

{ ERROR_ATTEMPT_EXPORT_EMPTY_FIRE, "Cannot export empty fire perimeter." },

Expand Down
1 change: 1 addition & 0 deletions WISE_Project/cpp/CWFGMProject.Serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const struct Project::_error_msg _error_msgs[] = {
{ ERROR_GRID_WEATHER_NOT_IMPLEMENTED, "An object associated with a simulation which can handle weather data is missing." },
{ ERROR_GRID_WEATHER_INVALID_DATES, "If the times for the weather don't work with the scenario start and end times." },
{ ERROR_PROJECTION_UNKNOWN, "Cannot parse the provided projection file." },
{ ERROR_TIMEZONE_UNKNOWN, "Cannot determine timezone." },

{ ERROR_GRID_PRIMARY_STREAM_UNSPECIFIED, "Multiple weather streams exist, but none have been identified as the primary weather stream." },
{ ERROR_GRID_WEATHERSTATIONS_TOO_CLOSE, "At least 2 weather stations are within 100m of each other." },
Expand Down
14 changes: 5 additions & 9 deletions WISE_Project/cpp/CWFGMProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,6 @@ HRESULT Project::CWFGMProject::SetTimeZone(std::uint32_t timezoneId)
if (!timezone)
return E_INVALIDARG;

HRESULT hr;
PolymorphicAttribute var(timezoneId);
WTimeSpan diff = m_timeManager->m_worldLocation.m_timezone() - timezone->m_timezone;
WorldLocation& worldLocation = (WorldLocation&)(m_timeManager->m_worldLocation);
worldLocation.SetTimeZoneOffset(timezoneId);
Expand Down Expand Up @@ -587,8 +585,6 @@ HRESULT Project::CWFGMProject::SetTimeZone(std::uint32_t timezoneId)
HRESULT Project::CWFGMProject::SetTimeZoneTS(const WTimeSpan &Timezone)
{
WTimeSpan diff = m_timeManager->m_worldLocation.m_timezone() - Timezone;
PolymorphicAttribute var(Timezone);
HRESULT hr;
WorldLocation& worldLocation = (WorldLocation&)(m_timeManager->m_worldLocation);
worldLocation.m_timezone(Timezone);

Expand Down Expand Up @@ -1313,11 +1309,11 @@ static UINT AFX_CDECL stepBuildGrid(APTR parameter)
startUnits = 0;
break;
case PARA_WS:
value = std::max(0.0, min(200.0, wx.WindSpeed));
value = std::max(0.0, std::min(200.0, wx.WindSpeed));
startUnits = STORAGE_FORMAT_KM | STORAGE_FORMAT_HOUR;
break;
case PARA_GUST:
value = std::max(0.0, min(200.0, wx.WindGust));
value = std::max(0.0, std::min(200.0, wx.WindGust));
startUnits = STORAGE_FORMAT_KM | STORAGE_FORMAT_HOUR;
break;
case PARA_PRECIP:
Expand Down Expand Up @@ -1472,11 +1468,11 @@ static UINT AFX_CDECL stepBuildGrid(APTR parameter)
startUnits = 0;
break;
case PARA_WS:
value = std::max(0.0, min(200.0, wx.WindSpeed));
value = std::max(0.0, std::min(200.0, wx.WindSpeed));
startUnits = STORAGE_FORMAT_KM | STORAGE_FORMAT_HOUR;
break;
case PARA_GUST:
value = std::max(0.0, min(200.0, wx.WindGust));
value = std::max(0.0, std::min(200.0, wx.WindGust));
startUnits = STORAGE_FORMAT_KM | STORAGE_FORMAT_HOUR;
break;
case PARA_PRECIP:
Expand Down Expand Up @@ -3922,7 +3918,7 @@ HRESULT Project::CWFGMProject::PrintReportTxt(const TCHAR *szPath, const PrintRe
resultString += "Active Fuel Types :\n";
std::string moddedResult = "\nActive Fuel Types (modified):\n";

UCHAR count, unique_count, ii;
UCHAR count, unique_count;
long ASCII_index, tmp, export_index;

ICWFGM_Fuel *fuel = NULL;
Expand Down
38 changes: 16 additions & 22 deletions WISE_Project/cpp/CWFGMProject.proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,15 @@ HRESULT Project::CWFGMProject::deserialize(const std::string& filename, std::uin
file_major_version = data->project().version();
retval = S_OK;
}
catch (const ISerializeProto::DeserializeError& de)
{
std::cerr << "Error deserializing protobuf " << de.what() << std::endl;
retval = de.hr;
}
catch (std::exception &e)
{
auto ee = dynamic_cast_assert<ISerializeProto::DeserializeError*>(&e);
if ((ee) && (ee->hr != 0))
retval = ee->hr;
else
retval = ERROR_FILE_FORMAT_INVALID | ERROR_SEVERITY_WARNING;
std::cerr << "Error deserializing protobuf " << e.what() << std::endl;
retval = ERROR_FILE_FORMAT_INVALID | ERROR_SEVERITY_WARNING;
}
}
if (result)
Expand Down Expand Up @@ -690,9 +692,6 @@ auto Project::CWFGMProject::deserialize(const google::protobuf::Message& proto,
m_weatherCollection.AssignNewGrid(m_gridEngine.get());
m_scenarioCollection.AssignNewGrid(oldgrid.get(), m_gridEngine.get());

PolymorphicAttribute attr;
double temp;

if (project->has_vectors())
if (!m_vectorCollection.deserialize(project->vectors(), myValid, "vectors"))
retval = nullptr;
Expand Down Expand Up @@ -1890,10 +1889,6 @@ void Project::Fuel::PrintReportChanges(FuelCollection* m_fuelCollection, void* m
if (!defaultFuel) // can happen if m_csLUTFileName is empty
defaultFuel = FindDefault(m_fuelCollection->m_fuelCollection_Canada, m_fuelCollection->m_fuelCollection_NewZealand, m_fuelCollection->m_fuelCollection_Tasmania);

//Check for differences and build both the unmodified and modified lists
UCHAR count, unique_count, ii;
long ASCII_index, export_index, tmp;

//Get the full fuel name
Fuel* f = Fuel::FromCOM(this->m_fuel.get());

Expand Down Expand Up @@ -2523,7 +2518,7 @@ auto Project::FGMOutputs::deserialize(const google::protobuf::Message& proto, st
/// <type>user</type>
valid->add_child_validation("WISE.ProjectProto.Project.Outputs.SummaryOutput", strprintf("summaries[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto.version()));
weak_assert(false);
throw std::invalid_argument("StatsOutputs: Version is invalid");
throw ISerializeProto::DeserializeError("StatsOutputs: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}

auto vt2 = validation::conditional_make_object(valid, "WISE.ProjectProto.Project.Outputs.SummaryOutput", strprintf("seasonal[%d]", i));
Expand Down Expand Up @@ -2621,7 +2616,7 @@ auto Project::FGMOutputs::deserialize(const google::protobuf::Message& proto, st
/// <type>user</type>
valid->add_child_validation("WISE.ProjectProto.Project.Outputs.StatsOutput", strprintf("stats[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto.version()));
weak_assert(false);
throw std::invalid_argument("StatsOutputs: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.StatsOutputs: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}

/// <summary>
Expand Down Expand Up @@ -2764,7 +2759,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
statsValid->add_child_validation("WISE.ProjectProto.Project.Outputs.DiscretizedStatsOptions", strprintf("grids[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto.version()));
weak_assert(false);
throw std::invalid_argument("DiscretizedStatsOptions: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.DiscretizedStatsOptions: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}
so.discretize = (std::uint16_t)dopt.discretize();
if ((so.discretize < 1) || (so.discretize > 1000))
Expand Down Expand Up @@ -2822,7 +2817,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
statsValid->add_child_validation("WISE.ProjectProto.Project.Outputs.DiscretizedStatsOptions", strprintf("grids[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto.version()));
weak_assert(false);
throw std::invalid_argument("DiscretizedStatsOptions: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.DiscretizedStatsOptions: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}
so.discretize = (std::uint16_t)dopt.discretize();
if ((so.discretize < 1) || (so.discretize > 1000))
Expand Down Expand Up @@ -2858,7 +2853,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
valid->add_child_validation("WISE.ProjectProto.Project.Outputs.VectorOutput", strprintf("vectors[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto1.version()));
weak_assert(false);
throw std::invalid_argument("StatsOutputs: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.VectorOutput: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}

/// <summary>
Expand Down Expand Up @@ -3034,7 +3029,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
valid->add_child_validation("WISE.ProjectProto.Project.Outputs.FuelGridOutput", strprintf("fuelgrids[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto1.version()));
weak_assert(false);
throw std::invalid_argument("StatsOutputs: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.FuelGridOutput: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}

/// <summary>
Expand Down Expand Up @@ -3136,7 +3131,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
valid->add_child_validation("WISE.ProjectProto.Project.Outputs.GridOutput", strprintf("grids[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto.version()));
weak_assert(false);
throw std::invalid_argument("StatsOutputs: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.GridOutput: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}

/// <summary>
Expand Down Expand Up @@ -3291,7 +3286,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
gridValid->add_child_validation("WISE.ProjectProto.Project.Outputs.DiscretizedStatsOptions", strprintf("grids[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(proto.version()));
weak_assert(false);
throw std::invalid_argument("DiscretizedStatsOptions: Unknown version");
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.Project.Outputs.DiscretizedStatsOptions: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}
grid.discretize = (std::uint16_t)dopt.discretize();
if ((grid.discretize < 1) || (grid.discretize > 1000))
Expand Down Expand Up @@ -3424,7 +3419,7 @@ HSS_PRAGMA_WARNING_POP
/// <type>user</type>
valid->add_child_validation("WISE.ProjectProto.Project.Outputs.AssetStatsOutput", strprintf("assetStats[%d]", i), validation::error_level::SEVERE, validation::id::version_mismatch, std::to_string(asset.version()));
weak_assert(false);
throw std::invalid_argument("AssetOutput: Unknown version");
throw ISerializeProto::DeserializeError("AssetStatsOutput: Version is invalid", ERROR_PROTOBUF_OBJECT_VERSION_INVALID);
}

/// <summary>
Expand Down Expand Up @@ -3456,7 +3451,6 @@ HSS_PRAGMA_WARNING_POP
entry.criticalPath = asset.has_criticalpathembedded() && asset.criticalpathembedded().value();
entry.criticalPathFilename = asset.criticalpathfilename();

stats::StatsFileType filetype;
switch (asset.filetype())
{
case WISE::ProjectProto::Project_Outputs_StatsOutput::CSV:
Expand Down
1 change: 1 addition & 0 deletions WISE_Project/cpp/GridFilter.proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ auto Project::StaticVector::deserialize(const google::protobuf::Message& proto,
/// </summary>
/// <type>user</type>
v->add_child_validation("string", "name", validation::error_level::SEVERE, validation::id::missing_name, vector->name());
throw ISerializeProto::DeserializeError("CWFGM.ProjectProto.ProjectVectorFilter: Invalid or missing name.");
}
m_comments = vector->comments();
m_col = vector->color();
Expand Down
2 changes: 1 addition & 1 deletion WISE_Project/cpp/Scenario.proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ google::protobuf::Message* Project::Scenario::serialize(const SerializeProtoOpti
if (!data)
{
weak_assert(false);
throw std::invalid_argument("");
throw std::invalid_argument("Scenario: Parameter invalid");
}

if (options.fileVersion() == 1) {
Expand Down