KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_logger.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_LOGGER_H
23#define __PNS_LOGGER_H
24
25#include <cstdio>
26#include <vector>
27#include <string>
28#include <sstream>
29#include <set>
30
31#include <math/vector2d.h>
32#include <kiid.h>
33#include <json_common.h>
34
35#include "pns_sizes_settings.h"
36#include "pns_router.h"
37
39class SHAPE;
40
41void to_json( nlohmann::json& aJson, const VECTOR2I& aPoint );
42void from_json( const nlohmann::json& aJson, VECTOR2I& aPoint );
43
44namespace PNS {
45
46class ITEM;
47
48class LOGGER
49{
50public:
51
59
70
71 struct EVENT_ENTRY {
74 std::vector<KIID> uuids;
76 int layer;
78
81 layer( 0 ),
83 {
84 }
85
86 EVENT_ENTRY( const EVENT_ENTRY& aE ) :
87 p( aE.p ),
88 type( aE.type ),
89 uuids( aE.uuids ),
90 sizes( aE.sizes ),
91 layer( aE.layer ),
93 {
94 }
95 };
96
97 struct LOG_DATA
98 {
102 std::optional<wxString> m_BoardHash;
103 std::vector<ITEM*> m_AddedItems;
104 std::set<KIID> m_RemovedItems;
105 std::vector<ITEM*> m_Heads;
106 std::vector<EVENT_ENTRY> m_Events;
107 std::optional<TEST_CASE_TYPE> m_TestCaseType;
108 };
109
110 LOGGER();
111 ~LOGGER();
112
113 void Clear();
114
115 void LogM( EVENT_TYPE evt, const VECTOR2I& pos = VECTOR2I(), std::vector<ITEM*> items = {},
116 const SIZES_SETTINGS* sizes = nullptr, int aLayer = 0 );
117
118 void Log( EVENT_TYPE evt, const VECTOR2I& pos = VECTOR2I(), const ITEM* item = nullptr,
119 const SIZES_SETTINGS* sizes = nullptr, int aLayer = 0 );
120
121 const std::vector<EVENT_ENTRY>& GetEvents()
122 {
123 return m_events;
124 }
125
126 static nlohmann::json FormatEventAsJSON( const EVENT_ENTRY& aEvent );
127
128 static EVENT_ENTRY ParseEvent( const wxString& aLine );
129 static EVENT_ENTRY ParseEventFromJSON( const nlohmann::json& aJSON );
130 static wxString FormatLogFileAsJSON( const LOG_DATA& aLogData );
131
132protected:
133
134 static nlohmann::json formatSizesAsJSON( const SIZES_SETTINGS& aEvent );
135 static nlohmann::json formatRouterItemAsJSON( const PNS::ITEM* aItem );
136 static nlohmann::json formatShapeAsJSON( const SHAPE* aShape );
137 static SIZES_SETTINGS parseSizesFromJSON( const nlohmann::json& aJSON );
138
139
140 std::vector<EVENT_ENTRY> m_events;
141 std::optional<TEST_CASE_TYPE> m_testCaseType;
142};
143
144}
145
146#endif
Base class for PNS router board items.
Definition pns_item.h:98
static wxString FormatLogFileAsJSON(const LOG_DATA &aLogData)
void Log(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), const ITEM *item=nullptr, const SIZES_SETTINGS *sizes=nullptr, int aLayer=0)
static nlohmann::json formatShapeAsJSON(const SHAPE *aShape)
std::optional< TEST_CASE_TYPE > m_testCaseType
Definition pns_logger.h:141
const std::vector< EVENT_ENTRY > & GetEvents()
Definition pns_logger.h:121
static EVENT_ENTRY ParseEventFromJSON(const nlohmann::json &aJSON)
static SIZES_SETTINGS parseSizesFromJSON(const nlohmann::json &aJSON)
static nlohmann::json FormatEventAsJSON(const EVENT_ENTRY &aEvent)
void LogM(EVENT_TYPE evt, const VECTOR2I &pos=VECTOR2I(), std::vector< ITEM * > items={}, const SIZES_SETTINGS *sizes=nullptr, int aLayer=0)
@ TCT_STRICT_GEOMETRY
Definition pns_logger.h:54
@ TCT_EXPECTED_FAIL
Definition pns_logger.h:56
@ TCT_CONNECTIVITY_ONLY
Definition pns_logger.h:55
@ EVT_START_MULTIDRAG
Definition pns_logger.h:68
std::vector< EVENT_ENTRY > m_events
Definition pns_logger.h:140
static nlohmann::json formatRouterItemAsJSON(const PNS::ITEM *aItem)
static EVENT_ENTRY ParseEvent(const wxString &aLine)
static nlohmann::json formatSizesAsJSON(const SIZES_SETTINGS &aEvent)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
Definition shape.h:124
Push and Shove diff pair dimensions (gap) settings dialog.
ROUTER_MODE
Definition pns_router.h:68
@ PNS_MODE_ROUTE_SINGLE
Definition pns_router.h:69
void from_json(const nlohmann::json &aJson, VECTOR2I &aPoint)
void to_json(nlohmann::json &aJson, const VECTOR2I &aPoint)
int layer
Definition pns_logger.h:76
SIZES_SETTINGS sizes
Definition pns_logger.h:75
EVENT_ENTRY(const EVENT_ENTRY &aE)
Definition pns_logger.h:86
EVENT_ENTRY()
Definition pns_logger.h:79
std::vector< KIID > uuids
Definition pns_logger.h:74
EVENT_TYPE type
Definition pns_logger.h:73
VECTOR2I p
Definition pns_logger.h:72
bool useConnectedTrackWidth
Definition pns_logger.h:77
std::optional< wxString > m_BoardHash
Definition pns_logger.h:102
std::optional< TEST_CASE_TYPE > m_TestCaseType
Definition pns_logger.h:107
std::vector< ITEM * > m_AddedItems
Definition pns_logger.h:103
std::vector< EVENT_ENTRY > m_Events
Definition pns_logger.h:106
std::set< KIID > m_RemovedItems
Definition pns_logger.h:104
std::vector< ITEM * > m_Heads
Definition pns_logger.h:105
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708