2023-08-13 18:44:31 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RC_JSON_SCHEMA_H
|
|
|
|
#define RC_JSON_SCHEMA_H
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains the json serialization structs for DRC and ERC reports
|
|
|
|
* If you are trying to change the output schema
|
|
|
|
* Please update the schemas located in /resources/schemas/ as both documentation
|
|
|
|
* and use by end user implementations
|
|
|
|
*/
|
|
|
|
namespace RC_JSON
|
|
|
|
{
|
|
|
|
struct COORDINATE
|
|
|
|
{
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
};
|
|
|
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( COORDINATE, x, y )
|
|
|
|
|
|
|
|
struct AFFECTED_ITEM
|
|
|
|
{
|
|
|
|
wxString uuid;
|
|
|
|
wxString description;
|
|
|
|
COORDINATE pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( AFFECTED_ITEM, uuid, description, pos )
|
|
|
|
|
|
|
|
struct VIOLATION
|
|
|
|
{
|
|
|
|
wxString type;
|
|
|
|
wxString description;
|
|
|
|
wxString severity;
|
|
|
|
std::vector<AFFECTED_ITEM> items;
|
2024-02-13 23:38:12 +00:00
|
|
|
bool excluded;
|
2023-08-13 18:44:31 +00:00
|
|
|
};
|
|
|
|
|
2024-02-13 23:38:12 +00:00
|
|
|
inline void to_json( nlohmann::json& aJson, const VIOLATION& aViolation )
|
|
|
|
{
|
|
|
|
aJson["type"] = aViolation.type;
|
|
|
|
aJson["description"] = aViolation.description;
|
|
|
|
aJson["severity"] = aViolation.severity;
|
|
|
|
aJson["items"] = aViolation.items;
|
|
|
|
|
|
|
|
if( aViolation.excluded )
|
|
|
|
aJson["excluded"] = aViolation.excluded;
|
|
|
|
}
|
|
|
|
inline void from_json( const nlohmann::json& aJson, VIOLATION& aViolation )
|
|
|
|
{
|
|
|
|
aJson.at( "type" ).get_to( aViolation.type );
|
|
|
|
aJson.at( "description" ).get_to( aViolation.description );
|
|
|
|
aJson.at( "severity" ).get_to( aViolation.severity );
|
|
|
|
aJson.at( "items" ).get_to( aViolation.items );
|
|
|
|
aJson.at( "excluded" ).get_to( aViolation.excluded );
|
|
|
|
}
|
2023-08-13 18:44:31 +00:00
|
|
|
|
|
|
|
struct REPORT_BASE
|
|
|
|
{
|
2024-02-14 00:03:22 +00:00
|
|
|
wxString $schema;
|
2023-08-13 18:44:31 +00:00
|
|
|
wxString source;
|
|
|
|
wxString date;
|
|
|
|
wxString kicad_version;
|
|
|
|
wxString type;
|
|
|
|
wxString coordinate_units;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DRC_REPORT : REPORT_BASE
|
|
|
|
{
|
|
|
|
DRC_REPORT() { type = wxS( "drc" ); }
|
|
|
|
|
|
|
|
std::vector<VIOLATION> violations;
|
|
|
|
std::vector<VIOLATION> unconnected_items;
|
|
|
|
std::vector<VIOLATION> schematic_parity;
|
|
|
|
};
|
|
|
|
|
2024-02-14 00:03:22 +00:00
|
|
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( DRC_REPORT, $schema, source, date, kicad_version, violations,
|
2023-08-13 18:44:31 +00:00
|
|
|
unconnected_items, schematic_parity, coordinate_units )
|
|
|
|
|
|
|
|
struct ERC_SHEET
|
|
|
|
{
|
2023-08-13 23:10:26 +00:00
|
|
|
wxString uuid_path;
|
2023-08-13 18:44:31 +00:00
|
|
|
wxString path;
|
|
|
|
std::vector<VIOLATION> violations;
|
|
|
|
};
|
|
|
|
|
2023-08-13 23:10:26 +00:00
|
|
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_SHEET, uuid_path, path, violations )
|
2023-08-13 18:44:31 +00:00
|
|
|
|
|
|
|
struct ERC_REPORT : REPORT_BASE
|
|
|
|
{
|
|
|
|
ERC_REPORT() { type = wxS( "erc" ); }
|
|
|
|
|
|
|
|
std::vector<ERC_SHEET> sheets;
|
|
|
|
};
|
|
|
|
|
2024-02-14 00:03:22 +00:00
|
|
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE( ERC_REPORT, $schema, source, date, kicad_version, sheets,
|
2023-08-13 18:44:31 +00:00
|
|
|
coordinate_units )
|
|
|
|
|
|
|
|
} // namespace RC_JSON
|
|
|
|
|
|
|
|
#endif
|