33#include <nlohmann/json.hpp>
39 m_reportUnits( aReportUnits )
48 wxString msg = wxString::Format(
_(
"ERC report (%s, Encoding UTF8)\n" ),
51 std::map<KIID, EDA_ITEM*> itemMap;
62 for(
unsigned i = 0; i < sheetList.size(); i++ )
64 msg << wxString::Format(
_(
"\n***** Sheet %s\n" ), sheetList[i].PathHumanReadable() );
84 msg << marker->
GetRCItem()->ShowReport( &unitsProvider, severity, itemMap );
88 msg << wxString::Format(
_(
"\n ** ERC messages: %d Errors %d Warnings %d\n" ), total_count,
89 err_count, warn_count );
97 wxFFile file( aFullFileName, wxT(
"wt" ) );
99 if( !file.IsOpened() )
111 std::ofstream jsonFileStream( aFullFileName.fn_str() );
114 std::map<KIID, EDA_ITEM*> itemMap;
118 reportHead.
$schema =
"https://schemas.kicad.org/erc.v1.json";
119 reportHead.
source = fn.GetFullName();
129 for(
unsigned i = 0; i < sheetList.size(); i++ )
131 RC_JSON::ERC_SHEET jsonSheet;
132 jsonSheet.path = sheetList[i].PathHumanReadable();
133 jsonSheet.uuid_path = sheetList[i].Path().AsString();
145 marker->
GetRCItem()->GetJsonViolation( violation, &unitsProvider, severity, itemMap );
147 jsonSheet.violations.push_back( violation );
150 reportHead.
sheets.push_back( jsonSheet );
153 nlohmann::json saveJson = nlohmann::json( reportHead );
154 jsonFileStream << std::setw( 4 ) << saveJson << std::endl;
155 jsonFileStream.flush();
156 jsonFileStream.close();
constexpr EDA_IU_SCALE schIUScale
constexpr EDA_IU_SCALE pcbIUScale
wxString GetMajorMinorPatchVersion()
Get the major, minor and patch version in a string major.minor.patch This is extracted by CMake from ...
ERC_REPORT(SCHEMATIC *aSchematic, EDA_UNITS aReportUnits)
wxString GetTextReport()
Returns the ERC report in "text" (human readable) format.
bool WriteJsonReport(const wxString &aFullFileName)
Writes a JSON formatted ERC Report to the given file path.
bool WriteTextReport(const wxString &aFullFileName)
Writes the text report also available via GetTextReport directly to a given file path.
Container for ERC settings.
SEVERITY GetSeverity(int aErrorCode) const
std::shared_ptr< RC_ITEM > GetRCItem() const
enum MARKER_T GetMarkerType() const
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Holds all the data relating to one schematic.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const override
ERC_SETTINGS & ErcSettings() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
wxString GetISO8601CurrentDateTime()
std::vector< ERC_SHEET > sheets
wxString coordinate_units