Skip to content
Snippets Groups Projects
Commit 723c6ba1 authored by Stephan Philips's avatar Stephan Philips
Browse files

c++ upload functionality

parent d022e11e
No related branches found
No related tags found
No related merge requests found
Showing
with 6386 additions and 4 deletions
No preview for this file type
No preview for this file type
#include "Rectangle.h"
using namespace shapes;
Rectangle::Rectangle(int X0, int Y0, int X1, int Y1)
{
x0 = X0;
y0 = Y0;
x1 = X1;
y1 = Y1;
}
Rectangle::~Rectangle()
{
}
int Rectangle::getLength()
{
return (x1 - x0);
}
int Rectangle::getHeight()
{
return (y1 - y0);
}
int Rectangle::getArea()
{
return (x1 - x0) * (y1 - y0);
}
void Rectangle::move(int dx, int dy)
{
x0 += dx;
y0 += dy;
x1 += dx;
y1 += dy;
}
namespace shapes {
class Rectangle {
public:
int x0, y0, x1, y1;
Rectangle(int x0, int y0, int x1, int y1);
~Rectangle();
int getLength();
int getHeight();
int getArea();
void move(int dx, int dy);
};
}
\ No newline at end of file
File added
File added
File added
File added
namespace shapes {
class Rectangle {
public:
int x0, y0, x1, y1;
Rectangle(int x0, int y0, int x1, int y1);
~Rectangle();
int getLength();
int getHeight();
int getArea();
void move(int dx, int dy);
};
}
\ No newline at end of file
This diff is collapsed.
File added
cdef extern from "Rectangle.h" namespace "shapes":
cdef cppclass Rectangle:
Rectangle(int, int, int, int)
int x0, y0, x1, y1
int getLength()
int getHeight()
int getArea()
void move(int, int)
cdef Rectangle *rec = new Rectangle(1, 2, 3, 4)
del rec
This diff is collapsed.
File added
File added
cdef extern from "Rectangle.h" namespace "shapes":
cdef cppclass Rectangle:
Rectangle(int, int, int, int)
int x0, y0, x1, y1
int getLength()
int getHeight()
int getArea()
void move(int, int)
cdef class PyRectangle:
cdef Rectangle *thisptr # hold a C++ instance which we're wrapping
def __cinit__(self, int x0, int y0, int x1, int y1):
self.thisptr = new Rectangle(x0, y0, x1, y1)
def __dealloc__(self):
del self.thisptr
def getLength(self):
return self.thisptr.getLength()
def getHeight(self):
return self.thisptr.getHeight()
def getArea(self):
return self.thisptr.getArea()
def move(self, dx, dy):
self.thisptr.move(dx, dy)
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import numpy
extensions = [
Extension("rectangle",
["rectangle.pyx", "Rectangle.cpp"],
language='c++',
# sources = ["test.h",],
# extra_compile_args=['-fopenmp'],
)
]
setup(
name="uploader",
ext_modules=cythonize(extensions),
cmdclass = {'build_ext': build_ext}
)
\ No newline at end of file
class c_Foo
{
public:
c_Foo();
c_Foo(const c_Foo& orig);
~c_Foo();
double alfa;
int beta;
};
\ No newline at end of file
import rectangle
rectangle.PyRectangle(1,2,3,4)
\ No newline at end of file
......@@ -2,7 +2,7 @@ import threading as th
import numpy as np
import time
from pulse_lib.keysight.AWG_memory_manager import Memory_manager
from pulse_lib.keysight.uploader_core.uploader import waveform_upload_chache
def mk_thread(function):
def wrapper(*args, **kwargs):
thread = th.Thread(target=function, args=args, kwargs=kwargs)
......@@ -123,7 +123,6 @@ class keysight_uploader():
prescaler = job.sequence[i][2]
# TODO add precaler in as sample rate
print(getattr(seg, 'P1')._pulse_data_all)
for channel in self.channel_map:
if i == 0:
pre_delay = self.channel_delays[channel][0]
......@@ -140,7 +139,7 @@ class keysight_uploader():
vmin = getattr(seg, channel).v_min(job.index, sample_rate)
vmax = getattr(seg, channel).v_max(job.index, sample_rate)
waveform_cache[channel].add_data(wvf, integral, (vmin, vmax))
waveform_cache[channel].add_data(wvf, (vmin, vmax), integral)
pre_delay = 0
post_delay = 0
......@@ -155,10 +154,19 @@ class keysight_uploader():
c) add segments with the compenstated pulse for the given total time.
'''
compensation_time = 0
wvf_npt = 0
for chan in waveform_cache:
if waveform_cache[chan].compensation_time > compensation_time:
compensation_time = waveform_cache[chan].compensation_time
wvf_npt = waveform_cache[chan].npt
# make sure we have modulo 10 time
total_pt = compensation_time + wvf_npt
mod = total_pt%10
if mod != 0:
total_pt += 10-mod
compensation_time = total_pt - wvf_npt
#generate the compensation
for chan in waveform_cache:
waveform_cache[chan].generate_voltage_compensation(compensation_time)
end = time.time()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment