Skip to content

Commit 4284627

Browse files
committed
Refactor Radar constructors to use shared_ptr
Updated Radar, Transmitter, and Receiver constructors to use shared_ptr for improved memory management and compatibility with C++ interfaces. Adjusted function signatures and object instantiations in both the pxd and pyx files to reflect these changes.
1 parent 4458aaf commit 4284627

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/radarsimpy/includes/radarsimc.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ cdef extern from "radar.hpp":
253253
Radar() except +
254254

255255
# Radar system constructor
256-
Radar(Transmitter[H, L] & tx, # Transmitter configuration
257-
Receiver[L] & rx, # Receiver configuration
256+
Radar(const shared_ptr[Transmitter[H, L]] & tx, # Transmitter configuration
257+
const shared_ptr[Receiver[L]] & rx, # Receiver configuration
258258
vector[H] & frame_start_time, # Frame timing array (s)
259259
vector[Vec3[L]] & location_array, # Platform locations
260260
Vec3[L] speed_array, # Platform velocity

src/radarsimpy/lib/cp_radarsimc.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ cdef void cp_AddPoint(location, speed, rcs, phase, shape, PointsManager[float_t]
292292
@cython.cdivision(True)
293293
@cython.boundscheck(False)
294294
@cython.wraparound(False)
295-
cdef Transmitter[double, float_t] cp_Transmitter(radar):
295+
cdef shared_ptr[Transmitter[double, float_t]] cp_Transmitter(radar):
296296
"""
297297
cp_Transmitter(radar)
298298
@@ -340,7 +340,7 @@ cdef Transmitter[double, float_t] cp_Transmitter(radar):
340340
pn_imag_mv = np.imag(radar.sample_prop["phase_noise"]).astype(np.float64)
341341
Mem_Copy_Complex(&pn_real_mv[0], &pn_imag_mv[0], <int_t>(np.size(radar.sample_prop["phase_noise"])), pn_vt)
342342

343-
return Transmitter[double, float_t](
343+
return make_shared[Transmitter[double, float_t]](
344344
<float_t> radar.radar_prop["transmitter"].rf_prop["tx_power"],
345345
f_vt,
346346
t_vt,
@@ -582,8 +582,8 @@ cdef shared_ptr[Radar[double, float_t]] cp_Radar(radar, frame_start_time):
582582
- Handles coordinate transformations and unit conversions
583583
- Optimized for high-performance simulation engine interface
584584
"""
585-
cdef Transmitter[double, float_t] tx_c
586-
cdef Receiver[float_t] rx_c
585+
cdef shared_ptr[Transmitter[double, float_t]] tx_c
586+
cdef shared_ptr[Receiver[float_t]] rx_c
587587

588588
# Extract key system dimensions from radar configuration
589589
cdef int_t txsize_c = radar.radar_prop["transmitter"].txchannel_prop["size"]
@@ -622,22 +622,22 @@ cdef shared_ptr[Radar[double, float_t]] cp_Radar(radar, frame_start_time):
622622
"""
623623
tx_c = cp_Transmitter(radar)
624624
for idx_c in range(0, txsize_c):
625-
tx_c.AddChannel(
625+
tx_c.get()[0].AddChannel(
626626
cp_TxChannel(radar.radar_prop["transmitter"], idx_c)
627627
)
628628

629629
"""
630630
Receiver
631631
"""
632-
rx_c = Receiver[float_t](
632+
rx_c = make_shared[Receiver[float_t]](
633633
<float_t> radar.radar_prop["receiver"].bb_prop["fs"],
634634
<float_t> radar.radar_prop["receiver"].rf_prop["rf_gain"],
635635
<float_t> radar.radar_prop["receiver"].bb_prop["load_resistor"],
636636
<float_t> radar.radar_prop["receiver"].bb_prop["baseband_gain"],
637637
<float_t> radar.radar_prop["receiver"].bb_prop["noise_bandwidth"]
638638
)
639639
for idx_c in range(0, rxsize_c):
640-
rx_c.AddChannel(
640+
rx_c.get()[0].AddChannel(
641641
cp_RxChannel(radar.radar_prop["receiver"], idx_c)
642642
)
643643

0 commit comments

Comments
 (0)